KVM: x86/mmu: check for invalid async page faults involving private memory
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 27 Feb 2024 14:11:28 +0000 (09:11 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 7 May 2024 15:59:20 +0000 (11:59 -0400)
commitcd389f50700343774ae6b25b08e16247b3c7fa4c
treec973b84f3c93c52c82e2a5c0f8e7e104497f68ab
parentb3d5dc629c32f03d6ae0ddff628a67d999b723e0
KVM: x86/mmu: check for invalid async page faults involving private memory

Right now the error code is not used when an async page fault is completed.
This is not a problem in the current code, but it is untidy.  For protected
VMs, we will also need to check that the page attributes match the current
state of the page, because asynchronous page faults can only occur on
shared pages (private pages go through kvm_faultin_pfn_private() instead of
__gfn_to_pfn_memslot()).

Start by piping the error code from kvm_arch_setup_async_pf() to
kvm_arch_async_page_ready() via the architecture-specific async page
fault data.  For now, it can be used to assert that there are no
async page faults on private memory.

Extracted from a patch by Isaku Yamahata.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu/mmu.c