From mboxrd@z Thu Jan 1 00:00:00 1970 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 8C42DEB48EC for ; Thu, 12 Feb 2026 09:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cVndAX1vCJiQZT2vUkz3GfbNqdE3mYKlXDm5Ov0T3K4=; b=OEJNQOcBTI+RTILwrw4W0HtUKc 5DXRg6+l5wy+4+zJfeqA/Nlt3CA2TeES+6Ww6L5/FvrE3QD4A1anmPvQU1eFjglNpih40SaYAop2z Yv2UjSl9I4TXbuFeBaAPGhwId7MSM4u7MarvxaKO0Wi4cFja3TMhiOMXVcoJ70AabD3LoFlJZ8txk l6uMf5W8Zd0lBv3NxM0infPvP0fyOjhxfcQohUlpWoLGF9s7ZS30te0ERNsdR7thJmnWgfR9B8iYH CoUHomXtj2LCSq21f7FY1H0/evrjqWm10zZXsK5crpC9H8JMR6Zo4j26c6A7qYB+OtRd12xnQiVCl 081wvH4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vqT15-00000001ppo-3Mqu; Thu, 12 Feb 2026 09:29:43 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vqT13-00000001poz-17u6 for linux-arm-kernel@lists.infradead.org; Thu, 12 Feb 2026 09:29:42 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 8217841ADF; Thu, 12 Feb 2026 09:29:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59B38C4CEF7; Thu, 12 Feb 2026 09:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770888580; bh=iZyfNOwyD37sadNlp31+zwi7lJubFRN6RKclXfibhQU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WMgzjksRKXmhbGYgMOwxiC5W35cIH5gveVPwAbB0ugycGDjtRFyhYm+pVLcLCKNZH mgYBR18nhaEB09FQmWkgWqRb3Hy6itiCTaZi5xp1oBM/Rz2NUp+yjdNYyTdjpKjXOL p2KxjU6sUMhkkM+8Xpffp1+3QrDskT6ZTwfJaPDeaI7ylWms4Yn9SwWzds+6AXzAvs 7eZg7YX8rneAfFHB9hNH7El+/LsAx7R+F9sKZMEygrkhH/cWD5ASfMziXEHSMkJUP9 vcGtYql3keB9zjO7TmY1jmMXoiYL5TQuKPD7278uJdB1UgkH/6fXXtUCkotomFtHwn uxYF3nCaEhGlw== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vqT0z-0000000AZEb-3wuv; Thu, 12 Feb 2026 09:29:38 +0000 Date: Thu, 12 Feb 2026 09:29:37 +0000 Message-ID: <86jywib98e.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v1 1/3] KVM: arm64: Hide S1POE from guests when not supported by the host In-Reply-To: <20260212090252.158689-2-tabba@google.com> References: <20260212090252.158689-1-tabba@google.com> <20260212090252.158689-2-tabba@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: tabba@google.com, kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, stable@vger.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-20260212_012941_351424_A3B39BA9 X-CRM114-Status: GOOD ( 26.67 ) 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 Hi Fuad, On Thu, 12 Feb 2026 09:02:50 +0000, Fuad Tabba wrote: > > When CONFIG_ARM64_POE is disabled, KVM does not save/restore POR_EL1. > However, ID_AA64MMFR3_EL1 sanitisation currently exposes the feature to > guests whenever the hardware supports it, ignoring the host kernel > configuration. This is the umpteenth time we get caught by this. PAN was the latest instance until this one. Maybe an approach would be to have a default override when a config option is not enabled, so that KVM is consistent with the rest of the kernel? > > If a guest detects this feature and attempts to use it, the host will > fail to context-switch POR_EL1, potentially leading to state corruption. > > Fix this by masking ID_AA64MMFR3_EL1.S1POE and preventing KVM from > advertising the feature when the host does not support it, i.e., > system_supports_poe() is false. > > Fixes: 70ed7238297f ("KVM: arm64: Sanitise ID_AA64MMFR3_EL1") > Signed-off-by: Fuad Tabba > --- > arch/arm64/include/asm/kvm_host.h | 3 ++- > arch/arm64/kvm/sys_regs.c | 3 +++ > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index ac7f970c7883..7af72ca749a6 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -1592,7 +1592,8 @@ void kvm_set_vm_id_reg(struct kvm *kvm, u32 reg, u64 val); > (kvm_has_feat((k), ID_AA64MMFR3_EL1, S1PIE, IMP)) > > #define kvm_has_s1poe(k) \ > - (kvm_has_feat((k), ID_AA64MMFR3_EL1, S1POE, IMP)) > + (system_supports_poe() && \ > + kvm_has_feat((k), ID_AA64MMFR3_EL1, S1POE, IMP)) Why do we need to further key this on system_supports_poe()? I can see this is a potential optimisation, but I don't think this is part of the minimal fix. > > #define kvm_has_ras(k) \ > (kvm_has_feat((k), ID_AA64PFR0_EL1, RAS, IMP)) > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 88a57ca36d96..237e8bd1cf29 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -1816,6 +1816,9 @@ static u64 __kvm_read_sanitised_id_reg(const struct kvm_vcpu *vcpu, > ID_AA64MMFR3_EL1_SCTLRX | > ID_AA64MMFR3_EL1_S1POE | > ID_AA64MMFR3_EL1_S1PIE; > + > + if (!system_supports_poe()) > + val &= ~ID_AA64MMFR3_EL1_S1POE; How about S1PIE? It seems to have a similar problem, in the sense that it has extra state. But I guess because we don't put it behind a config option, we context-switch it anyway and all is good? Thanks, M. -- Without deviation from the norm, progress is not possible.