From patchwork Tue Sep 20 07:30:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12981502 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 A252DC6FA82 for ; Tue, 20 Sep 2022 07:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230203AbiITHhL (ORCPT ); Tue, 20 Sep 2022 03:37:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbiITHhJ (ORCPT ); Tue, 20 Sep 2022 03:37:09 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB91060519; Tue, 20 Sep 2022 00:37:07 -0700 (PDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7VuuO003445; Tue, 20 Sep 2022 07:37:07 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=Sch/KijMF+Mv4TSW1LR/yOGkNcQ3exSLSmAIozsuy7g=; b=I9llzA82p1py83NTqkgaxYFeYw7nnT5ht4sVfwP0obr1NFzC9pZrdq/70NgLoeSYzzfq 4U2L9X90nonkhnKe5abIS1aOBzStCxpggfbWUSSBOvzksba4B2m3hRTPhTN9g+RVe9CS socObKgyLHeRaJhe0I5ejF65+AqsNhc4vz0q1kHSN36635dqK6BTc/euCKdO7ik2r39e Lf4Z39FggEfAxo+aCayibqepSC71O9Nx9L3E5ywZfInDB2d18SuUQSIfj9b2IfF2iXUF uD4rrllB0mp0aacc//1DAcjW+ComsXJjRbPGq8/IyT0efkOXH7SqOD29PL+1iPhkxjxX Ew== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3jq97a05kq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:37:06 +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 28K7Wr5u010432; Tue, 20 Sep 2022 07:37:06 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 3jq97a05jc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:37:06 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28K7L6qX021752; Tue, 20 Sep 2022 07:32:03 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03ams.nl.ibm.com with ESMTP id 3jn5v93fh9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:03 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28K7S2k845482266 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Sep 2022 07:28:02 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6C95311C050; Tue, 20 Sep 2022 07:32:00 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 706BC11C04A; Tue, 20 Sep 2022 07:31:59 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Sep 2022 07:31:59 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@de.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 01/11] s390x: smp: move sigp calls with invalid cpu address to array Date: Tue, 20 Sep 2022 07:30:25 +0000 Message-Id: <20220920073035.29201-2-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920073035.29201-1-frankja@linux.ibm.com> References: <20220920073035.29201-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: MUHfAlNdBbbLFjxYnO-mtJq4dKn1q7kr X-Proofpoint-ORIG-GUID: DLzGbwGZLMptMeJGr5tKmkYfrPuQo9fw X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 spamscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200045 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr We have the nice array to test SIGP calls with invalid CPU addresses. Move the SIGP cases there to eliminate some of the duplicated code in test_emcall and test_cond_emcall. Since adding coverage for invalid CPU addresses in the ecall case is now trivial, do that as well. Signed-off-by: Nico Boehr Reviewed-by: Janosch Frank Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20220810074616.1223561-2-nrb@linux.ibm.com Message-Id: <20220810074616.1223561-2-nrb@linux.ibm.com> Signed-off-by: Janosch Frank --- s390x/smp.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/s390x/smp.c b/s390x/smp.c index 0df4751f..34ae91c3 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -30,6 +30,9 @@ static const struct sigp_invalid_cases cases_invalid_cpu_addr[] = { { SIGP_STOP, "stop with invalid CPU address" }, { SIGP_START, "start with invalid CPU address" }, { SIGP_CPU_RESET, "reset with invalid CPU address" }, + { SIGP_COND_EMERGENCY_SIGNAL, "conditional emcall with invalid CPU address" }, + { SIGP_EMERGENCY_SIGNAL, "emcall with invalid CPU address" }, + { SIGP_EXTERNAL_CALL, "ecall with invalid CPU address" }, { INVALID_ORDER_CODE, "invalid order code and CPU address" }, { SIGP_SENSE, "sense with invalid CPU address" }, { SIGP_STOP_AND_STORE_STATUS, "stop and store status with invalid CPU address" }, @@ -329,7 +332,6 @@ static void emcall(void) static void test_emcall(void) { struct psw psw; - int cc; psw.mask = extract_psw_mask(); psw.addr = (unsigned long)emcall; @@ -343,13 +345,6 @@ static void test_emcall(void) wait_for_flag(); smp_cpu_stop(1); - report_prefix_push("invalid CPU address"); - - cc = sigp(INVALID_CPU_ADDRESS, SIGP_EMERGENCY_SIGNAL, 0, NULL); - report(cc == 3, "CC = 3"); - - report_prefix_pop(); - report_prefix_pop(); } @@ -368,13 +363,6 @@ static void test_cond_emcall(void) goto out; } - report_prefix_push("invalid CPU address"); - - cc = sigp(INVALID_CPU_ADDRESS, SIGP_COND_EMERGENCY_SIGNAL, 0, NULL); - report(cc == 3, "CC = 3"); - - report_prefix_pop(); - report_prefix_push("success"); set_flag(0); From patchwork Tue Sep 20 07:30:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12981476 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 32295C6FA82 for ; Tue, 20 Sep 2022 07:32:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229741AbiITHcL (ORCPT ); Tue, 20 Sep 2022 03:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbiITHcK (ORCPT ); Tue, 20 Sep 2022 03:32:10 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD52E5C9E0; Tue, 20 Sep 2022 00:32:08 -0700 (PDT) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7C0KD030929; Tue, 20 Sep 2022 07:32:08 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=tzdweaAPtwJgvpfcfcPDznzC421wM64SrkE4H9SPoDs=; b=GtK5PHwR/vy2DLp5qwDGMQKtWlmbBu6AW2+bHbBhMHglCkipAjmGIOCBkc3WAi0dDehP J1l25znWYimmB6kfXZY42YKfcwhy6Wuyv26/0RTTqkJRmZMV1X1HQhS9mku8TN3MYK8c 0xTgfx8CAZ22ikpm1Sy/8GxmxtMU++rc22guHxlALTE2pwKyECWSmaZ020UUYHDe3bMz rKGXLggwpxKqUpDuMDi/UAkHycaiN7RwqOOnCqEm8qjmGkw70vr/uEWkFwC2plpGjohd YlnIXsVZhMBPap4g22+n3/Q4MGLqQvLMLunypyyTx9Cx+PzAR8/UHnGQpKmkMhtZLYXL rA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jq8wu0jky-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:08 +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 28K7CMgq031759; Tue, 20 Sep 2022 07:32:07 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 3jq8wu0jjg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:07 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28K7LZMn025971; Tue, 20 Sep 2022 07:32:05 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06fra.de.ibm.com with ESMTP id 3jn5ghjjyy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:04 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28K7W1en44564812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Sep 2022 07:32:01 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8FA3A11C050; Tue, 20 Sep 2022 07:32:01 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 92DF511C04A; Tue, 20 Sep 2022 07:32:00 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Sep 2022 07:32:00 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@de.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 02/11] s390x: smp: use an array for sigp calls Date: Tue, 20 Sep 2022 07:30:26 +0000 Message-Id: <20220920073035.29201-3-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920073035.29201-1-frankja@linux.ibm.com> References: <20220920073035.29201-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: aPtVnc_ug-zbPyv5St80T7aXfJXPnwQ7 X-Proofpoint-ORIG-GUID: IwtZE9V4D_3rGPmtH8Ejo-IV-Eu2tPkf X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 phishscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200045 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr Tests for the SIGP calls are quite similar, so we have a lot of code duplication right now. Since upcoming changes will add more cases, refactor the code to iterate over an array, similarily as we already do for test_invalid(). The receiving CPU is disabled for IO interrupts. This makes sure the conditional emergency signal is accepted and doesn't hurt the other orders. Signed-off-by: Nico Boehr Reviewed-by: Janosch Frank Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20220810074616.1223561-3-nrb@linux.ibm.com Message-Id: <20220810074616.1223561-3-nrb@linux.ibm.com> Signed-off-by: Janosch Frank --- s390x/smp.c | 128 ++++++++++++++++++++-------------------------------- 1 file changed, 50 insertions(+), 78 deletions(-) diff --git a/s390x/smp.c b/s390x/smp.c index 34ae91c3..5a269087 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -43,6 +43,20 @@ static const struct sigp_invalid_cases cases_valid_cpu_addr[] = { static uint32_t cpu1_prefix; +struct sigp_call_cases { + char name[20]; + int call; + uint16_t ext_int_expected_type; + unsigned int cr0_bit; + bool supports_pv; +}; +static const struct sigp_call_cases cases_sigp_call[] = { + { "emcall", SIGP_EMERGENCY_SIGNAL, 0x1201, CTL0_EMERGENCY_SIGNAL, true }, + { "cond emcall", SIGP_COND_EMERGENCY_SIGNAL, 0x1201, CTL0_EMERGENCY_SIGNAL, false }, + { "ecall", SIGP_EXTERNAL_CALL, 0x1202, CTL0_EXTERNAL_CALL, true }, +}; +static const struct sigp_call_cases *current_sigp_call_case; + static void test_invalid(void) { const struct sigp_invalid_cases *c; @@ -289,97 +303,57 @@ static void test_set_prefix(void) } -static void ecall(void) +static void call_received(void) { expect_ext_int(); - ctl_set_bit(0, CTL0_EXTERNAL_CALL); - psw_mask_set_bits(PSW_MASK_EXT); + ctl_set_bit(0, current_sigp_call_case->cr0_bit); + /* make sure conditional emergency is accepted by disabling IO interrupts */ + psw_mask_clear_and_set_bits(PSW_MASK_IO, PSW_MASK_EXT); + + /* Indicate that we're ready to receive the call */ set_flag(1); - while (lowcore.ext_int_code != 0x1202) { mb(); } + + while (lowcore.ext_int_code != current_sigp_call_case->ext_int_expected_type) + mb(); report_pass("received"); + + ctl_clear_bit(0, current_sigp_call_case->cr0_bit); + + /* Indicate that we're done */ set_flag(1); } -static void test_ecall(void) +static void test_calls(void) { + int i; struct psw psw; - psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)ecall; - report_prefix_push("ecall"); - set_flag(0); + for (i = 0; i < ARRAY_SIZE(cases_sigp_call); i++) { + current_sigp_call_case = &cases_sigp_call[i]; - smp_cpu_start(1, psw); - wait_for_flag(); - set_flag(0); - smp_sigp(1, SIGP_EXTERNAL_CALL, 0, NULL); - wait_for_flag(); - smp_cpu_stop(1); - report_prefix_pop(); -} + report_prefix_push(current_sigp_call_case->name); + if (!current_sigp_call_case->supports_pv && uv_os_is_guest()) { + report_skip("Not supported under PV"); + report_prefix_pop(); + continue; + } -static void emcall(void) -{ - expect_ext_int(); - ctl_set_bit(0, CTL0_EMERGENCY_SIGNAL); - psw_mask_set_bits(PSW_MASK_EXT); - set_flag(1); - while (lowcore.ext_int_code != 0x1201) { mb(); } - report_pass("received"); - set_flag(1); -} + set_flag(0); + psw.mask = extract_psw_mask(); + psw.addr = (unsigned long)call_received; + smp_cpu_start(1, psw); -static void test_emcall(void) -{ - struct psw psw; - psw.mask = extract_psw_mask(); - psw.addr = (unsigned long)emcall; + /* Wait until the receiver has finished setup */ + wait_for_flag(); + set_flag(0); - report_prefix_push("emcall"); - set_flag(0); + smp_sigp(1, current_sigp_call_case->call, 0, NULL); - smp_cpu_start(1, psw); - wait_for_flag(); - set_flag(0); - smp_sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL); - wait_for_flag(); - smp_cpu_stop(1); - - report_prefix_pop(); -} - -static void test_cond_emcall(void) -{ - uint32_t status = 0; - struct psw psw; - int cc; - psw.mask = extract_psw_mask() & ~PSW_MASK_IO; - psw.addr = (unsigned long)emcall; - - report_prefix_push("conditional emergency call"); - - if (uv_os_is_guest()) { - report_skip("unsupported under PV"); - goto out; + /* Wait until the receiver has handled the call */ + wait_for_flag(); + smp_cpu_stop(1); + report_prefix_pop(); } - - report_prefix_push("success"); - set_flag(0); - - smp_cpu_start(1, psw); - wait_for_flag(); - set_flag(0); - cc = smp_sigp(1, SIGP_COND_EMERGENCY_SIGNAL, 0, &status); - report(!cc, "CC = 0"); - - wait_for_flag(); - smp_cpu_stop(1); - - report_prefix_pop(); - -out: - report_prefix_pop(); - } static void test_sense_running(void) @@ -499,9 +473,7 @@ int main(void) test_stop_store_status(); test_store_status(); test_set_prefix(); - test_ecall(); - test_emcall(); - test_cond_emcall(); + test_calls(); test_sense_running(); test_reset(); test_reset_initial(); From patchwork Tue Sep 20 07:30:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12981503 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 B81ACC6FA8E for ; Tue, 20 Sep 2022 07:37:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230202AbiITHhM (ORCPT ); Tue, 20 Sep 2022 03:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230201AbiITHhL (ORCPT ); Tue, 20 Sep 2022 03:37:11 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D6C160516; Tue, 20 Sep 2022 00:37:09 -0700 (PDT) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7VlJe012159; Tue, 20 Sep 2022 07:37:09 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=XJS6h7Hqf7r1OPV/ZjjGlGunF+tbbmUOOmgrsrVKS2s=; b=muV1alMZrSNVGOSbNLkrtNIYHxyUFu4RLfOPF8pN5kuyh+ctD6Fasp2DJsQzaak+7Otc EVBPWczKU1h/Sdl+zr1Q+e5VPYvUOm6r5zJdLOOH/d5KdHKu6SEAQUB4CVB0wzKTIG6M hB4mTWOMNJFriHUUnJ+DnJ1XdJridzPN6KHS/fDOKZ1T0rgWrLCT7Rwz2MBmtuXf/sWi 7oR4kWvK4t3cBuQzE7OG7S45CxiT9qfea5SyW2ulCh2DfP01s+dJB/pMq7c5EWhaDs0g qlQveQzDFGB0ZCICHiSBXCQGSu87MdlnyBZX9+8WGNqnreLguUPSCJ1G/QUCmXQwIfh7 IQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3jq978046k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:37:08 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 28K7VnaG012206; Tue, 20 Sep 2022 07:37:08 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3jq9780458-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:37:08 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28K7KrWU005773; Tue, 20 Sep 2022 07:32:06 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma01fra.de.ibm.com with ESMTP id 3jn5v8jj5p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:05 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28K7W29p45154560 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Sep 2022 07:32:02 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B090011C050; Tue, 20 Sep 2022 07:32:02 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B5AD311C04A; Tue, 20 Sep 2022 07:32:01 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Sep 2022 07:32:01 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@de.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 03/11] s390x: smp: add tests for calls in wait state Date: Tue, 20 Sep 2022 07:30:27 +0000 Message-Id: <20220920073035.29201-4-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920073035.29201-1-frankja@linux.ibm.com> References: <20220920073035.29201-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: _HAdkx2w_g2LlAUGlBjTp1T9BB0RkbdF X-Proofpoint-ORIG-GUID: 4ezAsU8EtN-DEZEvHoSwAEuoMD_PZ2w6 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 bulkscore=0 impostorscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200045 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr When the SIGP interpretation facility is in use a SIGP external call to a waiting CPU will result in an exit of the calling cpu. For non-pv guests it's a code 56 (partial execution) exit otherwise its a code 108 (secure instruction notification) exit. Those exits are handled differently from a normal SIGP instruction intercept that happens without interpretation and hence need to be tested. Signed-off-by: Nico Boehr Reviewed-by: Janosch Frank Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20220810074616.1223561-4-nrb@linux.ibm.com Message-Id: <20220810074616.1223561-4-nrb@linux.ibm.com> Signed-off-by: Janosch Frank --- s390x/smp.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/s390x/smp.c b/s390x/smp.c index 5a269087..91f3e3bc 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -356,6 +356,102 @@ static void test_calls(void) } } +static void call_in_wait_ext_int_fixup(struct stack_frame_int *stack) +{ + /* Clear wait bit so we don't immediately wait again after the fixup */ + lowcore.ext_old_psw.mask &= ~PSW_MASK_WAIT; +} + +static void call_in_wait_setup(void) +{ + expect_ext_int(); + ctl_set_bit(0, current_sigp_call_case->cr0_bit); + register_ext_cleanup_func(call_in_wait_ext_int_fixup); + + set_flag(1); +} + +static void call_in_wait_received(void) +{ + report(lowcore.ext_int_code == current_sigp_call_case->ext_int_expected_type, "received"); + + set_flag(1); +} + +static void call_in_wait_cleanup(void) +{ + ctl_clear_bit(0, current_sigp_call_case->cr0_bit); + register_ext_cleanup_func(NULL); + + set_flag(1); +} + +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++) { + current_sigp_call_case = &cases_sigp_call[i]; + + report_prefix_push(current_sigp_call_case->name); + if (!current_sigp_call_case->supports_pv && uv_os_is_guest()) { + report_skip("Not supported under PV"); + report_prefix_pop(); + continue; + } + + /* 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); + + /* Wait until the receiver has finished setup */ + wait_for_flag(); + set_flag(0); + + /* + * To avoid races, we need to know that the secondary CPU has entered wait, + * but the architecture provides no way to check whether the secondary CPU + * is in wait. + * + * But since a waiting CPU is considered operating, simply stop the CPU, set + * up the restart new PSW mask in wait, send the restart interrupt and then + * 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_sigp(1, current_sigp_call_case->call, 0, NULL); + + /* Wait until the receiver has handled the call */ + wait_for_flag(); + smp_cpu_stop(1); + set_flag(0); + + /* + * Now clean up the mess we have left behind. If the cleanup + * were part of call_in_wait_received we would not get a chance + * 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); + + /* Wait until the cleanup has been completed */ + wait_for_flag(); + smp_cpu_stop(1); + + report_prefix_pop(); + } + report_prefix_pop(); +} + static void test_sense_running(void) { report_prefix_push("sense_running"); @@ -474,6 +570,7 @@ int main(void) test_store_status(); test_set_prefix(); test_calls(); + test_calls_in_wait(); test_sense_running(); test_reset(); test_reset_initial(); From patchwork Tue Sep 20 07:30:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12981477 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 1AC5AC54EE9 for ; Tue, 20 Sep 2022 07:32:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229557AbiITHcO (ORCPT ); Tue, 20 Sep 2022 03:32:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229822AbiITHcM (ORCPT ); Tue, 20 Sep 2022 03:32:12 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 058FE5C9E0; Tue, 20 Sep 2022 00:32:10 -0700 (PDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7C0Ak005828; Tue, 20 Sep 2022 07:32:10 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=lCZTiM3nGoxQyg4TriCgaJ7Ni50ZCoeazIAdurTY4uo=; b=mX7F1zNgxBIn99rY4wSlbaXQeFFFmRPDZc0TkrbLXMZyqiLdbcPaKyBlnzyv8EcN/7/Q 7LKLpVtO/4S1yWOELwJlSWQsiZQs4pgfa1EZysByVxlKkL1Qte4KVVeP3GUYI3B9zmyZ Mo4hYwpLDkipfpRHNzO4FtlmG8U2vZ699jRHS0tj8Z77qxMBavWIlkE03tkN/uVXRTbE aGmMFPRTWzfTQCruOYrggDhNaGN3TPba099h0LIa8F2HsHz+Z6KtkqNcjA4BTDVQP4/1 GOk4jJgdh4YqS7tJT2PExMP/DWtsO8XtY3yFHBuIXf3gBmF5R3QHz5uisi411bwj6u/y lg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jq8wu8hw0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:10 +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 28K7DIhn012802; Tue, 20 Sep 2022 07:32:10 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 3jq8wu8hun-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:09 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28K7L6UL029483; Tue, 20 Sep 2022 07:32:07 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma04ams.nl.ibm.com with ESMTP id 3jn5v8kgb5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:07 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28K7W3kc39977278 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Sep 2022 07:32:04 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D1BC111C050; Tue, 20 Sep 2022 07:32:03 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D75F011C04A; Tue, 20 Sep 2022 07:32:02 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Sep 2022 07:32:02 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@de.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 04/11] lib/s390x: fix SMP setup bug Date: Tue, 20 Sep 2022 07:30:28 +0000 Message-Id: <20220920073035.29201-5-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920073035.29201-1-frankja@linux.ibm.com> References: <20220920073035.29201-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: H8Pepv9jxR4mJpmdFBBdXK7QXzuAN0k8 X-Proofpoint-GUID: lkbms8x9Cstsvcoa6xszT75Eidfny9KT X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=868 lowpriorityscore=0 bulkscore=0 mlxscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 adultscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200045 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Claudio Imbrenda The lowcore pointer pointing to the current CPU (THIS_CPU) was not initialized for the boot CPU. The pointer is needed for correct interrupt handling, which is needed in the setup process before the struct cpu array is allocated. The bug went unnoticed because some environments (like qemu/KVM) clear all memory and don't write anything in the lowcore area before starting the payload. The pointer thus pointed to 0, an area of memory also not used. Other environments will write to memory before starting the payload, causing the unit tests to crash at the first interrupt. Fix by assigning a temporary struct cpu before the rest of the setup process, and assigning the pointer to the correct allocated struct during smp initialization. Fixes: 4e5dd758 ("lib: s390x: better smp interrupt checks") Signed-off-by: Claudio Imbrenda Reviewed-by: Nico Boehr Reviewed-by: Janosch Frank Tested-by: Nico Boehr Reported-by: Janosch Frank Link: https://lore.kernel.org/r/20220818152114.213135-1-imbrenda@linux.ibm.com Message-Id: <20220818152114.213135-1-imbrenda@linux.ibm.com> Signed-off-by: Janosch Frank --- lib/s390x/io.c | 9 +++++++++ lib/s390x/smp.c | 1 + 2 files changed, 10 insertions(+) diff --git a/lib/s390x/io.c b/lib/s390x/io.c index a4f1b113..fb7b7dda 100644 --- a/lib/s390x/io.c +++ b/lib/s390x/io.c @@ -33,6 +33,15 @@ void puts(const char *s) void setup(void) { + struct cpu this_cpu_tmp = { 0 }; + + /* + * Set a temporary empty struct cpu for the boot CPU, needed for + * correct interrupt handling in the setup process. + * smp_setup will allocate and set the permanent one. + */ + THIS_CPU = &this_cpu_tmp; + setup_args_progname(ipl_args); setup_facilities(); sclp_read_info(); diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c index 0d98c17d..03d6d2a4 100644 --- a/lib/s390x/smp.c +++ b/lib/s390x/smp.c @@ -353,6 +353,7 @@ void smp_setup(void) cpus[0].stack = stackptr; cpus[0].lowcore = (void *)0; cpus[0].active = true; + THIS_CPU = &cpus[0]; } } spin_unlock(&lock); From patchwork Tue Sep 20 07:30:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12981478 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 2A5FAC6FA91 for ; Tue, 20 Sep 2022 07:32:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229437AbiITHcP (ORCPT ); Tue, 20 Sep 2022 03:32:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbiITHcM (ORCPT ); Tue, 20 Sep 2022 03:32:12 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECCF15727D; Tue, 20 Sep 2022 00:32:11 -0700 (PDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7C0If005810; Tue, 20 Sep 2022 07:32:11 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=/wpnWlchDiGjvVFkjqRLpcTYWZijj2Qkk4hqEz7u4wY=; b=TzSOl9p6Rgm5Pt/0A2OONBCl7kzmm3xn0kv9qijI+XBts4/YGOjcI/ymxFOPUNLXI7L0 3pcRDMr/V4rpzUD02Q5V40aFQh7ka7001HKmqz9OSN9DyhRqj1/KSHidtpLu+Un6LyCT /ma5V71T7MfAvGRL68ltzSgJrFtgqzUPaIwqd4LblFseO+nVU5tBEWmir/BxBCXu8EKi UpNF17epAgqRtNSS/Rv3peC7Lb3WmvmbZ/+hN2ooHzxHyVQ0JgADvFJeIAJ/I2I4EpMS pzWzXFGZEzzoGT9AWPI/oEdvYhcO9EMMNmyPun4XhLdYlh/CrqfHB7kO4XWSgsK1i3Zx uA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jq8wu8hwk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:11 +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 28K7CH4N007199; Tue, 20 Sep 2022 07:32:11 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jq8wu8hv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:11 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28K7KnWi021819; Tue, 20 Sep 2022 07:32:08 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma02fra.de.ibm.com with ESMTP id 3jn5v8tj8y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:08 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28K7W54T54067504 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Sep 2022 07:32:05 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F384E11C050; Tue, 20 Sep 2022 07:32:04 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 04A6A11C04A; Tue, 20 Sep 2022 07:32:04 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Sep 2022 07:32:03 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@de.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 05/11] runtime: add support for panic tests Date: Tue, 20 Sep 2022 07:30:29 +0000 Message-Id: <20220920073035.29201-6-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920073035.29201-1-frankja@linux.ibm.com> References: <20220920073035.29201-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: AXbuuk03gs9yDQEN_95slE4BAWfTFQT7 X-Proofpoint-GUID: ixqTCWGMMxAQsvx4haIkT29z2PVz_p2d X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 mlxscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 adultscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200045 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr QEMU supports a guest state "guest-panicked" which indicates something in the guest went wrong. For example on s390x, when an external interrupt loop was triggered. Since the guest does not continue to run when it is in the guest-panicked state, it is currently impossible to write panicking tests in kvm-unit-tests. Support from the runtime is needed to check that the guest enters the guest-panicked state. Similar to migration tests, add a new "panic" group. Tests in this group must enter the guest-panicked state to succeed. The runtime will spawn a QEMU instance, connect to the QMP and listen for events. To parse the QMP protocol, jq[1] is used. Same as with netcat in the migration tests, panic tests won't run if jq is not installed. The guest is created in the stopped state and only is resumed when connection to the QMP was successful. This ensures no events are missed between QEMU start and the connect to the QMP. [1] https://stedolan.github.io/jq/ Signed-off-by: Nico Boehr Reviewed-by: Thomas Huth Reviewed-by: Claudio Imbrenda Acked-by: Janosch Frank Link: https://lore.kernel.org/r/20220823103833.156942-2-nrb@linux.ibm.com Message-Id: <20220823103833.156942-2-nrb@linux.ibm.com> Signed-off-by: Janosch Frank --- s390x/run | 2 +- scripts/arch-run.bash | 49 +++++++++++++++++++++++++++++++++++++++++++ scripts/runtime.bash | 3 +++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/s390x/run b/s390x/run index 24138f68..f1111dbd 100755 --- a/s390x/run +++ b/s390x/run @@ -30,7 +30,7 @@ M+=",accel=$ACCEL" command="$qemu -nodefaults -nographic $M" command+=" -chardev stdio,id=con0 -device sclpconsole,chardev=con0" command+=" -kernel" -command="$(migration_cmd) $(timeout_cmd) $command" +command="$(panic_cmd) $(migration_cmd) $(timeout_cmd) $command" # We return the exit code via stdout, not via the QEMU return code run_qemu_status $command "$@" diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 0dfaf017..51e4b97b 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -104,6 +104,14 @@ qmp () echo '{ "execute": "qmp_capabilities" }{ "execute":' "$2" '}' | ncat -U $1 } +qmp_events () +{ + while ! test -S "$1"; do sleep 0.1; done + echo '{ "execute": "qmp_capabilities" }{ "execute": "cont" }' | + ncat --no-shutdown -U $1 | + jq -c 'select(has("event"))' +} + run_migration () { if ! command -v ncat >/dev/null 2>&1; then @@ -164,6 +172,40 @@ run_migration () return $ret } +run_panic () +{ + if ! command -v ncat >/dev/null 2>&1; then + echo "${FUNCNAME[0]} needs ncat (netcat)" >&2 + return 77 + fi + + if ! command -v jq >/dev/null 2>&1; then + echo "${FUNCNAME[0]} needs jq" >&2 + return 77 + fi + + qmp=$(mktemp -u -t panic-qmp.XXXXXXXXXX) + + trap 'kill 0; exit 2' INT TERM + trap 'rm -f ${qmp}' RETURN EXIT + + # start VM stopped so we don't miss any events + eval "$@" -chardev socket,id=mon1,path=${qmp},server=on,wait=off \ + -mon chardev=mon1,mode=control -S & + + panic_event_count=$(qmp_events ${qmp} | jq -c 'select(.event == "GUEST_PANICKED")' | wc -l) + if [ "$panic_event_count" -lt 1 ]; then + echo "FAIL: guest did not panic" + ret=3 + else + # some QEMU versions report multiple panic events + echo "PASS: guest panicked" + ret=1 + fi + + return $ret +} + migration_cmd () { if [ "$MIGRATION" = "yes" ]; then @@ -171,6 +213,13 @@ migration_cmd () fi } +panic_cmd () +{ + if [ "$PANIC" = "yes" ]; then + echo "run_panic" + fi +} + search_qemu_binary () { local save_path=$PATH diff --git a/scripts/runtime.bash b/scripts/runtime.bash index bbf87cf4..f8794e9a 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -145,6 +145,9 @@ function run() if find_word "migration" "$groups"; then cmdline="MIGRATION=yes $cmdline" fi + if find_word "panic" "$groups"; then + cmdline="PANIC=yes $cmdline" + fi if [ "$verbose" = "yes" ]; then echo $cmdline fi From patchwork Tue Sep 20 07:30:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12981479 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 16A5CECAAD8 for ; Tue, 20 Sep 2022 07:32:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230030AbiITHcR (ORCPT ); Tue, 20 Sep 2022 03:32:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbiITHcN (ORCPT ); Tue, 20 Sep 2022 03:32:13 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7D8D5FACE; Tue, 20 Sep 2022 00:32:12 -0700 (PDT) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7VkLL012137; Tue, 20 Sep 2022 07:32:11 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=zHHALfZF8bmyprv06ktyW0VatWEan4k+TIjdCoKp5EA=; b=mBk2WHFtatp671fwIva/0xGH46SwiXk+TWh5yNEZM3BNu3bKm+zUB3pt/Q/OnCMcnQwj 49d8z3kUeP+r2OgCcI0kluWoHbj7x00eOdRV8nilhKqmLeQjXNwM6Kjqc4rX+yhf1KIc jefR81IrFiu21/+11lqqtdGkJhtw0RoFutw8NtnfXiDHkmDMVorfHCZ6qYBx+ECGRgqq bt49PPx0I5pKMbhFtDalmJCwTVw8vw31l/ctemGPSxNwcQZ57N4OeVai4NhyF3bGmr+z Ex5HnnnyO0Iof4EhggaOg7BvCMEAi19HU3hGnTR8iSQ41RXFUXYMWai0s6eq2gFBSN1g lQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3jq978007a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:11 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 28K7WB9o013510; Tue, 20 Sep 2022 07:32:11 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 3jq9780070-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:11 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28K7MRDx011889; Tue, 20 Sep 2022 07:32:09 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04fra.de.ibm.com with ESMTP id 3jn5v92jm2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:09 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28K7WWQI52035996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Sep 2022 07:32:32 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2186611C04C; Tue, 20 Sep 2022 07:32:06 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 25F6311C04A; Tue, 20 Sep 2022 07:32:05 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Sep 2022 07:32:05 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@de.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 06/11] lib/s390x: add CPU timer related defines and functions Date: Tue, 20 Sep 2022 07:30:30 +0000 Message-Id: <20220920073035.29201-7-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920073035.29201-1-frankja@linux.ibm.com> References: <20220920073035.29201-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: icY3XKEla9_HOfV868fxfgXJZR3NACKL X-Proofpoint-ORIG-GUID: CBZE__BMtcY7xREJFECM0tEuMbw3rbqt X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 bulkscore=0 impostorscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200042 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr Upcoming changes will make use of the CPU timer, so add some defines and functions to work with the CPU timer. Since shifts for both CPU timer and TOD clock are the same, introduce a new constant S390_CLOCK_SHIFT_US for this value. The respective shifts for CPU timer and TOD clock reference it, so the semantic difference between the two defines is kept. Also add a constant for the CPU timer subclass mask. Signed-off-by: Nico Boehr Reviewed-by: Janosch Frank Reviewed-by: Thomas Huth Link: https://lore.kernel.org/r/20220823103833.156942-3-nrb@linux.ibm.com Message-Id: <20220823103833.156942-3-nrb@linux.ibm.com> Signed-off-by: Janosch Frank --- lib/s390x/asm/arch_def.h | 1 + lib/s390x/asm/time.h | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h index e7ae454b..b92291e8 100644 --- a/lib/s390x/asm/arch_def.h +++ b/lib/s390x/asm/arch_def.h @@ -78,6 +78,7 @@ struct cpu { #define CTL0_EMERGENCY_SIGNAL (63 - 49) #define CTL0_EXTERNAL_CALL (63 - 50) #define CTL0_CLOCK_COMPARATOR (63 - 52) +#define CTL0_CPU_TIMER (63 - 53) #define CTL0_SERVICE_SIGNAL (63 - 54) #define CR0_EXTM_MASK 0x0000000000006200UL /* Combined external masks */ diff --git a/lib/s390x/asm/time.h b/lib/s390x/asm/time.h index 7652a151..d8d91d68 100644 --- a/lib/s390x/asm/time.h +++ b/lib/s390x/asm/time.h @@ -11,9 +11,13 @@ #ifndef _ASMS390X_TIME_H_ #define _ASMS390X_TIME_H_ -#define STCK_SHIFT_US (63 - 51) +#define S390_CLOCK_SHIFT_US (63 - 51) + +#define STCK_SHIFT_US S390_CLOCK_SHIFT_US #define STCK_MAX ((1UL << 52) - 1) +#define CPU_TIMER_SHIFT_US S390_CLOCK_SHIFT_US + static inline uint64_t get_clock_us(void) { uint64_t clk; @@ -45,4 +49,15 @@ static inline void mdelay(unsigned long ms) udelay(ms * 1000); } +static inline void cpu_timer_set_ms(int64_t timeout_ms) +{ + int64_t timer_value = (timeout_ms * 1000) << CPU_TIMER_SHIFT_US; + + asm volatile ( + "spt %[timer_value]\n" + : + : [timer_value] "Q" (timer_value) + ); +} + #endif From patchwork Tue Sep 20 07:30:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12981480 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 CB10AC54EE9 for ; Tue, 20 Sep 2022 07:32:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229920AbiITHcT (ORCPT ); Tue, 20 Sep 2022 03:32:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229822AbiITHcO (ORCPT ); Tue, 20 Sep 2022 03:32:14 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDA2C5727D; Tue, 20 Sep 2022 00:32:13 -0700 (PDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7Bx1I005791; Tue, 20 Sep 2022 07:32:13 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=bAHhLZtUowHFMN52SbTEI5xHh+QJ2+pR39YAxJjXst8=; b=OkzBIWti9If85ivNDacWvZ/EKcPYmi0RRjNqtk0PAZQ+abiUBdkMb6+ULixXOt1Vj8wn 4nT+uKF29Gh+u3uwr7cs2uy/9LBZ/448cu+7vLUIBvZOOuOWrgCGN7vkkMuK2JzDC+Uk ut3Nu5Q2EOYOoOHg/YsRWFnSAwMxbMxvAU9vW8LAF6umgRhoPHDLftPUQUSJoSjchTV7 /7LCadGX85pUdM/KLYG8JDWaL2yetB91piSUSdCDEj9zxrmXK2Dl02uu/NhVOAogXQrF uoMCSqKipEbk/rnZ6mmo4ZSfsiEuy9/VfUDfKgFp6TT0buJ0bCq8F55JvZCbG8Ng8/Ws BQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jq8wu8hxh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:13 +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 28K7FSEp021363; Tue, 20 Sep 2022 07:32:12 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 3jq8wu8hwb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:12 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28K7L1Lf029298; Tue, 20 Sep 2022 07:32:10 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04ams.nl.ibm.com with ESMTP id 3jn5v8kgba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:10 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28K7S9BJ17236362 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Sep 2022 07:28:09 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 432E111C04C; Tue, 20 Sep 2022 07:32:07 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 47E9D11C04A; Tue, 20 Sep 2022 07:32:06 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Sep 2022 07:32:06 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@de.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 07/11] s390x: add extint loop test Date: Tue, 20 Sep 2022 07:30:31 +0000 Message-Id: <20220920073035.29201-8-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920073035.29201-1-frankja@linux.ibm.com> References: <20220920073035.29201-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 924NXMrXU3yWLPbr210iA6T5Xuh3vDaM X-Proofpoint-GUID: 1Vbsm155IX25g8XcFyqms3lUHZcuREdf X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 mlxscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 adultscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200045 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr The CPU timer interrupt stays pending as long as the CPU timer value is negative. This can lead to interruption loops when the ext_new_psw mask has external interrupts enabled and the CPU timer subclass in CR0 is enabled. QEMU is able to detect this situation and panic the guest, so add a test for it. Signed-off-by: Nico Boehr Reviewed-by: Thomas Huth Reviewed-by: Janosch Frank Link: https://lore.kernel.org/r/20220823103833.156942-4-nrb@linux.ibm.com Message-Id: <20220823103833.156942-4-nrb@linux.ibm.com> Signed-off-by: Janosch Frank --- s390x/Makefile | 1 + s390x/panic-loop-extint.c | 59 +++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 6 ++++ 3 files changed, 66 insertions(+) create mode 100644 s390x/panic-loop-extint.c diff --git a/s390x/Makefile b/s390x/Makefile index efd5e0c1..e4649da5 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -34,6 +34,7 @@ tests += $(TEST_DIR)/migration.elf tests += $(TEST_DIR)/pv-attest.elf tests += $(TEST_DIR)/migration-cmm.elf tests += $(TEST_DIR)/migration-skey.elf +tests += $(TEST_DIR)/panic-loop-extint.elf pv-tests += $(TEST_DIR)/pv-diags.elf diff --git a/s390x/panic-loop-extint.c b/s390x/panic-loop-extint.c new file mode 100644 index 00000000..07325147 --- /dev/null +++ b/s390x/panic-loop-extint.c @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * External interrupt loop test + * + * Copyright IBM Corp. 2022 + * + * Authors: + * Nico Boehr + */ +#include +#include +#include +#include +#include +#include + +static void ext_int_cleanup(struct stack_frame_int *stack) +{ + /* + * Since we form a loop of ext interrupts, this code should never be + * executed. In case it is executed, something went wrong and we want to + * print a failure. + * + * Because the CPU timer subclass mask is still enabled, the CPU timer + * interrupt will fire every time we enable external interrupts, + * preventing us from printing the failure on the console. To avoid + * this, clear the CPU timer subclass mask here. + */ + stack->crs[0] &= ~BIT(CTL0_CPU_TIMER); +} + +int main(void) +{ + report_prefix_push("panic-loop-extint"); + + if (!host_is_qemu() || host_is_tcg()) { + report_skip("QEMU-KVM-only test"); + goto out; + } + + expect_ext_int(); + lowcore.ext_new_psw.mask |= PSW_MASK_EXT; + + psw_mask_set_bits(PSW_MASK_EXT); + + register_ext_cleanup_func(ext_int_cleanup); + + cpu_timer_set_ms(10); + ctl_set_bit(0, CTL0_CPU_TIMER); + mdelay(2000); + + register_ext_cleanup_func(NULL); + + report_fail("survived extint loop"); + +out: + report_prefix_pop(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index f7b1fc3d..b1b25f11 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -185,3 +185,9 @@ groups = migration [migration-skey] file = migration-skey.elf groups = migration + +[panic-loop-extint] +file = panic-loop-extint.elf +groups = panic +accel = kvm +timeout = 5 From patchwork Tue Sep 20 07:30:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12981483 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 C2720ECAAD8 for ; Tue, 20 Sep 2022 07:32:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230089AbiITHcf (ORCPT ); Tue, 20 Sep 2022 03:32:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbiITHc2 (ORCPT ); Tue, 20 Sep 2022 03:32:28 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54CFA60504; Tue, 20 Sep 2022 00:32:25 -0700 (PDT) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7KrC7034474; Tue, 20 Sep 2022 07:32:24 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=ofRcp07j1PJPDGnm6mBkIo8oVlkmag0fdOyvEJUZv1o=; b=qnQnGB16P8698ElqhRR4AdXE3vPBYfuc+G76SaXu/qOhxC+8k9lJnBT2LGbVDKRZrtRP dT0m9YldpOEpbZ2VJ/Tg/nc7E3fsm0eCNYQA5BSd+0AJKl/P/WhSOvs+JeMATnKTrHmK /3/9qTlssCN/WJWyfsjCOblK98dgkEIDmk3zTQPXX9qHAM8CRgtijpIbJZ0afvRziK6a QznmXzSAcAPmO5e99JxhD38acY7YUZihbQRqvL51Il6LyuXd6RTAe0ZMQCOCBxWiNVUe vbUlMTflnxusVicBIKSlNkVXOQqifhvztjuHuGmPWfb7bb5d3+6+NwzO9z4903eTGN60 WA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jq924r9w1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:24 +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 28K7L4a4035411; Tue, 20 Sep 2022 07:32:23 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 3jq924r9sb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:23 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28K7L90q031193; Tue, 20 Sep 2022 07:32:13 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06ams.nl.ibm.com with ESMTP id 3jn5gj3fqy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:12 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28K7W8mJ49873214 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Sep 2022 07:32:08 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 76EF211C050; Tue, 20 Sep 2022 07:32:08 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6902111C04C; Tue, 20 Sep 2022 07:32:07 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Sep 2022 07:32:07 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@de.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, Nico Boehr , Janosch Frank Subject: [kvm-unit-tests GIT PULL 08/11] s390x: add pgm spec interrupt loop test Date: Tue, 20 Sep 2022 07:30:32 +0000 Message-Id: <20220920073035.29201-9-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920073035.29201-1-frankja@linux.ibm.com> References: <20220920073035.29201-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 5dG9CsBNnoe2y6giKXLy8Fg7VJTHKdq_ X-Proofpoint-ORIG-GUID: EksnxkBSx6YkwJVWgBMt-Dp_hI6Zr9fS X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 phishscore=0 mlxlogscore=999 adultscore=0 spamscore=0 mlxscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200045 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr An invalid PSW causes a program interrupt. When an invalid PSW is introduced in the pgm_new_psw, an interrupt loop occurs as soon as a program interrupt is caused. QEMU should detect that and panic the guest, hence add a test for it. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Reviewed-by: Janosch Frank Reviewed-by: Thomas Huth Link: https://lore.kernel.org/r/20220823103833.156942-5-nrb@linux.ibm.com Message-Id: <20220823103833.156942-5-nrb@linux.ibm.com> Signed-off-by: Janosch Frank --- s390x/Makefile | 1 + s390x/panic-loop-pgm.c | 38 ++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 6 ++++++ 3 files changed, 45 insertions(+) create mode 100644 s390x/panic-loop-pgm.c diff --git a/s390x/Makefile b/s390x/Makefile index e4649da5..66415d0b 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -35,6 +35,7 @@ tests += $(TEST_DIR)/pv-attest.elf tests += $(TEST_DIR)/migration-cmm.elf tests += $(TEST_DIR)/migration-skey.elf tests += $(TEST_DIR)/panic-loop-extint.elf +tests += $(TEST_DIR)/panic-loop-pgm.elf pv-tests += $(TEST_DIR)/pv-diags.elf diff --git a/s390x/panic-loop-pgm.c b/s390x/panic-loop-pgm.c new file mode 100644 index 00000000..23e97347 --- /dev/null +++ b/s390x/panic-loop-pgm.c @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Program interrupt loop test + * + * Copyright IBM Corp. 2022 + * + * Authors: + * Nico Boehr + */ +#include +#include +#include +#include +#include + +int main(void) +{ + report_prefix_push("panic-loop-pgm"); + + if (!host_is_qemu() || host_is_tcg()) { + report_skip("QEMU-KVM-only test"); + goto out; + } + + expect_pgm_int(); + /* bit 12 set is invalid */ + lowcore.pgm_new_psw.mask = extract_psw_mask() | BIT(63 - 12); + mb(); + + /* cause a pgm int */ + psw_mask_set_bits(BIT(63 - 12)); + + report_fail("survived pgm int loop"); + +out: + report_prefix_pop(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index b1b25f11..f9f102ab 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -191,3 +191,9 @@ file = panic-loop-extint.elf groups = panic accel = kvm timeout = 5 + +[panic-loop-pgm] +file = panic-loop-pgm.elf +groups = panic +accel = kvm +timeout = 5 From patchwork Tue Sep 20 07:30:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12981481 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 DD06CC54EE9 for ; Tue, 20 Sep 2022 07:32:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230096AbiITHcW (ORCPT ); Tue, 20 Sep 2022 03:32:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230041AbiITHcR (ORCPT ); Tue, 20 Sep 2022 03:32:17 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 819C15FF45; Tue, 20 Sep 2022 00:32:16 -0700 (PDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7C0Im005810; Tue, 20 Sep 2022 07:32:16 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=whKim/Xq+IG5qT1dAB6h70ws4IH7R5f+Ji5JDcPeiPI=; b=cvlo4D/UAnRtUOTmdLH6mKKvTAD+kxekEAxCdPiTG9UeaerOIouAzFTG1FS+ufIi8syR MEqXQ9YqbrpgtlptAElnlIZEJOuJ+I0F2rgsyWWvlAQuIlokoTRKR6wXjH9TIEti50pw IWEUn16oIRU5sOPZV9ieFZRZ4FqV6yDTD8yIh6JoaiVSYRTRW5rR7a63tVw062zvNo6U MoZZSN8WbNyOHx4yfVqfddjyXkuEWNIhma2WV0x4hklUeUQdEvSywTB8n5XNrQdg9kKt +fRbaAMxRKFUfcQUCWpsXlBZ/gOBAmo+M+zhfZm5xah//MorXz09O7dPJQ1LKHVGg+Vg UA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jq8wu8j0f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:15 +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 28K7JROG008354; Tue, 20 Sep 2022 07:32:15 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 3jq8wu8hy2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:15 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28K7KweW030734; Tue, 20 Sep 2022 07:32:13 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma06ams.nl.ibm.com with ESMTP id 3jn5gj3fqx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:12 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28K7W9MD31588810 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Sep 2022 07:32:09 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9916911C050; Tue, 20 Sep 2022 07:32:09 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D3EC11C04A; Tue, 20 Sep 2022 07:32:08 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Sep 2022 07:32:08 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@de.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, Janis Schoetterl-Glausch Subject: [kvm-unit-tests GIT PULL 09/11] s390x: Add strict mode to specification exception interpretation test Date: Tue, 20 Sep 2022 07:30:33 +0000 Message-Id: <20220920073035.29201-10-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920073035.29201-1-frankja@linux.ibm.com> References: <20220920073035.29201-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: e0xb8d737ReSJbrlngs_bieMseVPddqP X-Proofpoint-GUID: zhjYdaNKEMAE1lTYGlog4mOERrA5b3tW X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 mlxscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 adultscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200045 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janis Schoetterl-Glausch While specification exception interpretation is not required to occur, it can be useful for automatic regression testing to fail the test if it does not occur. Add a `--strict` argument to enable this. `--strict` takes a list of machine types (as reported by STIDP) for which to enable strict mode, for example `--strict 3931,8562,8561,3907,3906,2965,2964` will enable it for models z16 - z13. Alternatively, strict mode can be enabled for all but the listed machine types by prefixing the list with a `!`, for example `--strict !1090,1091,2064,2066,2084,2086,2094,2096,2097,2098,2817,2818,2827,2828` will enable it for z/Architecture models except those older than z13. `--strict !` will enable it always. Signed-off-by: Janis Schoetterl-Glausch Reviewed-by: Thomas Huth Link: https://lore.kernel.org/r/20220825112047.2206929-1-scgl@linux.ibm.com Message-Id: <20220825112047.2206929-1-scgl@linux.ibm.com> Signed-off-by: Janosch Frank --- s390x/spec_ex-sie.c | 53 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/s390x/spec_ex-sie.c b/s390x/spec_ex-sie.c index d8e25e75..5fa135b8 100644 --- a/s390x/spec_ex-sie.c +++ b/s390x/spec_ex-sie.c @@ -7,16 +7,19 @@ * specification exception interpretation is off/on. */ #include +#include #include #include #include #include #include #include +#include static struct vm vm; extern const char SNIPPET_NAME_START(c, spec_ex)[]; extern const char SNIPPET_NAME_END(c, spec_ex)[]; +static bool strict; static void setup_guest(void) { @@ -37,6 +40,8 @@ static void reset_guest(void) static void test_spec_ex_sie(void) { + const char *msg; + setup_guest(); report_prefix_push("SIE spec ex interpretation"); @@ -60,16 +65,60 @@ static void test_spec_ex_sie(void) report(vm.sblk->icptcode == ICPT_PROGI && vm.sblk->iprcc == PGM_INT_CODE_SPECIFICATION, "Received specification exception intercept"); - if (vm.sblk->gpsw.addr == 0xdeadbeee) - report_info("Interpreted initial exception, intercepted invalid program new PSW exception"); + msg = "Interpreted initial exception, intercepted invalid program new PSW exception"; + if (strict) + report(vm.sblk->gpsw.addr == 0xdeadbeee, "%s", msg); + else if (vm.sblk->gpsw.addr == 0xdeadbeee) + report_info("%s", msg); else report_info("Did not interpret initial exception"); report_prefix_pop(); report_prefix_pop(); } +static bool parse_strict(int argc, char **argv) +{ + uint16_t machine_id; + char *list; + bool ret; + + if (argc < 1) + return false; + if (strcmp("--strict", argv[0])) + return false; + + machine_id = get_machine_id(); + if (argc < 2) { + printf("No argument to --strict, ignoring\n"); + return false; + } + list = argv[1]; + if (list[0] == '!') { + ret = true; + list++; + } else { + ret = false; + } + while (true) { + long input = 0; + + if (strlen(list) == 0) + return ret; + input = strtol(list, &list, 16); + if (*list == ',') + list++; + else if (*list != '\0') + break; + if (input == machine_id) + return !ret; + } + printf("Invalid --strict argument \"%s\", ignoring\n", list); + return ret; +} + int main(int argc, char **argv) { + strict = parse_strict(argc - 1, argv + 1); if (!sclp_facilities.has_sief2) { report_skip("SIEF2 facility unavailable"); goto out; From patchwork Tue Sep 20 07:30:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12981482 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 4A0FEC54EE9 for ; Tue, 20 Sep 2022 07:32:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230097AbiITHcZ (ORCPT ); Tue, 20 Sep 2022 03:32:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbiITHcS (ORCPT ); Tue, 20 Sep 2022 03:32:18 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 283C45FF44; Tue, 20 Sep 2022 00:32:18 -0700 (PDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7C0In005810; Tue, 20 Sep 2022 07:32:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=sUIFZrpGlpTvuA3kCg3kXzy8bTqCuhVZHRQZQpT4P8U=; b=ap6vlr2kQPuP7wvEe2IOSfyquuynaW9ubjnUb3avoi4MRa3JuNIa6WlV/7uHHAXIPqqR BFEUN4L1+sC85Rp78STr6svTZL81NrIiB3KMMmcZTzKGX/la67e54kO9sjRqVM0Oxksc RWy4HRGyKhxI8Mh7BVgsQ0JdGSndjJBjWYw4qFRHeiB9OUxMCKGHhdllhsttQ1Tt79C5 /5eTbe1TkN88sMKIL9UKRCmpCMt+XPG4Vj7VVXdrdpvOPO0kf6QzZVPwlpEYGvlbampn KXtV4dyp6uToIucQjFZQ3gGUkfs+ZJ5Q6TtKkoRvC5YT9DOcfWZkbus2jfzPJGp2c/xX 8A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jq8wu8j1v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:17 +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 28K7CH4P007199; Tue, 20 Sep 2022 07:32:17 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 3jq8wu8hyj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:17 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28K7LYrw025929; Tue, 20 Sep 2022 07:32:14 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06fra.de.ibm.com with ESMTP id 3jn5ghjk06-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:14 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28K7WAs540436182 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Sep 2022 07:32:10 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BA42111C050; Tue, 20 Sep 2022 07:32:10 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BF46C11C04A; Tue, 20 Sep 2022 07:32:09 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Sep 2022 07:32:09 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@de.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 10/11] s390x: factor out common args for genprotimg Date: Tue, 20 Sep 2022 07:30:34 +0000 Message-Id: <20220920073035.29201-11-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920073035.29201-1-frankja@linux.ibm.com> References: <20220920073035.29201-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: tc2B8TqH474PiwTdDXPCMBFUjMUVg20g X-Proofpoint-GUID: oqQ107RqKzza2rxaZlsUss7rVw8Ha4ov X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 mlxscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 adultscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200045 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr Upcoming changes will add more arguments to genprotimg. To avoid duplicating this logic, move the arguments to genprotimg to a variable. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20220909121453.202548-2-nrb@linux.ibm.com Message-Id: <20220909121453.202548-2-nrb@linux.ibm.com> Signed-off-by: Janosch Frank --- s390x/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/s390x/Makefile b/s390x/Makefile index 66415d0b..a3647689 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -167,11 +167,13 @@ $(SNIPPET_DIR)/c/%.hdr: $(SNIPPET_DIR)/c/%.gbin $(HOST_KEY_DOCUMENT) %.bin: %.elf $(OBJCOPY) -O binary $< $@ +genprotimg_args = --host-key-document $(HOST_KEY_DOCUMENT) --no-verify + %selftest.pv.bin: %selftest.bin $(HOST_KEY_DOCUMENT) $(patsubst %.pv.bin,%.parmfile,$@) - $(GENPROTIMG) --host-key-document $(HOST_KEY_DOCUMENT) --parmfile $(patsubst %.pv.bin,%.parmfile,$@) --no-verify --image $< -o $@ + $(GENPROTIMG) $(genprotimg_args) --parmfile $(patsubst %.pv.bin,%.parmfile,$@) --image $< -o $@ %.pv.bin: %.bin $(HOST_KEY_DOCUMENT) - $(GENPROTIMG) --host-key-document $(HOST_KEY_DOCUMENT) --no-verify --image $< -o $@ + $(GENPROTIMG) $(genprotimg_args) --image $< -o $@ $(snippet_asmlib): $$(patsubst %.o,%.S,$$@) $(asm-offsets) $(CC) $(CFLAGS) -c -nostdlib -o $@ $< From patchwork Tue Sep 20 07:30:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12981504 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 0D5DCECAAD8 for ; Tue, 20 Sep 2022 07:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230213AbiITHhV (ORCPT ); Tue, 20 Sep 2022 03:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbiITHhU (ORCPT ); Tue, 20 Sep 2022 03:37:20 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28CDA606B4; Tue, 20 Sep 2022 00:37:18 -0700 (PDT) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28K7JhFH003403; Tue, 20 Sep 2022 07:37:18 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=cD+v84j6lTvUofwhz5cILra8bqEbQk/dHqf+ffSrRZs=; b=WuJbhctw2vZ7L12jcxgQ0T+g5Kojbe2luyGsKpBzvI+G6CLR0aTFgbgPasr+eEJc/zeV 12dbkv1X+qC37swbh5oY6kA12KD693zyfQb9PuXPExCknCvurJzHaLPdPU/ITkKGEZHg 6tbNZqW4geVVBRahkEUUbpnruSmjBog0iFMOtu8FWjqeLoDaWUXssq3oAtiaVQNzaOzE 9kp40vcU/8baR9a1cid7mbkIEln4VBv4pLGq3TB1uyepxvqShSLEkozQN6TueqQ+YdVv ONLUj5Fcrp/XF+YIVv2qpXG9uzc40VkpCB7rp4sHgqjV+lYY+Qfz20EyL+vrXsf286jV iw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jq91j8eqy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:37:17 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 28K7LUxF008920; Tue, 20 Sep 2022 07:37:17 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 3jq91j8epb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:37:17 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 28K7LoLf026014; Tue, 20 Sep 2022 07:32:15 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06fra.de.ibm.com with ESMTP id 3jn5ghjk08-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 20 Sep 2022 07:32:14 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 28K7WBtJ48562556 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Sep 2022 07:32:12 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCEC711C050; Tue, 20 Sep 2022 07:32:11 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E156511C04A; Tue, 20 Sep 2022 07:32:10 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Sep 2022 07:32:10 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@de.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 11/11] s390x: create persistent comm-key Date: Tue, 20 Sep 2022 07:30:35 +0000 Message-Id: <20220920073035.29201-12-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920073035.29201-1-frankja@linux.ibm.com> References: <20220920073035.29201-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: qpVH3qM3mSUC9N5mePuU9xNyUC3kT6E1 X-Proofpoint-ORIG-GUID: IwYVTwR21lqrkOoQ845O73F4THGX4kw2 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-20_02,2022-09-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 priorityscore=1501 spamscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2209200045 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr To decrypt the dump of a PV guest, the comm-key (CCK) is required. Until now, no comm-key was provided to genprotimg, therefore decrypting the dump of a kvm-unit-test under PV was not possible. This patch makes sure that we create a random CCK if there's no $(TEST_DIR)/comm.key file. Also allow dumping of PV tests by passing the appropriate PCF to genprotimg (bit 34). --x-pcf is used to be compatible with older genprotimg versions, which don't support --enable-dump. 0xe0 is the default PCF value and only bit 34 is added. Unfortunately, recent versions of genprotimg removed the --x-comm-key argument which was used by older versions to specify the CCK. To support these versions, we need to parse the genprotimg help output and decide which argument to use. Signed-off-by: Nico Boehr Reviewed-by: Janosch Frank Link: https://lore.kernel.org/r/20220909121453.202548-3-nrb@linux.ibm.com Message-Id: <20220909121453.202548-3-nrb@linux.ibm.com> Signed-off-by: Janosch Frank --- s390x/Makefile | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/s390x/Makefile b/s390x/Makefile index a3647689..649486f2 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -164,15 +164,33 @@ $(SNIPPET_DIR)/c/%.hdr: $(SNIPPET_DIR)/c/%.gbin $(HOST_KEY_DOCUMENT) $(RM) $(@:.elf=.aux.o) @chmod a-x $@ +# Secure Execution Customer Communication Key file +# 32 bytes of key material, uses existing one if available +comm-key = $(TEST_DIR)/comm.key +$(comm-key): + dd if=/dev/urandom of=$@ bs=32 count=1 status=none + %.bin: %.elf $(OBJCOPY) -O binary $< $@ -genprotimg_args = --host-key-document $(HOST_KEY_DOCUMENT) --no-verify +# The genprotimg arguments for the cck changed over time so we need to +# figure out which argument to use in order to set the cck +GENPROTIMG_HAS_COMM_KEY = $(shell $(GENPROTIMG) --help | grep -q -- --comm-key && echo yes) +ifeq ($(GENPROTIMG_HAS_COMM_KEY),yes) + GENPROTIMG_COMM_KEY = --comm-key $(comm-key) +else + GENPROTIMG_COMM_KEY = --x-comm-key $(comm-key) +endif -%selftest.pv.bin: %selftest.bin $(HOST_KEY_DOCUMENT) $(patsubst %.pv.bin,%.parmfile,$@) +# use x-pcf to be compatible with old genprotimg versions +# allow dumping + PCKMO +genprotimg_pcf = 0x200000e0 +genprotimg_args = --host-key-document $(HOST_KEY_DOCUMENT) --no-verify $(GENPROTIMG_COMM_KEY) --x-pcf $(genprotimg_pcf) + +%selftest.pv.bin: %selftest.bin $(HOST_KEY_DOCUMENT) $(patsubst %.pv.bin,%.parmfile,$@) $(comm-key) $(GENPROTIMG) $(genprotimg_args) --parmfile $(patsubst %.pv.bin,%.parmfile,$@) --image $< -o $@ -%.pv.bin: %.bin $(HOST_KEY_DOCUMENT) +%.pv.bin: %.bin $(HOST_KEY_DOCUMENT) $(comm-key) $(GENPROTIMG) $(genprotimg_args) --image $< -o $@ $(snippet_asmlib): $$(patsubst %.o,%.S,$$@) $(asm-offsets) @@ -180,7 +198,7 @@ $(snippet_asmlib): $$(patsubst %.o,%.S,$$@) $(asm-offsets) arch_clean: asm_offsets_clean - $(RM) $(TEST_DIR)/*.{o,elf,bin} $(SNIPPET_DIR)/*/*.{o,elf,*bin,*obj,hdr} $(SNIPPET_DIR)/asm/.*.d $(TEST_DIR)/.*.d lib/s390x/.*.d + $(RM) $(TEST_DIR)/*.{o,elf,bin} $(SNIPPET_DIR)/*/*.{o,elf,*bin,*obj,hdr} $(SNIPPET_DIR)/asm/.*.d $(TEST_DIR)/.*.d lib/s390x/.*.d $(comm-key) generated-files = $(asm-offsets) $(tests:.elf=.o) $(asmlib) $(cflatobjs): $(generated-files)