"Lorenzo Stoakes (ARM)" <[email protected]> writes:

> This series implements the KVM stage 2 page table pre-faulting feature for
> arm64.
>

> == Foundations ==
>
> The series begins by establishing the required foundations:
>
> 1. Update kvm_s2_fault_desc to store the exception syndrome register (ESR)
>    value independently, and update all code paths to use this value
>    exclusively.
>
> This is required to generate a synthetic fault for pre-faulting without
> inadvertently obtaining an incorrect ESR from elsewhere.
>
> 2. Update kvm_s2_fault_desc to store the kvm_s2_mmu independently, and
>    update all code paths to use this value exclusively.
>
> This is similarly required to generate a synthetic fault against the
> canonical stage-2 MMU. It would make no sense for pre-faulting to modify
> nested shadow page tables, so the code must not obtain an incorrect MMU
> from elsewhere.
>
> 3. Update the abort paths that consume kvm_s2_fault_desc to also return a
>    kvm_s2_fault_result.
>
> Pre-faulting needs to know the granule size handled by the fault, so the
> abort paths must return that information.
>
> 4. Pass walk flags to kvm_pgtable_get_leaf() to allow page-table walks
>    under the MMU read lock.
>
> This is Jack's patch verbatim. It allows KVM_PGTABLE_WALK_SHARED to be used
> when walking page tables under the MMU read lock.
>
> The API permits pre-faulting to run in parallel, and the read lock prevents
> the page tables from being torn down during the walk.
>
> == Implementation ==
>
> Pre-faulting is implemented in kvm_arch_vcpu_pre_fault_memory(), which
> pre-faults the stage-2 page tables for a specific GPA (the guest IPA on
> arm64).
>
> kvm_vcpu_pre_fault_memory() calls this function for each GPA in the range
> requested by userspace through the KVM_PRE_FAULT_MEMORY ioctl.
>
> The implementation is straightforward: walk the stage-2 page tables for
> the GPA and, if it is unmapped, populate the mapping by handling a
> synthetic page fault.

 [ ... 47 lines skipped ... ] 

>
> pKVM is not supported regardless of whether the VM is protected or
> not.
>
> This is because pKVM instantiates vCPUs upon run,
>

Can pKVM instantiate the hyp vCPU during pre-faulting ?


> but pre-faulting is  typically performed before a vCPU is run.  It would be 
> confusing and
> inconsistent to error out on non-running vCPUs but to pre-fault running
> ones.


I use KVM pre-faulting when transitioning pages from shared to private
with CoCo guest. This ensures that a trusted device can DMA to private
memory before the guest accesses it.

-aneesh

Reply via email to