]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: X86: Move PTE present check from loop body to __shadow_walk_next()
authorLai Jiangshan <laijs@linux.alibaba.com>
Mon, 6 Sep 2021 12:25:47 +0000 (20:25 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 1 Oct 2021 07:44:46 +0000 (03:44 -0400)
commita3dc83a7e8a5fdff6711b90678d9fe3ee5368012
treef2e1087b2285439ffec11a3ecb136080065a9f0f
parent2a2ef63e0cee85d0e6fada59de1f5c11ee056c35
KVM: X86: Move PTE present check from loop body to __shadow_walk_next()

So far, the loop bodies already ensure the PTE is present before calling
__shadow_walk_next():  Some loop bodies simply exit with a !PRESENT
directly and some other loop bodies, i.e. FNAME(fetch) and __direct_map()
do not currently guard their walks with is_shadow_present_pte, but only
because they install present non-leaf SPTEs in the loop itself.

But checking pte present in __shadow_walk_next() (which is called from
shadow_walk_okay()) is more prudent; walking past a !PRESENT SPTE
would lead to attempting to read a the next level SPTE from a garbage
iter->shadow_addr.  It also allows to remove the is_shadow_present_pte()
checks from the loop bodies.

Reviewed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
Message-Id: <20210906122547.263316-2-jiangshanlai@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/mmu/paging_tmpl.h