Skip to contentSkip to conversation

Simple test for sysenter instruction

PATCH New Maxim Levitsky 1 participant 3 messages Mar 15, 2021 KVM

lore
Share & tools
lore
#0 lore raw

v2 cover Simple test for sysenter instruction

Hi,

This patch series adds a simple test for sysenter instruction running in comp32 mode, while using Intel vendor ID.

In this setting, KVM emulates this instruction to help with cross-vendor migration on AMD.

I also added a patch to 'msr' test to run it with Intel's vendor ID, since this test tests that SYSENTER EIP/ESP msrs are 64 bit wide which is only true on AMD.

KVM used to emulate these msrs to be always 64 bit on AMD, but this soon will be changed to do the emulation only when guest CPU vendor ID is of Intel.

Best regards,
Maxim Levitsky

Maxim Levitsky (2):
x86/msr: run this test with intel vendor id
Add a simple test for SYSENTER instruction.

 x86/Makefile.x86_64 |  3 ++
 x86/cstart64.S      |  1 +
 x86/sysenter.c      | 91 +++++++++++++++++++++++++++++++++++++++++++++
 x86/unittests.cfg   |  6 +++
 4 files changed, 101 insertions(+)
 create mode 100644 x86/sysenter.c
Signature · 1 line
2.26.2
#1 lore raw

PATCH v2 1/2 x86/msr: run this test with intel vendor id

Part of this test, tests that sysenter msrs are 64 bit wide which is only true on Intel.

We emulate Intel variant of SYSENTER in KVM when Intel's vendor ID is used to help with cross-vendor migration, which includes extending SYSENTER msrs to 64 bit.

The later was done unconditionally which soon will be limited to VMs which use Intel's vendor ID.

So run the test with Intel's vendor ID so it continues to pass.

---
 x86/unittests.cfg | 1 +
 1 file changed, 1 insertion(+)
x86/unittests.cfg +1 -0
index 0698d15..60c4b13 100644
@@ -168,6 +168,7 @@ arch = x86_64
 
 [msr]
 file = msr.flat
+extra_params = -cpu host,vendor=GenuineIntel
 
 [pmu]
 file = pmu.flat
Signature · 1 line
2.26.2
#2 lore raw

PATCH v2 2/2 Add a simple test for SYSENTER instruction.

In reply to Maxim Levitsky

Run the test with Intel's vendor ID and in the long mode, to test the emulation of this instruction on AMD.

---
 x86/Makefile.x86_64 |  3 ++
 x86/cstart64.S      |  1 +
 x86/sysenter.c      | 91 +++++++++++++++++++++++++++++++++++++++++++++
 x86/unittests.cfg   |  5 +++
 4 files changed, 100 insertions(+)
 create mode 100644 x86/sysenter.c
x86/Makefile.x86_64 +3 -0
index 8134952..c430bfb 100644
@@ -16,6 +16,7 @@ tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \
 	  $(TEST_DIR)/ioapic.flat $(TEST_DIR)/memory.flat \
 	  $(TEST_DIR)/pku.flat $(TEST_DIR)/hyperv_clock.flat
 tests += $(TEST_DIR)/syscall.flat
+tests += $(TEST_DIR)/sysenter.flat
 tests += $(TEST_DIR)/svm.flat
 tests += $(TEST_DIR)/vmx.flat
 tests += $(TEST_DIR)/tscdeadline_latency.flat
@@ -35,3 +36,5 @@ $(TEST_DIR)/hyperv_clock.elf: $(TEST_DIR)/hyperv_clock.o
 
 $(TEST_DIR)/vmx.elf: $(TEST_DIR)/vmx_tests.o
 $(TEST_DIR)/svm.elf: $(TEST_DIR)/svm_tests.o
+
+$(TEST_DIR)/sysenter.o: CFLAGS += -Wa,-mintel64
\ No newline at end of file
x86/cstart64.S +1 -0
index 5c6ad38..62ace35 100644
@@ -62,6 +62,7 @@ gdt64_desc:
 	.word gdt64_end - gdt64 - 1
 	.quad gdt64
 
+.globl gdt64
 gdt64:
 	.quad 0
 	.quad 0x00af9b000000ffff // 64-bit code segment
x86/sysenter.c new file +91 -0

91 lines not on this page · raw message

x86/unittests.cfg +5 -0
index 60c4b13..5fe39f5 100644
@@ -205,6 +205,11 @@ file = syscall.flat
 arch = x86_64
 extra_params = -cpu Opteron_G1,vendor=AuthenticAMD
 
+[sysenter]
+file = sysenter.flat
+arch = x86_64
+extra_params = -cpu host,vendor=GenuineIntel
+
 [tsc]
 file = tsc.flat
 extra_params = -cpu kvm64,+rdtscp
Signature · 1 line
2.26.2