@@ -7783,7 +7783,7 @@ bugs and reported to the maintainers so that annotations can be added.
7.35 KVM_CAP_NOWAIT_ON_FAULT
----------------------------
-:Architectures: x86
+:Architectures: x86, arm64
:Returns: -EINVAL.
The presence of this capability indicates that userspace may pass the
@@ -235,6 +235,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
case KVM_CAP_IRQFD_RESAMPLE:
case KVM_CAP_COUNTER_OFFSET:
case KVM_CAP_MEMORY_FAULT_INFO:
+ case KVM_CAP_NOWAIT_ON_FAULT:
r = 1;
break;
case KVM_CAP_SET_GUEST_DEBUG2:
@@ -1232,6 +1232,8 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
long vma_pagesize, fault_granule;
enum kvm_pgtable_prot prot = KVM_PGTABLE_PROT_R;
struct kvm_pgtable *pgt;
+ bool exit_on_memory_fault = kvm_slot_nowait_on_fault(memslot);
+ uint64_t memory_fault_flags;
fault_granule = 1UL << ARM64_HW_PGTABLE_LEVEL_SHIFT(fault_level);
write_fault = kvm_is_write_fault(vcpu);
@@ -1325,8 +1327,20 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
mmu_seq = vcpu->kvm->mmu_invalidate_seq;
mmap_read_unlock(current->mm);
- pfn = __gfn_to_pfn_memslot(memslot, gfn, false, false, NULL,
+ pfn = __gfn_to_pfn_memslot(memslot, gfn, exit_on_memory_fault, false, NULL,
write_fault, &writable, NULL);
+
+ if (exit_on_memory_fault && pfn == KVM_PFN_ERR_FAULT) {
+ memory_fault_flags = 0;
+ if (write_fault)
+ memory_fault_flags |= KVM_MEMORY_FAULT_FLAG_EXEC;
+ if (exec_fault)
+ memory_fault_flags |= KVM_MEMORY_FAULT_FLAG_EXEC;
+ kvm_populate_efault_info(vcpu,
+ round_down(gfn * PAGE_SIZE, vma_pagesize), vma_pagesize,
+ memory_fault_flags);
+ return -EFAULT;
+ }
if (pfn == KVM_PFN_ERR_HWPOISON) {
kvm_send_hwpoison_signal(hva, vma_shift);
return 0;
Return -EFAULT from user_mem_abort when the memslot flag is enabled and fast GUP fails to find a present mapping for the page. Signed-off-by: Anish Moorthy <amoorthy@google.com> --- Documentation/virt/kvm/api.rst | 2 +- arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/mmu.c | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-)