From patchwork Mon Feb 5 10:34:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13545201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E0E6CC4828D for ; Mon, 5 Feb 2024 10:36:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gHvIpgEDTqD/YvcMlIw1uygH1BxywyJr2Iy/a/Iezec=; b=yA7QyQSMzsA2wa hLwIiD/Grsgt4awy2Bz+cc6s4MfBy2MZNPG6myD1rSSpONkzsZcUG4CL943bnZaLLxBzxc7e4a3PQ EqkRVsj3tm6UKK6ZD+SMXsLaGJRcL/SZqbcoGXVez7yvH681J+vhsJQVPNO9ECUptvBRuOczJod7/ R4jzexLehFoDPj344G0xjGuwflnBIMT8h4maW298/44X9sAQgBizT9m3IlMn+FV9/kbEN4bw6tGEY x2X3xjyasIvcTOAH8lF6uAjs7DSin7oTysL5/g7WKgGbfISEr75V2LYv2h3Y5QXDewBeXZQzzLi7l uzMymTxruD/QsMqYEZ0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWwKR-00000002q1Y-3sAg; Mon, 05 Feb 2024 10:35:55 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWwJR-00000002p9y-2fcY for linux-arm-kernel@lists.infradead.org; Mon, 05 Feb 2024 10:34:57 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id ADF2E61013; Mon, 5 Feb 2024 10:34:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79A02C433F1; Mon, 5 Feb 2024 10:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707129291; bh=dIJkF1mYYrrWiIgVuWE1ahoSVnnmnY+7OH6lcrJJCb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Er17CJtiVMWFa5j0zYBY8uMo4KBboyJZKnzNV/OuqkJSabLZ8dca0dPXbo6sAwSun MEqX4dT6M8gikHpcLWWsoZmBl4v+LkwF8Fw1NU6D6BXShSOPTvvrTWixbERQAQ3To9 ipgBvDQECgDFHHEjgVACPg0vTcb74D7CgPpTabUum4YOXvYL6sfm6e+u5++QbVDhzO 7X0s2NcuOobJ5wv4enmDyWRgzCGEsvorQRaKzq7LmtW0I+/t1KLUS+38qjTwy3b6ug gvJgIcWahBn4Sulxuj7sb+Z0YJhv9omaUeB4z4vHwZX7BTX1f+q6JEIFn/sCvyQDaL VsetO1nOMbduw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rWwJN-000Nc3-L0; Mon, 05 Feb 2024 10:34:49 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Catalin Marinas , Will Deacon , Joey Gouly , Mark Brown Subject: [PATCH v3 23/26] KVM: arm64: Make AMU sysreg UNDEF if FEAT_AMU is not advertised to the guest Date: Mon, 5 Feb 2024 10:34:28 +0000 Message-Id: <20240205103431.1104133-24-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240205103431.1104133-1-maz@kernel.org> References: <20240205103431.1104133-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, joey.gouly@arm.com, broonie@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_023453_891912_D65AF21D X-CRM114-Status: UNSURE ( 9.58 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org No AMU? No AMU! IF we see an AMU-related trap, let's turn it into an UNDEF! Reviewed-by: Joey Gouly Signed-off-by: Marc Zyngier --- arch/arm64/kvm/sys_regs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index da9db99c77e7..38ed47bd29db 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -3998,6 +3998,10 @@ void kvm_init_sysreg(struct kvm_vcpu *vcpu) kvm->arch.fgu[HFGxTR_GROUP] |= (HFGxTR_EL2_nPIRE0_EL1 | HFGxTR_EL2_nPIR_EL1); + if (!kvm_has_feat(kvm, ID_AA64PFR0_EL1, AMU, IMP)) + kvm->arch.fgu[HAFGRTR_GROUP] |= ~(HAFGRTR_EL2_RES0 | + HAFGRTR_EL2_RES1); + set_bit(KVM_ARCH_FLAG_FGU_INITIALIZED, &kvm->arch.flags); out: mutex_unlock(&kvm->arch.config_lock);