From patchwork Fri Sep 8 17:05:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 720843 Delivered-To: patch@linaro.org Received: by 2002:adf:eec5:0:b0:31d:da82:a3b4 with SMTP id a5csp884404wrp; Fri, 8 Sep 2023 10:08:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPfwmnjB3uZO3GtHa+U8jjEShCvcAt57uMbWsb0iKMdGKTQUhigtXmgJyP7YMM0X5al0HA X-Received: by 2002:a05:620a:19a3:b0:765:9c48:a930 with SMTP id bm35-20020a05620a19a300b007659c48a930mr3191304qkb.67.1694192920399; Fri, 08 Sep 2023 10:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694192920; cv=none; d=google.com; s=arc-20160816; b=pClNGyO6qG8fSVpLOt+gvhstWtuKxCCmG++iFCddI7jFq22uuKUsye8Ym/C8fA2jpc YISF9U9zPhvroVHizbDfLYIUxP8dpv08WVSS1OTrnlpZ63zAcVNIZaZnb7PLtgaDITZx n928Mg8rhZrUMFNktQ4jqEf/qgxnyZRDVyfcbX3ah5MtxGnctEFZU42YU5XmIcB20WU6 6cbezW0MUqI+qxWVkDFop1wcF5BhBiwppSsPoTd8IhGf7KY4VgfW5o28ngyLPjARJSp/ lTutKoEo6f08kbWBjISetRUSGt7gz+yzQzRvrLZjqOT0GFl+CYqXIIH97ztRGQyId3Cj 638Q== 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:to:from :dkim-signature; bh=Y3fdZw1RfPhJKCd65KPY6TC+lTEu607zM4Lh3UAYxaM=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=jgnbmr2n26l4OGOIH3DxVdqBOAs9QBYwJ68Ex3RoQNFwe/NsoPRjGBtm5gZSS2dWvo yoPQxW1xLc8ht5uV+4CQU38PhL7h7uvyni1gy6m4cs0d1Gtdtifyg4Y/7pNRV8zARzHZ GVnG9bjWfZboaldWFJlZhkB00gxZ2mYo9xrIG+8V2t3AsiZFPZeW8d+7bXgcqH2jJi4d +NrPTRbHobn5hw8Ww/NEUidtzoeHXWeZqWFQvJ6GNVXesh45BEc1y37XTlfMJk2qFyur AdjSI/pft/PVay1mw5jeOT+JlOmpEemfqxnDJFt3WxkLOJ2BAMv+/E7g19iUv2TEzN+i 2Paw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vmrz1xvt; 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 u7-20020a05620a454700b0076f08396be2si1261760qkp.546.2023.09.08.10.08.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Sep 2023 10:08:40 -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=vmrz1xvt; 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 1qeevv-00053Z-JU; Fri, 08 Sep 2023 13:06:15 -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 1qeevs-0004yr-Lv for qemu-devel@nongnu.org; Fri, 08 Sep 2023 13:06:12 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeevn-00016X-Jf for qemu-devel@nongnu.org; Fri, 08 Sep 2023 13:06:12 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-400a087b0bfso24194785e9.2 for ; Fri, 08 Sep 2023 10:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694192762; x=1694797562; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Y3fdZw1RfPhJKCd65KPY6TC+lTEu607zM4Lh3UAYxaM=; b=vmrz1xvtlFAAt3zz2hp/fOZ1LRxReLPsQAdcdniklO1+SJTpMmsewpeg+bwHNlk2Ne XVkasEUReU78UgMo5ScWRx55Qx2JG8um+ukk8OzbGfwfbeu8QnEzkqgRiHr7ZkMCnruK VHGw8YAojOWe4T6eCzoC1VpOLaQmzodLCWPv5UFl9b2i9J0yaeLHlFqjByN1+CAriGtQ Owvd8mtgyvueWANz1qMQrnhKn/1P8YFXgUrCday4NxP7hRkKTtCG8cqh7YZ5X8Q5elU/ b6Yd4EcLwjuXQ7CAwh+1w95aBYlDKN8S6ySegC2WUU/rNUB+ALg+Ev+sFFTI5IQHGHRe apxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694192762; x=1694797562; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y3fdZw1RfPhJKCd65KPY6TC+lTEu607zM4Lh3UAYxaM=; b=isH+lpwfKupbpbBKTKqX5S8pwYyvvv/nl8HSI6JZHiPcSGSxFxNea4aGGinQN04Ape fXbhWQNVvpZtzGol49MSsuE+qw06HP2cxAn4/ypd3Jkpsm3IRbBy6CpcrLqRUu/fH1at OCff8+OHrS07xcmtPiqe2OmmtnsKLcDjwNa8l8QVLxVJb9ve+xgPulAMZ35iFaonMpW+ Hjv9RCD2iB1iscEMpRwPVz1j9aGctlyur+1ItGl/69ztwNIN/MI56rFjOCT+PYL52WNg /eve8S9cAQogQK1WEE9xHMVZwP5GbDgujLQhusx+ju2hS20otE3LKpCzwKioULsG+/6u Tp1A== X-Gm-Message-State: AOJu0YwovvA7rh641OBVwgeTc/iTiPtdqLHsmBVBGpOXZWSdMawvKKlN wmmpcYh0PVZH3YtawNUIF+OnCUP3g1WZpn9Guz0= X-Received: by 2002:a1c:f70c:0:b0:402:cf9e:fc84 with SMTP id v12-20020a1cf70c000000b00402cf9efc84mr2324482wmh.26.1694192762541; Fri, 08 Sep 2023 10:06:02 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id d21-20020a1c7315000000b00400268671c6sm2427152wmb.13.2023.09.08.10.06.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 10:06:02 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 04/26] target/arm: Don't change pauth features when changing algorithm Date: Fri, 8 Sep 2023 18:05:35 +0100 Message-Id: <20230908170557.773048-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230908170557.773048-1-peter.maydell@linaro.org> References: <20230908170557.773048-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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 From: Richard Henderson 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. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20230829232335.965414-5-richard.henderson@linaro.org Signed-off-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 96158093cc6..fd584a31da7 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 0f8972950d6..4a1d9816dfb 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -803,6 +803,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 */