On 07.06.2017 16:01, David Hildenbrand wrote: > On 07.06.2017 15:41, Thomas Huth wrote: >> 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). >> >> Signed-off-by: Thomas Huth <thuth@xxxxxxxxxx> >> --- >> v3: >> - Split the prefix tests into spx and stpx tests, so checking the >> exception with check_pgm_int_code() is now possible with the right >> report_prefix_push() >> - Move low_prot enable/disable code into interrupt.h >> - Added -i and -t parameters for running the tests more than once >> >> 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 >> >> diff --git a/lib/s390x/asm/interrupt.h b/lib/s390x/asm/interrupt.h >> index 383d312..e4bde6c 100644 >> --- a/lib/s390x/asm/interrupt.h >> +++ b/lib/s390x/asm/interrupt.h >> @@ -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 0,0,%0 " : : "Q"(cr0)); > > You then also might want to use %%c0 here. D'oh, you're right of course ... I'll send a v4... [...] >> +/* Test the STORE CPU ADDRESS instruction */ >> +static void test_stap(void) >> +{ >> + uint16_t cpuid = 0xffff; >> + >> + asm volatile ("stap %0\n" : "+Q"(cpuid)); >> + report("get cpu id", cpuid != 0xffff); > > CPUID is returned by STIDP (STORE CPU ID). You most likely want to name > this "get CPU address" / cpu_addr here. I'll fix that, too. > Reviewed-by: David Hildenbrand <david@xxxxxxxxxx> Thanks! Thomas