From patchwork Thu Feb 16 17:12:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13143535 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 EE55DC6379F for ; Thu, 16 Feb 2023 17:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbjBPRNJ (ORCPT ); Thu, 16 Feb 2023 12:13:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbjBPRNG (ORCPT ); Thu, 16 Feb 2023 12:13:06 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B8243346A for ; Thu, 16 Feb 2023 09:13:02 -0800 (PST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31GGMgJJ015010 for ; Thu, 16 Feb 2023 17:13:01 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 : content-transfer-encoding : mime-version; s=pp1; bh=ThE+300bTPfKcmB+pP5LjwjG/c5CnpJoo0ZOjQKtNxQ=; b=BhcuzRl+qOjUV0kuKkoS5w7RsJL4nB8z6tUhXsB6mVh21GCLPbTSLOVj2ltbH2w8vnkq 9OQ6ogGExupevLZlcn8VG+w1bFK+bc9+c9phln4sSSF34n/XZedKww4EDmfiGSbicheo A9rDzMZU3UkTZwt8t00qf5o1kJf9OOmFjAiewQcJT8UbYdeix2MftZcOMWaqE+ObGDnf VXnkY2MKAyjayjrade4CLdp2G88RxyVD/O91xLB6rYVF373Nmog61F54FqJMOLckjrMw yr/6uKqlH9ILXJCRYk1LUp/85zOSNKY36XhJ/3b/TYYv8w4N3ZVGobeJLjqlFEecwdIm Lg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nsqy3h7ew-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Feb 2023 17:13:01 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 31GGxeBN003257 for ; Thu, 16 Feb 2023 17:13:00 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nsqy3h7e0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:13:00 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31GFYara021570; Thu, 16 Feb 2023 17:12:58 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma02fra.de.ibm.com (PPS) with ESMTPS id 3np2n6n4wd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:12:58 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31GHCuDR47186422 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Feb 2023 17:12:56 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 25CBC2004B; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF8062005A; Thu, 16 Feb 2023 17:12:55 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.56]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 16 Feb 2023 17:12:55 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com, thuth@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com Subject: [kvm-unit-tests GIT PULL 01/10] lib: s390x: add PSW and PSW_WITH_CUR_MASK macros Date: Thu, 16 Feb 2023 18:12:46 +0100 Message-Id: <20230216171255.48799-2-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216171255.48799-1-imbrenda@linux.ibm.com> References: <20230216171255.48799-1-imbrenda@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 6aJo4LIF-fa53a85q37EnPCNv6wuHtIV X-Proofpoint-GUID: 831cpLj-RJDlSxGPHvA46NBITApG3eTb X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-16_13,2023-02-16_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 bulkscore=0 spamscore=0 malwarescore=0 phishscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 suspectscore=0 mlxlogscore=994 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302160148 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Since a lot of code starts new CPUs using the current PSW mask, add two macros to streamline the creation of generic PSWs and PSWs with the current program mask. Reviewed-by: Nico Boehr Reviewed-by: Janis Schoetterl-Glausch Reviewed-by: Janosch Frank Link: https://lore.kernel.org/r/20221130154038.70492-2-imbrenda@linux.ibm.com Signed-off-by: Claudio Imbrenda Message-Id: <20221130154038.70492-2-imbrenda@linux.ibm.com> --- lib/s390x/asm/arch_def.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h index 783a7eaa..bb26e008 100644 --- a/lib/s390x/asm/arch_def.h +++ b/lib/s390x/asm/arch_def.h @@ -41,6 +41,8 @@ struct psw { uint64_t addr; }; +#define PSW(m, a) ((struct psw){ .mask = (m), .addr = (uint64_t)(a) }) + struct short_psw { uint32_t mask; uint32_t addr; @@ -321,6 +323,8 @@ static inline uint64_t extract_psw_mask(void) return (uint64_t) mask_upper << 32 | mask_lower; } +#define PSW_WITH_CUR_MASK(addr) PSW(extract_psw_mask(), (addr)) + static inline void load_psw_mask(uint64_t mask) { struct psw psw = { From patchwork Thu Feb 16 17:12:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13143536 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 E5071C61DA4 for ; Thu, 16 Feb 2023 17:13:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229837AbjBPRNK (ORCPT ); Thu, 16 Feb 2023 12:13:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230057AbjBPRNH (ORCPT ); Thu, 16 Feb 2023 12:13:07 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54E6B4E5C9 for ; Thu, 16 Feb 2023 09:13:02 -0800 (PST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31GFsF4A006559 for ; Thu, 16 Feb 2023 17:13:02 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 : content-transfer-encoding : mime-version; s=pp1; bh=0VBSSY0G101+awYFx0IKgYPGzk8Au8tWPNol83K79AA=; b=SGjUHEZceFjHmRyHCQSpiOJpHD32ReLW/nkQZvgkwPHYQG0cxaH8PKH/eb5Oix3MVhKM 3/O7hpRsNRXzXVnecrPPBHlaUpNH+eRa3L9lAJsjw11zl/XgnKZs1C2/2J/V9au7W/a9 g5fqXEi8VfYC9hgVTb3MFL08sEwAFFGpDp9aQlvRxCTs8SmLdxJbbRsiQZtIa9yv/E0v NbAnsOnHvy18xHEtrb4tYT1Ngd97oDekYI2cKS9YuUJcKkTGHESvsoDzf5AxuAxVy6y6 tapRJFFaDWdZvkihsSPDURLGLI9wmQ0sLVgCNztnO7xNaI/rneegxw7cEdtK8Ayqbv8D VA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nsqhcj0b3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Feb 2023 17:13:01 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 31GH5rnU029334 for ; Thu, 16 Feb 2023 17:13:01 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 3nsqhcj0a1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:13:01 +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 31GH8pxG026199; Thu, 16 Feb 2023 17:12:58 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma06fra.de.ibm.com (PPS) with ESMTPS id 3np29fd52a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:12:58 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31GHCunT47186426 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Feb 2023 17:12:56 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 55A1D2004B; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2DF112004F; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.56]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com, thuth@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com Subject: [kvm-unit-tests GIT PULL 02/10] s390x: use the new PSW and PSW_WITH_CUR_MASK macros Date: Thu, 16 Feb 2023 18:12:47 +0100 Message-Id: <20230216171255.48799-3-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216171255.48799-1-imbrenda@linux.ibm.com> References: <20230216171255.48799-1-imbrenda@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 3ABlb468iMiDmgP5Z1C_Mt9IMkcUQYrN X-Proofpoint-ORIG-GUID: _eduWW3ZvfWbjlrsnmS4ykq3SPbGXL0V X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-16_13,2023-02-16_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 adultscore=0 clxscore=1015 suspectscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=981 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302160144 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Use the new macros in the existing code. No functional changes intended. Reviewed-by: Janis Schoetterl-Glausch Reviewed-by: Janosch Frank Link: https://lore.kernel.org/r/20221130154038.70492-3-imbrenda@linux.ibm.com Signed-off-by: Claudio Imbrenda Message-Id: <20221130154038.70492-3-imbrenda@linux.ibm.com> --- s390x/adtl-status.c | 24 ++++---------------- s390x/firq.c | 5 +---- s390x/migration.c | 6 +---- s390x/skrf.c | 7 +----- s390x/smp.c | 53 ++++++++++----------------------------------- s390x/uv-host.c | 5 +---- 6 files changed, 19 insertions(+), 81 deletions(-) diff --git a/s390x/adtl-status.c b/s390x/adtl-status.c index 9fb76319..2db650a1 100644 --- a/s390x/adtl-status.c +++ b/s390x/adtl-status.c @@ -205,16 +205,11 @@ static void restart_write_vector(void) static void cpu_write_magic_to_vector_regs(uint16_t cpu_idx) { - struct psw new_psw; - smp_cpu_stop(cpu_idx); - new_psw.mask = extract_psw_mask(); - new_psw.addr = (unsigned long)restart_write_vector; - set_flag(0); - smp_cpu_start(cpu_idx, new_psw); + smp_cpu_start(cpu_idx, PSW_WITH_CUR_MASK(restart_write_vector)); wait_for_flag(); } @@ -241,7 +236,6 @@ static int adtl_status_check_unmodified_fields_for_lc(unsigned long lc) static void __store_adtl_status_vector_lc(unsigned long lc) { uint32_t status = -1; - struct psw psw; int cc; report_prefix_pushf("LC %lu", lc); @@ -274,9 +268,7 @@ static void __store_adtl_status_vector_lc(unsigned long lc) * Destroy and re-initalize the CPU to fix that. */ smp_cpu_destroy(1); - psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)test_func; - smp_cpu_setup(1, psw); + smp_cpu_setup(1, PSW_WITH_CUR_MASK(test_func)); out: report_prefix_pop(); @@ -325,16 +317,11 @@ static void restart_write_gs_regs(void) static void cpu_write_to_gs_regs(uint16_t cpu_idx) { - struct psw new_psw; - smp_cpu_stop(cpu_idx); - new_psw.mask = extract_psw_mask(); - new_psw.addr = (unsigned long)restart_write_gs_regs; - set_flag(0); - smp_cpu_start(cpu_idx, new_psw); + smp_cpu_start(cpu_idx, PSW_WITH_CUR_MASK(restart_write_gs_regs)); wait_for_flag(); } @@ -382,7 +369,6 @@ out: int main(void) { - struct psw psw; report_prefix_push("adtl_status"); if (smp_query_num_cpus() == 1) { @@ -391,9 +377,7 @@ int main(void) } /* Setting up the cpu to give it a stack and lowcore */ - psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)test_func; - smp_cpu_setup(1, psw); + smp_cpu_setup(1, PSW_WITH_CUR_MASK(test_func)); smp_cpu_stop(1); test_store_adtl_status_unavail(); diff --git a/s390x/firq.c b/s390x/firq.c index b4b3542e..0d65d87f 100644 --- a/s390x/firq.c +++ b/s390x/firq.c @@ -33,7 +33,6 @@ static void wait_for_sclp_int(void) */ static void test_wait_state_delivery(void) { - struct psw psw; SCCBHeader *h; int ret; @@ -55,9 +54,7 @@ static void test_wait_state_delivery(void) sclp_mark_busy(); /* Start CPU #1 and let it wait for the interrupt. */ - psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)wait_for_sclp_int; - ret = smp_cpu_setup(1, psw); + ret = smp_cpu_setup(1, PSW_WITH_CUR_MASK(wait_for_sclp_int)); /* This must not fail because we have at least 3 CPUs */ assert(!ret); diff --git a/s390x/migration.c b/s390x/migration.c index fe6ea836..269e272d 100644 --- a/s390x/migration.c +++ b/s390x/migration.c @@ -159,8 +159,6 @@ static void test_func(void) int main(void) { - struct psw psw; - /* don't say migrate here otherwise we will migrate right away */ report_prefix_push("migration"); @@ -170,9 +168,7 @@ int main(void) } /* Second CPU does the actual tests */ - psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)test_func; - smp_cpu_setup(1, psw); + smp_cpu_setup(1, PSW_WITH_CUR_MASK(test_func)); /* wait for thread setup */ while(!flag_thread_complete) diff --git a/s390x/skrf.c b/s390x/skrf.c index 4cb563c3..e72a2b19 100644 --- a/s390x/skrf.c +++ b/s390x/skrf.c @@ -151,11 +151,6 @@ static void ecall_setup(void) static void test_exception_ext_new(void) { - struct psw psw = { - .mask = extract_psw_mask(), - .addr = (unsigned long)ecall_setup - }; - report_prefix_push("exception external new"); if (smp_query_num_cpus() < 2) { report_skip("Need second cpu for exception external new test."); @@ -163,7 +158,7 @@ static void test_exception_ext_new(void) return; } - smp_cpu_setup(1, psw); + smp_cpu_setup(1, PSW_WITH_CUR_MASK(ecall_setup)); wait_for_flag(); set_flag(0); diff --git a/s390x/smp.c b/s390x/smp.c index 91f3e3bc..2b03bf0c 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -101,12 +101,8 @@ static void test_func(void) static void test_start(void) { - struct psw psw; - psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)test_func; - set_flag(0); - smp_cpu_start(1, psw); + smp_cpu_start(1, PSW_WITH_CUR_MASK(test_func)); wait_for_flag(); report_pass("start"); } @@ -120,8 +116,7 @@ static void test_restart(void) report_prefix_push("restart"); report_prefix_push("stopped"); - lc->restart_new_psw.mask = extract_psw_mask(); - lc->restart_new_psw.addr = (unsigned long)test_func; + lc->restart_new_psw = PSW_WITH_CUR_MASK(test_func); /* Make sure cpu is stopped */ smp_cpu_stop(1); @@ -256,7 +251,6 @@ static void test_set_prefix(void) struct lowcore *new_lc = alloc_pages_flags(1, AREA_DMA31); struct cpu *cpu1 = smp_cpu_from_idx(1); uint32_t status = 0; - struct psw new_psw; int cc; report_prefix_push("set prefix"); @@ -268,9 +262,7 @@ static void test_set_prefix(void) report_prefix_push("running"); set_flag(0); - new_psw.addr = (unsigned long)stpx_and_set_flag; - new_psw.mask = extract_psw_mask(); - smp_cpu_start(1, new_psw); + smp_cpu_start(1, PSW_WITH_CUR_MASK(stpx_and_set_flag)); wait_for_flag(); cpu1_prefix = 0xFFFFFFFF; @@ -326,7 +318,6 @@ static void call_received(void) static void test_calls(void) { int i; - struct psw psw; for (i = 0; i < ARRAY_SIZE(cases_sigp_call); i++) { current_sigp_call_case = &cases_sigp_call[i]; @@ -339,9 +330,7 @@ static void test_calls(void) } set_flag(0); - psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)call_received; - smp_cpu_start(1, psw); + smp_cpu_start(1, PSW_WITH_CUR_MASK(call_received)); /* Wait until the receiver has finished setup */ wait_for_flag(); @@ -389,7 +378,6 @@ static void call_in_wait_cleanup(void) static void test_calls_in_wait(void) { int i; - struct psw psw; report_prefix_push("psw wait"); for (i = 0; i < ARRAY_SIZE(cases_sigp_call); i++) { @@ -404,9 +392,7 @@ static void test_calls_in_wait(void) /* Let the secondary CPU setup the external mask and the external interrupt cleanup function */ set_flag(0); - psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)call_in_wait_setup; - smp_cpu_start(1, psw); + smp_cpu_start(1, PSW_WITH_CUR_MASK(call_in_wait_setup)); /* Wait until the receiver has finished setup */ wait_for_flag(); @@ -422,9 +408,7 @@ static void test_calls_in_wait(void) * wait until the CPU becomes operating (done by smp_cpu_start). */ smp_cpu_stop(1); - psw.mask = extract_psw_mask() | PSW_MASK_EXT | PSW_MASK_WAIT; - psw.addr = (unsigned long)call_in_wait_received; - smp_cpu_start(1, psw); + smp_cpu_start(1, PSW(extract_psw_mask() | PSW_MASK_EXT | PSW_MASK_WAIT, call_in_wait_received)); smp_sigp(1, current_sigp_call_case->call, 0, NULL); @@ -439,9 +423,7 @@ static void test_calls_in_wait(void) * to catch an interrupt that is presented twice since we would * disable the external call on the first interrupt. */ - psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)call_in_wait_cleanup; - smp_cpu_start(1, psw); + smp_cpu_start(1, PSW_WITH_CUR_MASK(call_in_wait_cleanup)); /* Wait until the cleanup has been completed */ wait_for_flag(); @@ -478,15 +460,11 @@ static void test_func_initial(void) static void test_reset_initial(void) { struct cpu_status *status = alloc_pages_flags(0, AREA_DMA31); - struct psw psw; int i; - psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)test_func_initial; - report_prefix_push("reset initial"); set_flag(0); - smp_cpu_start(1, psw); + smp_cpu_start(1, PSW_WITH_CUR_MASK(test_func_initial)); wait_for_flag(); smp_sigp(1, SIGP_INITIAL_CPU_RESET, 0, NULL); @@ -525,22 +503,16 @@ static void test_local_ints(void) static void test_reset(void) { - struct psw psw; - - psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)test_func; - report_prefix_push("cpu reset"); smp_sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL); smp_sigp(1, SIGP_EXTERNAL_CALL, 0, NULL); - smp_cpu_start(1, psw); + smp_cpu_start(1, PSW_WITH_CUR_MASK(test_func)); smp_sigp(1, SIGP_CPU_RESET, 0, NULL); report(smp_cpu_stopped(1), "cpu stopped"); set_flag(0); - psw.addr = (unsigned long)test_local_ints; - smp_cpu_start(1, psw); + smp_cpu_start(1, PSW_WITH_CUR_MASK(test_local_ints)); wait_for_flag(); report_pass("local interrupts cleared"); report_prefix_pop(); @@ -548,7 +520,6 @@ static void test_reset(void) int main(void) { - struct psw psw; report_prefix_push("smp"); if (smp_query_num_cpus() == 1) { @@ -557,9 +528,7 @@ int main(void) } /* Setting up the cpu to give it a stack and lowcore */ - psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)test_func; - smp_cpu_setup(1, psw); + smp_cpu_setup(1, PSW_WITH_CUR_MASK(test_func)); smp_cpu_stop(1); test_start(); diff --git a/s390x/uv-host.c b/s390x/uv-host.c index 9f09f80e..33e6eec6 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -501,7 +501,6 @@ static void test_init(void) { int rc; uint64_t mem; - struct psw psw; /* Donated storage needs to be over 2GB */ mem = (uint64_t)memalign_pages_flags(SZ_1M, uvcb_qui.uv_base_stor_len, AREA_NORMAL); @@ -547,9 +546,7 @@ static void test_init(void) "storage below 2GB"); uvcb_init.stor_origin = mem; - psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)cpu_loop; - smp_cpu_setup(1, psw); + smp_cpu_setup(1, PSW_WITH_CUR_MASK(cpu_loop)); rc = uv_call(0, (uint64_t)&uvcb_init); report(rc == 1 && uvcb_init.header.rc == 0x102, "too many running cpus"); From patchwork Thu Feb 16 17:12:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13143541 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 D7E25C61DA4 for ; Thu, 16 Feb 2023 17:13:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbjBPRNR (ORCPT ); Thu, 16 Feb 2023 12:13:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230064AbjBPRNK (ORCPT ); Thu, 16 Feb 2023 12:13:10 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 826294E5D2 for ; Thu, 16 Feb 2023 09:13:03 -0800 (PST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31GGfieo025176 for ; Thu, 16 Feb 2023 17:13:03 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 : content-transfer-encoding : mime-version; s=pp1; bh=Ej0Jfz7BUe3iF+jeMfhb6h0eJuJ9WIwT8Nd7of0qhG4=; b=DsUBAcMUKM3mpPMr+XEaNBHDW8HfeFxRNTnsu7HuYMS8bfal31V1QtUo+KPrJzh3802B u8kEftZT2k5LwcU7p7AjuKghveAoolIKn0C5KwbqVtfCiKW2vOcOownfEnCcHm9pckx2 ymJhGE4OuKmznrhLB72xVuflZiLn6ttPQKlNqU5lMTfp67+o7rXuiBhxCIeFsQvibAL8 U3X5s/DVHaxBScR2y/d7HbEHYJpvv5spEGH87SOhnrbkjyOro+xCRK/0BLRpc7t1Qlb+ RT9F7Hq5gV/e99vfC0hFkHgFQea2TlewPA9pl3nBGfNw2+EwUMBJRceDIg9dfPKrYjxd NQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nsr7tgsde-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Feb 2023 17:13:02 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 31GHB4Fm014252 for ; Thu, 16 Feb 2023 17:13:02 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 3nsr7tgscf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:13:02 +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 31G12mxx007609; Thu, 16 Feb 2023 17:13:00 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma04fra.de.ibm.com (PPS) with ESMTPS id 3np2n6d58b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:12:59 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31GHCu3N47186430 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Feb 2023 17:12:56 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 85C052004B; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5DD492005A; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.56]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com, thuth@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com Subject: [kvm-unit-tests GIT PULL 03/10] s390x: add parallel skey migration test Date: Thu, 16 Feb 2023 18:12:48 +0100 Message-Id: <20230216171255.48799-4-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216171255.48799-1-imbrenda@linux.ibm.com> References: <20230216171255.48799-1-imbrenda@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: lJIujtQbb2H3jVfqHlIeyGuhWqkFVKsb X-Proofpoint-GUID: CN5bsoY6q5fUcqmyIZvO7X9ZRUsix-I1 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-16_13,2023-02-16_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 mlxscore=0 spamscore=0 priorityscore=1501 phishscore=0 adultscore=0 clxscore=1015 bulkscore=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302160148 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr Right now, we have a test which sets storage keys, then migrates the VM and - after migration finished - verifies the skeys are still there. Add a new version of the test which changes storage keys while the migration is in progress. This is achieved by adding a command line argument to the existing migration-skey test. Signed-off-by: Nico Boehr Reviewed-by: Nina Schoetterl-Glausch Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20221220083030.30153-2-nrb@linux.ibm.com Message-Id: <20221220083030.30153-2-nrb@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- s390x/migration-skey.c | 218 +++++++++++++++++++++++++++++++++++++---- s390x/unittests.cfg | 15 ++- 2 files changed, 210 insertions(+), 23 deletions(-) diff --git a/s390x/migration-skey.c b/s390x/migration-skey.c index a91eb6b5..8d6d8ecf 100644 --- a/s390x/migration-skey.c +++ b/s390x/migration-skey.c @@ -2,6 +2,12 @@ /* * Storage Key migration tests * + * There are two variants of this test: + * - sequential: set storage keys on some pages, migrates the VM and then + * verifies that the storage keys are still as we expect. + * - parallel: start migration and set and check storage keys on some + * pages while migration is in process. + * * Copyright IBM Corp. 2022 * * Authors: @@ -13,16 +19,45 @@ #include #include #include -#include +#include #include +#include + +struct verify_result { + bool verify_failed; + union skey expected_key; + union skey actual_key; + unsigned long page_mismatch_idx; + unsigned long page_mismatch_addr; +}; #define NUM_PAGES 128 -static uint8_t pagebuf[NUM_PAGES][PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); +static uint8_t pagebuf[NUM_PAGES * PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); + +static struct verify_result result; + +static unsigned int thread_iters; +static bool thread_should_exit; +static bool thread_exited; + +static enum { + TEST_INVALID, + TEST_SEQUENTIAL, + TEST_PARALLEL +} arg_test_to_run; -static void test_migration(void) +/* + * Set storage key test pattern on pagebuf with a seed for the storage keys. + * + * Each page's storage key is generated by taking the page's index in pagebuf, + * XOR-ing that with the given seed and then multipling the result with two. + * + * Only the lower seven bits of the seed are considered. + */ +static void set_test_pattern(unsigned char seed) { - union skey expected_key, actual_key; - int i, key_to_set, key_mismatches = 0; + unsigned char key_to_set; + unsigned long i; for (i = 0; i < NUM_PAGES; i++) { /* @@ -32,15 +67,34 @@ static void test_migration(void) * protection as well as reference and change indication for * some keys. */ - key_to_set = i * 2; - set_storage_key(pagebuf[i], key_to_set, 1); + key_to_set = (i ^ seed) * 2; + set_storage_key(pagebuf + i * PAGE_SIZE, key_to_set, 1); } +} - migrate_once(); +/* + * Verify storage keys on pagebuf. + * Storage keys must have been set by set_test_pattern on pagebuf before. + * set_test_pattern must have been called with the same seed value. + * + * If storage keys match the expected result, will return a verify_result + * with verify_failed false. All other fields are then invalid. + * If there is a mismatch, returned struct will have verify_failed true and will + * be filled with the details on the first mismatch encountered. + */ +static struct verify_result verify_test_pattern(unsigned char seed) +{ + union skey expected_key, actual_key; + struct verify_result result = { + .verify_failed = true + }; + uint8_t *cur_page; + unsigned long i; for (i = 0; i < NUM_PAGES; i++) { - actual_key.val = get_storage_key(pagebuf[i]); - expected_key.val = i * 2; + cur_page = pagebuf + i * PAGE_SIZE; + actual_key.val = get_storage_key(cur_page); + expected_key.val = (i ^ seed) * 2; /* * The PoP neither gives a guarantee that the reference bit is @@ -51,27 +105,153 @@ static void test_migration(void) actual_key.str.rf = 0; expected_key.str.rf = 0; - /* don't log anything when key matches to avoid spamming the log */ if (actual_key.val != expected_key.val) { - key_mismatches++; - report_fail("page %d expected_key=0x%x actual_key=0x%x", i, expected_key.val, actual_key.val); + result.expected_key.val = expected_key.val; + result.actual_key.val = actual_key.val; + result.page_mismatch_idx = i; + result.page_mismatch_addr = (unsigned long)cur_page; + return result; } } - report(!key_mismatches, "skeys after migration match"); + result.verify_failed = false; + return result; +} + +static void report_verify_result(const struct verify_result * result) +{ + if (result->verify_failed) + report_fail("page skey mismatch: first page idx = %lu, addr = 0x%lx, " + "expected_key = 0x%02x, actual_key = 0x%02x", + result->page_mismatch_idx, result->page_mismatch_addr, + result->expected_key.val, result->actual_key.val); + else + report_pass("skeys match"); +} + +static void test_skey_migration_sequential(void) +{ + report_prefix_push("sequential"); + + set_test_pattern(0); + + migrate_once(); + + result = verify_test_pattern(0); + report_verify_result(&result); + + report_prefix_pop(); +} + +static void set_skeys_thread(void) +{ + while (!READ_ONCE(thread_should_exit)) { + set_test_pattern(thread_iters); + + result = verify_test_pattern(thread_iters); + + /* + * Always increment even if the verify fails. This ensures primary CPU knows where + * we left off and can do an additional verify round after migration finished. + */ + thread_iters++; + + if (result.verify_failed) + break; + } + + WRITE_ONCE(thread_exited, 1); +} + +static void test_skey_migration_parallel(void) +{ + report_prefix_push("parallel"); + + if (smp_query_num_cpus() == 1) { + report_skip("need at least 2 cpus for this test"); + goto error; + } + + smp_cpu_setup(1, PSW_WITH_CUR_MASK(set_skeys_thread)); + + migrate_once(); + + WRITE_ONCE(thread_should_exit, 1); + + while (!READ_ONCE(thread_exited)) + ; + + /* Ensure we read result and thread_iters below from memory after thread exited */ + mb(); + report_info("thread completed %u iterations", thread_iters); + + report_prefix_push("during migration"); + report_verify_result(&result); + report_prefix_pop(); + + /* + * Verification of skeys occurs on the thread. We don't know if we + * were still migrating during the verification. + * To be sure, make another verification round after the migration + * finished to catch skeys which might not have been migrated + * correctly. + */ + report_prefix_push("after migration"); + assert(thread_iters > 0); + result = verify_test_pattern(thread_iters - 1); + report_verify_result(&result); + report_prefix_pop(); + +error: + report_prefix_pop(); +} + +static void print_usage(void) +{ + report_info("Usage: migration-skey [--parallel|--sequential]"); +} + +static void parse_args(int argc, char **argv) +{ + if (argc < 2) { + /* default to sequential since it only needs one cpu */ + arg_test_to_run = TEST_SEQUENTIAL; + return; + } + + if (!strcmp("--parallel", argv[1])) + arg_test_to_run = TEST_PARALLEL; + else if (!strcmp("--sequential", argv[1])) + arg_test_to_run = TEST_SEQUENTIAL; + else + arg_test_to_run = TEST_INVALID; } -int main(void) +int main(int argc, char **argv) { report_prefix_push("migration-skey"); - if (test_facility(169)) + if (test_facility(169)) { report_skip("storage key removal facility is active"); - else - test_migration(); + goto error; + } - migrate_once(); + parse_args(argc, argv); + + switch (arg_test_to_run) { + case TEST_SEQUENTIAL: + test_skey_migration_sequential(); + break; + case TEST_PARALLEL: + test_skey_migration_parallel(); + break; + default: + print_usage(); + break; + } +error: + migrate_once(); report_prefix_pop(); return report_summary(); } diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 3caf81ed..d97eb5e9 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -185,10 +185,6 @@ smp = 2 file = migration-cmm.elf groups = migration -[migration-skey] -file = migration-skey.elf -groups = migration - [panic-loop-extint] file = panic-loop-extint.elf groups = panic @@ -208,3 +204,14 @@ groups = migration [exittime] file = exittime.elf smp = 2 + +[migration-skey-sequential] +file = migration-skey.elf +groups = migration +extra_params = -append '--sequential' + +[migration-skey-parallel] +file = migration-skey.elf +smp = 2 +groups = migration +extra_params = -append '--parallel' From patchwork Thu Feb 16 17:12:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13143534 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 94214C636CC for ; Thu, 16 Feb 2023 17:13:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230062AbjBPRNI (ORCPT ); Thu, 16 Feb 2023 12:13:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229797AbjBPRNF (ORCPT ); Thu, 16 Feb 2023 12:13:05 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D82E4E5CB for ; Thu, 16 Feb 2023 09:13:02 -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 31GG0vQ5023047 for ; Thu, 16 Feb 2023 17:13:01 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 : content-transfer-encoding : mime-version; s=pp1; bh=VgEA9dGL7D0WG4z8GE/Svbcfd8eeeWIXv8ToWW8F6mc=; b=suHXYhu1qwUziFqNCBvmSw87MDQNQrEunm3RPGU7fEPyrCqMTA1DGXfYYbmegosOUQGj VFMwoibq/wFjawhFrkZbwygDLagwoI5bIXHRFY1bzNbhHGM1lmNixEq80mSjqmoLc1u1 mPhc3O2dxAtzjDZ3Njo6fm7zT+QKlhSdad8C0GYLV8wipXDc+98QdNaqDEEQ+epJ/Qcy RQJwarys4Id6ua135JN4vaHMmTkA6CdLupghzaiwSrMeNDHWrbFl1iufjW9FhvfBQNRq soT1yUJ34zlxE3tKbIve+P2/ST7opM42RC5ldK4iV7kYskMfWkWSorqCYrGa9CB5V0Ti Nw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nsnmf5mba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Feb 2023 17:13:01 +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 31GGdD4P034025 for ; Thu, 16 Feb 2023 17:13:00 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 3nsnmf5maj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:13:00 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31G5KK27010698; Thu, 16 Feb 2023 17:12:59 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3np2n6xyn6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:12:58 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31GHCu7x47186176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Feb 2023 17:12:56 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE35820063; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8DE282004F; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.56]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com, thuth@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com Subject: [kvm-unit-tests GIT PULL 04/10] s390x: Cleanup flat.lds Date: Thu, 16 Feb 2023 18:12:49 +0100 Message-Id: <20230216171255.48799-5-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216171255.48799-1-imbrenda@linux.ibm.com> References: <20230216171255.48799-1-imbrenda@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: arFJiKNeDo2jjnPacXssYKXdaF5zyl7F X-Proofpoint-ORIG-GUID: wTaQsJJ1RId_HXDgXqVqn3VeYS56_h5e X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-16_12,2023-02-16_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 adultscore=0 suspectscore=0 bulkscore=0 impostorscore=0 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302160144 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank 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 Link: https://lore.kernel.org/r/20230112154548.163021-2-frankja@linux.ibm.com Message-Id: <20230112154548.163021-2-frankja@linux.ibm.com> --- 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 Feb 16 17:12:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13143533 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 DA703C636D7 for ; Thu, 16 Feb 2023 17:13:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230056AbjBPRNH (ORCPT ); Thu, 16 Feb 2023 12:13:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjBPRNF (ORCPT ); Thu, 16 Feb 2023 12:13:05 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70F1D4E5CC for ; Thu, 16 Feb 2023 09:13:02 -0800 (PST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31GGfg3C025129 for ; Thu, 16 Feb 2023 17:13:02 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 : content-transfer-encoding : mime-version; s=pp1; bh=PfJD8uNVWHyySio+b+MYaXlGRKlFmIIrsUdNruxhpc4=; b=nNhQFLx7JfKVmR9S2qQ8rxt3O+PWKlTxMwV/ysJhxuSe/EvEwlmVwpdtU4eS4g4PgAJ0 e212bilTQpQsLzeNwWUfwksctsH8HN9UF2TO7tp+caxwh3RO18bFkvj1i8bV9t4IRmyX qHO7vpnDur7C49OLL3yTp/xAId6xq3cZC8ofwCZbsWS4DGisunZgrz62wuHN7l+whgpB YLjIxTTm2+LCRZfMY4mD87SQhLeSf6cLtMgTDmzxwNd6bPIBZ7lNizPT5oKurcJSok3s Pe3X2cIyff++/RV91jYYMmbUa++IWEidFD+wo/5Kd5jHof75zjQ0chWhUmX4MAh247+w WQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nsr7tgsd2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Feb 2023 17:13:02 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 31GH0WaZ031655 for ; Thu, 16 Feb 2023 17:13:01 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 3nsr7tgsc4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:13:01 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31G63IWW010953; Thu, 16 Feb 2023 17:12:59 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3np2n6xyn7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:12:59 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31GHCuWn46596466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Feb 2023 17:12:57 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD6AC2004F; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B62AD2004B; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.56]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com, thuth@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com Subject: [kvm-unit-tests GIT PULL 05/10] s390x: snippets: c: Cleanup flat.lds Date: Thu, 16 Feb 2023 18:12:50 +0100 Message-Id: <20230216171255.48799-6-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216171255.48799-1-imbrenda@linux.ibm.com> References: <20230216171255.48799-1-imbrenda@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: pFOCw9mtiC_5Rwi8og3sgWx1DYt6MoEt X-Proofpoint-GUID: zR5JAlRQ9uDpTJrjR8PZ_eN9DCQICDzg X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-16_13,2023-02-16_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 mlxscore=0 spamscore=0 priorityscore=1501 phishscore=0 adultscore=0 clxscore=1015 bulkscore=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=832 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302160148 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank 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 Link: https://lore.kernel.org/r/20230112154548.163021-3-frankja@linux.ibm.com Message-Id: <20230112154548.163021-3-frankja@linux.ibm.com> --- 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 Feb 16 17:12:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13143540 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 C1602C636CC for ; Thu, 16 Feb 2023 17:13:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbjBPRNP (ORCPT ); Thu, 16 Feb 2023 12:13:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230063AbjBPRNI (ORCPT ); Thu, 16 Feb 2023 12:13:08 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 205404DBC6 for ; Thu, 16 Feb 2023 09:13:03 -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 31GF7Wms018251 for ; Thu, 16 Feb 2023 17:13:02 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 : content-transfer-encoding : mime-version; s=pp1; bh=UsECbBINLFm3SYoui4Vn+V9IJmGiYdftnYC04XiJu8E=; b=bQRCKTSXfJbzRYYMdv+iHcahOk+7+QmQDNw278iEKvtTHnfWBXP36uJtc1uYX65Q6IuA rkh8R619gFXQRbMQwGlidzYYiQR7TWrMGZWI1q3duxdc/iHO/cGOCLxbYY4+hPndIp0x MLUpedlZR7AcgxWGhKEYVr3mI7GZ87BeXGLHRH4cPq3m1HLHVXCe6858KFhY5w33Pg6n UpfffXkXeov38BSsxD4YTrgLI5D2wCxXvgp94xE2t6rLo1XVAJy3BtN90DYF5zUgtDZe GIaJ3DZQoKclhvNQcajY5f3hBBQEwAWM8Exl931n+4M9n6z1zeGo790fY7CpbOFVtJRV Hw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nskd8s383-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Feb 2023 17:13:02 +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 31GFeAc1017757 for ; Thu, 16 Feb 2023 17:13:02 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 3nskd8s379-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:13:02 +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 31G1akpO009865; Thu, 16 Feb 2023 17:12:59 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3np2n6d4g0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:12:59 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31GHCvW033489310 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Feb 2023 17:12:57 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B6842004B; Thu, 16 Feb 2023 17:12:57 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DEF4F2005A; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.56]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 16 Feb 2023 17:12:56 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com, thuth@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com Subject: [kvm-unit-tests GIT PULL 06/10] s390x: Add a linker script to assembly snippets Date: Thu, 16 Feb 2023 18:12:51 +0100 Message-Id: <20230216171255.48799-7-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216171255.48799-1-imbrenda@linux.ibm.com> References: <20230216171255.48799-1-imbrenda@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: mB8jasOTZ6QxcGlLWU88P9lmB00t-8i_ X-Proofpoint-ORIG-GUID: kVgQrlFI-SgAOGQYLUu_GjXsjZ7ILDrx X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-16_13,2023-02-16_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 bulkscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302160148 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank 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 Link: https://lore.kernel.org/r/20230112154548.163021-4-frankja@linux.ibm.com Message-Id: <20230112154548.163021-4-frankja@linux.ibm.com> --- s390x/Makefile | 5 +++-- lib/s390x/snippet.h | 3 +-- s390x/snippets/asm/flat.lds | 41 +++++++++++++++++++++++++++++++++++++ s390x/mvpg-sie.c | 2 +- s390x/pv-diags.c | 6 +++--- 5 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 s390x/snippets/asm/flat.lds 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/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/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 */ +} 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"); From patchwork Thu Feb 16 17:12:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13143537 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 BE181C636D7 for ; Thu, 16 Feb 2023 17:13:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230057AbjBPRNL (ORCPT ); Thu, 16 Feb 2023 12:13:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230058AbjBPRNH (ORCPT ); Thu, 16 Feb 2023 12:13:07 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B352A4E5CD for ; Thu, 16 Feb 2023 09:13:02 -0800 (PST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31GFs7da006450 for ; Thu, 16 Feb 2023 17:13:02 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 : content-transfer-encoding : mime-version; s=pp1; bh=PaWAWM9+fPR8oze7+bBM2ZXMLR/yf7n9sRB1PEVsfA0=; b=mMWTvE73xe2jzzOriYm5OaszBKzsweyFrvMswmDi8iJFTQKX1EI4evdCKQtxidnwcjhF z4Fo2DJOu4nsfwe1mMLuiDvFOJsp2aTxO7CWBr7RKoKb+S7LvmTKcqFrBidQ8SVz5i46 3bly5nDvmQCLw3ck6bIR4eIBZFaMJFdGhnbNNmPC7ipowQIYFScPbMfAIi9bK5+tcsfj SgjWg1ROUejjPrk9A3OFFlMbr0C07j55/+RT5Gdo7zfKNmxAdwC+1rrXULUN5YosSxJw gYD032OEAdMop0lxWjQhtQ+Pzd7kWDJgm2Am87zRdb/XF1TKZ9McGliAYbFdyue5vSI8 SQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nsqhcj0b8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Feb 2023 17:13:02 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 31GH5kuX028462 for ; Thu, 16 Feb 2023 17:13:02 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 3nsqhcj0ad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:13:01 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31G4JYON010684; Thu, 16 Feb 2023 17:12:59 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3np2n6xyn8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:12:59 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31GHCvY735651844 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Feb 2023 17:12:57 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 336CC2005A; Thu, 16 Feb 2023 17:12:57 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 134B52004D; Thu, 16 Feb 2023 17:12:57 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.56]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 16 Feb 2023 17:12:57 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com, thuth@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com Subject: [kvm-unit-tests GIT PULL 07/10] s390x: snippets: Fix SET_PSW_NEW_ADDR macro Date: Thu, 16 Feb 2023 18:12:52 +0100 Message-Id: <20230216171255.48799-8-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216171255.48799-1-imbrenda@linux.ibm.com> References: <20230216171255.48799-1-imbrenda@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: qiJuXlLIZi8Rb284vTB7DudviYqVrCPO X-Proofpoint-ORIG-GUID: EHfleHA5Z4xG-JgfWCP8m8rEw05Ask1u X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-16_13,2023-02-16_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 adultscore=0 clxscore=1015 suspectscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=934 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302160144 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank 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 Link: https://lore.kernel.org/r/20230112154548.163021-5-frankja@linux.ibm.com Message-Id: <20230112154548.163021-5-frankja@linux.ibm.com> --- 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 Feb 16 17:12:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13143539 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 70C74C61DA4 for ; Thu, 16 Feb 2023 17:13:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229739AbjBPRNO (ORCPT ); Thu, 16 Feb 2023 12:13:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjBPRNH (ORCPT ); Thu, 16 Feb 2023 12:13:07 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36BA24E5CE for ; Thu, 16 Feb 2023 09:13:03 -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 31GF7WJ1018237 for ; Thu, 16 Feb 2023 17:13:03 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 : content-transfer-encoding : mime-version; s=pp1; bh=QpTHR2ZOWZwdlMf0y7OHKOAR6pZArI1zA+1S5YDI9YU=; b=Js/ddu5+gB3c8gptH4Dx4m3S8UTzD/9md3TQEVSc3lvgtm1auXBsWXx7yr7B5+JP7Q/j L4mYPEcErj84/+ppTyfCPQs0hxtCDpcciMIR16vk+6DWiEzzvLZ1/1iZgfa5NbBt0Yf5 Lzy9bAEC0jwRo72heZ08dFcCyCkBJh1MUdx4ZJFGPkLMWu9Jjm7j5eKN2yFjvpuXjT6N IaPhA5NVfeCH3HekLwClxIGyhGoqjDa0YjXwHLXBIjwgp6or+hPQWVZNzhEATje3Zcia +Xc7xqyGUaCjhQaSFxO13AYqFLNJO0YbNLzwS3K+0CR7quOy57XLi296wQYsyZIlsVjz VQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nskd8s386-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Feb 2023 17:13:02 +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 31GF7YQ5018368 for ; Thu, 16 Feb 2023 17:13:02 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 3nskd8s37f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:13:02 +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 31G0ujpA022275; Thu, 16 Feb 2023 17:13:00 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma06fra.de.ibm.com (PPS) with ESMTPS id 3np29fd52b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:12:59 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31GHCvBU35651846 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Feb 2023 17:12:57 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6E88520043; Thu, 16 Feb 2023 17:12:57 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 44DE12004B; Thu, 16 Feb 2023 17:12:57 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.56]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 16 Feb 2023 17:12:57 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com, thuth@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com Subject: [kvm-unit-tests GIT PULL 08/10] lib: s390x: sie: Set guest memory pointer Date: Thu, 16 Feb 2023 18:12:53 +0100 Message-Id: <20230216171255.48799-9-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216171255.48799-1-imbrenda@linux.ibm.com> References: <20230216171255.48799-1-imbrenda@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 4LeZM5PP1FpIWyVTPEyFaRAXLiKorwhF X-Proofpoint-ORIG-GUID: sL71eJcqb0M2favuxRF6N9S9MQs4XWuo X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-16_13,2023-02-16_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 bulkscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302160148 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank 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 Link: https://lore.kernel.org/r/20230112154548.163021-6-frankja@linux.ibm.com Message-Id: <20230112154548.163021-6-frankja@linux.ibm.com> --- 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 Feb 16 17:12:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13143538 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 2AD83C6379F for ; Thu, 16 Feb 2023 17:13:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230079AbjBPRNN (ORCPT ); Thu, 16 Feb 2023 12:13:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230059AbjBPRNH (ORCPT ); Thu, 16 Feb 2023 12:13:07 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EE674E5CF for ; Thu, 16 Feb 2023 09:13:03 -0800 (PST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31GGMfde014952 for ; Thu, 16 Feb 2023 17:13:02 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 : content-transfer-encoding : mime-version; s=pp1; bh=fLzBHvB5ua71RNOfYeCXVebfugEMhF3red/bgamVwqI=; b=qMRfCzpzpMuLbsc9y7Aiy7ZHnJaleqOQ9BQ8a54Ggp8nC2y9hIRSokYys6qXR1oR88f2 Vo9GbFEFw9AohCa5e1tpWftQAJVF8uDHhWsIrzhFrDPmAFSt9z5+B0vUdOKkyn/xB4me JbedIBqxJC8x9jGrQC0uUUXMvyLFp7SsrUTKgcHIvtaAUULjldFNuXLiUNYouF11Wf76 7kqgSdJuDyhRunfBQHhMUdz7NWRWBxAIuwhR4wd8lALT/A75n/QxQkcRG718hBLSUBgc p7Ll/2Njvwi3U/3laWoEnnABuK6psFx4HatUd9r1z0z6rn1cY/une5PPuRXnnpA1Iul4 /g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nsqy3h7fd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Feb 2023 17:13:02 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 31GH8GRb009974 for ; Thu, 16 Feb 2023 17:13:01 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3nsqy3h7eq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:13:01 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31G62oRM010856; Thu, 16 Feb 2023 17:13:00 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3np2n6xyn9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:13:00 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31GHCvnH33489320 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Feb 2023 17:12:57 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 98C4D20043; Thu, 16 Feb 2023 17:12:57 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 75F422004D; Thu, 16 Feb 2023 17:12:57 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.56]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 16 Feb 2023 17:12:57 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com, thuth@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com Subject: [kvm-unit-tests GIT PULL 09/10] s390x: Clear first stack frame and end backtrace early Date: Thu, 16 Feb 2023 18:12:54 +0100 Message-Id: <20230216171255.48799-10-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216171255.48799-1-imbrenda@linux.ibm.com> References: <20230216171255.48799-1-imbrenda@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 3pbghYxW3nWmZuxEEX1OMv85Wu4G9_k1 X-Proofpoint-GUID: zMgKor-uAAw3QFUtz2F_5cPwPTPBSc6S X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-16_13,2023-02-16_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 bulkscore=0 spamscore=0 malwarescore=0 phishscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 suspectscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302160148 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank 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 Link: https://lore.kernel.org/r/20230112154548.163021-7-frankja@linux.ibm.com Message-Id: <20230112154548.163021-7-frankja@linux.ibm.com> --- 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 Feb 16 17:12:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13143542 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 A95FDC636D7 for ; Thu, 16 Feb 2023 17:13:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230086AbjBPRNT (ORCPT ); Thu, 16 Feb 2023 12:13:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbjBPRNK (ORCPT ); Thu, 16 Feb 2023 12:13:10 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72AE54E5D0 for ; Thu, 16 Feb 2023 09:13:03 -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 31GFeSqR039316 for ; Thu, 16 Feb 2023 17:13:02 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 : content-transfer-encoding : mime-version; s=pp1; bh=+NOHX9kxPBkS46JGBV24HYfE0JBykDiVnrigNd2Ipxg=; b=KjstL9SzH+FXI6wX6jhThUM8belh2gNwgrdrUYEHTNAx3mYR1z8KM2d8zYf648DAwjlJ RKplRGxBG4kNWwz8WkrVW6zeSM7w0vyrTCifVO5cJPvvxNycRVCLFhCeNCGb0LMocpcM TjRWHKBKiwe0JCLKai9tmixQappJAHRh4U7jp/OLt4/qoES/HL3aqndjH64y+767+Uwz zmcYtwG0O+prr9bmRgph/o7gOAkowlqMKhfocs1C2aLb1Fbv9ZiliqpUVMPLY+ly+V5n CN/7X22Q1QpaV5/C2U32SBGTbhwImDqrjdvqFhzY5NsrPS5rwdAxG7k1v/9t9cWmMitF QQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3nsnmf5mbx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Feb 2023 17:13:02 +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 31GGfnL6000705 for ; Thu, 16 Feb 2023 17:13:02 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 3nsnmf5mb6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:13:01 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 31G4YDH6029819; Thu, 16 Feb 2023 17:13:00 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3np29fpyta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Feb 2023 17:13:00 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 31GHCvSh41288166 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Feb 2023 17:12:57 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C18042004D; Thu, 16 Feb 2023 17:12:57 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A0F162004F; Thu, 16 Feb 2023 17:12:57 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.56]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 16 Feb 2023 17:12:57 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com, thuth@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com Subject: [kvm-unit-tests GIT PULL 10/10] lib: s390x: Handle debug prints for SIE exceptions correctly Date: Thu, 16 Feb 2023 18:12:55 +0100 Message-Id: <20230216171255.48799-11-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216171255.48799-1-imbrenda@linux.ibm.com> References: <20230216171255.48799-1-imbrenda@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 59J3v3DbkoHgrCzurDJqg5xVJ-mA35Ok X-Proofpoint-ORIG-GUID: MGudCH0YM3erL6a68hLC-5km97vooBqT X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.170.22 definitions=2023-02-16_12,2023-02-16_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=982 priorityscore=1501 adultscore=0 suspectscore=0 bulkscore=0 impostorscore=0 spamscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2302160144 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank 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 Link: https://lore.kernel.org/r/20230112154548.163021-8-frankja@linux.ibm.com Message-Id: <20230112154548.163021-8-frankja@linux.ibm.com> --- lib/s390x/sie.h | 2 ++ lib/s390x/interrupt.c | 46 ++++++++++++++++++++++++++++++++++++++----- s390x/cpu.S | 6 ++++-- 3 files changed, 47 insertions(+), 7 deletions(-) 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/lib/s390x/interrupt.c b/lib/s390x/interrupt.c index dadb7415..3f993a36 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/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