From patchwork Thu Jun 9 09:05:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 580288 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp689309max; Thu, 9 Jun 2022 04:34:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymLQ0kujhn/zas4TbQXCNvFVuGgt6t+QJL5kKoTj7vv79yiOesVa2MDP70wd/I80p2Ol2a X-Received: by 2002:ac8:5f91:0:b0:304:df67:c780 with SMTP id j17-20020ac85f91000000b00304df67c780mr26123357qta.248.1654774473524; Thu, 09 Jun 2022 04:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654774473; cv=none; d=google.com; s=arc-20160816; b=wjPSvJUCYskNQcbh2qwxbBJU0FZ6PssqMxL4P5nNqPzJIVI4aKJFUGpdH4vc6XyZ2y bmYz8kouGdL+c1mXo7KTybCYXplISZrJvfsJGUxD2myvLBgMgnlqO3xP6mujKQDNdje6 OhA9nRVG0DvQYiPEu5PXB0qWy2PbTxx6lOP3ULNtHYaKT8COt+PYMqG6RRSqLfP4QPI/ tmvb6As3V1N5cXahHQJ/hIFzYUMBC+MZrNTsnS7jZA6jA/bzP3aZyJLgyTEa48h5pzx6 /zvOHhvRys0RX3ffo79gGfresVuFkSKezO4Mnx9Jni3DG2EsvBeZXCyuCARPJWEH2P8v FooQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=aIxMiFOj5OlkrMNI1jLiszeJAUOpuEVyCOWF9sP0Y2w=; b=NfuOlHwDaxyuNS379SL+3rsqWOqqtDjjkwz8shvsygQUwUjvw6bHO/8px3L3Qmhr/G JyW5PkjrphDbcmm6rEbryrC53B39/SuWpYWTVAwIV8BKay32kg+mo6/5LlV/AZZGFObl BDUwUE2jPhDMfDI3zSGvhPNXxOrGhIkjdSBVJmrmvUOcs6xq/QxKWMQukt8OslfJTsSi V3LeMWILExWIpzrYXc8vR3iHp7/hA5rYrq5/DwhEsGa8m4fWl2wjgr+rT0WukeQxwU7V 5F7F0bAT5i2Yl8zC9Ts13PUoxq/tYCha/3qax0N2OwvIOBu0059QHYeseAoGaIR2MslX YOgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZC2m5FbC; 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=pass (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 h17-20020ac85e11000000b00304f6988cd4si4708868qtx.778.2022.06.09.04.34.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Jun 2022 04:34:33 -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=pass header.i=@linaro.org header.s=google header.b=ZC2m5FbC; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzGQr-00083e-0D for patch@linaro.org; Thu, 09 Jun 2022 07:34:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7U-0001by-MH for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:24 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:36483) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7S-00063j-WC for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:24 -0400 Received: by mail-wr1-x42c.google.com with SMTP id o8so3625877wro.3 for ; Thu, 09 Jun 2022 02:06:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=aIxMiFOj5OlkrMNI1jLiszeJAUOpuEVyCOWF9sP0Y2w=; b=ZC2m5FbCfDchAohCh+UlgwvHp2J/t873YzrMo6IFMAN9+gJvfhwOkbmJ2P0QABjLmY nJOWXN3pusATWYgARANTam9uSrR6CgjXHEf1cRsLX1V2nw2QJgC0yqEVhHXVhVB7UDBN AQ2Zi1Ovk55YuyXHvS7xSav3xNhdu7vDjQGeoB8Um4SAlD2iLvyDrwc7yIuPmcuTxA0A WCc8QjFcUNz/78CVEl9ly1FKvseMuP2teBu6akkxWA7vasDNP9on8bFv0ZTZO2qQjjVr a7RjAmgCZe+E9PDvwSx4vM2JpzKLrelM4oR4mHYWHpl9h1YzsvtxD2b/uKrDc8pLkyCi d+TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aIxMiFOj5OlkrMNI1jLiszeJAUOpuEVyCOWF9sP0Y2w=; b=yuiFcMp9+lnCRhTcJkvtmRouAGLdWvlQPkdsOmNvagGO8q5xK8CkTYp1J+1GHCYSpc FLLdNrtJpmPSP51BITY5QiBSz3mxiRk16TcYYy8yPjqGtRjJtK9zPBQ68+9nLf937Qj9 M4bjW7RuUECdGASkOwcn/wKimgiqcG02OCUK/SnPsIMyccL8I6QiCZ+CX8Ue2VxdzM5+ pu3u+sU4yPnG4lRwF/5rKpmMHK6EEbOXt+8Exb+UUImXJWAWzEOJr5A4EvKvuz5nhMXK l/Mi3IEDBs9CCKtH2mRXkA0Lh0+nFTm9ehYUXCEPrecwyGJYofiQYSiH2clcCqC2cdPG ja0w== X-Gm-Message-State: AOAM532zRD+XeiXPYBUcGiJfM85PlRh7VAYfLLDqUIfec2x8GsBMhsD9 uj7poBVoKb0y8QDLY7EsU4O8TkKrXY6jgw== X-Received: by 2002:a05:6000:1888:b0:218:3fab:c510 with SMTP id a8-20020a056000188800b002183fabc510mr19871078wri.473.1654765580495; Thu, 09 Jun 2022 02:06:20 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:20 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 37/55] linux-user/aarch64: Introduce sve_vq Date: Thu, 9 Jun 2022 10:05:19 +0100 Message-Id: <20220609090537.1971756-38-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Add an interface function to extract the digested vector length rather than the raw zcr_el[1] value. This fixes an incorrect return from do_prctl_set_vl where we didn't take into account the set of vector lengths supported by the cpu. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20220607203306.657998-3-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- linux-user/aarch64/target_prctl.h | 20 +++++++++++++------- target/arm/cpu.h | 11 +++++++++++ linux-user/aarch64/signal.c | 4 ++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_prctl.h index 3f5a5d3933a..1d440ffbea4 100644 --- a/linux-user/aarch64/target_prctl.h +++ b/linux-user/aarch64/target_prctl.h @@ -10,7 +10,7 @@ static abi_long do_prctl_get_vl(CPUArchState *env) { ARMCPU *cpu = env_archcpu(env); if (cpu_isar_feature(aa64_sve, cpu)) { - return ((cpu->env.vfp.zcr_el[1] & 0xf) + 1) * 16; + return sve_vq(env) * 16; } return -TARGET_EINVAL; } @@ -25,18 +25,24 @@ static abi_long do_prctl_set_vl(CPUArchState *env, abi_long arg2) */ if (cpu_isar_feature(aa64_sve, env_archcpu(env)) && arg2 >= 0 && arg2 <= 512 * 16 && !(arg2 & 15)) { - ARMCPU *cpu = env_archcpu(env); uint32_t vq, old_vq; - old_vq = (env->vfp.zcr_el[1] & 0xf) + 1; - vq = MAX(arg2 / 16, 1); - vq = MIN(vq, cpu->sve_max_vq); + old_vq = sve_vq(env); + /* + * Bound the value of arg2, so that we know that it fits into + * the 4-bit field in ZCR_EL1. Rely on the hflags rebuild to + * sort out the length supported by the cpu. + */ + vq = MAX(arg2 / 16, 1); + vq = MIN(vq, ARM_MAX_VQ); + env->vfp.zcr_el[1] = vq - 1; + arm_rebuild_hflags(env); + + vq = sve_vq(env); if (vq < old_vq) { aarch64_sve_narrow_vq(env, vq); } - env->vfp.zcr_el[1] = vq - 1; - arm_rebuild_hflags(env); return vq * 16; } return -TARGET_EINVAL; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index e791ffdd6b6..f5af88b686d 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3286,6 +3286,17 @@ static inline int cpu_mmu_index(CPUARMState *env, bool ifetch) return EX_TBFLAG_ANY(env->hflags, MMUIDX); } +/** + * sve_vq + * @env: the cpu context + * + * Return the VL cached within env->hflags, in units of quadwords. + */ +static inline int sve_vq(CPUARMState *env) +{ + return EX_TBFLAG_A64(env->hflags, VL) + 1; +} + static inline bool bswap_code(bool sctlr_b) { #ifdef CONFIG_USER_ONLY diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index 7de4c96eb9d..7da0e36c6d4 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -315,7 +315,7 @@ static int target_restore_sigframe(CPUARMState *env, case TARGET_SVE_MAGIC: if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { - vq = (env->vfp.zcr_el[1] & 0xf) + 1; + vq = sve_vq(env); sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16); if (!sve && size == sve_size) { sve = (struct target_sve_context *)ctx; @@ -434,7 +434,7 @@ static void target_setup_frame(int usig, struct target_sigaction *ka, /* SVE state needs saving only if it exists. */ if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { - vq = (env->vfp.zcr_el[1] & 0xf) + 1; + vq = sve_vq(env); sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16); sve_ofs = alloc_sigframe_space(sve_size, &layout); }