From patchwork Thu Jan 12 15:45:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13098284 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 2250AC54EBC for ; Thu, 12 Jan 2023 15:57:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240580AbjALP52 (ORCPT ); Thu, 12 Jan 2023 10:57:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233662AbjALP4b (ORCPT ); Thu, 12 Jan 2023 10:56:31 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9A435D412; Thu, 12 Jan 2023 07:46:42 -0800 (PST) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30CFhB1t035687; Thu, 12 Jan 2023 15:46:42 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=KFUrNtigUEeaHqHBmmpeE1iOWem11CVHE+3cGHeVykU=; b=forpD1MPaH6QLhqUZSH9eaQ5lRnTUeSz7SXtQFvxfG8D5Ay6XaRxcgs0mQOs3KukkL/P rWc2+TJp19ifIkJ1OzlL3GK1+RDZ/PiuUjaic38apu/OqGtHm/9lX52oMZcQHjFo2GPc nNiHNXg30HxrcLxD9YlqJRGxV10W9QNPYST2wjbo5dbzzNe4+h2VDpycNFDPE1Eo+K0d WujoN3Fru2FastGO1o4/7xRqXVy7CG4GjBdPu6CGMoUXX3bX9wmHf3JNSrq2a/GVw/T3 QxfTlH7UwmG8NYdd4wFkWxSP+MPSPyIkHYZVs0O6MQYt3Km61cMbPFlLCFfu8iHGgY8T 1A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n2n3e835n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:41 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 30CFh1S9035247; Thu, 12 Jan 2023 15:46:41 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n2n3e834u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:41 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30CFMRWd030858; Thu, 12 Jan 2023 15:46:39 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3n1kf7jprf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:39 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30CFkac223658982 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 15:46:36 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F32FF20049; Thu, 12 Jan 2023 15:46:35 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C81A420040; Thu, 12 Jan 2023 15:46:35 +0000 (GMT) Received: from a46lp67.. (unknown [9.152.108.100]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Jan 2023 15:46:35 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, david@redhat.com, nsg@linux.ibm.com, nrb@linux.ibm.com Subject: [kvm-unit-tests PATCH v2 1/7] s390x: Cleanup flat.lds Date: Thu, 12 Jan 2023 15:45:42 +0000 Message-Id: <20230112154548.163021-2-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230112154548.163021-1-frankja@linux.ibm.com> References: <20230112154548.163021-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: -cWULVOz1rVe4br72WcDKGie9Y_A1dcY X-Proofpoint-GUID: W0r4RtyFv7k3fyyhMMcrV_SFf77wkBGI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-12_08,2023-01-12_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 mlxlogscore=987 malwarescore=0 spamscore=0 clxscore=1015 adultscore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120112 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org It seems like the loader file was copied over from another architecture which has a different page size (64K) than s390 (4K). Let's use a 4k alignment instead of the 64k one and remove unneeded entries. Signed-off-by: Janosch Frank Reviewed-by: Claudio Imbrenda --- s390x/flat.lds | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/s390x/flat.lds b/s390x/flat.lds index de9da1a8..952f6cd4 100644 --- a/s390x/flat.lds +++ b/s390x/flat.lds @@ -24,20 +24,8 @@ SECTIONS *(.text) *(.text.*) } - . = ALIGN(64K); + . = ALIGN(4K); etext = .; - .opd : { *(.opd) } - . = ALIGN(16); - .dynamic : { - dynamic_start = .; - *(.dynamic) - } - .dynsym : { - dynsym_start = .; - *(.dynsym) - } - .rela.dyn : { *(.rela*) } - . = ALIGN(16); .data : { *(.data) *(.data.rel*) @@ -48,10 +36,11 @@ SECTIONS __bss_start = .; .bss : { *(.bss) } __bss_end = .; - . = ALIGN(64K); + . = ALIGN(4K); edata = .; + /* Reserve 64K for the stack */ . += 64K; - . = ALIGN(64K); + . = ALIGN(4K); /* * stackptr set with initial stack frame preallocated */ From patchwork Thu Jan 12 15:45:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13098288 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 680A7C54EBD for ; Thu, 12 Jan 2023 15:57:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238794AbjALP5p (ORCPT ); Thu, 12 Jan 2023 10:57:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230359AbjALP4v (ORCPT ); Thu, 12 Jan 2023 10:56:51 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A5325FE1; Thu, 12 Jan 2023 07:47:38 -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 30CFcrrx011765; Thu, 12 Jan 2023 15:47:38 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=ll1HBSaTjnNwq5VWjmoTQ922t4aAQXroHF/DN5fBBQI=; b=hwLsFEc737RQ3xGsGX5+jfrQsgR2qnquofefBhbqkgPZ06f+rDnA88al4U9cAEz1nwsC PKDfFKNLSa81Y7+5ML9f7mmyr10aQUXMlH42DmieIClF4Ug7TWpRVvT+apj0S23b6M5U B9dGHQPLG9trwLkjMEISsv/PqABHAbo/Dg1RZRpx65iPcgvRy1iXjMFWIP8hyEf1JwCN ncj81qT3UsRLTf/mtx8RauRDCj0MwLOM4ELer+OdagdvTAyKD3Ndy0dqSplx+g/2a4kI 9FbuhnLlANp7W11ziE+zPw8HtiNv67IQ7Z2UngDDre37IgKcVWo/c5OZjmBh76NnYvLY jA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n2mb0hhdm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:47:37 +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 30CFd5km012467; Thu, 12 Jan 2023 15:47:37 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 3n2mb0hhca-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:47:37 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30CC5BRU030569; Thu, 12 Jan 2023 15:46:39 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3n1kyx9xsf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:39 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30CFka2420381964 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 15:46:36 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2663620040; Thu, 12 Jan 2023 15:46:36 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0449E2004B; Thu, 12 Jan 2023 15:46:36 +0000 (GMT) Received: from a46lp67.. (unknown [9.152.108.100]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Jan 2023 15:46:35 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, david@redhat.com, nsg@linux.ibm.com, nrb@linux.ibm.com Subject: [kvm-unit-tests PATCH v2 2/7] s390x: snippets: c: Cleanup flat.lds Date: Thu, 12 Jan 2023 15:45:43 +0000 Message-Id: <20230112154548.163021-3-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230112154548.163021-1-frankja@linux.ibm.com> References: <20230112154548.163021-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Y3GNx-DAt8zmkKT7mnd3FkDROXGNQj-v X-Proofpoint-ORIG-GUID: T1Yt3a6T4rM8YGC8XC5DQVftVEd0L79i X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-12_08,2023-01-12_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 mlxscore=0 malwarescore=0 mlxlogscore=746 spamscore=0 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120112 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org There are a lot of things in there which we don't need for snippets and the alignments can be switched from 64K to 4K since that's the s390 page size. Signed-off-by: Janosch Frank Reviewed-by: Claudio Imbrenda --- s390x/snippets/c/flat.lds | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/s390x/snippets/c/flat.lds b/s390x/snippets/c/flat.lds index 260ab1c4..9e5eb66b 100644 --- a/s390x/snippets/c/flat.lds +++ b/s390x/snippets/c/flat.lds @@ -16,27 +16,22 @@ SECTIONS QUAD(0x0000000000004000) } . = 0x4000; + /* + * The stack grows down from 0x4000 to 0x2000, we pre-allocoate + * a frame via the -160. + */ stackptr = . - 160; stacktop = .; + /* Start text 0x4000 */ .text : { *(.init) *(.text) *(.text.*) } - . = ALIGN(64K); + . = ALIGN(4K); etext = .; - .opd : { *(.opd) } - . = ALIGN(16); - .dynamic : { - dynamic_start = .; - *(.dynamic) - } - .dynsym : { - dynsym_start = .; - *(.dynsym) - } - .rela.dyn : { *(.rela*) } - . = ALIGN(16); + /* End text */ + /* Start data */ .data : { *(.data) *(.data.rel*) @@ -44,11 +39,6 @@ SECTIONS . = ALIGN(16); .rodata : { *(.rodata) *(.rodata.*) } . = ALIGN(16); - __bss_start = .; .bss : { *(.bss) } - __bss_end = .; - . = ALIGN(64K); - edata = .; - . += 64K; - . = ALIGN(64K); + /* End data */ } From patchwork Thu Jan 12 15:45:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13098283 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 C1DAAC54EBD for ; Thu, 12 Jan 2023 15:57:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240511AbjALP5Y (ORCPT ); Thu, 12 Jan 2023 10:57:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230390AbjALP4c (ORCPT ); Thu, 12 Jan 2023 10:56:32 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 365FDCF3; Thu, 12 Jan 2023 07:46:43 -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 30CFMi0W007486; Thu, 12 Jan 2023 15:46:42 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=FymxuNJ0TKR8x2t9YRt0aljKT6E83V80FCzzVLfyHYA=; b=JDM/+1dgnWcSft66esu/ymY1EKG47wHBJ/xA25V28ZzWskKJ9bs6421sjNC8ISlhgWga sz/msk52tDNCBbarv7DQ0FLlhJ1o70YqXu1F5lpuIByKHWeWQ7SWvIij60pe/frusMBA NrOQVYCrSCFfhcmWaiet9aaqQObD+Mh3r3DW+fok/fWKSGgS5zPOUo+DkS9KLt2Dua8m 0+Xh0KcOhmcOSuaoxdrFxiRg031PtJTh5ewVN3NGmxQOHX4IxtioQkKZJw8eU90wU7W1 3PyG5q9K3FCUUwt2y3CgoTuDX7NIJ9TZvCUpMuaY/NVTBDM2Ucm1qJIy3WKnUb3Qz8iE ig== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3n2msmgqd6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:42 +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 30CFPOVA015365; Thu, 12 Jan 2023 15:46:41 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3n2msmgqcp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:41 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30CFMRWe030858; Thu, 12 Jan 2023 15:46:40 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3n1kf7jprh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:39 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30CFkaIe23658988 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 15:46:36 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 501B52004B; Thu, 12 Jan 2023 15:46:36 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B14820049; Thu, 12 Jan 2023 15:46:36 +0000 (GMT) Received: from a46lp67.. (unknown [9.152.108.100]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Jan 2023 15:46:36 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, david@redhat.com, nsg@linux.ibm.com, nrb@linux.ibm.com Subject: [kvm-unit-tests PATCH v2 3/7] s390x: Add a linker script to assembly snippets Date: Thu, 12 Jan 2023 15:45:44 +0000 Message-Id: <20230112154548.163021-4-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230112154548.163021-1-frankja@linux.ibm.com> References: <20230112154548.163021-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 3UkvUpH6VqIWiNMO3FDwOICAq064bH4r X-Proofpoint-ORIG-GUID: 4aL5t40ysSw1doeZfAd5zV6gpDXBXsUO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-12_08,2023-01-12_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120112 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 Reviewed-by: Claudio Imbrenda --- lib/s390x/snippet.h | 3 +-- s390x/Makefile | 5 +++-- s390x/mvpg-sie.c | 2 +- s390x/pv-diags.c | 6 +++--- s390x/snippets/asm/flat.lds | 41 +++++++++++++++++++++++++++++++++++++ 5 files changed, 49 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 52a9d821..97a61611 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -136,7 +136,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 $< + $(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) @@ -145,7 +146,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..ab0031ac --- /dev/null +++ b/s390x/snippets/asm/flat.lds @@ -0,0 +1,41 @@ +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; + /* Start text 0x4000 */ + .text : { + *(.text) + *(.text.*) + } + . = ALIGN(16); + etext = .; + /* End text */ + /* Start data */ + .data : { + *(.data) + *(.data.rel*) + } + . = ALIGN(16); + .rodata : { *(.rodata) *(.rodata.*) } + /* End data */ +} From patchwork Thu Jan 12 15:45:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13098287 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 F057BC67871 for ; Thu, 12 Jan 2023 15:57:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240634AbjALP5l (ORCPT ); Thu, 12 Jan 2023 10:57:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240342AbjALP4u (ORCPT ); Thu, 12 Jan 2023 10:56:50 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8575A62CD; Thu, 12 Jan 2023 07:47:38 -0800 (PST) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30CFafYX009957; Thu, 12 Jan 2023 15:47:38 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=c62SJHG2j4sax8tnzOM4l8DvZUjd1arD3GDQ0uDymE8=; b=LLur9RS5vzA9bfrv8KqOJGXSt0KDRce0/SM82RQLMGOWz7+JdMQOgxg/iDqsiBnAwgux SFyaO+QKX7a+WQMMpiCqiOVvNi3fqCoB/ZO3D35t4OzQBEcsU+YjjsauX2k2n+ClXZLb FQG0NgH2VNBGqDFnz9kW999fE2702j9LKpLaJ+SDSF8Yk1luM9rTK4YonSidmN6CkgCL Un2ceGi1i1tNvt6j62OFaEDs7BAK7PHs0+92mF067x/GgKpaTIt3zVA55U8gU2QD1ViH 2n4LNXVzDBnjNpYk+hlik/bYlnrVhhG1Fql/GRtop5EC/raxtn6Bwes7WFU5TbFcw9/A PA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n2m01as01-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:47:38 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 30CEUrxa021256; Thu, 12 Jan 2023 15:47:37 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n2m01arxj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:47:37 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30CCGGBs003305; Thu, 12 Jan 2023 15:46:40 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma06fra.de.ibm.com (PPS) with ESMTPS id 3n1kmthydr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:40 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30CFkaZh23658992 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 15:46:36 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9287920040; Thu, 12 Jan 2023 15:46:36 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 554EF2004D; Thu, 12 Jan 2023 15:46:36 +0000 (GMT) Received: from a46lp67.. (unknown [9.152.108.100]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Jan 2023 15:46:36 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, david@redhat.com, nsg@linux.ibm.com, nrb@linux.ibm.com Subject: [kvm-unit-tests PATCH v2 4/7] s390x: snippets: Fix SET_PSW_NEW_ADDR macro Date: Thu, 12 Jan 2023 15:45:45 +0000 Message-Id: <20230112154548.163021-5-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230112154548.163021-1-frankja@linux.ibm.com> References: <20230112154548.163021-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: o0v8SDN6HTgmqJS9nWGtlx659TNuXFrS X-Proofpoint-GUID: 82JACaKE5f09KwjDK3n2goBEleNL54Ee X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-12_08,2023-01-12_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 mlxscore=0 suspectscore=0 adultscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 phishscore=0 spamscore=0 mlxlogscore=981 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120112 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 Thu Jan 12 15:45:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13098282 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 918E3C54EBC for ; Thu, 12 Jan 2023 15:57:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240318AbjALP5V (ORCPT ); Thu, 12 Jan 2023 10:57:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239955AbjALP4c (ORCPT ); Thu, 12 Jan 2023 10:56:32 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C8D35F51; Thu, 12 Jan 2023 07:46:43 -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 30CFMVnT007188; Thu, 12 Jan 2023 15:46:42 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=QDKrRVqYm2//ElF5qsIbukRrYfV3hJ5VB07SX8s8rTI=; b=ghqTlScWwtFCyxgZfydWrqK3FcYJ3ZobFCiBXaZAjWWPzTGnE0ezmCaJCe01Mi2LopzF isg6wAk4Wh57n2hxLPpg7+TLdb/II3tzIUBnGuHbFjiApqpWoIZJd/sXR2gLmUH/XMai UmUjMhkUZ+e+WF6QY/OAoGkrXQyFfVUiZqzKNGcsVHRbTYetbfp6nZivZjW0emvICyds I9aPd6TyQZpC/vdMHVbN80BrZRTzKqXWS/mM2FZnJdtXd0TBzTexzR4jI3AQ7U/sYj8v Ih7EZn/wtKXavYhGqE9i8u9z3w+4rebe35ry5hecM+y5Dh5aeJKwmn5XIRg1aB3OI+7t yg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3n2msmgqdn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:42 +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 30CFfEXE030740; Thu, 12 Jan 2023 15:46:42 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 3n2msmgqcu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:42 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30CBNuMm022367; Thu, 12 Jan 2023 15:46:40 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma04fra.de.ibm.com (PPS) with ESMTPS id 3n1k5ua049-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:40 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30CFkalO22937930 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 15:46:36 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CEF2F20040; Thu, 12 Jan 2023 15:46:36 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9836D20049; Thu, 12 Jan 2023 15:46:36 +0000 (GMT) Received: from a46lp67.. (unknown [9.152.108.100]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Jan 2023 15:46:36 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, david@redhat.com, nsg@linux.ibm.com, nrb@linux.ibm.com Subject: [kvm-unit-tests PATCH v2 5/7] lib: s390x: sie: Set guest memory pointer Date: Thu, 12 Jan 2023 15:45:46 +0000 Message-Id: <20230112154548.163021-6-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230112154548.163021-1-frankja@linux.ibm.com> References: <20230112154548.163021-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: CmwL4Qgd-SAS3J4q7Oa9ZqFW0PphM6VF X-Proofpoint-ORIG-GUID: bNRD-T39_5XUxn-qvYxUnpgoodiJAWQN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-12_08,2023-01-12_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120112 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 Thu Jan 12 15:45:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13098285 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 38BECC61DB3 for ; Thu, 12 Jan 2023 15:57:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234994AbjALP5e (ORCPT ); Thu, 12 Jan 2023 10:57:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240520AbjALP4c (ORCPT ); Thu, 12 Jan 2023 10:56:32 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0B8955A1; Thu, 12 Jan 2023 07:46:43 -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 30CFctKi011913; Thu, 12 Jan 2023 15:46:43 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=XdC8GH3ZK4EuK5OfGuPY1Po0QSkN915WuoNiyho0ydQ=; b=n0AGQyY7cTMB/6Sj+HfNL/3zFcEYKTKSs06F7Yc9L50Zl7rW8IDqvfkl1Ln6AE7P1ZEY i+BYVRXr1qZAqzaGx87D3WG6KpMdB9UJbms5VDLy7wU+vaW/oPDHJImev44XHM7wq5JK tCzSAAkp6RyXl5uTHyzsC/LVm0X821buVtuMmRl0Q5Xv+7PXZttdc9o9MS4uRTTrIvyQ OYW8D19CSd2WroaThA+rh4zpjPPLCl5n2pGEArOkJXGSM+xRUq/txfN0HWZB8w1d0WYY 9025AVIAUplkatHbcM6XMCPBqM3XcsOcUA92dWMs0v64xjGvuAy6rd1pRSmhvDXYphKW ew== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n2mb0hgq3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:43 +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 30CFeI9x018004; Thu, 12 Jan 2023 15:46:43 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n2mb0hgp9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:43 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30BMNev4032022; Thu, 12 Jan 2023 15:46:40 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma05fra.de.ibm.com (PPS) with ESMTPS id 3n1kuc1xx5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:40 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30CFkbTs44827094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 15:46:37 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1257320049; Thu, 12 Jan 2023 15:46:37 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D405B2004B; Thu, 12 Jan 2023 15:46:36 +0000 (GMT) Received: from a46lp67.. (unknown [9.152.108.100]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Jan 2023 15:46:36 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, david@redhat.com, nsg@linux.ibm.com, nrb@linux.ibm.com Subject: [kvm-unit-tests PATCH v2 6/7] s390x: Clear first stack frame and end backtrace early Date: Thu, 12 Jan 2023 15:45:47 +0000 Message-Id: <20230112154548.163021-7-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230112154548.163021-1-frankja@linux.ibm.com> References: <20230112154548.163021-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 0puERrryjr-kODmQk9r0OQ-HY47jFlwD X-Proofpoint-ORIG-GUID: _q5m8CFPSiikPheePQe1KaMUbiw_BB7r X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-12_08,2023-01-12_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 mlxscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120112 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 Thu Jan 12 15:45:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13098286 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 844F2C54EBC for ; Thu, 12 Jan 2023 15:57:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240459AbjALP5f (ORCPT ); Thu, 12 Jan 2023 10:57:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240526AbjALP4c (ORCPT ); Thu, 12 Jan 2023 10:56:32 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F7C75F4B; Thu, 12 Jan 2023 07:46:44 -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 30CFLMFe012826; Thu, 12 Jan 2023 15:46:44 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=Sc5Grvz0gdgxMpRz2VdSPRHowjEknw9fbE351yuzINv6D6jV369LM9EF9fPpwMmCUwQW NLMdBRmB0X3WxAxQRGk9R/pMxbJSlvFHRHskicYQv8bBWMAp+e4OyjYBifVq8y1KcjOr 8dCh4gcnRqPgZQfWPy+sjWPcH96R9pJjspiMuAlVb9H/Q6eC541pu/COf00KrSjDvB/C VCTDKZ3NfpfTBRXYwiyib6WE5pU8VOUBEO2Dy/MpF5UCPCWbOyNEEFSTvYuHeBskC2sb 59H00PwrIRU8tlD5yH3rBBM7QXpZ+r8eY7MOIhQBa4JEqd5jkU8ncWsXcDx6Q5Y43ucF dg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n2msc8p76-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:43 +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 30CFPhdJ027068; Thu, 12 Jan 2023 15:46:43 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 3n2msc8p6d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:43 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30CConSH030619; Thu, 12 Jan 2023 15:46:41 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3n1kyx9xsg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Jan 2023 15:46:41 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30CFkbe442467760 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jan 2023 15:46:37 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C33520040; Thu, 12 Jan 2023 15:46:37 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 155D22004D; Thu, 12 Jan 2023 15:46:37 +0000 (GMT) Received: from a46lp67.. (unknown [9.152.108.100]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 12 Jan 2023 15:46:37 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, david@redhat.com, nsg@linux.ibm.com, nrb@linux.ibm.com Subject: [kvm-unit-tests PATCH v2 7/7] lib: s390x: Handle debug prints for SIE exceptions correctly Date: Thu, 12 Jan 2023 15:45:48 +0000 Message-Id: <20230112154548.163021-8-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230112154548.163021-1-frankja@linux.ibm.com> References: <20230112154548.163021-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: DWvQysgobXtpz_0ix7TKqlobNXdsCNSN X-Proofpoint-GUID: -7KWSVHmAD8EZzbXERJBTgoHP9t0bmDc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-12_08,2023-01-12_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 bulkscore=0 malwarescore=0 impostorscore=0 mlxscore=0 mlxlogscore=931 spamscore=0 adultscore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301120112 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 Reviewed-by: Claudio Imbrenda --- 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