Skip to contentSkip to conversation

x86: Add guest physical bits tests

PATCH New Mohammed Gamal 1 participant 4 messages Aug 6, 2020 KVM

lore
Share & tools
lore
#0 lore raw

cover x86: Add guest physical bits tests

This patch series re-enables the guest physical bits tests, in addition timeouts are also tweaked for AMD without NPT enabled, and the tests are also disabled on AMD with NPT enabled, since we aren't able to support them properly due to the way CPUs set PTE bits on NPT VM exits

Mohammed Gamal (3):
unittests.cfg: Increase timeout for access test x86/access: Skip running guest physical bits tests on AMD with NPT
enabled
Revert "access: disable phys-bits=36 for now"

 x86/access.c      | 8 ++++++++
 x86/unittests.cfg | 3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/3 unittests.cfg: Increase timeout for access test

From: Mohammed Gamal <[email protected]>

In case of npt=0 on kvm_amd, tests run slower and timeout, so increase the timeout. The tests then do succeed.

---
 x86/unittests.cfg | 1 +
 1 file changed, 1 insertion(+)
x86/unittests.cfg +1 -0
index 3a79151..4fa42fa 100644
@@ -117,6 +117,7 @@ extra_params = -cpu qemu64,+x2apic,+tsc-deadline -append tscdeadline_immed
 file = access.flat
 arch = x86_64
 extra_params = -cpu host,host-phys-bits
+timeout = 180
 
 [smap]
 file = smap.flat
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/3 x86/access: Skip running guest physical bits tests on AMD with NPT enabled

In reply to Mohammed Gamal

Since we can't handle NPT VM exits properly. We won't run guest physical bits tests if NPT is enabled.

---
 x86/access.c | 8 ++++++++
 1 file changed, 8 insertions(+)
x86/access.c +8 -0
index 7dc9eb6..90c5fe4 100644
@@ -973,6 +973,14 @@ static int ac_test_run(void)
         invalid_mask |= AC_PTE_BIT36_MASK;
     }
 
+    if (this_cpu_has(X86_FEATURE_NPT)) {
+        printf("NPT enabled. Skipping physical bits tests\n");
+        invalid_mask |= AC_PDE_BIT51_MASK;
+        invalid_mask |= AC_PTE_BIT51_MASK;
+        invalid_mask |= AC_PDE_BIT36_MASK;
+        invalid_mask |= AC_PTE_BIT36_MASK;
+    }
+
     if (this_cpu_has(X86_FEATURE_PKU)) {
         set_cr4_pke(1);
         set_cr4_pke(0);
Signature · 1 line
2.26.2
#3 lore raw

PATCH 3/3 Revert "access: disable phys-bits=36 for now"

In reply to Mohammed Gamal

From: Mohammed Gamal <[email protected]>

This reverts commit 71de9c93fbdb15978ffa2f290dd120d3005a9292.

Now that guest_maxphyaddr < host_maxphyaddr patches are sent. Revert this change in kvm-unit-test

---
 x86/unittests.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
x86/unittests.cfg +1 -1
index 4fa42fa..3c0b992 100644
@@ -116,7 +116,7 @@ extra_params = -cpu qemu64,+x2apic,+tsc-deadline -append tscdeadline_immed
 [access]
 file = access.flat
 arch = x86_64
-extra_params = -cpu host,host-phys-bits
+extra_params = -cpu host,phys-bits=36
 timeout = 180
 
 [smap]
Signature · 1 line
2.26.2