From patchwork Tue Aug 29 23:23:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 718259 Delivered-To: patch@linaro.org Received: by 2002:adf:d20a:0:b0:31d:da82:a3b4 with SMTP id j10csp243651wrh; Tue, 29 Aug 2023 16:26:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGiCaaVhMEd6hK3PnWPrnf7XiesTwQZpKeeGQzBaftcDhDaD0L1WQH1ArtadCZFQiZXaHyr X-Received: by 2002:a05:6358:89b:b0:139:b4c0:94d with SMTP id m27-20020a056358089b00b00139b4c0094dmr385325rwj.12.1693351564420; Tue, 29 Aug 2023 16:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693351564; cv=none; d=google.com; s=arc-20160816; b=f0UoiD+FUec1GcIxkvLxSkYbNKM39H2eGzT3o6Z9HC02HXvlsgMviZr0R4tQARpGtJ ak5Vloxx48qimI6neOWmhXy7XY/4dfK1cZi19Dp2fWHHOJh7MIhs61vuWc3eCTBqi8g6 jDLxEHu4BRjrk/A3iIf19VGh4afSQgXmqUc1uqaORDPBBY58F0DxQVPO4UMsjYOg2grd zqA7wzar9Q2gATqzUixe0um2zNsEsq83Xs/wocE9uQongJa34Zwg3Y9jlivcVZV9/+Co uV43TVtpwyiKOt+fu9UPW8vGYHbGVFRhYzm7MGMQ064rTMmCwFqQTQz7jmm6nW+pUizo yNEg== 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=Hb9dMZIAxrLN24ygvHA9pXLZxd+STyR5WIcVAOZOt3k=; fh=L6OjQZ2TPsHFQEGPRBuboSqhQBavDZ5pPqlyX67xn3A=; b=wRAyy/FKCuIxg87+NIAVyanNtAXtJBjFCdchVg4ySot3Sd1WQVifXtpxB6nflFG3aO EwCxPWv7BU+Edp6K3QzC4qpu6UzFSRyCnbKdNPzcgBsFumqeElKYNoSSS/K3hCLnUIus eZaANI1UXtjuqBs/G2mZauv184kPLhjyVJM69SGtmXxuh1AaE9+klksXx9DYFY+v+abz mu/owBzWnXcmR+gRCMo7r4mov8gcV7o7YES0jXFS/YM/OUt4suYIGWR2qKxYmHqRg14F PP4szxsg3cP1A10MGF/xxspzL5rv2fEUje28TD2gSO/pTgzi3Zw56n8YGBPQ5VtRXQcK YZ6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NJ2aySW5; 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 qr18-20020a05620a391200b0076d7f1f203esi6586340qkn.268.2023.08.29.16.26.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Aug 2023 16:26:04 -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=NJ2aySW5; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb83p-0003iF-Jb; Tue, 29 Aug 2023 19:23:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qb83m-0003KV-Ft for qemu-devel@nongnu.org; Tue, 29 Aug 2023 19:23:46 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qb83h-0001MD-Px for qemu-devel@nongnu.org; Tue, 29 Aug 2023 19:23:46 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1bdbf10333bso39077355ad.1 for ; Tue, 29 Aug 2023 16:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693351420; x=1693956220; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Hb9dMZIAxrLN24ygvHA9pXLZxd+STyR5WIcVAOZOt3k=; b=NJ2aySW5dDJ8u3pIIxwpMHZXyjcXe5FJhvqBhqZd2tUFfoq5FXmiJTYewJ+cLK50Yy X5WtkkTCtxxy2H0BCqXwwYyGFq8IHzU+GPvJ9z75YILeferAPoAbqvTR/0yh9ddPHKwC +DVvgUVX9L175qwh9JCoNxoUs4a/vHMs+nh+ItNEalpuaVblDq38tLTrdE77wwWlLlUa +eTLzSp3LFuDQslhmjH2j62ASCtUzhssMJybrN398W8yzTa1ZHNIZQ+2gO6ZbCblL1WK v6xlSBwhyO2G8JRENGRocICvGOvjmlU4wryqdN7wdR2LXtigGyQ/nrQdplQmR97eLct/ g31w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693351420; x=1693956220; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hb9dMZIAxrLN24ygvHA9pXLZxd+STyR5WIcVAOZOt3k=; b=fYJqyWdb+MSgYxo4pCpZ2mFIFmAtdOPk9MOMFU54GPXVrr5k8ID5FKiec0eng78wRF mid2JYfpjKZ/1JaQR2nZTguz4hiqX4dOIIj16+cmjIhx1fA//r+V4/RDnen03+pzeU0y EQwfrpcFCN/IPARd80gGpeicUi6q4VWWelWRmsxtFTE0VdE+BmcInv4fTjmWsfPxndjO 56dH5udEZzzgIjMiNeXqMZO6JYYB85AC0zZOkgPY+oymrP3TFC/gWyNrgy8LmO7dc5fZ Po595KJIEv3I4q4nGeJTo+HFGdG7jIM3ohCUsmFeG9wED4/m91uJFegR0hxC1/bTZOAX S54w== X-Gm-Message-State: AOJu0YxJ0M0z9DVDGsEZDGww92YLBQhBNYCOlqSplRfHoTjpDGs8mbZW rcgs/RK5X2bie57YFsoLJ7W8fh7ZWz5C/j33veM= X-Received: by 2002:a17:902:684c:b0:1c0:9abb:4873 with SMTP id f12-20020a170902684c00b001c09abb4873mr503273pln.64.1693351420134; Tue, 29 Aug 2023 16:23:40 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id t9-20020a170902e84900b001b9dadf8bd2sm9829970plg.190.2023.08.29.16.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 16:23:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: aaron@os.amperecomputing.com, qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v5 03/12] target/arm: Add feature detection for FEAT_Pauth2 and extensions Date: Tue, 29 Aug 2023 16:23:26 -0700 Message-Id: <20230829232335.965414-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829232335.965414-1-richard.henderson@linaro.org> References: <20230829232335.965414-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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.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-bounces+patch=linaro.org@nongnu.org From: Aaron Lindsay Rename isar_feature_aa64_pauth_arch to isar_feature_aa64_pauth_qarma5 to distinguish the other architectural algorithm qarma3. Add ARMPauthFeature and isar_feature_pauth_feature to cover the other pauth conditions. Reviewed-by: Peter Maydell Signed-off-by: Aaron Lindsay Message-Id: <20230609172324.982888-3-aaron@os.amperecomputing.com> [rth: Add ARMPauthFeature and eliminate most other predicates] Signed-off-by: Richard Henderson --- target/arm/cpu.h | 47 +++++++++++++++++++++++++++++------ target/arm/tcg/pauth_helper.c | 2 +- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 4a5a5e9eb8..0e2545d631 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3801,28 +3801,59 @@ static inline bool isar_feature_aa64_fcma(const ARMISARegisters *id) return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FCMA) != 0; } +/* + * These are the values from APA/API/APA3. + * In general these must be compared '>=', per the normal Arm ARM + * treatment of fields in ID registers. + */ +typedef enum { + PauthFeat_None = 0, + PauthFeat_1 = 1, + PauthFeat_EPAC = 2, + PauthFeat_2 = 3, + PauthFeat_FPAC = 4, + PauthFeat_FPACCOMBINED = 5, +} ARMPauthFeature; + +static inline ARMPauthFeature +isar_feature_pauth_feature(const ARMISARegisters *id) +{ + /* + * Architecturally, only one of {APA,API,APA3} may be active (non-zero) + * and the other two must be zero. Thus we may avoid conditionals. + */ + return (FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, APA) | + FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, API) | + FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, APA3)); +} + static inline bool isar_feature_aa64_pauth(const ARMISARegisters *id) { /* * Return true if any form of pauth is enabled, as this * predicate controls migration of the 128-bit keys. */ - return (id->id_aa64isar1 & - (FIELD_DP64(0, ID_AA64ISAR1, APA, 0xf) | - FIELD_DP64(0, ID_AA64ISAR1, API, 0xf) | - FIELD_DP64(0, ID_AA64ISAR1, GPA, 0xf) | - FIELD_DP64(0, ID_AA64ISAR1, GPI, 0xf))) != 0; + return isar_feature_pauth_feature(id) != PauthFeat_None; } -static inline bool isar_feature_aa64_pauth_arch(const ARMISARegisters *id) +static inline bool isar_feature_aa64_pauth_qarma5(const ARMISARegisters *id) { /* - * Return true if pauth is enabled with the architected QARMA algorithm. - * QEMU will always set APA+GPA to the same value. + * Return true if pauth is enabled with the architected QARMA5 algorithm. + * QEMU will always enable or disable both APA and GPA. */ return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, APA) != 0; } +static inline bool isar_feature_aa64_pauth_qarma3(const ARMISARegisters *id) +{ + /* + * Return true if pauth is enabled with the architected QARMA3 algorithm. + * QEMU will always enable or disable both APA3 and GPA3. + */ + return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, APA3) != 0; +} + static inline bool isar_feature_aa64_tlbirange(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TLB) == 2; diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c index 62af569341..6271a84ec9 100644 --- a/target/arm/tcg/pauth_helper.c +++ b/target/arm/tcg/pauth_helper.c @@ -282,7 +282,7 @@ static uint64_t pauth_computepac_impdef(uint64_t data, uint64_t modifier, static uint64_t pauth_computepac(CPUARMState *env, uint64_t data, uint64_t modifier, ARMPACKey key) { - if (cpu_isar_feature(aa64_pauth_arch, env_archcpu(env))) { + if (cpu_isar_feature(aa64_pauth_qarma5, env_archcpu(env))) { return pauth_computepac_architected(data, modifier, key); } else { return pauth_computepac_impdef(data, modifier, key);