From patchwork Tue Jun 7 20:32:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579354 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5517277max; Tue, 7 Jun 2022 14:15:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ1gthia4Ug1fmt9R/WyId4B4q2ZCtQ7JBLvwQnmpKX4pgGhhjUNOr03EwUFkNayW5baYK X-Received: by 2002:a05:622a:6082:b0:2f1:1f9c:251e with SMTP id hf2-20020a05622a608200b002f11f9c251emr24946487qtb.230.1654636505859; Tue, 07 Jun 2022 14:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654636505; cv=none; d=google.com; s=arc-20160816; b=a6DY7AD4K3wP9V1+VkvhRqm0hTeSkSnaenfLVGer9T544tLFuRM4mJ3On7fPw2zfgy p4V3qmPwp3lmTft13yIYCkbRP0vfwjuKucIAOLmH/2PcemsQOlIYNwWTH2l8dVXzaQoI 62Wh6gcX0exk+q8bDbCyko/SbA4ciAFE0auUXy7rL0rIEH0/19OrDTNoKecIvvTKIihl ZvVJT9iJfLHdvLoPOGulJ8unx89QF4BHM1+tkPZUV/NE+SXkGpJeo69Rww0IG3ci8oxA EeT8CeMDQIl/as+mm6TB8h4ocV2PyaWdRbDJ4VXLo85UUp0Xi8l+xYTSM0MwBzVVvH0Q jo3Q== 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:cc:to :from:dkim-signature; bh=1+sOff0+QrylHPJptcCOIS0ShDDTD4Sb4O393k+bbFc=; b=iuVH5qb/xu20DvbeB2/bxPp/xtEIehqGcGEhgg9h1Qq+/5/l8yljkl4uimt+VjDZqc HKSLHwhhYlCyp1uROyjGfahpyj5Afzz3ZcLUDKHtLesgLPCOvPGG8od9AERhUo3gfjjs aBxJyxpgz5hP+GG2NSITcxrBEZbkt06bEDO6XeLU+EXpu1sHs+K5ty6ZLittDMuEVMvE I3mXpdrq7F34099sVbfxR0grGXjgvCXIueAlJOExvbLONE7+68q04hjj9TfhTdo7OnhD LIHaXVYwfSjI4lxkjQmD65I+KfT0RjNtRYkeOiaixRO0wwqftA6qcnPzKgA2SxHn0Egz 4TLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sh1z2Z8d; 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 d6-20020a05622a05c600b00300c8625c9asi10670504qtb.238.2022.06.07.14.15.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 14:15:05 -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=Sh1z2Z8d; 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]:42706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nygXZ-0001vm-Af for patch@linaro.org; Tue, 07 Jun 2022 17:15:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyftc-0000Dy-1X for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:33:48 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:44789) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyftS-0007Ra-Lw for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:33:47 -0400 Received: by mail-pj1-x102c.google.com with SMTP id gc3-20020a17090b310300b001e33092c737so16422673pjb.3 for ; Tue, 07 Jun 2022 13:33:38 -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=1+sOff0+QrylHPJptcCOIS0ShDDTD4Sb4O393k+bbFc=; b=Sh1z2Z8dy75CpmxSz/Cm2fbWdPPDzFPOTSXp0hu6LbszyPtiEIxPvkvZClnI/1d4Ul s/VrsIhL0y4kmJDiKgeglJs8HfLSSl13Mv7ScB0B0XHuSy5Ij2XPcE9G66jM3MEIDcCn F/rkb1EqsbamZQIxmZMUBiEtMdkZkYt0bcyMy4MwNj5HYmGzQdgEq7oSfHGw8ya2ZKaD s8+X3I3Xos1qGVMvFnnoe9UeI2tqnQVKoaU7lmdqoPS6hAXf6+U75z0WLFCRm7SjsBI/ k7XP+MrTXZe6YYpnNosq0LtXEHDR1PpqKlDiRzeyjYHbO5K0+jZSqnVnL+IpyIrSM8lo +a+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1+sOff0+QrylHPJptcCOIS0ShDDTD4Sb4O393k+bbFc=; b=rcQ4e6b+iESB9WIQKC0nDXP75FDFcei9UfHqnsZXEymlM8JJE135Yr5R3W0l/TTEuk ZwQkXjmLPdqb818X7NZC6ATjkmVLON8q2ADEx3q7+CUq58DQ3NmOeWDTokALtjOqs/Uy 8dzM+0VBHM0njeR+iI6XAEW/qSHd8HWJc4Payykzw6OnHB6abIKU219eNaJhs5wOwmxM cWkCnT7lfixqQwctTD8K9Ms03neO3X3qdiKTHABByryTjRWApvri3BYRI0b+GTWfV/ko HhZkZOdoEZZsD1dvGF1TF+R89MLtSIor9ZlGRj6Avme2edLoVcHd1q5SYueVyJi+yRk7 sy1Q== X-Gm-Message-State: AOAM533dACTTEHKGq8rP8cvhp83KkvTsjMiOTGCDFS6v8WhLSYnHodix rroJKYBZSjJH2iyHnzhV3xk6CkrAqPcVYg== X-Received: by 2002:a17:902:e886:b0:163:f3e5:b3b9 with SMTP id w6-20020a170902e88600b00163f3e5b3b9mr30442727plg.80.1654634017274; Tue, 07 Jun 2022 13:33:37 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:3cf2:c634:5b19:25f6]) by smtp.gmail.com with ESMTPSA id s22-20020a17090aba1600b001d9780b7779sm4227856pjr.15.2022.06.07.13.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 13:33:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Subject: [PATCH v2 32/71] target/arm: Create ARMVQMap Date: Tue, 7 Jun 2022 13:32:27 -0700 Message-Id: <20220607203306.657998-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220607203306.657998-1-richard.henderson@linaro.org> References: <20220607203306.657998-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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=unavailable 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" Pull the three sve_vq_* values into a structure. This will be reused for SME. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/cpu.h | 29 ++++++++++++++--------------- target/arm/cpu64.c | 22 +++++++++++----------- target/arm/helper.c | 2 +- target/arm/kvm64.c | 2 +- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index e7ec03a8a7..4e86d143c8 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -793,6 +793,19 @@ typedef enum ARMPSCIState { typedef struct ARMISARegisters ARMISARegisters; +/* + * In map, each set bit is a supported vector length of (bit-number + 1) * 16 + * bytes, i.e. each bit number + 1 is the vector length in quadwords. + * + * While processing properties during initialization, corresponding init bits + * are set for bits in sve_vq_map that have been set by properties. + * + * Bits set in supported represent valid vector lengths for the CPU type. + */ +typedef struct { + uint32_t map, init, supported; +} ARMVQMap; + /** * ARMCPU: * @env: #CPUARMState @@ -1041,21 +1054,7 @@ struct ArchCPU { uint32_t sve_default_vq; #endif - /* - * In sve_vq_map each set bit is a supported vector length of - * (bit-number + 1) * 16 bytes, i.e. each bit number + 1 is the vector - * length in quadwords. - * - * While processing properties during initialization, corresponding - * sve_vq_init bits are set for bits in sve_vq_map that have been - * set by properties. - * - * Bits set in sve_vq_supported represent valid vector lengths for - * the CPU type. - */ - uint32_t sve_vq_map; - uint32_t sve_vq_init; - uint32_t sve_vq_supported; + ARMVQMap sve_vq; /* Generic timer counter frequency, in Hz */ uint64_t gt_cntfrq_hz; diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index e18f585fa7..0a2f4f3170 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -355,8 +355,8 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) * any of the above. Finally, if SVE is not disabled, then at least one * vector length must be enabled. */ - uint32_t vq_map = cpu->sve_vq_map; - uint32_t vq_init = cpu->sve_vq_init; + uint32_t vq_map = cpu->sve_vq.map; + uint32_t vq_init = cpu->sve_vq.init; uint32_t vq_supported; uint32_t vq_mask = 0; uint32_t tmp, vq, max_vq = 0; @@ -369,14 +369,14 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) */ if (kvm_enabled()) { if (kvm_arm_sve_supported()) { - cpu->sve_vq_supported = kvm_arm_sve_get_vls(CPU(cpu)); - vq_supported = cpu->sve_vq_supported; + cpu->sve_vq.supported = kvm_arm_sve_get_vls(CPU(cpu)); + vq_supported = cpu->sve_vq.supported; } else { assert(!cpu_isar_feature(aa64_sve, cpu)); vq_supported = 0; } } else { - vq_supported = cpu->sve_vq_supported; + vq_supported = cpu->sve_vq.supported; } /* @@ -534,7 +534,7 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) /* From now on sve_max_vq is the actual maximum supported length. */ cpu->sve_max_vq = max_vq; - cpu->sve_vq_map = vq_map; + cpu->sve_vq.map = vq_map; } static void cpu_max_get_sve_max_vq(Object *obj, Visitor *v, const char *name, @@ -595,7 +595,7 @@ static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name, if (!cpu_isar_feature(aa64_sve, cpu)) { value = false; } else { - value = extract32(cpu->sve_vq_map, vq - 1, 1); + value = extract32(cpu->sve_vq.map, vq - 1, 1); } visit_type_bool(v, name, &value, errp); } @@ -611,8 +611,8 @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, return; } - cpu->sve_vq_map = deposit32(cpu->sve_vq_map, vq - 1, 1, value); - cpu->sve_vq_init |= 1 << (vq - 1); + cpu->sve_vq.map = deposit32(cpu->sve_vq.map, vq - 1, 1, value); + cpu->sve_vq.init |= 1 << (vq - 1); } static bool cpu_arm_get_sve(Object *obj, Error **errp) @@ -973,7 +973,7 @@ static void aarch64_max_initfn(Object *obj) cpu->dcz_blocksize = 7; /* 512 bytes */ #endif - cpu->sve_vq_supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ); + cpu->sve_vq.supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ); aarch64_add_pauth_properties(obj); aarch64_add_sve_properties(obj); @@ -1022,7 +1022,7 @@ static void aarch64_a64fx_initfn(Object *obj) /* The A64FX supports only 128, 256 and 512 bit vector lengths */ aarch64_add_sve_properties(obj); - cpu->sve_vq_supported = (1 << 0) /* 128bit */ + cpu->sve_vq.supported = (1 << 0) /* 128bit */ | (1 << 1) /* 256bit */ | (1 << 3); /* 512bit */ diff --git a/target/arm/helper.c b/target/arm/helper.c index e065a1deb8..e3f3e4dfc2 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6291,7 +6291,7 @@ uint32_t sve_vqm1_for_el(CPUARMState *env, int el) len = MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[3]); } - len = 31 - clz32(cpu->sve_vq_map & MAKE_64BIT_MASK(0, len + 1)); + len = 31 - clz32(cpu->sve_vq.map & MAKE_64BIT_MASK(0, len + 1)); return len; } diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index ff8f65da22..d16d4ea250 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -820,7 +820,7 @@ uint32_t kvm_arm_sve_get_vls(CPUState *cs) static int kvm_arm_sve_set_vls(CPUState *cs) { ARMCPU *cpu = ARM_CPU(cs); - uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = { cpu->sve_vq_map }; + uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = { cpu->sve_vq.map }; struct kvm_one_reg reg = { .id = KVM_REG_ARM64_SVE_VLS, .addr = (uint64_t)&vls[0],