[kvm-unit-tests PATCH v2 4/6] x86: Expand LA57 test to 64-bit mode (to prep for canonical testing)

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

 



Expand the LA57 test to also validate that attempting to toggle LA57 while
in 64-bit mode fails.  The extra test coverage isn't terribly interesting,
but it's still useful, and extending the LA57 test to 64-bit configs will
allow extending it further with LA57-specific canonical tests.

Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
 x86/Makefile.common | 3 ++-
 x86/Makefile.i386   | 2 +-
 x86/la57.c          | 9 ++++++---
 x86/unittests.cfg   | 2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/x86/Makefile.common b/x86/Makefile.common
index 4ae9a557..0b7f35c8 100644
--- a/x86/Makefile.common
+++ b/x86/Makefile.common
@@ -96,7 +96,8 @@ tests-common = $(TEST_DIR)/vmexit.$(exe) $(TEST_DIR)/tsc.$(exe) \
 # use absolute addresses in their inline assembly code, which cannot compile
 # with the '-fPIC' flag
 ifneq ($(CONFIG_EFI),y)
-tests-common += $(TEST_DIR)/realmode.$(exe)
+tests-common += $(TEST_DIR)/realmode.$(exe) \
+		$(TEST_DIR)/la57.$(exe)
 endif
 
 test_cases: $(tests-common) $(tests)
diff --git a/x86/Makefile.i386 b/x86/Makefile.i386
index 0a845e65..a1ea1c2d 100644
--- a/x86/Makefile.i386
+++ b/x86/Makefile.i386
@@ -9,6 +9,6 @@ arch_LDFLAGS = -m elf_i386
 cflatobjs += lib/x86/setjmp32.o lib/ldiv32.o
 
 tests = $(TEST_DIR)/taskswitch.$(exe) $(TEST_DIR)/taskswitch2.$(exe) \
-	$(TEST_DIR)/cmpxchg8b.$(exe) $(TEST_DIR)/la57.$(exe)
+	$(TEST_DIR)/cmpxchg8b.$(exe)
 
 include $(SRCDIR)/$(TEST_DIR)/Makefile.common
diff --git a/x86/la57.c b/x86/la57.c
index 1f11412c..aff35ead 100644
--- a/x86/la57.c
+++ b/x86/la57.c
@@ -5,9 +5,12 @@
 int main(int ac, char **av)
 {
 	int vector = write_cr4_safe(read_cr4() | X86_CR4_LA57);
-	int expected = this_cpu_has(X86_FEATURE_LA57) ? 0 : 13;
+	bool is_64bit = rdmsr(MSR_EFER) & EFER_LMA;
+	int expected = !is_64bit && this_cpu_has(X86_FEATURE_LA57) ? 0 : GP_VECTOR;
+
+	report(vector == expected, "%s when CR4.LA57 %ssupported (in %u-bit mode)",
+	       expected ? "#GP" : "No fault",
+	       this_cpu_has(X86_FEATURE_LA57) ? "un" : "", is_64bit ? 64 : 32);
 
-	report(vector == expected, "%s when CR4.LA57 %ssupported",
-	       expected ? "#GP" : "No fault", expected ? "un" : "");
 	return report_summary();
 }
diff --git a/x86/unittests.cfg b/x86/unittests.cfg
index 7c1691a9..665f3d4c 100644
--- a/x86/unittests.cfg
+++ b/x86/unittests.cfg
@@ -316,7 +316,7 @@ extra_params = -cpu qemu64,+umip
 
 [la57]
 file = la57.flat
-arch = i386
+extra_params = -cpu max,host-phys-bits
 
 [vmx]
 file = vmx.flat
-- 
2.48.1.601.g30ceb7b040-goog





[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