From patchwork Tue May 30 12:52:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 13259986 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 CCCA4C77B73 for ; Tue, 30 May 2023 12:53:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232170AbjE3Mxc (ORCPT ); Tue, 30 May 2023 08:53:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232377AbjE3Mx3 (ORCPT ); Tue, 30 May 2023 08:53:29 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B74E4E62; Tue, 30 May 2023 05:53:05 -0700 (PDT) Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34UBe1p0001412; Tue, 30 May 2023 12:52:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=3/MUmf6RVrTbJWhz8ZWo7HLQ56Zo6u83ZOAVpDo2Mf0=; b=AcPzAI1CXd8SGhk2/Q/LnfIVDHK0mOS5ivEK2nKvFPS+gy48faXzJl3NgOyM89zn2mAC 7og/foFRQDYUtpamggKfZ2BFyvc0G8Jesphl+nQpBDAKJvuj8A8/owtPLdRu8+WP+qMw 2YeOcGnNxZLslevrmrlM5qpCDghnoJPJguWgeg0gMwt48LhMxTuPIRIyC5sdtQOYmSxA 9P56DcwJCj0YOiXjUSq7ZdFbnXIvw0BvzkeP0xmtKeiJ4HMA9RH1TyvZVFF54g2iq13o IQDhCAh4NRE3J7v4vWDgEweC0/FdBPVlkI8hDJzXpSchJdBFPVHX4WaVzZU+54LD3txT IA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qwbst1ygt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 May 2023 12:52:50 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 34UBvBgp025142; Tue, 30 May 2023 12:52:50 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qwbst1yg0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 May 2023 12:52:50 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 34U4TtWN032765; Tue, 30 May 2023 12:52:48 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma01fra.de.ibm.com (PPS) with ESMTPS id 3qu9g518hk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 May 2023 12:52:48 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 34UCqiP642533244 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 May 2023 12:52:44 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8BD5A2004D; Tue, 30 May 2023 12:52:44 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 548212004E; Tue, 30 May 2023 12:52:44 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com (unknown [9.152.222.242]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 30 May 2023 12:52:44 +0000 (GMT) From: Pierre Morel To: linux-s390@vger.kernel.org Cc: frankja@linux.ibm.com, thuth@redhat.com, kvm@vger.kernel.org, imbrenda@linux.ibm.com, david@redhat.com, nrb@linux.ibm.com, nsg@linux.ibm.com, cohuck@redhat.com Subject: [kvm-unit-tests PATCH v4 1/2] s390x: sclp: consider monoprocessor on read_info error Date: Tue, 30 May 2023 14:52:42 +0200 Message-Id: <20230530125243.18883-2-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230530125243.18883-1-pmorel@linux.ibm.com> References: <20230530125243.18883-1-pmorel@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: oqd37jY6Pk4FguE9c8VFciny0ogKBxKt X-Proofpoint-GUID: GPljcLOhVgRjLn9hSezBQYXpW7X0-VDv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-30_08,2023-05-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 mlxscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 adultscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305300103 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org A test would hang if an abort happens before SCLP Read SCP Information has completed. Signed-off-by: Pierre Morel Reviewed-by: Nico Boehr --- lib/s390x/sclp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c index acdc8a9..34a31da 100644 --- a/lib/s390x/sclp.c +++ b/lib/s390x/sclp.c @@ -119,8 +119,15 @@ void sclp_read_info(void) int sclp_get_cpu_num(void) { - assert(read_info); - return read_info->entries_cpu; + if (read_info) + return read_info->entries_cpu; + /* + * If we fail here and read_info has not being set, + * it means we failed early and we try to abort the test. + * We need to return at least one CPU, and obviously we have + * at least one, for the smp_teardown to correctly work. + */ + return 1; } CPUEntry *sclp_get_cpu_entries(void) From patchwork Tue May 30 12:52:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 13259988 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 32673C7EE23 for ; Tue, 30 May 2023 12:53:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232399AbjE3Mxg (ORCPT ); Tue, 30 May 2023 08:53:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232392AbjE3Mx3 (ORCPT ); Tue, 30 May 2023 08:53:29 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10AA1FC; Tue, 30 May 2023 05:53:05 -0700 (PDT) Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34UCOgEL004816; Tue, 30 May 2023 12:52:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=AwsM0KHoRY8ND2CYmfVHWD9IMFqjKUjDnDev17HtS10=; b=PCUMGLDngW85WYyeJvXyabC0cgMNC6vuSkvFPDXcOljqAxaVHF8m3tazseTN8gkCqekE GStsouXORSgV6PfFxgCLys5K++ylrYuNOR8vhyYElBp4f4GA/qjc7NXB2oVk9Adpjcgz tUF+yKlIzmq7+LZ2rytAG3+TQ3q4g9McT8uU9lcm+LbTvYkWWaGDBD4d+UQMROxIviLO kRqtd4bA5p/GNmRj+6y7UUsm4wrSJKNp7G8gaR6LgJXPc0Cwo5X72dg4v/P466bszXRy 4pLvxICZJVjxTC6r6hOcg8e9CgHmi7ttCR71NaT0UxtE6njRxhjrAGQxhb93DocHBLpT Vw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qwh4g8wmn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 May 2023 12:52:50 +0000 Received: from m0353723.ppops.net (m0353723.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 34UCfZnP021102; Tue, 30 May 2023 12:52:50 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qwh4g8wkw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 May 2023 12:52:50 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 34UC4m5u008343; Tue, 30 May 2023 12:52:48 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma05fra.de.ibm.com (PPS) with ESMTPS id 3qu9g598fh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 May 2023 12:52:48 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 34UCqivp34013948 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 May 2023 12:52:44 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD8852004B; Tue, 30 May 2023 12:52:44 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 92C222004F; Tue, 30 May 2023 12:52:44 +0000 (GMT) Received: from li-c6ac47cc-293c-11b2-a85c-d421c8e4747b.ibm.com (unknown [9.152.222.242]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 30 May 2023 12:52:44 +0000 (GMT) From: Pierre Morel To: linux-s390@vger.kernel.org Cc: frankja@linux.ibm.com, thuth@redhat.com, kvm@vger.kernel.org, imbrenda@linux.ibm.com, david@redhat.com, nrb@linux.ibm.com, nsg@linux.ibm.com, cohuck@redhat.com Subject: [kvm-unit-tests PATCH v4 2/2] s390x: sclp: Implement SCLP_RC_INSUFFICIENT_SCCB_LENGTH Date: Tue, 30 May 2023 14:52:43 +0200 Message-Id: <20230530125243.18883-3-pmorel@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230530125243.18883-1-pmorel@linux.ibm.com> References: <20230530125243.18883-1-pmorel@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Q-x_K94qSmGRRMktU4ap02eezBwXmktv X-Proofpoint-GUID: YGyGNFHWSVSBQSm7Sz-k9bSgudyVY4Kd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-30_08,2023-05-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305300103 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org If SCLP_CMDW_READ_SCP_INFO fails due to a short buffer, retry with a greater buffer. Signed-off-by: Pierre Morel --- lib/s390x/sclp.c | 58 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c index 34a31da..9d51ca4 100644 --- a/lib/s390x/sclp.c +++ b/lib/s390x/sclp.c @@ -17,13 +17,14 @@ #include "sclp.h" #include #include +#include extern unsigned long stacktop; static uint64_t storage_increment_size; static uint64_t max_ram_size; static uint64_t ram_size; -char _read_info[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); +char _read_info[2 * PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); static ReadInfo *read_info; struct sclp_facilities sclp_facilities; @@ -89,10 +90,41 @@ void sclp_clear_busy(void) spin_unlock(&sclp_lock); } -static void sclp_read_scp_info(ReadInfo *ri, int length) +static bool sclp_read_scp_info_extended(unsigned int command, ReadInfo *ri) +{ + int cc; + + if (!test_facility(140)) { + report_abort("S390_FEAT_EXTENDED_LENGTH_SCCB missing"); + return false; + } + if (ri->h.length > (2 * PAGE_SIZE)) { + report_abort("SCLP_READ_INFO expected size too big"); + return false; + } + + sclp_mark_busy(); + memset(&ri->h, 0, sizeof(ri->h)); + ri->h.length = 2 * PAGE_SIZE; + + cc = sclp_service_call(command, ri); + if (cc) { + report_abort("SCLP_READ_INFO error"); + return false; + } + if (ri->h.response_code != SCLP_RC_NORMAL_READ_COMPLETION) { + report_abort("SCLP_READ_INFO error %02x", ri->h.response_code); + return false; + } + + return true; +} + +static void sclp_read_scp_info(ReadInfo *ri) { unsigned int commands[] = { SCLP_CMDW_READ_SCP_INFO_FORCED, SCLP_CMDW_READ_SCP_INFO }; + int length = PAGE_SIZE; int i, cc; for (i = 0; i < ARRAY_SIZE(commands); i++) { @@ -101,19 +133,29 @@ static void sclp_read_scp_info(ReadInfo *ri, int length) ri->h.length = length; cc = sclp_service_call(commands[i], ri); - if (cc) - break; - if (ri->h.response_code == SCLP_RC_NORMAL_READ_COMPLETION) + if (cc) { + report_abort("SCLP_READ_INFO error"); return; - if (ri->h.response_code != SCLP_RC_INVALID_SCLP_COMMAND) + } + + switch (ri->h.response_code) { + case SCLP_RC_NORMAL_READ_COMPLETION: + return; + case SCLP_RC_INVALID_SCLP_COMMAND: break; + case SCLP_RC_INSUFFICIENT_SCCB_LENGTH: + sclp_read_scp_info_extended(commands[i], ri); + return; + default: + report_abort("READ_SCP_INFO failed"); + return; + } } - report_abort("READ_SCP_INFO failed"); } void sclp_read_info(void) { - sclp_read_scp_info((void *)_read_info, SCCB_SIZE); + sclp_read_scp_info((void *)_read_info); read_info = (ReadInfo *)_read_info; }