Skip to contentSkip to conversation

s390x: Interception tests

PATCH Applied Thomas Huth 2 participants 2 messages Jun 7, 2017 – Jun 14, 2017 KVM

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 s390x: Interception tests

Certain CPU instructions will cause an exit of the virtual machine. Run some of these instructions to check whether they are emulated right by KVM (or QEMU).

---
v4:
- Use %%c0 for lctlg instead of 0
- Replaced "CPU ID" with "CPU address" in the STAP test

 lib/s390x/asm/interrupt.h |  20 ++++
 s390x/Makefile            |   1 +
 s390x/intercept.c         | 227 ++++++++++++++++++++++++++++++++++++++++++++++
 s390x/unittests.cfg       |   3 +
 4 files changed, 251 insertions(+)
 create mode 100644 s390x/intercept.c
lib/s390x/asm/interrupt.h +20 -0
index 383d312..41be039 100644
@@ -15,4 +15,24 @@ void handle_pgm_int(void);
 void expect_pgm_int(void);
 void check_pgm_int_code(uint16_t code);
 
+/* Activate low-address protection */
+static inline void low_prot_enable(void)
+{
+	uint64_t cr0;
+
+	asm volatile (" stctg %%c0,%%c0,%0 " : : "Q"(cr0) : "memory");
+	cr0 |= 1ULL << (63-35);
+	asm volatile (" lctlg %%c0,%%c0,%0 " : : "Q"(cr0));
+}
+
+/* Disable low-address protection */
+static inline void low_prot_disable(void)
+{
+	uint64_t cr0;
+
+	asm volatile (" stctg %%c0,%%c0,%0 " : : "Q"(cr0) : "memory");
+	cr0 &= ~(1ULL << (63-35));
+	asm volatile (" lctlg %%c0,%%c0,%0 " : : "Q"(cr0));
+}
+
 #endif
s390x/Makefile +1 -0
index b48f8ab..a61e163 100644
@@ -1,4 +1,5 @@
 tests = $(TEST_DIR)/selftest.elf
+tests += $(TEST_DIR)/intercept.elf
 
 all: directories test_cases
 
s390x/intercept.c new file +227 -0

227 lines not on this page · raw message

s390x/unittests.cfg +3 -0
index 92e01ab..3b6b892 100644
@@ -22,3 +22,6 @@
 file = selftest.elf
 groups = selftest
 extra_params = -append 'test 123'
+
+[intercept]
+file = intercept.elf
Signature · 1 line
1.8.3.1