From patchwork Wed Nov 23 08:46:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13053257 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F20AAC3A59F for ; Wed, 23 Nov 2022 08:47:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236679AbiKWIrU (ORCPT ); Wed, 23 Nov 2022 03:47:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236672AbiKWIrS (ORCPT ); Wed, 23 Nov 2022 03:47:18 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65AF3E914C; Wed, 23 Nov 2022 00:47:17 -0800 (PST) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AN89sGj030715; Wed, 23 Nov 2022 08:47:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=dIXAbs8L0FNhYEv7IRk6FkP6z3D7BuE1OclD+TXjfVw=; b=omXFdj641jGyY28SPQFZ1HtUAblmnF7W7mjOXnFkc1gp6JkYM6lXmnIpVpCCAe/GMcNe 8uhyTJMVbNbnLNwm0QWlNxsROQUWS7iyMrIZLirgHoBKkHUh3+dUblppkwl4ax0GhWhQ MLOUisSsnsZbLkGacUCI519OXxcMdF49YyB7YEKvbnpZp/tH5MDxdRtKRwYoUCSq6yri JwOoS22a3tRhxMjU9s1ra1P9yjSHEJMYnv5bref6aBxTX+bv1SGbWeG1sIna+e1Rexsn 33qOgxlx5zZpMIuGTNfkwZa8x9KaxzFovMVTyxVnx8niehr2kfJ5AxhXKwl24rnCqq8e HA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m0yk7820n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:16 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AN8gp18030750; Wed, 23 Nov 2022 08:47:16 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m0yk781ys-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:16 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AN8Ytao009961; Wed, 23 Nov 2022 08:47:14 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04fra.de.ibm.com with ESMTP id 3kxps8uxm6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:13 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AN8lpYr42009076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 08:47:51 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A20CA11C04A; Wed, 23 Nov 2022 08:47:10 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DEF6E11C052; Wed, 23 Nov 2022 08:47:09 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 23 Nov 2022 08:47:09 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, david@redhat.com, thuth@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com Subject: [kvm-unit-tests PATCH 1/5] s390x: Add a linker script to assembly snippets Date: Wed, 23 Nov 2022 08:46:52 +0000 Message-Id: <20221123084656.19864-2-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221123084656.19864-1-frankja@linux.ibm.com> References: <20221123084656.19864-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fd_EWanMd5kUnn0ej_Yv-UgoMZWLl95K X-Proofpoint-ORIG-GUID: ADuRBXAHoEtNUHvss1_XD5Qzx_VWCfrp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-23_04,2022-11-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230064 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org A linker script has a few benefits: - Random data doesn't end up in the binary breaking tests - We can easily define a lowcore and load the snippet from 0x0 instead of 0x4000 which makes asm snippets behave like c snippets - We can easily define an invalid PGM new PSW to ensure an exit on a guest PGM Signed-off-by: Janosch Frank --- lib/s390x/snippet.h | 3 +-- s390x/Makefile | 5 +++-- s390x/mvpg-sie.c | 2 +- s390x/pv-diags.c | 6 +++--- s390x/snippets/asm/flat.lds | 43 +++++++++++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 s390x/snippets/asm/flat.lds diff --git a/lib/s390x/snippet.h b/lib/s390x/snippet.h index b17b2a4c..57045994 100644 --- a/lib/s390x/snippet.h +++ b/lib/s390x/snippet.h @@ -32,8 +32,7 @@ #define SNIPPET_PV_TWEAK0 0x42UL #define SNIPPET_PV_TWEAK1 0UL -#define SNIPPET_OFF_C 0 -#define SNIPPET_OFF_ASM 0x4000 +#define SNIPPET_UNPACK_OFF 0 /* diff --git a/s390x/Makefile b/s390x/Makefile index bf1504f9..bb0f9eb8 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -135,7 +135,8 @@ $(SNIPPET_DIR)/c/%.o: $(SNIPPET_DIR)/c/%.c $(asm-offsets) $(CC) $(CFLAGS) -c -nostdlib -o $@ $< $(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.o - $(OBJCOPY) -O binary -j ".rodata" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $(patsubst %.gbin,%.o,$@) $@ + $(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/snippets/asm/flat.lds $(patsubst %.gbin,%.o,$@) + $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $@ $@ truncate -s '%4096' $@ $(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) @@ -144,7 +145,7 @@ $(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) truncate -s '%4096' $@ $(SNIPPET_DIR)/asm/%.hdr: $(SNIPPET_DIR)/asm/%.gbin $(HOST_KEY_DOCUMENT) - $(GEN_SE_HEADER) -k $(HOST_KEY_DOCUMENT) -c $<,0x4000,0x00000000000000420000000000000000 --psw-addr 0x4000 -o $@ + $(GEN_SE_HEADER) -k $(HOST_KEY_DOCUMENT) -c $<,0x0,0x00000000000000420000000000000000 --psw-addr 0x4000 -o $@ $(SNIPPET_DIR)/c/%.hdr: $(SNIPPET_DIR)/c/%.gbin $(HOST_KEY_DOCUMENT) $(GEN_SE_HEADER) -k $(HOST_KEY_DOCUMENT) -c $<,0x0,0x00000000000000420000000000000000 --psw-addr 0x4000 -o $@ diff --git a/s390x/mvpg-sie.c b/s390x/mvpg-sie.c index 46a2edb6..99f4859b 100644 --- a/s390x/mvpg-sie.c +++ b/s390x/mvpg-sie.c @@ -87,7 +87,7 @@ static void setup_guest(void) snippet_setup_guest(&vm, false); snippet_init(&vm, SNIPPET_NAME_START(c, mvpg_snippet), - SNIPPET_LEN(c, mvpg_snippet), SNIPPET_OFF_C); + SNIPPET_LEN(c, mvpg_snippet), SNIPPET_UNPACK_OFF); /* Enable MVPG interpretation as we want to test KVM and not ourselves */ vm.sblk->eca = ECA_MVPGI; diff --git a/s390x/pv-diags.c b/s390x/pv-diags.c index 9ced68c7..5165937a 100644 --- a/s390x/pv-diags.c +++ b/s390x/pv-diags.c @@ -28,7 +28,7 @@ static void test_diag_500(void) snippet_pv_init(&vm, SNIPPET_NAME_START(asm, snippet_pv_diag_500), SNIPPET_HDR_START(asm, snippet_pv_diag_500), - size_gbin, size_hdr, SNIPPET_OFF_ASM); + size_gbin, size_hdr, SNIPPET_UNPACK_OFF); sie(&vm); report(vm.sblk->icptcode == ICPT_PV_INSTR && vm.sblk->ipa == 0x8302 && @@ -83,7 +83,7 @@ static void test_diag_288(void) snippet_pv_init(&vm, SNIPPET_NAME_START(asm, snippet_pv_diag_288), SNIPPET_HDR_START(asm, snippet_pv_diag_288), - size_gbin, size_hdr, SNIPPET_OFF_ASM); + size_gbin, size_hdr, SNIPPET_UNPACK_OFF); sie(&vm); report(vm.sblk->icptcode == ICPT_PV_INSTR && vm.sblk->ipa == 0x8302 && @@ -124,7 +124,7 @@ static void test_diag_yield(void) snippet_pv_init(&vm, SNIPPET_NAME_START(asm, snippet_pv_diag_yield), SNIPPET_HDR_START(asm, snippet_pv_diag_yield), - size_gbin, size_hdr, SNIPPET_OFF_ASM); + size_gbin, size_hdr, SNIPPET_UNPACK_OFF); /* 0x44 */ report_prefix_push("0x44"); diff --git a/s390x/snippets/asm/flat.lds b/s390x/snippets/asm/flat.lds new file mode 100644 index 00000000..366d2d78 --- /dev/null +++ b/s390x/snippets/asm/flat.lds @@ -0,0 +1,43 @@ +SECTIONS +{ + .lowcore : { + /* + * Initial short psw for disk boot, with 31 bit addressing for + * non z/Arch environment compatibility and the instruction + * address 0x4000. + */ + . = 0; + LONG(0x00080000) + LONG(0x80004000) + /* Restart new PSW for booting via PSW restart. */ + . = 0x1a0; + QUAD(0x0000000180000000) + QUAD(0x0000000000004000) + /* + * Invalid PGM new PSW so we hopefully get a code 8 + * intercept on a PGM + */ + . = 0x1d0; + QUAD(0x0008000000000000) + QUAD(0x0000000000000001) + } + . = 0x4000; + .text : { + *(.text) + *(.text.*) + } + . = ALIGN(64K); + etext = .; + . = ALIGN(16); + .data : { + *(.data) + *(.data.rel*) + } + . = ALIGN(16); + .rodata : { *(.rodata) *(.rodata.*) } + . = ALIGN(16); + __bss_start = .; + .bss : { *(.bss) } + __bss_end = .; + . = ALIGN(64K); +} From patchwork Wed Nov 23 08:46:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13053258 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22DA9C433FE for ; Wed, 23 Nov 2022 08:47:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236685AbiKWIrW (ORCPT ); Wed, 23 Nov 2022 03:47:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236674AbiKWIrS (ORCPT ); Wed, 23 Nov 2022 03:47:18 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8DB532BA3; Wed, 23 Nov 2022 00:47:17 -0800 (PST) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AN7sLhW029553; Wed, 23 Nov 2022 08:47:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=99tkEHRVz/AHqBjmpUDXhzmGqqsCdJI6AVMCEWISEQo=; b=Zn7865xcPHSmAQufiYDS41mM8ZdjgCgvn5Sjk2aZxXpw+5a2GrGlA2ym4ZtE7iQBnYZV jcZi5pXXIztfzpU9ke6ME56XlLYHLJdsq/4aSJ1HX5gYs01s1USSERC4LbYy9UjFx9P4 ouqDj1HqciW+4MTENdrHOw1QhBv5/lRIAO9VWDyd2+1pUOWrzUOO3CvQJDhq+8M73WDX sANAA1RniHvsz5fBqsvD18Cibb5Id2UVILWu18nRtmfulEwhEio9iY+osUbI8TgA8x5K tH4drwUghJJ336pqM7V1eLG+T9w8d/0enmPn8JBluNtFM+/Slzmmh2s0ZGOy0LfxP7jU EQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m100sqn0e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:17 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AN8KaEq003262; Wed, 23 Nov 2022 08:47:16 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m100sqmyn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:16 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AN8Z2SG009977; Wed, 23 Nov 2022 08:47:14 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04fra.de.ibm.com with ESMTP id 3kxps8uxm8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:14 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AN8evBh30540266 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 08:40:57 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9373611C054; Wed, 23 Nov 2022 08:47:11 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C82F811C04A; Wed, 23 Nov 2022 08:47:10 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 23 Nov 2022 08:47:10 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, david@redhat.com, thuth@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com Subject: [kvm-unit-tests PATCH 2/5] s390x: snippets: Fix SET_PSW_NEW_ADDR macro Date: Wed, 23 Nov 2022 08:46:53 +0000 Message-Id: <20221123084656.19864-3-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221123084656.19864-1-frankja@linux.ibm.com> References: <20221123084656.19864-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: t-zMY1j3fKJSRSlR8yXXJjqRRG2Zkw04 X-Proofpoint-ORIG-GUID: z-dKX-91OJjhW237ZBK_hELbwBcE0y2w X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-23_04,2022-11-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 mlxlogscore=899 adultscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 spamscore=0 clxscore=1015 bulkscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230064 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Let's store the psw mask instead of the address of the location where we should load the mask from. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Reviewed-by: Claudio Imbrenda --- s390x/snippets/asm/macros.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s390x/snippets/asm/macros.S b/s390x/snippets/asm/macros.S index 667fb6dc..09d7f5be 100644 --- a/s390x/snippets/asm/macros.S +++ b/s390x/snippets/asm/macros.S @@ -18,7 +18,7 @@ */ .macro SET_PSW_NEW_ADDR reg, psw_new_addr, addr_psw larl \reg, psw_mask_64 -stg \reg, \addr_psw +mvc \addr_psw(8,%r0), 0(\reg) larl \reg, \psw_new_addr stg \reg, \addr_psw + 8 .endm From patchwork Wed Nov 23 08:46:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13053260 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F054BC433FE for ; Wed, 23 Nov 2022 08:47:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236688AbiKWIrY (ORCPT ); Wed, 23 Nov 2022 03:47:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236681AbiKWIrV (ORCPT ); Wed, 23 Nov 2022 03:47:21 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0A9A92B57; Wed, 23 Nov 2022 00:47:19 -0800 (PST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AN6C7bs039793; Wed, 23 Nov 2022 08:47:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=zke0vGSRnM2M3jyXPQp7cHnF4OeHrBe60tp0p0hm6/k=; b=OFYk7XeCrzFaXXI4xKKgZ2iEIwfojgHcgT6D6RIcQrXhhIFZMbri9s2PcOLsGYyBoDgY JL5cvLaGFqB4Pl/5bxMdyIAZiMEj+FVOMe05xw2QLByRDybn/rJws85bBcNJlGE2KCG0 0+oo9uRc+E8RN36Qa1T2kCCexzCR3HIJDZxJniageJhPxvKMVKnG3r8X2+sj9/BG+4VW LWJIUiU1TEChf/zN/QXd/U72UYFq34MDwGve2nhO9o7IM5qlUFSalgsd+VV3e4K/pvZO qZopQSSO9gm8dcKwj/rZ+l04AbA2drev+z6JStfdID5XAofpANnBjcnamUR7zpHet4rF DA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m10ffeww8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:18 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AN8kceV028283; Wed, 23 Nov 2022 08:47:18 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m10ffewv2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:18 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AN8ZKo6007498; Wed, 23 Nov 2022 08:47:15 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03fra.de.ibm.com with ESMTP id 3kxps93xfq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:15 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AN8lCiE63766956 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 08:47:12 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 848D911C04C; Wed, 23 Nov 2022 08:47:12 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B96C811C04A; Wed, 23 Nov 2022 08:47:11 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 23 Nov 2022 08:47:11 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, david@redhat.com, thuth@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com Subject: [kvm-unit-tests PATCH 3/5] lib: s390x: sie: Set guest memory pointer Date: Wed, 23 Nov 2022 08:46:54 +0000 Message-Id: <20221123084656.19864-4-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221123084656.19864-1-frankja@linux.ibm.com> References: <20221123084656.19864-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: CijI2Z_Uharv_zFQS-vhakKYG2MhRxHE X-Proofpoint-GUID: lPwzxoU-tseG11B9UsOM9bPF25GV1-o6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-23_04,2022-11-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 priorityscore=1501 spamscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 suspectscore=0 impostorscore=0 malwarescore=0 mlxscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230064 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Seems like it was introduced but never set. It's nicer to have a pointer than to cast the MSO of a VM. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Reviewed-by: Claudio Imbrenda --- lib/s390x/sie.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c index a71985b6..9241b4b4 100644 --- a/lib/s390x/sie.c +++ b/lib/s390x/sie.c @@ -93,6 +93,7 @@ void sie_guest_create(struct vm *vm, uint64_t guest_mem, uint64_t guest_mem_len) /* Guest memory chunks are always 1MB */ assert(!(guest_mem_len & ~HPAGE_MASK)); + vm->guest_mem = (uint8_t *)guest_mem; /* For non-PV guests we re-use the host's ASCE for ease of use */ vm->save_area.guest.asce = stctg(1); /* Currently MSO/MSL is the easiest option */ From patchwork Wed Nov 23 08:46:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13053259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F638C4332F for ; Wed, 23 Nov 2022 08:47:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236689AbiKWIrX (ORCPT ); Wed, 23 Nov 2022 03:47:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236680AbiKWIrU (ORCPT ); Wed, 23 Nov 2022 03:47:20 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5621D2DDC; Wed, 23 Nov 2022 00:47:19 -0800 (PST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AN6M5KN039609; Wed, 23 Nov 2022 08:47:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=92bj0GHN32CsEjX9VmkfiBaFpHqsTz6F4uXbW75Sj2Q=; b=KL0bG+8hZguth0WC/jaDLSOmsTbnakOmIssqBlCtn5WgJy0RXDL2nP4c3Wu6uKyxZsy4 fwyl8+OSEZknESy5cWF+RhTSaVPSH8s13G81YFn/4hP4rpU86W/lNtTb0mxnR33CZlQ1 e7E6nze6m8NvrV3mdH3Xwc4fywjwL3kPLnhkPuKAixcIqA9OLR0OCvePMbG3X1WWdsR8 BojOv4JdiLtTWWCmGoDYGYFKFJvwlFNo0Gib0jVrX9xbWmYqAmKJKgyu32BRsaIllkg1 SpZdZGIm6mE99BQW72WjALVs/8rxYnebqpLh/6Wcz2QReuLaOspFeBs6yrf2ytjz/BRO WA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m10ffewwk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:19 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AN86fPQ036526; Wed, 23 Nov 2022 08:47:19 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m10ffewvq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:18 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AN8Z8mu001203; Wed, 23 Nov 2022 08:47:16 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 3kxps8wc5r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:16 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AN8lDpe48693520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 08:47:13 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 753FD11C04A; Wed, 23 Nov 2022 08:47:13 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AA0C111C04C; Wed, 23 Nov 2022 08:47:12 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 23 Nov 2022 08:47:12 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, david@redhat.com, thuth@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com Subject: [kvm-unit-tests PATCH 4/5] s390x: Clear first stack frame and end backtrace early Date: Wed, 23 Nov 2022 08:46:55 +0000 Message-Id: <20221123084656.19864-5-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221123084656.19864-1-frankja@linux.ibm.com> References: <20221123084656.19864-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: DELy4Db56bwxpSK43DYNsLmX-ie9pfUI X-Proofpoint-GUID: DtrRJ3cfbt9VyDWzpwTCKeAtdfaig-Fm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-23_04,2022-11-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 priorityscore=1501 spamscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 suspectscore=0 impostorscore=0 malwarescore=0 mlxscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230064 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When setting the first stack frame to 0, we can check for a 0 backchain pointer when doing backtraces to know when to stop. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Reviewed-by: Claudio Imbrenda --- lib/s390x/stack.c | 2 ++ s390x/cstart64.S | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/s390x/stack.c b/lib/s390x/stack.c index e714e07c..9f234a12 100644 --- a/lib/s390x/stack.c +++ b/lib/s390x/stack.c @@ -22,6 +22,8 @@ int backtrace_frame(const void *frame, const void **return_addrs, int max_depth) for (depth = 0; stack && depth < max_depth; depth++) { return_addrs[depth] = (void *)stack->grs[8]; stack = stack->back_chain; + if (!stack) + break; } return depth; diff --git a/s390x/cstart64.S b/s390x/cstart64.S index 666a9567..6f83da2a 100644 --- a/s390x/cstart64.S +++ b/s390x/cstart64.S @@ -37,6 +37,8 @@ start: sam64 # Set addressing mode to 64 bit /* setup stack */ larl %r15, stackptr + /* Clear first stack frame */ + xc 0(160,%r15), 0(%r15) /* setup initial PSW mask + control registers*/ larl %r1, initial_psw lpswe 0(%r1) From patchwork Wed Nov 23 08:46:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13053261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77142C4332F for ; Wed, 23 Nov 2022 08:47:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236694AbiKWIr0 (ORCPT ); Wed, 23 Nov 2022 03:47:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236684AbiKWIrW (ORCPT ); Wed, 23 Nov 2022 03:47:22 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BCEC32BA3; Wed, 23 Nov 2022 00:47:21 -0800 (PST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AN8LNUa014558; Wed, 23 Nov 2022 08:47:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=N6KQpyCIRLGVNI2BKxfLkWTQQxU4f9VG2jydRh65aag=; b=Ec4cIW/rVyN60oIpCtr70ksemEydK1oYK93q4TEaGL9uNBeASwLkinbJ5cjmRjSfHO7o 94veJ9rmooajGqrj7g8+haw8ku+kIqW+sBJfuNS9D0XXkuqdWjxBiGA5F4FW5Te9adpG aGbjMOojweGELjoymdr808Z4PsDGbQbVA8cx/cabR1QVIM/GitSxH4bF9gHjfcFdyHhw lB+q5OTcGXdP5vooMxQHDWFLaSIOrPff+cf3ChFUwZRskxokljNsj+qMRiLZTnK8/us4 NkR1oCGbGxcmAUXMuomfaTgttl/cjt5XIBx+Yd1+rN3GiEfSnWC3MUTmodL0zqe86Dj0 IA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m10pfxka8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:20 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AN8astc018667; Wed, 23 Nov 2022 08:47:20 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m10pfxk9f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:20 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AN8ZeUR022807; Wed, 23 Nov 2022 08:47:17 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06ams.nl.ibm.com with ESMTP id 3kxpdhwcvg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:47:17 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AN8lEIG6423090 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Nov 2022 08:47:14 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D81D11C04C; Wed, 23 Nov 2022 08:47:14 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B66311C04A; Wed, 23 Nov 2022 08:47:13 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 23 Nov 2022 08:47:13 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, david@redhat.com, thuth@redhat.com, seiden@linux.ibm.com, nrb@linux.ibm.com Subject: [kvm-unit-tests PATCH 5/5] lib: s390x: Handle debug prints for SIE exceptions correctly Date: Wed, 23 Nov 2022 08:46:56 +0000 Message-Id: <20221123084656.19864-6-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221123084656.19864-1-frankja@linux.ibm.com> References: <20221123084656.19864-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: saKs2rWI3ENc4AIXd2OnRJddwu64qPxg X-Proofpoint-GUID: PGSzQMdilxOOJ1VzxdGb1J-w1OE4zZ9E X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-23_04,2022-11-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 adultscore=0 spamscore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 clxscore=1015 impostorscore=0 mlxlogscore=919 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230064 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When we leave SIE due to an exception, we'll still have guest values in registers 0 - 13 and that's not clearly portraied in our debug prints. So let's fix that. Signed-off-by: Janosch Frank --- lib/s390x/interrupt.c | 46 ++++++++++++++++++++++++++++++++++++++----- lib/s390x/sie.h | 2 ++ s390x/cpu.S | 6 ++++-- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c index dadb7415..ff47c2c2 100644 --- a/lib/s390x/interrupt.c +++ b/lib/s390x/interrupt.c @@ -9,6 +9,7 @@ */ #include #include +#include #include #include #include @@ -188,9 +189,12 @@ static void print_storage_exception_information(void) } } -static void print_int_regs(struct stack_frame_int *stack) +static void print_int_regs(struct stack_frame_int *stack, bool sie) { + struct kvm_s390_sie_block *sblk; + printf("\n"); + printf("%s\n", sie ? "Guest registers:" : "Host registers:"); printf("GPRS:\n"); printf("%016lx %016lx %016lx %016lx\n", stack->grs1[0], stack->grs1[1], stack->grs0[0], stack->grs0[1]); @@ -198,24 +202,56 @@ static void print_int_regs(struct stack_frame_int *stack) stack->grs0[2], stack->grs0[3], stack->grs0[4], stack->grs0[5]); printf("%016lx %016lx %016lx %016lx\n", stack->grs0[6], stack->grs0[7], stack->grs0[8], stack->grs0[9]); - printf("%016lx %016lx %016lx %016lx\n", - stack->grs0[10], stack->grs0[11], stack->grs0[12], stack->grs0[13]); + + if (sie) { + sblk = (struct kvm_s390_sie_block *)stack->grs0[12]; + printf("%016lx %016lx %016lx %016lx\n", + stack->grs0[10], stack->grs0[11], sblk->gg14, sblk->gg15); + } else { + printf("%016lx %016lx %016lx %016lx\n", + stack->grs0[10], stack->grs0[11], stack->grs0[12], stack->grs0[13]); + } + printf("\n"); } static void print_pgm_info(struct stack_frame_int *stack) { - bool in_sie; + bool in_sie, in_sie_gregs; + struct vm_save_area *vregs; in_sie = (lowcore.pgm_old_psw.addr >= (uintptr_t)sie_entry && lowcore.pgm_old_psw.addr <= (uintptr_t)sie_exit); + in_sie_gregs = (lowcore.pgm_old_psw.addr >= (uintptr_t)sie_entry_gregs && + lowcore.pgm_old_psw.addr <= (uintptr_t)sie_exit_gregs); printf("\n"); printf("Unexpected program interrupt %s: %#x on cpu %d at %#lx, ilen %d\n", in_sie ? "in SIE" : "", lowcore.pgm_int_code, stap(), lowcore.pgm_old_psw.addr, lowcore.pgm_int_id); - print_int_regs(stack); + + /* + * If we fall out of SIE before loading the host registers, + * then we need to do it here so we print the host registers + * and not the guest registers. + * + * Back tracing is actually not a problem since SIE restores gr15. + */ + if (in_sie_gregs) { + print_int_regs(stack, true); + vregs = *((struct vm_save_area **)(stack->grs0[13] + __SF_SIE_SAVEAREA)); + + /* + * The grs are not linear on the interrupt stack frame. + * We copy 0 and 1 here and 2 - 15 with the memcopy below. + */ + stack->grs1[0] = vregs->host.grs[0]; + stack->grs1[1] = vregs->host.grs[1]; + /* 2 - 15 */ + memcpy(stack->grs0, &vregs->host.grs[2], sizeof(stack->grs0) - 8); + } + print_int_regs(stack, false); dump_stack(); /* Dump stack doesn't end with a \n so we add it here instead */ diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h index a27a8401..147cb0f2 100644 --- a/lib/s390x/sie.h +++ b/lib/s390x/sie.h @@ -273,6 +273,8 @@ struct vm { extern void sie_entry(void); extern void sie_exit(void); +extern void sie_entry_gregs(void); +extern void sie_exit_gregs(void); extern void sie64a(struct kvm_s390_sie_block *sblk, struct vm_save_area *save_area); void sie(struct vm *vm); void sie_expect_validity(struct vm *vm); diff --git a/s390x/cpu.S b/s390x/cpu.S index 45bd551a..9155b044 100644 --- a/s390x/cpu.S +++ b/s390x/cpu.S @@ -82,7 +82,8 @@ sie64a: # Store scb and save_area pointer into stack frame stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area - +.globl sie_entry_gregs +sie_entry_gregs: # Load guest's gprs, fprs and fpc .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 ld \i, \i * 8 + SIE_SAVEAREA_GUEST_FPRS(%r3) @@ -121,7 +122,8 @@ sie_exit: .endr lfpc SIE_SAVEAREA_HOST_FPC(%r14) lmg %r0,%r14,SIE_SAVEAREA_HOST_GRS(%r14) # restore kernel registers - +.globl sie_exit_gregs +sie_exit_gregs: br %r14 .align 8