Re: [PATCH 6/6] KVM: selftests: x86: Add test for KVM_PRE_FAULT_MEMORY

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/23/2024 11:18 PM, Xiaoyao Li wrote:
On 4/19/2024 4:59 PM, Paolo Bonzini wrote:

...

+static void __test_pre_fault_memory(unsigned long vm_type, bool private)
+{
+    const struct vm_shape shape = {
+        .mode = VM_MODE_DEFAULT,
+        .type = vm_type,
+    };
+    struct kvm_vcpu *vcpu;
+    struct kvm_run *run;
+    struct kvm_vm *vm;
+    struct ucall uc;
+
+    uint64_t guest_test_phys_mem;
+    uint64_t guest_test_virt_mem;
+    uint64_t alignment, guest_page_size;
+
+    vm = vm_create_shape_with_one_vcpu(shape, &vcpu, guest_code);
+
+    alignment = guest_page_size = vm_guest_mode_params[VM_MODE_DEFAULT].page_size;
+    guest_test_phys_mem = (vm->max_gfn - TEST_NPAGES) * guest_page_size;
+#ifdef __s390x__
+    alignment = max(0x100000UL, guest_page_size);
+#else
+    alignment = SZ_2M;
+#endif
+    guest_test_phys_mem = align_down(guest_test_phys_mem, alignment);
+    guest_test_virt_mem = guest_test_phys_mem;

guest_test_virt_mem cannot be assigned as guest_test_phys_mem, which leads to following virt_map() fails with

The root cause is that vm->pa_bits is 52 while vm->va_bits is 48. So vm->max_gfn is beyond the capability of va space

==== Test Assertion Failure ====
  lib/x86_64/processor.c:197: sparsebit_is_set(vm->vpages_valid, (vaddr >> vm->page_shift))
   pid=4773 tid=4773 errno=0 - Success
      1    0x000000000040f55c: __virt_pg_map at processor.c:197
      2    0x000000000040605e: virt_pg_map at kvm_util_base.h:1065
      3     (inlined by) virt_map at kvm_util.c:1571
     4    0x0000000000402b75: __test_pre_fault_memory at pre_fault_memory_test.c:96      5    0x000000000040246e: test_pre_fault_memory at pre_fault_memory_test.c:133 (discriminator 3)      6     (inlined by) main at pre_fault_memory_test.c:140 (discriminator 3)
      7    0x00007fcb68429d8f: ?? ??:0
      8    0x00007fcb68429e3f: ?? ??:0
      9    0x00000000004024e4: _start at ??:?
   Invalid virtual address, vaddr: 0xfffffffc00000

+
+    vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS,
+                    guest_test_phys_mem, TEST_SLOT, TEST_NPAGES,
+                    private ? KVM_MEM_GUEST_MEMFD : 0);
+    virt_map(vm, guest_test_virt_mem, guest_test_phys_mem, TEST_NPAGES);










[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux