From patchwork Tue Aug 22 04:25:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 715672 Delivered-To: patch@linaro.org Received: by 2002:adf:f747:0:b0:317:ecd7:513f with SMTP id z7csp69431wrp; Mon, 21 Aug 2023 21:27:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4PZVokqfXUlL08hFWfGtuSVOEyu4VUfJLPuDwdLWyjp6mHE6psQHNKIpe9FGmtAIsgHuH X-Received: by 2002:a05:622a:1a85:b0:405:4eec:6341 with SMTP id s5-20020a05622a1a8500b004054eec6341mr11642862qtc.56.1692678428038; Mon, 21 Aug 2023 21:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692678428; cv=none; d=google.com; s=arc-20160816; b=xFs0h4S5UizEhU9AhIX6snAmp8yPENxvtn721GRgJ6262QD6XWlb4IGqWcZuIYoZE5 dVIhv/Leae290NvW3mw/7Mxqrl9fzmjMgQZxwyy0HATUuGq478C0SB/w56rJ5jpVlKkj +kdaS1b89oiEk3upP1m2QIlUr7T2PMQf1MF8GIcHPJgNnzzJCO0iQINzwM2NgbY5zKEM QbLxYnVvkPrau75uDGjYRHo2KZb6w7FhxkdGgyKo25FOkTci2MAiwuG4JY38LKH4taTd iQ09EFOxWNy3UfCh9alpfeIiu5kBiSo8/Izm0+JyAK/p7oLSp/i4zUwJdFomKqwGXQZA Ofog== 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=vq6cFhLLgy1EjGAe2inqelLAnSEJzTAGffoR6HgTphI=; fh=oweadga+1U1BKjDqlK8hSmEWEC1EUfcsKuPkDinEDsU=; b=SlC2Tm+8ABYSK91/Y03Mg3GhvmcpM+XkGUJGYicG/t+7M8/QHreQyh/78sppEUQXQk eKg7gToLZc7HVlKThVHuCRBcAEffcyZTwGpGHBL7+7euBAfaeo94E+BYKIl2VWU8W45l YMYExYmlJXLWH1wpHyPGtUZT4/TY/j8GSshTj9ozaFAZcoLvL0OoesZTdMlP3xVCHvMq 0R8q+scxuJqFdnXkt4RI4MYAEmGO3WDF4MYqUyxOMxMJjt57tnKYuCvBoarXmrEpyzuH UNcWFjJ7QzEvWFPHIDwWCYxIVPGrkqui4vdr95QXC1/Lqlz2pGQVXqcHS0/XyNX0og1V 70Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LefaJBOs; 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 i7-20020ac85c07000000b00403eb7b883esi1036298qti.613.2023.08.21.21.27.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Aug 2023 21:27:08 -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=LefaJBOs; 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 1qYIxb-0006Ka-5f; Tue, 22 Aug 2023 00:25:43 -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 1qYIxZ-0006Ic-4I for qemu-devel@nongnu.org; Tue, 22 Aug 2023 00:25:41 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qYIxU-0007Wd-Nb for qemu-devel@nongnu.org; Tue, 22 Aug 2023 00:25:40 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-68a3e943762so1854921b3a.1 for ; Mon, 21 Aug 2023 21:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692678335; x=1693283135; 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=vq6cFhLLgy1EjGAe2inqelLAnSEJzTAGffoR6HgTphI=; b=LefaJBOs5sDQXKTlGNmxGIo3wTMIICdq+wkpVrLUMPjtvDkHZ8nBBCUOOc2TnPiYqk t+B0NVLp0izCCubqVDp6U7OTZwB4tqhQSl52z/Uad2IeDGTlETlsAaOkCyPhefR2aGQE c0WvX/VudK0YV800xugh5faF8wV580zDjX9/OHhK6UQXiPiT+rnuXJmKjsj9RC8liw7i wBVaaLcMGGT4qPlIGPUxCTVOeSKxhT5uX7dHhHZkCdSyFlgkLNzztAokMmgx144HMOur A6e/6ctCq4vZwnzvEYB9szInnUIDZ6I9UnHklpYoz70CNnv8zTNHuYwxw0FCywg79m/b dF1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692678335; x=1693283135; 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=vq6cFhLLgy1EjGAe2inqelLAnSEJzTAGffoR6HgTphI=; b=LY2H0oX4zZKf7fmkwBNpZr533VXigpkIHdPDae71pYmDKJULIrujZCatGf2AV8J1Jz aN2RF8Na5k6YFe/lo2EOidC8rHOLendmO1ROjwYsM9lQuOPECSPwlxfF1hlitk4ttHei eefJ+KQ2CbeEGS4+/XYudFIpa2dIXXy8ZWN6rWPh0O0xyl/tXJ6ep42uSJ359A/NDmfb F720t9wEGnkgD8q6d7NLoX/BHxVrdwkr3FyRq8q+jAFyCpnfLMhY2T3+vye/LQMWCY/W e1ehtvDrj9MRP4EsjOUb7DKut3eGtR9pTQUpiCKEFz4GZily09mjQXucODyKZMdLi25K 84Tg== X-Gm-Message-State: AOJu0Yxp3T9en18hKtxObZ1g8r7+K/R/BZS5PudUM7U1ZELIAagi890O 1y+Xpe9fK/NES9ufczO52BFppo5/Nn+GBNHz9gE= X-Received: by 2002:a05:6a00:148f:b0:68a:4d66:ca1 with SMTP id v15-20020a056a00148f00b0068a4d660ca1mr5808059pfu.6.1692678335410; Mon, 21 Aug 2023 21:25:35 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:2c08:e710:4459:46f1]) by smtp.gmail.com with ESMTPSA id m14-20020aa7900e000000b0068a3f861b24sm3364908pfo.195.2023.08.21.21.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Aug 2023 21:25:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v4 4/9] target/arm: Don't change pauth features when changing algorithm Date: Mon, 21 Aug 2023 21:25:25 -0700 Message-Id: <20230822042530.1026751-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230822042530.1026751-1-richard.henderson@linaro.org> References: <20230822042530.1026751-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.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.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 We have cpu properties to adjust the pauth algorithm for the purpose of speed of emulation. Retain the set of pauth features supported by the cpu even as the algorithm changes. This already affects the neoverse-v1 cpu, which has FEAT_EPAC. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/cpu64.c | 70 +++++++++++++++++++++++++++--------------- target/arm/tcg/cpu64.c | 2 ++ 2 files changed, 47 insertions(+), 25 deletions(-) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 96158093cc..fd584a31da 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -473,37 +473,57 @@ void aarch64_add_sme_properties(Object *obj) void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) { - int arch_val = 0, impdef_val = 0; - uint64_t t; + ARMPauthFeature features = cpu_isar_feature(pauth_feature, cpu); + uint64_t isar1; - /* Exit early if PAuth is enabled, and fall through to disable it */ - if ((kvm_enabled() || hvf_enabled()) && cpu->prop_pauth) { - if (!cpu_isar_feature(aa64_pauth, cpu)) { - error_setg(errp, "'pauth' feature not supported by %s on this host", - kvm_enabled() ? "KVM" : "hvf"); + /* + * These properties enable or disable Pauth as a whole, or change + * the pauth algorithm, but do not change the set of features that + * are present. We have saved a copy of those features above and + * will now place it into the field that chooses the algorithm. + * + * Begin by disabling all fields. + */ + isar1 = cpu->isar.id_aa64isar1; + isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, APA, 0); + isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, GPA, 0); + isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, API, 0); + isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, GPI, 0); + + if (kvm_enabled() || hvf_enabled()) { + /* + * Exit early if PAuth is enabled and fall through to disable it. + * The algorithm selection properties are not present. + */ + if (cpu->prop_pauth) { + if (features == 0) { + error_setg(errp, "'pauth' feature not supported by " + "%s on this host", current_accel_name()); + } + return; + } + } else { + /* Pauth properties are only present when the model supports it. */ + if (features == 0) { + assert(!cpu->prop_pauth); + return; } - return; - } - - /* TODO: Handle HaveEnhancedPAC, HaveEnhancedPAC2, HaveFPAC. */ - if (cpu->prop_pauth) { - if (cpu->prop_pauth_impdef) { - impdef_val = 1; - } else { - arch_val = 1; + if (cpu->prop_pauth) { + if (cpu->prop_pauth_impdef) { + isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, API, features); + isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, GPI, 1); + } else { + isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, APA, features); + isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, GPA, 1); + } + } else if (cpu->prop_pauth_impdef) { + error_setg(errp, "cannot enable pauth-impdef without pauth"); + error_append_hint(errp, "Add pauth=on to the CPU property list.\n"); } - } else if (cpu->prop_pauth_impdef) { - error_setg(errp, "cannot enable pauth-impdef without pauth"); - error_append_hint(errp, "Add pauth=on to the CPU property list.\n"); } - t = cpu->isar.id_aa64isar1; - t = FIELD_DP64(t, ID_AA64ISAR1, APA, arch_val); - t = FIELD_DP64(t, ID_AA64ISAR1, GPA, arch_val); - t = FIELD_DP64(t, ID_AA64ISAR1, API, impdef_val); - t = FIELD_DP64(t, ID_AA64ISAR1, GPI, impdef_val); - cpu->isar.id_aa64isar1 = t; + cpu->isar.id_aa64isar1 = isar1; } static Property arm_cpu_pauth_property = diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index 8019f00bc3..fec6a4875d 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -758,6 +758,8 @@ void aarch64_max_tcg_initfn(Object *obj) t = cpu->isar.id_aa64isar1; t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2); /* FEAT_DPB2 */ + t = FIELD_DP64(t, ID_AA64ISAR1, APA, PauthFeat_1); + t = FIELD_DP64(t, ID_AA64ISAR1, API, 1); t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); /* FEAT_JSCVT */ t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); /* FEAT_FCMA */ t = FIELD_DP64(t, ID_AA64ISAR1, LRCPC, 2); /* FEAT_LRCPC2 */