From patchwork Fri Apr 30 20:24:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 429837 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp769560jao; Fri, 30 Apr 2021 13:27:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUwUbMesXT2zHKfEa5WhylIjInBwPogdggrfxXwXAh1RfXrDizS6hIOWHpoaXIY97SyRzp X-Received: by 2002:a5d:9598:: with SMTP id a24mr5422850ioo.24.1619814464104; Fri, 30 Apr 2021 13:27:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619814464; cv=none; d=google.com; s=arc-20160816; b=V/bob+3H9bIFA6SkePtOLqRUQG3JjPe63ihwXZruCNBNOhFU4NZCIX6Dz1GB0MlJMX PmQshGqdJllVlQaQxU0Yc9Et9N73s1+VAMG47mfPpApNSt0DqX0LORPMdBSPC8rzuPxr Apu07g32x29aOgB7NmWHMw11+EiWSDK/oLAFk5UOSSxi1hxD8p48k4cjxATkyj0rabyp Q8HmKeZU+jwjQRn7U0mq9g3M/g6CqEpLh+1nOLExz6rvKQKdnAkntaSlaodQJ7kpWrqY hAWctYp3410zWs5pOFnnw4yikxGFoDhQENPpZ0P+bi8sQREpDVIwJgopBL+qDGgboHMj o1wg== 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=1UThjLBSb/XmVkkzs/Oev6mcIHSACdRwZzotytFesXI=; b=n+XBhhpmZPDm6kwoLmj6KNbVC65Oi2fVYhHywY1vWpDoQI3mO761CVjkdNOSDc00W1 kS5T9N3vbQaaWn2A8SjD26WX3UrmO3yLbqOs6VifjCxnDLj1Sl5hE5z1Ocb3m9XTPg8p aUG6i8gJyCxyly2N8pcDzTb7lj7sY7f5HXulGua1dmYKhEvk6kQ+N125qfp4VoYTMfDp /d9y56scAbOu1Csybt/IANw8ekxk/bk6HtpZnoR8vsS/Xzv8/inOcG2vtQH0CbFGlgHG eMy1pnvpT8WCrz0cCvrjR2R4JXib9XJdFUd/vC2uBrnW54pwyIIaPehE6mq21huiEm9k G74w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cNLHONW+; 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 g16si3300020jaj.93.2021.04.30.13.27.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Apr 2021 13:27:44 -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=cNLHONW+; 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]:54634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcZjj-0000N2-D0 for patch@linaro.org; Fri, 30 Apr 2021 16:27:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcZiK-00083f-T3 for qemu-devel@nongnu.org; Fri, 30 Apr 2021 16:26:16 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:39536) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lcZiH-0005rY-Kr for qemu-devel@nongnu.org; Fri, 30 Apr 2021 16:26:16 -0400 Received: by mail-pj1-x1034.google.com with SMTP id z6-20020a17090a1706b0290155e8a752d8so2344854pjd.4 for ; Fri, 30 Apr 2021 13:26:13 -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=1UThjLBSb/XmVkkzs/Oev6mcIHSACdRwZzotytFesXI=; b=cNLHONW+YFgQKZ2/axzcHwBr4YBzMah9n+gwaeVweoI3j/YXVc8aFIk4mJ4Qfkmdov 7SXTjZdzZgy1/RCowPKv1WInS7KBnMO/18GvHiqGpkIOuMIPXcgaDfY81yoIodvscjok 3zRA5epdBoxXOose2c8A7fjBukt7jn/reAmkF+ki3F1ha83DhaGNIZV8rRD2vrM+zqNk 3QNIuVuS/jy8WksY6W9RJ4kQOaVm/DFaulD/72c/IWOucrw6gEQtx4LdoLFqsLJ8UShB 34JLtGU3zn4CSi9m4aquihhy5magy+NeOXEHZGn1KPAlFzUH+BjBTNp8rJeMafDdLdg/ H4ew== 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=1UThjLBSb/XmVkkzs/Oev6mcIHSACdRwZzotytFesXI=; b=Ha6FGcgCoke1MFCj1BNY8RRvmRBDWueZKC6bWOhzWulurKvmwlffM/CG+FZ0LceWOq K6Xpupc9oqcrXIcvNxy51K/WEZlQtZ74WRmhraqIVe+jrlIN5cBMmNEcHbwdlGAqbvnB RTRRyT+COGphNUTudPmse3u33mHAlG/yLFXs+aT5HJ4StOPCQix9tE2rV52phauSohTP LeR1KQn3pEtqo+BJ9gpRkJq6lMgc7rP5rlkWrkkiW8t//Rjbu5ZCLp4jFZYRi9KbgL/i ONVSmwJC2uVB6pYxMZIYGY/Q/SpaTjnyxAYRhxogMJQZZlCOq1cN/GqPkVSoj3tRzpQe DMUw== X-Gm-Message-State: AOAM532AEB3P7mmMTPPQlVo3OON3v1+C9iCXhrc1/ycUYND6HmCB+3E1 Ipf8phXP1TpoEM2NKc+eqMXUySLio9Bycw== X-Received: by 2002:a17:902:501:b029:eb:7a1b:c96c with SMTP id 1-20020a1709020501b02900eb7a1bc96cmr7177337plf.76.1619814371770; Fri, 30 Apr 2021 13:26:11 -0700 (PDT) Received: from localhost.localdomain ([71.212.144.24]) by smtp.gmail.com with ESMTPSA id e6sm2905257pfd.219.2021.04.30.13.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Apr 2021 13:26:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 01/82] target/arm: Add ID_AA64ZFR0 fields and isar_feature_aa64_sve2 Date: Fri, 30 Apr 2021 13:24:49 -0700 Message-Id: <20210430202610.1136687-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210430202610.1136687-1-richard.henderson@linaro.org> References: <20210430202610.1136687-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Will be used for SVE2 isa subset enablement. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- v2: Do not read zfr0 from kvm unless sve is available. --- target/arm/cpu.h | 16 ++++++++++++++++ target/arm/helper.c | 3 +-- target/arm/kvm64.c | 11 +++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 616b393253..a6e1fa6333 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -947,6 +947,7 @@ struct ARMCPU { uint64_t id_aa64mmfr2; uint64_t id_aa64dfr0; uint64_t id_aa64dfr1; + uint64_t id_aa64zfr0; } isar; uint64_t midr; uint32_t revidr; @@ -2034,6 +2035,16 @@ FIELD(ID_AA64DFR0, DOUBLELOCK, 36, 4) FIELD(ID_AA64DFR0, TRACEFILT, 40, 4) FIELD(ID_AA64DFR0, MTPMU, 48, 4) +FIELD(ID_AA64ZFR0, SVEVER, 0, 4) +FIELD(ID_AA64ZFR0, AES, 4, 4) +FIELD(ID_AA64ZFR0, BITPERM, 16, 4) +FIELD(ID_AA64ZFR0, BFLOAT16, 20, 4) +FIELD(ID_AA64ZFR0, SHA3, 32, 4) +FIELD(ID_AA64ZFR0, SM4, 40, 4) +FIELD(ID_AA64ZFR0, I8MM, 44, 4) +FIELD(ID_AA64ZFR0, F32MM, 52, 4) +FIELD(ID_AA64ZFR0, F64MM, 56, 4) + FIELD(ID_DFR0, COPDBG, 0, 4) FIELD(ID_DFR0, COPSDBG, 4, 4) FIELD(ID_DFR0, MMAPDBG, 8, 4) @@ -4215,6 +4226,11 @@ static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id) return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0; } +static inline bool isar_feature_aa64_sve2(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SVEVER) != 0; +} + /* * Feature tests for "does this exist in either 32-bit or 64-bit?" */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 9b1b98705f..f47dd96076 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7561,8 +7561,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 4, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - /* At present, only SVEver == 0 is defined anyway. */ - .resetvalue = 0 }, + .resetvalue = cpu->isar.id_aa64zfr0 }, { .name = "ID_AA64PFR5_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 5, .access = PL1_R, .type = ARM_CP_CONST, diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index dff85f6db9..e8729b53fd 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -567,6 +567,17 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr2, ARM64_SYS_REG(3, 0, 0, 7, 2)); + /* + * Before v5.1, KVM did not support SVE and did not expose + * ID_AA64ZFR0_EL1 even as RAZ. After v5.1, KVM still does + * not expose the register to "user" requests like this + * unless the host supports SVE. + */ + if (isar_feature_aa64_sve(&ahcf->isar)) { + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64zfr0, + ARM64_SYS_REG(3, 0, 0, 4, 4)); + } + /* * Note that if AArch32 support is not present in the host, * the AArch32 sysregs are present to be read, but will