From patchwork Fri Jun 4 15:52:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 454089 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp571540jae; Fri, 4 Jun 2021 09:36:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdxj1YLSCAGqh67rE7kTxcy1cZxqtrEwg83GX7sPTeE2Edr3mS+Ys9izd6dHj49R60nyQB X-Received: by 2002:a67:1906:: with SMTP id 6mr3660321vsz.6.1622824584382; Fri, 04 Jun 2021 09:36:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622824584; cv=none; d=google.com; s=arc-20160816; b=qy2LFQDZ62azFJJRiSchEWWGO66qTvbegCNsVG/6D+k3YOn9muK2/1kCmU1lMVM+RL pTMZT80EqzjZjqGkIsY+OjAsbzCX4XvDgV9U1VDCD4ptz0I0KyrwrjpxSZ2+TnWHYTa9 96NyjC9MCvothSDKNuKm++p2rHnBwpk78lWjT0iDz4377qRDHLnCGTwrp096o53IsqrX ZsPxXys7HDZNaQCXFMO/gTvWtVQGEtAcV3oIQpxLdsICXKc0mUscIPdO1QrkyPd7VZpl o/BMv+bOQrsjnlXNVTtMORBgbc/fKkV2ihx5WdkUl/N1NdDT0/sbRSx0pLWy6JDdGykX 6q3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=YLNKH6WMEOpMy9rbclft4o2lCy4Z7+mVhGSkPGtULLE=; b=WqQeOQB8paqkHmZdJk0E5vyWkrvqAHncjU3HdAYarJonUU3S5vnZgTukvQTTdLbAwO o5xFg9aU2yXPDUknnkAkO7ipk2tSfcaGolt8SawnLpO7LPQic5kuv7DiAA4I5USdnIph SBAiLHw0R5Q8wcuALnLgPbCXUUpKidMaZHOs9v6F10RDkGU01ZWB26OxFudynCfrDoeu BK+yt4ux9FSHugBkMaRBofrSo4VBA54BwcD/pGUFvakTu8luLoFTnPVEPQ5+dF+4M9d5 HsPWzc2xeX2f7i5G+2NlL3DFl3u++C9+5Th/jAxXqXCOego4Oeg5jLjoxnldEVJ1CDM6 A9Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EknOOgdU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a74si3122758vke.94.2021.06.04.09.36.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Jun 2021 09:36:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EknOOgdU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpCo3-0005pC-NW for patch@linaro.org; Fri, 04 Jun 2021 12:36:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpCRU-0003E0-PV for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:13:06 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:55149) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpCRL-0003rr-E9 for qemu-devel@nongnu.org; Fri, 04 Jun 2021 12:13:04 -0400 Received: by mail-wm1-x329.google.com with SMTP id o127so5694414wmo.4 for ; Fri, 04 Jun 2021 09:12:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YLNKH6WMEOpMy9rbclft4o2lCy4Z7+mVhGSkPGtULLE=; b=EknOOgdUdP7RZfsZU2t6/2TJqfmiN7AvQ7GY/cTZ0Iei400/sBpXExpok5jn6i/mjF mve4BU73qU4B3sORAkOAgjnDZSt802eUqDVleFLRQbw1Z/MAU0xIBcvwRi8hNbNnHtNX ZeRQYlACHiFWPdgUlzJVag4i4UU3TXk0N2KTSmov3VuPl18R5nTSe2J5Jq8pi2YutFh6 vBNtntVGf909NpqPpdAp37HU1MUTusNODW3/NFEBLftAQx/6ZV+Els3vHSIcBWqIYz8f 4AiVOslN4ieIF96iPobJcMz/6IDA4sPnjuJ+Ocmii431oxEi+g1jQCpWMWyNlVpUKmYc OIrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YLNKH6WMEOpMy9rbclft4o2lCy4Z7+mVhGSkPGtULLE=; b=UGqJbwfFpZYxFugHNlWxoJhZAxD9ZOQqDKkedcIOrrtK4gpzU5sSM2ZVrf2ltcO66G AWc/7whEW2l3I+FG8fqhF6lMNbZEP7X6dzIhcH9fOzzYteS0BXNsdPVQQ6iUprLECTle nsZ2dToVm8F77gWW+BFuNm9VzRm6ACRcRN5cipklHYnG93oCBOjNFCe3s2NaX5z0J3y+ LMvPpoWSOgLGeVHNFNFzzs011HJroZGcdEilr+WvBcFdgz5+Y3OvswvVZvGaPUXvjb7W JcixxSzIfvYW4OSFXusDEsyYbQyVIPI5HbIzAHF8Y14m5fzNmxoNP0th3e3AfUvemP56 x1Vg== X-Gm-Message-State: AOAM53163r5oLP5kK/s5wswS6cS9gOiOQc37lGRCz900nXi86OSmy5hC yX+enyHQBRLJZKY8uFTHn3eJHw== X-Received: by 2002:a05:600c:4ba4:: with SMTP id e36mr3799460wmp.28.1622823173878; Fri, 04 Jun 2021 09:12:53 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a12sm5974399wmj.36.2021.06.04.09.12.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 09:12:52 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D4AA71FFF6; Fri, 4 Jun 2021 16:53:22 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v16 82/99] target/arm: move sve_zcr_len_for_el to TARGET_AARCH64-only cpu-sve Date: Fri, 4 Jun 2021 16:52:55 +0100 Message-Id: <20210604155312.15902-83-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210604155312.15902-1-alex.bennee@linaro.org> References: <20210604155312.15902-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Richard Henderson , Claudio Fontana , Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Claudio Fontana now that we handled the dependency between HELPER(), cpregs defs and functions in tcg/, we can make sve_zcr_len_for_el TARGET_AARCH64-only, and move it to the cpu-sve module. Signed-off-by: Claudio Fontana Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- target/arm/cpu-sve.h | 3 +++ target/arm/cpu.h | 4 ++-- target/arm/arch_dump.c | 1 + target/arm/cpu-common.c | 43 ----------------------------------------- target/arm/cpu-sve.c | 33 +++++++++++++++++++++++++++++++ target/arm/cpu.c | 4 ++++ target/arm/tcg/cpregs.c | 1 + target/arm/tcg/helper.c | 4 ++++ 8 files changed, 48 insertions(+), 45 deletions(-) -- 2.20.1 diff --git a/target/arm/cpu-sve.h b/target/arm/cpu-sve.h index 6ab74b1d8f..1512c56a6b 100644 --- a/target/arm/cpu-sve.h +++ b/target/arm/cpu-sve.h @@ -34,4 +34,7 @@ void cpu_sve_add_props(Object *obj); /* add the CPU SVE properties specific to the "MAX" CPU */ void cpu_sve_add_props_max(Object *obj); +/* return the vector length for EL */ +uint32_t sve_zcr_len_for_el(CPUARMState *env, int el); + #endif /* CPU_SVE_H */ diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 3edf8bb4ec..e9bfb6f575 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -223,7 +223,8 @@ typedef struct ARMPACKey { } ARMPACKey; #else static inline void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) { } -#endif + +#endif /* TARGET_AARCH64 */ /* See the commentary above the TBFLAG field definitions. */ typedef struct CPUARMTBFlags { @@ -1097,7 +1098,6 @@ void aarch64_sync_64_to_32(CPUARMState *env); int fp_exception_el(CPUARMState *env, int cur_el); int sve_exception_el(CPUARMState *env, int cur_el); -uint32_t sve_zcr_len_for_el(CPUARMState *env, int el); /* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c index 9cc75a6fda..9b2e76f5a7 100644 --- a/target/arm/arch_dump.c +++ b/target/arm/arch_dump.c @@ -24,6 +24,7 @@ #include "sysemu/dump.h" #ifdef TARGET_AARCH64 +#include "cpu-sve.h" /* struct user_pt_regs from arch/arm64/include/uapi/asm/ptrace.h */ struct aarch64_user_regs { diff --git a/target/arm/cpu-common.c b/target/arm/cpu-common.c index f4a3780e9e..b7a199a8d6 100644 --- a/target/arm/cpu-common.c +++ b/target/arm/cpu-common.c @@ -301,49 +301,6 @@ uint64_t arm_hcr_el2_eff(CPUARMState *env) return ret; } -/* - * these are AARCH64-only, but due to the chain of dependencies, - * between HELPER prototypes, hflags, cpreg definitions and functions in - * tcg/ etc, it becomes incredibly messy to add what should be here: - * - * #ifdef TARGET_AARCH64 - */ - -static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) -{ - uint32_t end_len; - - end_len = start_len &= 0xf; - if (!test_bit(start_len, cpu->sve_vq_map)) { - end_len = find_last_bit(cpu->sve_vq_map, start_len); - assert(end_len < start_len); - } - return end_len; -} - -/* - * Given that SVE is enabled, return the vector length for EL. - */ -uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) -{ - ARMCPU *cpu = env_archcpu(env); - uint32_t zcr_len = cpu->sve_max_vq - 1; - - if (el <= 1) { - zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[1]); - } - if (el <= 2 && arm_feature(env, ARM_FEATURE_EL2)) { - zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[2]); - } - if (arm_feature(env, ARM_FEATURE_EL3)) { - zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); - } - - return sve_zcr_get_valid_len(cpu, zcr_len); -} - -/* #endif TARGET_AARCH64 , see matching comment above */ - uint64_t arm_sctlr(CPUARMState *env, int el) { /* Only EL0 needs to be adjusted for EL1&0 or EL2&0. */ diff --git a/target/arm/cpu-sve.c b/target/arm/cpu-sve.c index 24bffbba8b..e8e817e110 100644 --- a/target/arm/cpu-sve.c +++ b/target/arm/cpu-sve.c @@ -288,3 +288,36 @@ void cpu_sve_add_props_max(Object *obj) { object_property_add(obj, "sve-max-vq", "uint32", get_prop_max_vq, set_prop_max_vq, NULL, NULL); } + +static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) +{ + uint32_t end_len; + + end_len = start_len &= 0xf; + if (!test_bit(start_len, cpu->sve_vq_map)) { + end_len = find_last_bit(cpu->sve_vq_map, start_len); + assert(end_len < start_len); + } + return end_len; +} + +/* + * Given that SVE is enabled, return the vector length for EL. + */ +uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) +{ + ARMCPU *cpu = env_archcpu(env); + uint32_t zcr_len = cpu->sve_max_vq - 1; + + if (el <= 1) { + zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[1]); + } + if (el <= 2 && arm_feature(env, ARM_FEATURE_EL2)) { + zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[2]); + } + if (arm_feature(env, ARM_FEATURE_EL3)) { + zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); + } + + return sve_zcr_get_valid_len(cpu, zcr_len); +} diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b297d0e6aa..0e41854b92 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -23,7 +23,11 @@ #include "target/arm/idau.h" #include "qapi/error.h" #include "cpu.h" + +#ifdef TARGET_AARCH64 #include "cpu-sve.h" +#endif /* TARGET_AARCH64 */ + #include "cpregs.h" #ifdef CONFIG_TCG diff --git a/target/arm/tcg/cpregs.c b/target/arm/tcg/cpregs.c index 9d4ac66281..c971dc6097 100644 --- a/target/arm/tcg/cpregs.c +++ b/target/arm/tcg/cpregs.c @@ -17,6 +17,7 @@ #include "cpregs.h" #ifdef TARGET_AARCH64 +#include "cpu-sve.h" #include "tcg/tcg-sve.h" #endif /* TARGET_AARCH64 */ diff --git a/target/arm/tcg/helper.c b/target/arm/tcg/helper.c index edc4b4cb4e..984dae7643 100644 --- a/target/arm/tcg/helper.c +++ b/target/arm/tcg/helper.c @@ -18,6 +18,10 @@ #include "cpregs.h" #include "tcg-cpu.h" +#ifdef TARGET_AARCH64 +#include "cpu-sve.h" +#endif /* TARGET_AARCH64 */ + static int vfp_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg) { ARMCPU *cpu = env_archcpu(env);