FAILED: patch "[PATCH] KVM: x86/mmu: Treat NX as used (not reserved) for all !TDP" failed to apply to 4.19-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 112022bdb5bc372e00e6e43cb88ee38ea67b97bd Mon Sep 17 00:00:00 2001
From: Sean Christopherson <[email protected]>
Date: Tue, 22 Jun 2021 10:56:47 -0700
Subject: [PATCH] KVM: x86/mmu: Treat NX as used (not reserved) for all !TDP
shadow MMUs
Mark NX as being used for all non-nested shadow MMUs, as KVM will set the NX bit for huge SPTEs if the iTLB mutli-hit mitigation is enabled. Checking the mitigation itself is not sufficient as it can be toggled on at any time and KVM doesn't reset MMU contexts when that happens. KVM could reset the contexts, but that would require purging all SPTEs in all MMUs, for no real benefit. And, KVM already forces EFER.NX=1 when TDP is disabled (for WP=0, SMEP=1, NX=0), so technically NX is never reserved for shadow MMUs.
Message-Id: <[email protected]>
arch/x86/kvm/mmu/mmu.c +9 -1
@@ -4221,7 +4221,15 @@ static inline u64 reserved_hpa_bits(void)void reset_shadow_zero_bits_mask (struct kvm_vcpu *vcpu,struct kvm_mmu *context) { -bool uses_nx = context->nx || +/* +* KVM uses NX when TDP is disabled to handle a variety of scenarios, +* notably for huge SPTEs if iTLB multi-hit mitigation is enabled and +* to generate correct permissions for CR0.WP=0/CR4.SMEP=1/EFER.NX=0. +* The iTLB multi-hit workaround can be toggled at any time, so assume +* NX can be used by any non-nested shadow MMU to avoid having to reset +* MMU contexts. Note, KVM forces EFER.NX=1 when TDP is disabled. +*/ +bool uses_nx = context->nx || !tdp_enabled || context->mmu_role.base.smep_andnot_wp;struct rsvd_bits_validate *shadow_zero_check;int i;
Hi Greg,
Quoted 5 lines · On Sun, Jul 11, 2021 at 02:40:52PM +0200, [email protected] wrote:
The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
Here is the backport, will also apply to 4.14-stable.
--
Regards
Sudip
From 19073fb2fa74d528620a0f0a1e2bf442c14a67ec Mon Sep 17 00:00:00 2001
From: Sean Christopherson <[email protected]>
Date: Tue, 22 Jun 2021 10:56:47 -0700
Subject: [PATCH] KVM: x86/mmu: Treat NX as used (not reserved) for all !TDP
shadow MMUs
commit 112022bdb5bc372e00e6e43cb88ee38ea67b97bd upstream
Mark NX as being used for all non-nested shadow MMUs, as KVM will set the NX bit for huge SPTEs if the iTLB mutli-hit mitigation is enabled. Checking the mitigation itself is not sufficient as it can be toggled on at any time and KVM doesn't reset MMU contexts when that happens. KVM could reset the contexts, but that would require purging all SPTEs in all MMUs, for no real benefit. And, KVM already forces EFER.NX=1 when TDP is disabled (for WP=0, SMEP=1, NX=0), so technically NX is never reserved for shadow MMUs.
Message-Id: <[email protected]>
--- arch/x86/kvm/mmu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/x86/kvm/mmu.c +10 -1
@@ -4557,7 +4557,16 @@ static void reset_rsvds_bits_mask_ept(struct kvm_vcpu *vcpu,void reset_shadow_zero_bits_mask (struct kvm_vcpu *vcpu,struct kvm_mmu *context) { -bool uses_nx = context->nx || context->base_role.smep_andnot_wp; +/* +* KVM uses NX when TDP is disabled to handle a variety of scenarios, +* notably for huge SPTEs if iTLB multi-hit mitigation is enabled and +* to generate correct permissions for CR0.WP=0/CR4.SMEP=1/EFER.NX=0. +* The iTLB multi-hit workaround can be toggled at any time, so assume +* NX can be used by any non-nested shadow MMU to avoid having to reset +* MMU contexts. Note, KVM forces EFER.NX=1 when TDP is disabled. +*/ +bool uses_nx = context->nx || !tdp_enabled || + context->base_role.smep_andnot_wp;struct rsvd_bits_validate *shadow_zero_check;int i;
Signature · 1 line
2.30.2