* [v2 PATCH] x86/kvm/mmu: Remove unnecessary ‘NULL’ values from sptep
@ 2023-09-05 18:20 Li zeming
2023-10-20 22:56 ` Sean Christopherson
0 siblings, 1 reply; 2+ messages in thread
From: Li zeming @ 2023-09-05 18:20 UTC (permalink / raw)
To: seanjc, pbonzini, tglx, mingo, bp, dave.hansen
Cc: x86, kvm, linux-kernel, Li zeming
Remove spte and sptep initialization assignments, add sptep assignment
check and processing.
Signed-off-by: Li zeming <zeming@nfschina.com>
---
v2:
1. Remove spte initialization assignment.
2. Add sptep assignment check.
arch/x86/kvm/mmu/mmu.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index ec169f5c7dce..0d11bfeae2f8 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -3456,8 +3456,8 @@ static int fast_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault)
{
struct kvm_mmu_page *sp;
int ret = RET_PF_INVALID;
- u64 spte = 0ull;
- u64 *sptep = NULL;
+ u64 spte;
+ u64 *sptep;
uint retry_count = 0;
if (!page_fault_can_be_fast(fault))
@@ -3473,6 +3473,14 @@ static int fast_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault)
else
sptep = fast_pf_get_last_sptep(vcpu, fault->addr, &spte);
+ /*
+ * It's entirely possible for the mapping to have been zapped
+ * by a different task, but the root page is should always be
+ * available as the vCPU holds a reference to its root(s).
+ */
+ if (WARN_ON_ONCE(!sptep))
+ spte = REMOVED_SPTE;
+
if (!is_shadow_present_pte(spte))
break;
--
2.18.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [v2 PATCH] x86/kvm/mmu: Remove unnecessary ‘NULL’ values from sptep
2023-09-05 18:20 [v2 PATCH] x86/kvm/mmu: Remove unnecessary ‘NULL’ values from sptep Li zeming
@ 2023-10-20 22:56 ` Sean Christopherson
0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2023-10-20 22:56 UTC (permalink / raw)
To: Sean Christopherson, pbonzini, tglx, mingo, bp, dave.hansen, Li zeming
Cc: x86, kvm, linux-kernel
On Wed, 06 Sep 2023 02:20:06 +0800, Li zeming wrote:
> Remove spte and sptep initialization assignments, add sptep assignment
> check and processing.
Applied to kvm-x86 mmu, with a beefed up changelog. Thanks!
[1/1] x86/kvm/mmu: Remove unnecessary ‘NULL’ values from sptep
https://github.com/kvm-x86/linux/commit/1de9992f9de0
--
https://github.com/kvm-x86/linux/tree/next
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-20 22:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-05 18:20 [v2 PATCH] x86/kvm/mmu: Remove unnecessary ‘NULL’ values from sptep Li zeming
2023-10-20 22:56 ` Sean Christopherson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®