From patchwork Mon Feb 21 09:27:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 544423 Delivered-To: patch@linaro.org Received: by 2002:ac0:e142:0:0:0:0:0 with SMTP id r2csp3109350imn; Mon, 21 Feb 2022 01:54:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJy52io+jzIVoR56poQ+YtyF14pAZcuo7cDqGEabW7lFdoGZxpM3lYTQcgaqwDsv57ZMHW7h X-Received: by 2002:a37:9e86:0:b0:507:42b:7540 with SMTP id h128-20020a379e86000000b00507042b7540mr11411036qke.159.1645437271894; Mon, 21 Feb 2022 01:54:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645437271; cv=none; d=google.com; s=arc-20160816; b=rczuWTbp6yGFww8uuQDpWcKbR5B6LZSb6oRqWJCg24fqrwivoquDX6Y4v/IXwFFcw2 LAbqiiOqwglFA0UojE1Q8rsiqvWgE3gsH6phQKRtdCgE5k1xRgAWE3F4PFzrjLVseE2C SRpTjW/D+WOdU5TklxmrXHd4s1YfMuvrXEd7dzGOEBEd4vVkhfs2YjzMRgURJYLY0KOQ 7x5STwTgQbV1bRcbAYz9bQazVb1/YA04aWH8D5W5ZFHaoUVT3DQBSQ2BBeIagddQqaXU 3YZ+JLbinHURIVKEH/YRNbBEf3ZOsvfGUQ+Pba7r+4ectVBEKqt9NqigW82WsJDJdx8K 2clg== 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=9uNHsCSBiyyY7VqKj99MP2CiA4TXNDtewjy7bEKnAE0=; b=hLp2rte6pWEEd+GR5LFwBUMTWB2La6xSZDg0MH8jABcHzHDwDWO0cKAqx6yTaw8zX6 46H1isiOZ7G0yRsPn4nG4EUzzyCxgXld0zTw5+gXQDhIhRDmp1xgPHx0nl5f9Zzw6yWP utsRL+eeaIAaKomY6R13NJaNX8pPVF1lln98WhbndMKL1CLrJ/dbP8x6wkhJIcUKcdvu H2f3/RdjhsU8Maf8nsIDmRExJtmB51HDrOzvPtRDvcecX3P5FAcYTgUCf2XCna0IY2ny YLqZQ5ytdUWnSE3yvss8I2j8ShXOWmWyG7FghBUwR7rCu8awDMElPdEqGjgz3+66zYjj 2qVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x0OJWEP3; 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 d197si4971024qke.79.2022.02.21.01.54.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Feb 2022 01:54:31 -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=x0OJWEP3; 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]:54420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nM5Op-000453-D4 for patch@linaro.org; Mon, 21 Feb 2022 04:54:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nM4zP-000873-Ca for qemu-devel@nongnu.org; Mon, 21 Feb 2022 04:28:15 -0500 Received: from [2a00:1450:4864:20::333] (port=36703 helo=mail-wm1-x333.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nM4zN-00011P-HM for qemu-devel@nongnu.org; Mon, 21 Feb 2022 04:28:15 -0500 Received: by mail-wm1-x333.google.com with SMTP id q198-20020a1ca7cf000000b0037bb52545c6so13077646wme.1 for ; Mon, 21 Feb 2022 01:28:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9uNHsCSBiyyY7VqKj99MP2CiA4TXNDtewjy7bEKnAE0=; b=x0OJWEP3PkkrmlmxIUYxo5YyvttK7BhvSIroXT6VB//6VZUGmv8C0QNSnE9rkJf/6a C7sAv/dt59kDQKN6dngDnEeLt116CcpFnd2H1rzwr4H77WDG9ZxVyS2roSGsNkzau5Pt y8g2g826sgngxOB2u5eMN2cBYKWd0lDvPv6gmwyq+2XofQ0Fui6XQLXSQQjjUxnbmgrS itzfNLk7xkbCqF/l3kagwEwAsp2L1k/IAhv5NfwVSVIg7YxxEhLHHdWgEiJvzU314aN0 4nd0u5PZLfhauNJwSqebIcEXXYLoCUxSscCArXpeHuVqkcVFHRr+ycPOP78Xmf8oIoWK hHCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9uNHsCSBiyyY7VqKj99MP2CiA4TXNDtewjy7bEKnAE0=; b=IPYkDLgd8QkkzH1lfefP8Yv4rQBJbtL2WOx2dGWMfydmA+J6uPARt6Qg7BVegu+Z8K V4HylHE4hNSorADW4wDn8gwZuOrza7sV/FrLHu6f8bJjKEOXyq6JiDX+RNccM/C1JcTi Y208Amw70dyJU1MABhbA2GZozULmGAsUoYrcNtU+8EHwHJDLwqxdYRYHU7EF/ZZPLA5W vF7a7FPkGS/FPUo1Jdr+7fsAan+UzCQtPlEdmFBUME5b9ehoUkgSToiDVLZ8HrPyxnKE HyEySJosZ+7IUm+hP4C7u5Acdhb3Hfx1Lr6qffQWz58662mA+1Xd9CMLHeujH+x5Tw+Q TM0w== X-Gm-Message-State: AOAM531+/n4lzJbpnEMV94/exUNFCVLd/l/oSUNabpAUSb4XmrdBGz9y 4aZX0OiQUFCp7goPIpNGmM7ULFRNMayOLg== X-Received: by 2002:a05:600c:1f14:b0:37b:c475:2de0 with SMTP id bd20-20020a05600c1f1400b0037bc4752de0mr17233629wmb.70.1645435692332; Mon, 21 Feb 2022 01:28:12 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id q76sm7555778wme.1.2022.02.21.01.28.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 01:28:11 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/26] target/arm: Support PAuth extension for hvf Date: Mon, 21 Feb 2022 09:27:46 +0000 Message-Id: <20220221092800.404870-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220221092800.404870-1-peter.maydell@linaro.org> References: <20220221092800.404870-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::333 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" Currently we don't allow guests under hvf to use the PAuth extension, because we didn't have any special code to handle that, and therefore in arm_cpu_pauth_finalize() we will sanitize the ID_AA64ISAR1 value the guest sees to clear the PAuth related fields. Add support for this in the same way that KVM does it, by defaulting to "PAuth enabled" if the host CPU has it and allowing the user to disable it via '-cpu pauth=no' on the command line. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Andrew Jones Reviewed-by: Alexander Graf Reviewed-by: Richard Henderson Message-id: 20220204165506.2846058-7-peter.maydell@linaro.org --- target/arm/cpu64.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 19330d9ee94..1171ab16b94 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -633,9 +633,10 @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) uint64_t t; /* Exit early if PAuth is enabled, and fall through to disable it */ - if (kvm_enabled() && cpu->prop_pauth) { + if ((kvm_enabled() || hvf_enabled()) && cpu->prop_pauth) { if (!cpu_isar_feature(aa64_pauth, cpu)) { - error_setg(errp, "'pauth' feature not supported by KVM on this host"); + error_setg(errp, "'pauth' feature not supported by %s on this host", + kvm_enabled() ? "KVM" : "hvf"); } return; @@ -672,10 +673,14 @@ void aarch64_add_pauth_properties(Object *obj) /* Default to PAUTH on, with the architected algorithm on TCG. */ qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property); - if (kvm_enabled()) { + if (kvm_enabled() || hvf_enabled()) { /* * Mirror PAuth support from the probed sysregs back into the - * property for KVM. Is it just a bit backward? Yes it is! + * property for KVM or hvf. Is it just a bit backward? Yes it is! + * Note that prop_pauth is true whether the host CPU supports the + * architected QARMA5 algorithm or the IMPDEF one. We don't + * provide the separate pauth-impdef property for KVM or hvf, + * only for TCG. */ cpu->prop_pauth = cpu_isar_feature(aa64_pauth, cpu); } else { @@ -695,6 +700,7 @@ static void aarch64_host_initfn(Object *obj) #elif defined(CONFIG_HVF) ARMCPU *cpu = ARM_CPU(obj); hvf_arm_set_cpu_features_from_host(cpu); + aarch64_add_pauth_properties(obj); #else g_assert_not_reached(); #endif