From patchwork Tue Mar 9 16:19:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 396016 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2766084jai; Tue, 9 Mar 2021 09:19:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzR11MQtFgZ7S8UoVohCl4POCBY2q8UCFHdhoPnMfufyoqHCQfXVTfuUHlN9sTOcwvUNYOo X-Received: by 2002:a02:3ec7:: with SMTP id s190mr29489867jas.11.1615310352716; Tue, 09 Mar 2021 09:19:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615310352; cv=none; d=google.com; s=arc-20160816; b=M0LMiIqLYLzBILXvVL5VP2mhIPd9+UC5uSkrZz+ttuK0hqrXwV3CWPb6C53o290O8B qnZmsR/AtHiLGGTMtI2lOWOTDHp2VIgfygYkmt2bT1yqu4eZ6Z2Qf1lwfCi3WoWB+i48 ACdb3f4gSzMwCq3PSI6tO/0ZFL2mykOsLws+LRgpM1gfNXwSfCMysE7eTA/8Ssz2i6g+ l5kZZGxS75iqHsgJwmWNrAVJY/8gQ/to8gKi1uAiId3P7aUH6ebqIkDmeJBrNU54Z+yL Quf1FPssintqc8QzrmvgnvCQQ2vLwgDJTT/oL/k4GtorpIRGSPdIms7g+qaxk92n2IzY vBaQ== 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=hYJXwe4FbJfgTdVPMN7My2daIn3Bg5z6ffUixEKobJI=; b=tDoWbwVkVzN0C/sXZMt/Jm/3SbjW+2S+iUKECplu2dd9+4N5bHgeQkIwlbKb9G68JU Qd3vcQCkA3h/n+En9+0P9yXyXwlLiahEMXsQkmTJt0B3cOtZkbcUjuvCqr7bDNPF6cPD XdcMtl/BLalt4mYhw0SbwQkNjUk93mTu2LmqeX/NGGDiG9177HEfUJUZHdcGvEN+kQSc XJjQME2GGMIANRV4NtS5ktuTb7cHMLb35udUrJJlXX74GfcgXUH2UUDA+ou0rMu8BQ7s 0LclSAM6p9Z7TFsQF+K4eJWNHeHCjnjSxlNe9YHzlM6D2fbnu1oP10bGBKXjVxb9Gv37 nfKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H3usu8MF; 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 v7si13275281ilu.80.2021.03.09.09.19.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Mar 2021 09:19:12 -0800 (PST) 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=H3usu8MF; 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]:57288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJg0m-0001Yb-1r for patch@linaro.org; Tue, 09 Mar 2021 12:19:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJf6L-0006w5-3t for qemu-devel@nongnu.org; Tue, 09 Mar 2021 11:20:54 -0500 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]:35192) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJf6E-0002Nh-F4 for qemu-devel@nongnu.org; Tue, 09 Mar 2021 11:20:52 -0500 Received: by mail-oi1-x22e.google.com with SMTP id u6so8187521oic.2 for ; Tue, 09 Mar 2021 08:20:45 -0800 (PST) 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=hYJXwe4FbJfgTdVPMN7My2daIn3Bg5z6ffUixEKobJI=; b=H3usu8MFzXk95EuTUYgzbCBYkuTSnaT2kJRw72Y3R+tuSgAz56SxHuGNH7gdhC2A5X 20V3EyL2kLhB+8d6dHZjLP5ErtnVhQNws2df7nyTdpBn35sIuq6oHzv4ZgngRnSfWWYT 0vQiYV/mLk+MuGF/kc92nIWO3gV9/mu/5T5xmqp8iHJ62HIhIRukH+rkzfp2C3Ls3vbC H8y3gDXIMA+zt9iKmT1fl60kydLpCVeXYyuXzb8t4xHfQNcgLheC4UhdbcgI/UTgjnwA /EQqoipyJ0FoXdYRbdNczgGpZ+wE63xSijN99T4cNMZdeKgQOIU+tIIEABYiw1pbYWFA ilzg== 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=hYJXwe4FbJfgTdVPMN7My2daIn3Bg5z6ffUixEKobJI=; b=Vk0eCW7MqyOehGNW2ShCcWYICnet52AHZEfz83fFdxRsRHstYIY/w3qhuAxxDYuShS bJb4T0mUhB9454sSRMq621YtjDOml2icw/eYDIWuJdBhixPA7wpzeRb6UT4B8Z43dv4N Up8obOLLryOc4+rm/SbApQflaR52tej6zaOSF4kLFECZqKBme9wTDMCovvXi4DyPQ98P I5qYUm+CTBTdJXdcacBBJw39WmBMBbUYmmxM7F+W8lAJoeaaY4m43oj9tArzlSKqvoEK Y8BO6lFtySZNzDPuq1A0/33QlreHNKAqcvJPz+VGOBLqrsiMluImz+z827zmddl+Fyki C1jQ== X-Gm-Message-State: AOAM531D9DAHR21kMfi1YKY7k60li+2SUqB2VKNHpQNTD/2zDn7c2cFX untohp5X7J/7YwbhuUpbkpN94SLjKISB7clZ X-Received: by 2002:aca:de82:: with SMTP id v124mr3481050oig.125.1615306844573; Tue, 09 Mar 2021 08:20:44 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id v23sm2516474ots.63.2021.03.09.08.20.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 08:20:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 01/78] target/arm: Add ID_AA64ZFR0 fields and isar_feature_aa64_sve2 Date: Tue, 9 Mar 2021 08:19:24 -0800 Message-Id: <20210309162041.23124-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210309162041.23124-1-richard.henderson@linaro.org> References: <20210309162041.23124-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22e; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22e.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=unavailable 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: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org 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 193a49ec7f..ee92ea876e 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -942,6 +942,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; @@ -2029,6 +2030,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) @@ -4182,6 +4193,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 904b0927cd..48c00de6ca 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