]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86/mmu: Block all page faults during kvm_zap_gfn_range()
authorSean Christopherson <seanjc@google.com>
Fri, 11 Nov 2022 00:18:41 +0000 (00:18 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 11 Nov 2022 12:19:46 +0000 (07:19 -0500)
commit41e8cf6b90debca77f91c97f5b1ba6d398615871
treec777842fc7f1aab49ac04b147a737475ab0d2718
parent1e750c452f7e147a26ec58c666e5ea13f3042d60
KVM: x86/mmu: Block all page faults during kvm_zap_gfn_range()

When zapping a GFN range, pass 0 => ALL_ONES for the to-be-invalidated
range to effectively block all page faults while the zap is in-progress.
The invalidation helpers take a host virtual address, whereas zapping a
GFN obviously provides a guest physical address and with the wrong unit
of measurement (frame vs. byte).

Alternatively, KVM could walk all memslots to get the associated HVAs,
but thanks to SMM, that would require multiple lookups.  And practically
speaking, kvm_zap_gfn_range() usage is quite rare and not a hot path,
e.g. MTRR and CR0.CD are almost guaranteed to be done only on vCPU0
during boot, and APICv inhibits are similarly infrequent operations.

Fixes: 5ce59bbf3e7a ("KVM: x86/mmu: bump mmu notifier count in kvm_zap_gfn_range")
Reported-by: Chao Peng <chao.p.peng@linux.intel.com>
Cc: stable@vger.kernel.org
Cc: Maxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20221111001841.2412598-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/mmu.c