From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C03F42D8DB9; Thu, 12 Feb 2026 09:29:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770888580; cv=none; b=pGflq2p+JeNUnwO3PMHnJdbFChbgkqfLAvXxS0YhJTwCm9gB2AHBIlZtQXZoQAfAWLP8Dnn5hr9a85hVe3EM20KJ7TsSE8YF0iDMxr/EyGhS5m73VGHWgUEwfiJaUpqnrZaXtC17y0pVGb1S1XcE8mLrlcg9FlrLUGLmUfZsBBI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770888580; c=relaxed/simple; bh=iZyfNOwyD37sadNlp31+zwi7lJubFRN6RKclXfibhQU=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=qGdMtlca68fNqFeiqeZhldcW3mE+a83TCQqwTh1azZ1BS8S4CoInkrHraH97gwYfSvw23CSUvQTDfw4VDRhVy+nYVdENwq9MzLnG6udWPf7qcTtiuUFJZizktwtbSIba+dyPiEXhS8LR/b3XMYPx9A/y+MRzE2P8WFyOLVqLjhs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WMgzjksR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WMgzjksR" 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) Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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.