From: Thomas Huth Subject: Re: [kvm-unit-tests PATCH v3] s390x: Interception tests Date: Wed, 7 Jun 2017 16:59:30 +0200 Message-ID: <07afcfb3-49ba-c77b-e41e-d91e32b95c80@redhat.com> References: <1496842891-18011-1-git-send-email-thuth@redhat.com> <1d0d501b-797b-424f-1553-2dc3fd768808@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= To: David Hildenbrand , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:33722 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751425AbdFGO7g (ORCPT ); Wed, 7 Jun 2017 10:59:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BEB473DBD4 for ; Wed, 7 Jun 2017 14:59:35 +0000 (UTC) In-Reply-To: <1d0d501b-797b-424f-1553-2dc3fd768808@redhat.com> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: 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 >> --- >> 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 Thanks! Thomas