kvm: selftests: stop lying to aarch64 tests about PA-bits
authorAndrew Jones <drjones@redhat.com>
Tue, 18 Sep 2018 17:54:35 +0000 (19:54 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 16 Oct 2018 22:29:38 +0000 (00:29 +0200)
Let's add the 40 PA-bit versions of the VM modes, that AArch64
should have been using, so we can extend the dirty log test without
breaking things.

Signed-off-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/dirty_log_test.c
tools/testing/selftests/kvm/include/kvm_util.h
tools/testing/selftests/kvm/lib/aarch64/processor.c
tools/testing/selftests/kvm/lib/kvm_util.c

index 3afc7d6..6139688 100644 (file)
@@ -230,9 +230,11 @@ static void run_test(enum vm_guest_mode mode, unsigned long iterations,
 
        switch (mode) {
        case VM_MODE_P52V48_4K:
+       case VM_MODE_P40V48_4K:
                guest_page_shift = 12;
                break;
        case VM_MODE_P52V48_64K:
+       case VM_MODE_P40V48_64K:
                guest_page_shift = 16;
                break;
        default:
@@ -317,11 +319,16 @@ static struct vm_guest_modes {
        bool supported;
        bool enabled;
 } vm_guest_modes[NUM_VM_MODES] = {
+#if defined(__x86_64__)
        { VM_MODE_P52V48_4K,    1, 1, },
-#ifdef __aarch64__
-       { VM_MODE_P52V48_64K,   1, 1, },
-#else
        { VM_MODE_P52V48_64K,   0, 0, },
+       { VM_MODE_P40V48_4K,    0, 0, },
+       { VM_MODE_P40V48_64K,   0, 0, },
+#elif defined(__aarch64__)
+       { VM_MODE_P52V48_4K,    0, 0, },
+       { VM_MODE_P52V48_64K,   0, 0, },
+       { VM_MODE_P40V48_4K,    1, 1, },
+       { VM_MODE_P40V48_64K,   1, 1, },
 #endif
 };
 
index 88df26c..a4e59e3 100644 (file)
@@ -36,6 +36,8 @@ typedef uint64_t vm_vaddr_t; /* Virtual Machine (Guest) virtual address */
 enum vm_guest_mode {
        VM_MODE_P52V48_4K,
        VM_MODE_P52V48_64K,
+       VM_MODE_P40V48_4K,
+       VM_MODE_P40V48_64K,
        NUM_VM_MODES,
 };
 
index b1dfc0d..b6022e2 100644 (file)
@@ -275,6 +275,14 @@ void vcpu_setup(struct kvm_vm *vm, int vcpuid, int pgd_memslot, int gdt_memslot)
                tcr_el1 |= 1ul << 14; /* TG0 = 64KB */
                tcr_el1 |= 6ul << 32; /* IPS = 52 bits */
                break;
+       case VM_MODE_P40V48_4K:
+               tcr_el1 |= 0ul << 14; /* TG0 = 4KB */
+               tcr_el1 |= 2ul << 32; /* IPS = 40 bits */
+               break;
+       case VM_MODE_P40V48_64K:
+               tcr_el1 |= 1ul << 14; /* TG0 = 64KB */
+               tcr_el1 |= 2ul << 32; /* IPS = 40 bits */
+               break;
        default:
                TEST_ASSERT(false, "Unknown guest mode, mode: 0x%x", vm->mode);
        }
index b37e52f..8c06da4 100644 (file)
@@ -99,6 +99,8 @@ static void vm_open(struct kvm_vm *vm, int perm)
 const char * const vm_guest_mode_string[] = {
        "PA-bits:52, VA-bits:48, 4K pages",
        "PA-bits:52, VA-bits:48, 64K pages",
+       "PA-bits:40, VA-bits:48, 4K pages",
+       "PA-bits:40, VA-bits:48, 64K pages",
 };
 
 /*
@@ -146,6 +148,20 @@ struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm)
                vm->page_shift = 16;
                vm->va_bits = 48;
                break;
+       case VM_MODE_P40V48_4K:
+               vm->pgtable_levels = 4;
+               vm->pa_bits = 40;
+               vm->va_bits = 48;
+               vm->page_size = 0x1000;
+               vm->page_shift = 12;
+               break;
+       case VM_MODE_P40V48_64K:
+               vm->pgtable_levels = 3;
+               vm->pa_bits = 40;
+               vm->va_bits = 48;
+               vm->page_size = 0x10000;
+               vm->page_shift = 16;
+               break;
        default:
                TEST_ASSERT(false, "Unknown guest mode, mode: 0x%x", mode);
        }