[PATCH 1/2] KVM: X86: Check pte present first in __shadow_walk_next()
From: Lai Jiangshan
Date: Thu Aug 12 2021 - 10:21:37 EST
From: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>
So far, the loop bodies already ensure the pte is present before calling
__shadow_walk_next(). But checking pte present in __shadow_walk_next()
is a more prudent way of programing and loop bodies will not need
to always check it. It allows us removing is_shadow_present_pte()
in the loop bodies.
Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxxxxx>
---
arch/x86/kvm/mmu/mmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index a272ccbddfa1..c48ecb25d5f8 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -2231,7 +2231,7 @@ static bool shadow_walk_okay(struct kvm_shadow_walk_iterator *iterator)
static void __shadow_walk_next(struct kvm_shadow_walk_iterator *iterator,
u64 spte)
{
- if (is_last_spte(spte, iterator->level)) {
+ if (!is_shadow_present_pte(spte) || is_last_spte(spte, iterator->level)) {
iterator->level = 0;
return;
}
--
2.19.1.6.gb485710b