]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86/mmu: Move guest PT write-protection to account_shadowed()
authorDavid Matlack <dmatlack@google.com>
Wed, 22 Jun 2022 19:26:56 +0000 (15:26 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 24 Jun 2022 08:51:55 +0000 (04:51 -0400)
commit3d8bef3a3cd26f99bfe0a9b5df7e0608496132d9
tree119c02cf8fd75866c4b16883d845c4dcba44f3f5
parent4a31afd2e3efa46d44e6a9a8ff40f0a1fda2e09f
KVM: x86/mmu: Move guest PT write-protection to account_shadowed()

Move the code that write-protects newly-shadowed guest page tables into
account_shadowed(). This avoids a extra gfn-to-memslot lookup and is a
more logical place for this code to live. But most importantly, this
reduces kvm_mmu_alloc_shadow_page()'s reliance on having a struct
kvm_vcpu pointer, which will be necessary when creating new shadow pages
during VM ioctls for eager page splitting.

Note, it is safe to drop the role.level == PG_LEVEL_4K check since
account_shadowed() returns early if role.level > PG_LEVEL_4K.

No functional change intended.

Reviewed-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: David Matlack <dmatlack@google.com>
Message-Id: <20220516232138.1783324-10-dmatlack@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/mmu.c