From patchwork Fri Apr 1 11:15:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798159 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 3C36CC433F5 for ; Fri, 1 Apr 2022 11:16:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345385AbiDALSd (ORCPT ); Fri, 1 Apr 2022 07:18:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345491AbiDALSV (ORCPT ); Fri, 1 Apr 2022 07:18:21 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B241183833 for ; Fri, 1 Apr 2022 04:16:32 -0700 (PDT) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2319nshx006693 for ; Fri, 1 Apr 2022 11:16:32 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=wzL5xJwNsFDnfnxbmIxwSXPBJVGThk0vkNbAHvvPNjQ=; b=otxd2NKadKkC+VSYok9EnaHIVActrhqdkxhHF3m4c5KZ96IGA9cz8K5wKe8y8ofFGw8K uMpVOCm7xsyyzQighPFtXqh18C/NVpWP9yc2zJrqA0h/iq2WNKd5afofTqh8d4zcbd7U gp+TEFQOZgIIJ5rypLrf+bAlWhuPm27skqDAwkPjHVotYyeGAJiFFvRLbUq24aceU2Sy Mb2fiv0Qfbwu3bgmYrUvydFgNWb3zVD+8zldw+4mb8HZTzny2tlAYsSLrvDP8C7cmXQQ +pbK2LG6RckOqSg3AhY/IzuPtZjkEphifiOZB4GVnqlRiZObU1RpNJ2ih+TOaUxbWGzq kA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y3y1rmc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:32 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231BGHv3021523 for ; Fri, 1 Apr 2022 11:16:31 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y3y1rkn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:31 +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 231B87Cd013029; Fri, 1 Apr 2022 11:16:29 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 3f1tf9mv09-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:29 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231B4MXT23265708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:04:22 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC2054C06D; Fri, 1 Apr 2022 11:16:25 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C7A74C06F; Fri, 1 Apr 2022 11:16:25 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:25 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Eric Farman , Nico Boehr Subject: [kvm-unit-tests GIT PULL 01/27] lib: s390x: smp: Retry SIGP SENSE on CC2 Date: Fri, 1 Apr 2022 13:15:54 +0200 Message-Id: <20220401111620.366435-2-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: D51sKuzq_mNXjARm6fiyf9OQn2qCXf-E X-Proofpoint-ORIG-GUID: 3Tlu9RaiOHo9zExxGXLVGMkbItRwC7Rw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 impostorscore=0 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Eric Farman The routine smp_cpu_stopped() issues a SIGP SENSE, and returns true if it received a CC1 (STATUS STORED) with the STOPPED or CHECK STOP bits enabled. Otherwise, it returns false. This is misleading, because a CC2 (BUSY) merely indicates that the order code could not be processed, not that the CPU is operating. It could be operating but in the process of being stopped. Convert the invocation of the SIGP SENSE to retry when a CC2 is received, so we get a more definitive answer. Signed-off-by: Eric Farman Reviewed-by: Janosch Frank Reviewed-by: Nico Boehr Reviewed-by: Claudio Imbrenda Reviewed-by: Thomas Huth Signed-off-by: Claudio Imbrenda --- lib/s390x/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c index 46e1b022..368d6add 100644 --- a/lib/s390x/smp.c +++ b/lib/s390x/smp.c @@ -78,7 +78,7 @@ bool smp_cpu_stopped(uint16_t idx) { uint32_t status; - if (smp_sigp(idx, SIGP_SENSE, 0, &status) != SIGP_CC_STATUS_STORED) + if (smp_sigp_retry(idx, SIGP_SENSE, 0, &status) != SIGP_CC_STATUS_STORED) return false; return !!(status & (SIGP_STATUS_CHECK_STOP|SIGP_STATUS_STOPPED)); } From patchwork Fri Apr 1 11:15:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798163 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 A0757C4332F for ; Fri, 1 Apr 2022 11:16:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345407AbiDALSk (ORCPT ); Fri, 1 Apr 2022 07:18:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345495AbiDALSW (ORCPT ); Fri, 1 Apr 2022 07:18:22 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C01D5181166 for ; Fri, 1 Apr 2022 04:16:33 -0700 (PDT) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 231BG7o8005658 for ; Fri, 1 Apr 2022 11:16:33 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=hmu+uZPEFlyEZgS+R2kC74MBT07MScaH69CYmFbypYc=; b=erA1m+a2oIP8W9lvQmsPqlPJONzU5HqXbIngr4nAiaXZVfqgKbvJ9tCH0JPv3Xmvv/Nn IGixJt8pI42uLwMNguhTDSAw5OFP3QfwGGG15OQfqneS03ptJrWOkm4ALkOY7sdiFI3s 4x2aeNPSCos9HMn0p5XPptk+D4BKxTbW4MiH0RdnS+N5M97/UM2toAbk2ZSumKj1L8LN 5Uz6S0oqz9q7OjVYBpmZmsTaQBrJKPYjG1amWQraGTjeH/+B+uPA5c7l7TgXasay2o30 wjceDibcwgiitoSmCggoVMXJBcdeASgxY4nrSXUIRz7iHpF2I2oSTD7qhl4yJKv7J2Sa +A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5wpv3k53-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:32 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231BEubL013527 for ; Fri, 1 Apr 2022 11:16:32 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5wpv3k4a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:32 +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 231B7ene012923; Fri, 1 Apr 2022 11:16:30 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03ams.nl.ibm.com with ESMTP id 3f1tf9mv0a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:30 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGQGp14811578 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:27 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 571F84C05C; Fri, 1 Apr 2022 11:16:26 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 083874C06E; Fri, 1 Apr 2022 11:16:26 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:25 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Eric Farman , Nico Boehr Subject: [kvm-unit-tests GIT PULL 02/27] s390x: smp: Test SIGP RESTART against stopped CPU Date: Fri, 1 Apr 2022 13:15:55 +0200 Message-Id: <20220401111620.366435-3-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: dDNRKvefsDgM_aa4iMrMH3eq4CEROiXO X-Proofpoint-GUID: pMOM7Kwgiugm6W2BbsvkcbcEJJq6_GSs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 priorityscore=1501 mlxscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Eric Farman test_restart() makes two smp_cpu_restart() calls against CPU 1. It claims to perform both of them against running (operating) CPUs, but the first invocation tries to achieve this by calling smp_cpu_stop() to CPU 0. This will be rejected by the library. Let's fix this by making the first restart operate on a stopped CPU, to ensure it gets test coverage instead of relying on other callers. Fixes: 166da884d ("s390x: smp: Add restart when running test") Signed-off-by: Eric Farman Reviewed-by: Janosch Frank Reviewed-by: Nico Boehr Reviewed-by: Claudio Imbrenda Reviewed-by: Thomas Huth Signed-off-by: Claudio Imbrenda --- s390x/smp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/s390x/smp.c b/s390x/smp.c index 068ac74d..2f4af820 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -50,10 +50,6 @@ static void test_start(void) report_pass("start"); } -/* - * Does only test restart when the target is running. - * The other tests do restarts when stopped multiple times already. - */ static void test_restart(void) { struct cpu *cpu = smp_cpu_from_idx(1); @@ -62,8 +58,8 @@ static void test_restart(void) lc->restart_new_psw.mask = extract_psw_mask(); lc->restart_new_psw.addr = (unsigned long)test_func; - /* Make sure cpu is running */ - smp_cpu_stop(0); + /* Make sure cpu is stopped */ + smp_cpu_stop(1); set_flag(0); smp_cpu_restart(1); wait_for_flag(); From patchwork Fri Apr 1 11:15:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798161 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 37B08C433F5 for ; Fri, 1 Apr 2022 11:16:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345397AbiDALSh (ORCPT ); Fri, 1 Apr 2022 07:18:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345494AbiDALSW (ORCPT ); Fri, 1 Apr 2022 07:18:22 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11E1518179A for ; Fri, 1 Apr 2022 04:16:34 -0700 (PDT) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2318lOcL005268 for ; Fri, 1 Apr 2022 11:16:33 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-type : content-transfer-encoding; s=pp1; bh=UK6vtJOY+vgwnxNapX6cnwFqud7CAyA0P11mjVkBMu0=; b=quKJOPVHFAZ5uT2JIw7JLvTKXan/s64XirmrPfmLuqSjoV7afh7a3DBsXANaAORV2jfH VSRvNMY1pm9xZ0NuZKVRRT4LXJ+VC/qoYgtb15x2P+brUaGYC7oOzfDDhVdjmzGldXOh R3nUzniUgLlCmel56Kp+o8Z55WvF/qh1M2nppaXbXRy15y7utMcAWdgs6tyGD1w1CJ8E XH+SLOsAJVb48sqz+QuMvD0jV2028SbWlm/xsYYJVqqnpAMtFw25Uo2xnfyLWmVAfHMI cNNRol+Lh8PqabZyLim2XHt5FaOXxECTSm8pOLYIY0cyCLtxnupxhuKfRlBG3lsxUVJf Aw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5x6gauns-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:33 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231BBENM009104 for ; Fri, 1 Apr 2022 11:16:33 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5x6gaumx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:33 +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 231B908T023393; Fri, 1 Apr 2022 11:16:30 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma01fra.de.ibm.com with ESMTP id 3f1tf8tvrt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:30 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGRhU24510834 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:27 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CE0774C059; Fri, 1 Apr 2022 11:16:26 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 74D264C066; Fri, 1 Apr 2022 11:16:26 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:26 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Eric Farman , Nico Boehr Subject: [kvm-unit-tests GIT PULL 03/27] s390x: smp: Fix checks for SIGP STOP STORE STATUS Date: Fri, 1 Apr 2022 13:15:56 +0200 Message-Id: <20220401111620.366435-4-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ce10IeXswsDw6Vl94kIolq27hnFwhXzj X-Proofpoint-GUID: c96olr7vvSA8B0l3pQYeVM9wc9fKP7Kh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 clxscore=1015 mlxlogscore=743 spamscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Eric Farman In the routine test_stop_store_status(), the "running" part of the test checks a few of the fields in lowcore (to verify the "STORE STATUS" part of the SIGP order), and then ensures that the CPU has stopped. But this is backwards, according to the Principles of Operation: The addressed CPU performs the stop function, fol- lowed by the store-status operation (see “Store Sta- tus” on page 4-82). If the CPU were not yet stopped, the contents of the lowcore fields would be unpredictable. It works today because the library functions wait on the stop function, so the CPU is stopped by the time it comes back. Let's first check that the CPU is stopped first, just to be clear. While here, add the same check to the second part of the test, even though the CPU is explicitly stopped prior to the SIGP. Fixes: fc67b07a4 ("s390x: smp: Test stop and store status on a running and stopped cpu") Signed-off-by: Eric Farman Reviewed-by: Claudio Imbrenda Reviewed-by: Nico Boehr Signed-off-by: Claudio Imbrenda --- s390x/smp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/s390x/smp.c b/s390x/smp.c index 2f4af820..50811bd0 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -98,9 +98,9 @@ static void test_stop_store_status(void) lc->grs_sa[15] = 0; smp_cpu_stop_store_status(1); mb(); + report(smp_cpu_stopped(1), "cpu stopped"); report(lc->prefix_sa == (uint32_t)(uintptr_t)cpu->lowcore, "prefix"); report(lc->grs_sa[15], "stack"); - report(smp_cpu_stopped(1), "cpu stopped"); report_prefix_pop(); report_prefix_push("stopped"); @@ -108,6 +108,7 @@ static void test_stop_store_status(void) lc->grs_sa[15] = 0; smp_cpu_stop_store_status(1); mb(); + report(smp_cpu_stopped(1), "cpu stopped"); report(lc->prefix_sa == (uint32_t)(uintptr_t)cpu->lowcore, "prefix"); report(lc->grs_sa[15], "stack"); report_prefix_pop(); From patchwork Fri Apr 1 11:15:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798156 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 84F75C433FE for ; Fri, 1 Apr 2022 11:16:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345419AbiDALS1 (ORCPT ); Fri, 1 Apr 2022 07:18:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345501AbiDALSX (ORCPT ); Fri, 1 Apr 2022 07:18:23 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 207D31834DF for ; Fri, 1 Apr 2022 04:16:34 -0700 (PDT) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2319CfX1016888 for ; Fri, 1 Apr 2022 11:16:33 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=uEsUI9hLlb7FWv7px1Ld0V8EmdRqzllBHKBonC6u39c=; b=Rb6iUkBSbAbjCHCR8OIHystV1ajxhhMc7Px7QSkB6Qdg1AN7afppZ9o/4pQieYb+Ueck 43M7pSs6DjDhpcz7xnxA+DXWddgOVaWco4idOFGiPHVhOMS/ACxcsV1g5I1GW6YHklCL 2nhEc31Ig5x/wuOZToleeyLFidi6ZAAEa6T1wIHF/1nihz4e4T5yzcxplpvQl/iacjuE SpLq9TIRoLnp0emnW6hUUwpxmT+y1TvYOwXt/jFsqmnByCIJId0qqWuHBHKi8jW+Vxyh s0bHCHGz5I7ugPsyT65q6CxtgtFr3oLbD3LwQjP3dbVy3r4YnSiAsNheKVeKVJ21Opo/ qQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3f57tpq1jq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:33 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231Avak6011092 for ; Fri, 1 Apr 2022 11:16:32 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 3f57tpq1ht-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:32 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 231B7P0H015859; Fri, 1 Apr 2022 11:16:30 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma05fra.de.ibm.com with ESMTP id 3f1tf92w96-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:30 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGRcg51118338 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:27 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 404914C06A; Fri, 1 Apr 2022 11:16:27 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E208B4C064; Fri, 1 Apr 2022 11:16:26 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:26 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Eric Farman , Nico Boehr Subject: [kvm-unit-tests GIT PULL 04/27] s390x: smp: Create and use a non-waiting CPU stop Date: Fri, 1 Apr 2022 13:15:57 +0200 Message-Id: <20220401111620.366435-5-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: bgMsSCJ_3goULiD0lxAPk_xWkoEf40yI X-Proofpoint-ORIG-GUID: Yfr6Bbf8SXqvJShGJkA8zBsBTTTglkyH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 priorityscore=1501 adultscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Eric Farman When stopping a CPU, kvm-unit-tests serializes/waits for everything to finish, in order to get a consistent result whenever those functions are used. But to test the SIGP STOP itself, these additional measures could mask other problems. For example, did the STOP work, or is the CPU still operating? Let's create a non-waiting SIGP STOP and use it here, to ensure that the CPU is correctly stopped. A smp_cpu_stopped() call will still be used to see that the SIGP STOP has been processed, and the state of the CPU can be used to determine whether the test passes/fails. Signed-off-by: Eric Farman Reviewed-by: Claudio Imbrenda Reviewed-by: Nico Boehr Signed-off-by: Claudio Imbrenda --- lib/s390x/smp.h | 1 + lib/s390x/smp.c | 27 +++++++++++++++++++++++++++ s390x/smp.c | 17 +++++++++-------- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/lib/s390x/smp.h b/lib/s390x/smp.h index 1e69a7de..bae03dfd 100644 --- a/lib/s390x/smp.h +++ b/lib/s390x/smp.h @@ -44,6 +44,7 @@ bool smp_sense_running_status(uint16_t idx); int smp_cpu_restart(uint16_t idx); int smp_cpu_start(uint16_t idx, struct psw psw); int smp_cpu_stop(uint16_t idx); +int smp_cpu_stop_nowait(uint16_t idx); int smp_cpu_stop_store_status(uint16_t idx); int smp_cpu_destroy(uint16_t idx); int smp_cpu_setup(uint16_t idx, struct psw psw); diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c index 368d6add..b69c0e09 100644 --- a/lib/s390x/smp.c +++ b/lib/s390x/smp.c @@ -119,6 +119,33 @@ int smp_cpu_stop(uint16_t idx) return rc; } +/* + * Functionally equivalent to smp_cpu_stop(), but without the + * elements that wait/serialize matters itself. + * Used to see if KVM itself is serialized correctly. + */ +int smp_cpu_stop_nowait(uint16_t idx) +{ + check_idx(idx); + + /* refuse to work on the boot CPU */ + if (idx == 0) + return -1; + + spin_lock(&lock); + + /* Don't suppress a CC2 with sigp_retry() */ + if (sigp(cpus[idx].addr, SIGP_STOP, 0, NULL)) { + spin_unlock(&lock); + return -1; + } + + cpus[idx].active = false; + spin_unlock(&lock); + + return 0; +} + int smp_cpu_stop_store_status(uint16_t idx) { int rc; diff --git a/s390x/smp.c b/s390x/smp.c index 50811bd0..f70a9c54 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -76,14 +76,15 @@ static void test_restart(void) static void test_stop(void) { - smp_cpu_stop(1); - /* - * The smp library waits for the CPU to shut down, but let's - * also do it here, so we don't rely on the library - * implementation - */ - while (!smp_cpu_stopped(1)) {} - report_pass("stop"); + int rc; + + report_prefix_push("stop"); + + rc = smp_cpu_stop_nowait(1); + report(!rc, "return code"); + report(smp_cpu_stopped(1), "cpu stopped"); + + report_prefix_pop(); } static void test_stop_store_status(void) From patchwork Fri Apr 1 11:15:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798158 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 32064C433EF for ; Fri, 1 Apr 2022 11:16:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345443AbiDALSb (ORCPT ); Fri, 1 Apr 2022 07:18:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345507AbiDALSY (ORCPT ); Fri, 1 Apr 2022 07:18:24 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 847E4184608 for ; Fri, 1 Apr 2022 04:16:34 -0700 (PDT) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 231BDIPe022732 for ; Fri, 1 Apr 2022 11:16:33 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=GGxeMJmfpJ3wIkc5x2jkg+bl3Tmillm6T7pUK+VdpvI=; b=bqX27WksK3+9wfp0wql+C+5pxwnSw6gspN57imr/97HerwXNYsBu8VUukIcT85OGxSYW FkRJahW8WJJPoBnfTKqDNHx8USocnTQ1xTp+TEWKUZc/AqWynwuVjdzQM+YLYb+SjJz2 yqy884NzflXHXE7nxl8dQ6S8Z9nKF2GJYwF+ca0E9DbFQ7Q3DHaIghU9rDugZosFGO2l tvqbvBzqaShzBOpqbpcpRvM0G1QhpKCGp4AvRB3OcrEwaJROA6h8JNAHMoUwbGIB/ZY9 tXnJm67QVrW6QprLwkxUZXtdP1Y9eCcRaZ4iJEncDCYc0rxK/ZoLkhMZexRUH6zDQ5IY jw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3f60awr24a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:33 +0000 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231BG8lO000888 for ; Fri, 1 Apr 2022 11:16:33 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 3f60awr23m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:33 +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 231B8dLk027950; Fri, 1 Apr 2022 11:16:31 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 3f1tf94v65-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:31 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGRPS49217940 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:28 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BB8C54C062; Fri, 1 Apr 2022 11:16:27 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5E95D4C040; Fri, 1 Apr 2022 11:16:27 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:27 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Eric Farman , Nico Boehr Subject: [kvm-unit-tests GIT PULL 05/27] s390x: smp: Create and use a non-waiting CPU restart Date: Fri, 1 Apr 2022 13:15:58 +0200 Message-Id: <20220401111620.366435-6-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: mOhkDGmFaBPx3vvjO-H-q9pB2odJ80oU X-Proofpoint-GUID: MC0K5vMYf6Wj-xiqp_YJzkSWh9SGbcaO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 mlxscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Eric Farman The kvm-unit-tests infrastructure for a CPU restart waits for the SIGP RESTART to complete. In order to test the restart itself, create a variation that does not wait, and test the state of the CPU directly. While here, add some better report prefixes/messages, to clarify which condition is being examined (similar to test_stop_store_status()). Signed-off-by: Eric Farman Reviewed-by: Janosch Frank Reviewed-by: Nico Boehr Signed-off-by: Claudio Imbrenda --- lib/s390x/smp.h | 1 + lib/s390x/smp.c | 24 ++++++++++++++++++++++++ s390x/smp.c | 21 ++++++++++++++++++--- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/lib/s390x/smp.h b/lib/s390x/smp.h index bae03dfd..24a0e2e0 100644 --- a/lib/s390x/smp.h +++ b/lib/s390x/smp.h @@ -42,6 +42,7 @@ uint16_t smp_cpu_addr(uint16_t idx); bool smp_cpu_stopped(uint16_t idx); bool smp_sense_running_status(uint16_t idx); int smp_cpu_restart(uint16_t idx); +int smp_cpu_restart_nowait(uint16_t idx); int smp_cpu_start(uint16_t idx, struct psw psw); int smp_cpu_stop(uint16_t idx); int smp_cpu_stop_nowait(uint16_t idx); diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c index b69c0e09..5be29d36 100644 --- a/lib/s390x/smp.c +++ b/lib/s390x/smp.c @@ -194,6 +194,30 @@ int smp_cpu_restart(uint16_t idx) return rc; } +/* + * Functionally equivalent to smp_cpu_restart(), but without the + * elements that wait/serialize matters here in the test. + * Used to see if KVM itself is serialized correctly. + */ +int smp_cpu_restart_nowait(uint16_t idx) +{ + check_idx(idx); + + spin_lock(&lock); + + /* Don't suppress a CC2 with sigp_retry() */ + if (sigp(cpus[idx].addr, SIGP_RESTART, 0, NULL)) { + spin_unlock(&lock); + return -1; + } + + cpus[idx].active = true; + + spin_unlock(&lock); + + return 0; +} + int smp_cpu_start(uint16_t idx, struct psw psw) { int rc; diff --git a/s390x/smp.c b/s390x/smp.c index f70a9c54..913da155 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -54,6 +54,10 @@ static void test_restart(void) { struct cpu *cpu = smp_cpu_from_idx(1); struct lowcore *lc = cpu->lowcore; + int rc; + + report_prefix_push("restart"); + report_prefix_push("stopped"); lc->restart_new_psw.mask = extract_psw_mask(); lc->restart_new_psw.addr = (unsigned long)test_func; @@ -61,17 +65,28 @@ static void test_restart(void) /* Make sure cpu is stopped */ smp_cpu_stop(1); set_flag(0); - smp_cpu_restart(1); + rc = smp_cpu_restart_nowait(1); + report(!rc, "return code"); + report(!smp_cpu_stopped(1), "cpu started"); wait_for_flag(); + report_pass("test flag"); + + report_prefix_pop(); + report_prefix_push("running"); /* * Wait until cpu 1 has set the flag because it executed the * restart function. */ set_flag(0); - smp_cpu_restart(1); + rc = smp_cpu_restart_nowait(1); + report(!rc, "return code"); + report(!smp_cpu_stopped(1), "cpu started"); wait_for_flag(); - report_pass("restart while running"); + report_pass("test flag"); + + report_prefix_pop(); + report_prefix_pop(); } static void test_stop(void) From patchwork Fri Apr 1 11:15:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798160 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 C95C7C433F5 for ; Fri, 1 Apr 2022 11:16:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345449AbiDALSe (ORCPT ); Fri, 1 Apr 2022 07:18:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345504AbiDALSY (ORCPT ); Fri, 1 Apr 2022 07:18:24 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFDAF184614 for ; Fri, 1 Apr 2022 04:16:34 -0700 (PDT) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 231ABpVD003366 for ; Fri, 1 Apr 2022 11:16:34 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=yRY4+CHouMOU7fTDUqftfj0e7++cWzg5RHwO9Q0kL8g=; b=YnSgKXlMvNdplNrLULZS+GqDBK8M/2U9Q3aT3AkjuRm6WtXUi2rLyynQt29Eg70phdzV RoPEVWcOofFyijB02eqd1/0OOB1Y3fYvAW2I3hS+BmXwvaMv0WDGTG45p4pcTVSKcWWy piLtAuFos6tNd8YTDIj+GaASYL9ROju46ckHJRdbkSHCma6u+OW5brzmMmgqGGNOOrSR C1fGyNJgMnVwYJPUqbeas6oCQqfUsGtLy9oAB4BvvudR7b6TnrgwMG8G6FkTwIHTk8fK Q0Aq2QRsWjcWgYkNaXDZOkjpnOIPQROd5BceiophJlAMueSk97geq91WA+WalCIGrKKM dA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5ye617as-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:33 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231BGXYw025876 for ; Fri, 1 Apr 2022 11:16:33 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5ye617a7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:33 +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 231B7kp9019698; Fri, 1 Apr 2022 11:16:31 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06ams.nl.ibm.com with ESMTP id 3f3rs3qumu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:31 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGSxC21758292 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:28 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3073F4C062; Fri, 1 Apr 2022 11:16:28 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CE8724C06F; Fri, 1 Apr 2022 11:16:27 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:27 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Eric Farman , Nico Boehr Subject: [kvm-unit-tests GIT PULL 06/27] lib: s390x: smp: Remove smp_sigp_retry Date: Fri, 1 Apr 2022 13:15:59 +0200 Message-Id: <20220401111620.366435-7-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 2hACPH3frWZAUPmshX7STc6umcoKgpED X-Proofpoint-GUID: Lg05tM5PlscvopZLx3V_prvx0kX_zcKQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 mlxlogscore=999 mlxscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Eric Farman The SIGP instruction presents a CC0 when an order is accepted, though the work for the order may be performed asynchronously. While any such work is outstanding, nearly any other SIGP order sent to the same CPU will be returned with a CC2. Currently, there are two library functions that perform a SIGP, one which retries a SIGP that gets a CC2, and one which doesn't. In practice, the users of this functionality want the CC2 to be handled by the library itself, rather than determine whether it needs to retry the request or not. To avoid confusion, let's convert the smp_sigp() routine to perform the sigp_retry() logic, and then convert any users of smp_sigp_retry() to smp_sigp(). This of course means that the external _retry() interface can be removed for simplicity. Signed-off-by: Eric Farman Reviewed-by: Nico Boehr Signed-off-by: Claudio Imbrenda --- lib/s390x/smp.h | 1 - lib/s390x/smp.c | 14 ++++---------- s390x/smp.c | 4 ++-- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/s390x/smp.h b/lib/s390x/smp.h index 24a0e2e0..df184cb8 100644 --- a/lib/s390x/smp.h +++ b/lib/s390x/smp.h @@ -52,6 +52,5 @@ int smp_cpu_setup(uint16_t idx, struct psw psw); void smp_teardown(void); void smp_setup(void); int smp_sigp(uint16_t idx, uint8_t order, unsigned long parm, uint32_t *status); -int smp_sigp_retry(uint16_t idx, uint8_t order, unsigned long parm, uint32_t *status); #endif diff --git a/lib/s390x/smp.c b/lib/s390x/smp.c index 5be29d36..a0495cd9 100644 --- a/lib/s390x/smp.c +++ b/lib/s390x/smp.c @@ -40,12 +40,6 @@ int smp_query_num_cpus(void) } int smp_sigp(uint16_t idx, uint8_t order, unsigned long parm, uint32_t *status) -{ - check_idx(idx); - return sigp(cpus[idx].addr, order, parm, status); -} - -int smp_sigp_retry(uint16_t idx, uint8_t order, unsigned long parm, uint32_t *status) { check_idx(idx); return sigp_retry(cpus[idx].addr, order, parm, status); @@ -78,7 +72,7 @@ bool smp_cpu_stopped(uint16_t idx) { uint32_t status; - if (smp_sigp_retry(idx, SIGP_SENSE, 0, &status) != SIGP_CC_STATUS_STORED) + if (smp_sigp(idx, SIGP_SENSE, 0, &status) != SIGP_CC_STATUS_STORED) return false; return !!(status & (SIGP_STATUS_CHECK_STOP|SIGP_STATUS_STOPPED)); } @@ -99,7 +93,7 @@ static int smp_cpu_stop_nolock(uint16_t idx, bool store) if (idx == 0) return -1; - if (smp_sigp_retry(idx, order, 0, NULL)) + if (smp_sigp(idx, order, 0, NULL)) return -1; while (!smp_cpu_stopped(idx)) @@ -251,11 +245,11 @@ static int smp_cpu_setup_nolock(uint16_t idx, struct psw psw) if (cpus[idx].active) return -1; - smp_sigp_retry(idx, SIGP_INITIAL_CPU_RESET, 0, NULL); + smp_sigp(idx, SIGP_INITIAL_CPU_RESET, 0, NULL); lc = alloc_pages_flags(1, AREA_DMA31); cpus[idx].lowcore = lc; - smp_sigp_retry(idx, SIGP_SET_PREFIX, (unsigned long )lc, NULL); + smp_sigp(idx, SIGP_SET_PREFIX, (unsigned long )lc, NULL); /* Copy all exception psws. */ memcpy(lc, cpus[0].lowcore, 512); diff --git a/s390x/smp.c b/s390x/smp.c index 913da155..81e02195 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -266,7 +266,7 @@ static void test_reset_initial(void) smp_cpu_start(1, psw); wait_for_flag(); - smp_sigp_retry(1, SIGP_INITIAL_CPU_RESET, 0, NULL); + smp_sigp(1, SIGP_INITIAL_CPU_RESET, 0, NULL); smp_sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL); report_prefix_push("clear"); @@ -316,7 +316,7 @@ static void test_reset(void) smp_sigp(1, SIGP_EXTERNAL_CALL, 0, NULL); smp_cpu_start(1, psw); - smp_sigp_retry(1, SIGP_CPU_RESET, 0, NULL); + smp_sigp(1, SIGP_CPU_RESET, 0, NULL); report(smp_cpu_stopped(1), "cpu stopped"); set_flag(0); From patchwork Fri Apr 1 11:16:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798162 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 CE41BC433EF for ; Fri, 1 Apr 2022 11:16:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345439AbiDALSi (ORCPT ); Fri, 1 Apr 2022 07:18:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345510AbiDALSY (ORCPT ); Fri, 1 Apr 2022 07:18:24 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46E63184629 for ; Fri, 1 Apr 2022 04:16:35 -0700 (PDT) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2318lMna005235 for ; Fri, 1 Apr 2022 11:16:35 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=WW8UMT7vAAqzcROcLwVNLM7p08Bt1a52Mqw6rsI5Tv4=; b=piw7TNZ7PVKxBDAdEgOFjtm+BYcLEVT3md2ZOak1Mw6W50Vi6FAkgLvRlvJbJ8IMdsl+ XLWx/H7hnh9jAh8I+CBolY6a+ClFEWRcyWjdyPHg1fgvmKEiAudHBfbmDorwGed22aka jVZqGk033P2DCqcwut39BZKvdiyMUyGNTp1MaYLk4J2Y9x3mvZ5thBic95OD/YMRxM0S XtHfACJfQW1PlvycQguo/B3v4QN27R55VUlSXUJ7UuenWKwT6HNqyYBdXxNbXz68FNQm GCKMFI1rTkI3GuKKGLoILoSkbYJ/86qZloKo4uPTmY02VQ4f331oaiD/+0WiIIHlIGhW Tg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5x6gaup7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:34 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231At4lI031519 for ; Fri, 1 Apr 2022 11:16:34 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5x6gaung-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:34 +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 231B8uZn020867; Fri, 1 Apr 2022 11:16:32 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 3f1t3j2xv2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:31 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGSDJ41877768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:28 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C3AC4C064; Fri, 1 Apr 2022 11:16:28 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 445324C059; Fri, 1 Apr 2022 11:16:28 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:28 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr , Pierre Morel Subject: [kvm-unit-tests GIT PULL 07/27] s390x: Add more tests for MSCH Date: Fri, 1 Apr 2022 13:16:00 +0200 Message-Id: <20220401111620.366435-8-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: OjKVFjyPr7faUus4s2wzTVS7b0zEbvzT X-Proofpoint-GUID: xQSZFxR9QH97OlR8TZawjBnorS2aLC7j 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.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 spamscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr We already have some coverage for MSCH, but there are more cases to test for: - invalid SCHIB structure. We cover that by setting reserved bits 0, 1, 6 and 7 in the flags of the PMCW. Older QEMU versions require this bit to always be zero on msch, which is why this test may fail. A fix is available in QEMU master commit 2df59b73e086 ("s390x/css: fix PMCW invalid mask"). - a pointer to an unaligned SCHIB. We cover misalignment by 1 and 2 bytes. Using pointer to valid memory avoids messing up random memory in case of test failures. Here's the QEMU PMCW invalid mask fix: https://lists.nongnu.org/archive/html/qemu-s390x/2021-12/msg00100.html Signed-off-by: Nico Boehr Reviewed-by: Janosch Frank Reviewed-by: Claudio Imbrenda Reviewed-by: Thomas Huth Reviewed-by: Pierre Morel Signed-off-by: Claudio Imbrenda --- s390x/css.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/s390x/css.c b/s390x/css.c index 881206ba..396007ed 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -27,6 +27,8 @@ static int test_device_sid; static struct senseid *senseid; struct ccw1 *ccw; +char alignment_test_page[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); + static void test_enumerate(void) { test_device_sid = css_enumerate(); @@ -331,6 +333,61 @@ static void test_schm_fmt1(void) free_io_mem(mb1, sizeof(struct measurement_block_format1)); } +static void test_msch(void) +{ + int invalid_pmcw_flags[] = {0, 1, 6, 7}; + struct schib test_schib; + uint16_t old_pmcw_flags; + const int align_to = 4; + int invalid_flag; + int cc; + + if (!test_device_sid) { + report_skip("No device"); + return; + } + + cc = stsch(test_device_sid, &schib); + if (cc) { + report_fail("stsch: sch %08x failed with cc=%d", test_device_sid, cc); + return; + } + + report_prefix_push("Unaligned"); + for (int i = 1; i < align_to; i *= 2) { + report_prefix_pushf("%d", i); + + expect_pgm_int(); + msch(test_device_sid, (struct schib *)(alignment_test_page + i)); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + + report_prefix_pop(); + } + report_prefix_pop(); + + report_prefix_push("Invalid SCHIB"); + old_pmcw_flags = schib.pmcw.flags; + for (int i = 0; i < ARRAY_SIZE(invalid_pmcw_flags); i++) { + invalid_flag = invalid_pmcw_flags[i]; + + report_prefix_pushf("PMCW flag bit %d set", invalid_flag); + + schib.pmcw.flags = old_pmcw_flags | BIT(15 - invalid_flag); + expect_pgm_int(); + msch(test_device_sid, &schib); + check_pgm_int_code(PGM_INT_CODE_OPERAND); + + cc = stsch(test_device_sid, &test_schib); + report(!cc, "STSCH succeeded"); + report(!(test_schib.pmcw.flags & BIT(15 - invalid_flag)), "Clear on STSCH"); + + report_prefix_pop(); + } + report_prefix_pop(); + + schib.pmcw.flags = old_pmcw_flags; +} + static struct { const char *name; void (*func)(void); @@ -343,6 +400,7 @@ static struct { { "measurement block (schm)", test_schm }, { "measurement block format0", test_schm_fmt0 }, { "measurement block format1", test_schm_fmt1 }, + { "msch", test_msch }, { NULL, NULL } }; From patchwork Fri Apr 1 11:16:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798157 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 8DEA3C433EF for ; Fri, 1 Apr 2022 11:16:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345426AbiDALS2 (ORCPT ); Fri, 1 Apr 2022 07:18:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345509AbiDALSY (ORCPT ); Fri, 1 Apr 2022 07:18:24 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CF9F18462B for ; Fri, 1 Apr 2022 04:16:35 -0700 (PDT) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2319j1Xt007294 for ; Fri, 1 Apr 2022 11:16:35 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=J08RTSthDlzbecxQQNYvs4aY7cSJUh2Aa5Q21E7FtwQ=; b=Htl4hfaUc4evcoA0Fra+ZOfMCV16n+QSGG1tJpeKL6hIOMpAXN10JqjIIRQeChEaeJor +0U9TRF1l9Ltapw3pUtsO7qgmKTTMdLiHyGqRapw2Zq8sGDFpTDsaHbcs/Z7k4YTZ1yk mm5NQ6vw/L7j1rxcbZIhP9uSd8indl5Dv4+echHKOA8oVoDWhKKxq+9LfOd8UUfN6G0d RJ80a5mTBnhWTwIWYYotkkXGr+I+2e5jc6Pg2gm7lYp+nc+ouVL+OVZJkTJsai5o9uDj 8v1J+IwOVnAmhl1/SbD22lF8DVSjH1a9WCcHv0kUfISoW0zp4CYZM/CGUTCNqaTfmJbQ iw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y1j9tts-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:34 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231BEPQK005068 for ; Fri, 1 Apr 2022 11:16:34 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y1j9tt0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:34 +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 231B8dGC027953; Fri, 1 Apr 2022 11:16:32 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04ams.nl.ibm.com with ESMTP id 3f1tf94v69-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:32 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGTe213631854 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:29 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 132664C040; Fri, 1 Apr 2022 11:16:29 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B19514C05C; Fri, 1 Apr 2022 11:16:28 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:28 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 08/27] s390x: Add test for PFMF low-address protection Date: Fri, 1 Apr 2022 13:16:01 +0200 Message-Id: <20220401111620.366435-9-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: TMNu4zmod0bQWSEwJur5-ACcJqnYE8zp X-Proofpoint-GUID: OYfKhwjhtDNHVcz0xkzynnd45i_0G3C0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_04,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 clxscore=1015 adultscore=0 phishscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 mlxlogscore=652 lowpriorityscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr PFMF should respect the low-address protection when clearing pages, hence add some tests for it. When low-address protection fails, clearing frame 0 is a destructive operation. It messes up interrupts and thus printing test results won't work properly. Hence, we first attempt to clear frame 1 which is not as destructive. Doing it this way around increases the chances for the user to see a proper failure message instead of QEMU randomly quitting in the middle of the test run. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Reviewed-by: Janosch Frank Reviewed-by: Thomas Huth Signed-off-by: Claudio Imbrenda --- s390x/pfmf.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/s390x/pfmf.c b/s390x/pfmf.c index 2f3cb110..aa130529 100644 --- a/s390x/pfmf.c +++ b/s390x/pfmf.c @@ -113,6 +113,34 @@ static void test_1m_clear(void) report_prefix_pop(); } +static void test_low_addr_prot(void) +{ + union pfmf_r1 r1 = { + .reg.cf = 1, + .reg.fsc = PFMF_FSC_4K + }; + + report_prefix_push("low-address protection"); + + report_prefix_push("0x1000"); + expect_pgm_int(); + low_prot_enable(); + pfmf(r1.val, (void *)0x1000); + low_prot_disable(); + check_pgm_int_code(PGM_INT_CODE_PROTECTION); + report_prefix_pop(); + + report_prefix_push("0x0"); + expect_pgm_int(); + low_prot_enable(); + pfmf(r1.val, 0); + low_prot_disable(); + check_pgm_int_code(PGM_INT_CODE_PROTECTION); + report_prefix_pop(); + + report_prefix_pop(); +} + int main(void) { bool has_edat = test_facility(8); @@ -124,6 +152,7 @@ int main(void) } test_priv(); + test_low_addr_prot(); /* Force the buffer pages in */ memset(pagebuf, 0, PAGE_SIZE * 256); From patchwork Fri Apr 1 11:16:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798164 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 D5755C433F5 for ; Fri, 1 Apr 2022 11:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345037AbiDALSl (ORCPT ); Fri, 1 Apr 2022 07:18:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345512AbiDALSZ (ORCPT ); Fri, 1 Apr 2022 07:18:25 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E56AB184B5B for ; Fri, 1 Apr 2022 04:16:35 -0700 (PDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 231AgIAl011995 for ; Fri, 1 Apr 2022 11:16:35 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=jETxoVn08qvds5M+02q9Vnysuogk8CrqcXWGecc1vYI=; b=NBVIJW++ZcEJ5muS2W8ZB9G0jRChEsDhMG+7Guhf+GLT1jnZyca8YHMXEAIBTvCqZXHu pyIRaITn8mHwiGSDfCsTYLHh7XwbAYYi4wh5rKWiJ8H8lx1AI4fC1E8N5GrVAgqyE+aZ kRcLMM+GrAL1yrApFbOBjr6uoWCjY7VfOpCel5KiLFdkCs5phfiZtdZT4InWhvDi/DfV 7+5TbKoxgpSGp/FoP2OHMXHw4BlbHMXFbGJ6U5LImRflijnhlmb7+ZUe9bC6yZ6kCF06 QMgsA0huVz5g9DhOxXnR1wdTDAsQ8yLQ/KcyWW6sBK21hlE4gfbwjJsY+7jHUig1HnFA 4Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5yv50mqt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:35 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231BDowi029980 for ; Fri, 1 Apr 2022 11:16:35 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5yv50mq0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:35 +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 231B7Qf6020778; Fri, 1 Apr 2022 11:16:32 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04fra.de.ibm.com with ESMTP id 3f1tf92wqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:32 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGTMR33227070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:29 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 824994C066; Fri, 1 Apr 2022 11:16:29 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 269F64C05A; Fri, 1 Apr 2022 11:16:29 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:29 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr , Pierre Morel Subject: [kvm-unit-tests GIT PULL 09/27] s390x: Add sck tests Date: Fri, 1 Apr 2022 13:16:02 +0200 Message-Id: <20220401111620.366435-10-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: D-0yRWKN2iz7REiEYaci13qmicif6XBC X-Proofpoint-GUID: axgKBLpPFLDw0ww4HqSy0HPXlb9ZbsZ8 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.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 bulkscore=0 clxscore=1015 spamscore=0 adultscore=0 lowpriorityscore=0 mlxscore=0 impostorscore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr SCK updates the guest's TOD clock. It needs to be intercepted, hence we should have some tests for it: - its operand must be 8-byte aligned. We test for 1, 2 and 4 byte misalignment. - it should actually update the clock value. As guests are unable to stop their clock, we can only check the clock value is at least higher than the value we set. - it is a privileged call, so expect it to fail when in problem state. We also test the clock value is not changed in this case. We do so by first adjusting it (privileged) to a high value. We then attempt, in nonprivileged mode, to set the clock to a comparatively small value. We can then store the clock value and test its value is strictly higher than the high value we set previously. SCK is currently broken in QEMU TCG. A fix was posted upstream ("s390x: sck: load into a temporary not into in1"): https://lore.kernel.org/qemu-devel/20220126084201.774457-1-nrb@linux.ibm.com/ Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Reviewed-by: Pierre Morel Signed-off-by: Claudio Imbrenda --- s390x/Makefile | 1 + s390x/sck.c | 136 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 + 3 files changed, 140 insertions(+) create mode 100644 s390x/sck.c diff --git a/s390x/Makefile b/s390x/Makefile index 53b0fe04..a76b78e5 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -17,6 +17,7 @@ tests += $(TEST_DIR)/stsi.elf tests += $(TEST_DIR)/skrf.elf tests += $(TEST_DIR)/smp.elf tests += $(TEST_DIR)/sclp.elf +tests += $(TEST_DIR)/sck.elf tests += $(TEST_DIR)/css.elf tests += $(TEST_DIR)/uv-guest.elf tests += $(TEST_DIR)/sie.elf diff --git a/s390x/sck.c b/s390x/sck.c new file mode 100644 index 00000000..88d52b74 --- /dev/null +++ b/s390x/sck.c @@ -0,0 +1,136 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Perform Set Clock tests + * + * Copyright IBM Corp. 2022 + * + * Authors: + * Nico Boehr + */ +#include +#include +#include +#include + +static inline int sck(uint64_t *time) +{ + int cc; + + asm volatile( + " sck %[time]\n" + " ipm %[cc]\n" + " srl %[cc],28\n" + : [cc] "=d"(cc) + : [time] "Q"(*time) + : "cc" + ); + + return cc; +} + +static inline int stck(uint64_t *time) +{ + int cc; + + asm volatile( + " stck %[time]\n" + " ipm %[cc]\n" + " srl %[cc],28\n" + : [cc] "=d" (cc), [time] "=Q" (*time) + : + : "cc", "memory" + ); + + return cc; +} + +static void test_priv(void) +{ + uint64_t time_to_set_privileged = 0xfacef00dcafe0000, + time_to_set_nonprivileged = 0xcafe0000, + time_verify; + int cc; + + report_prefix_push("privileged"); + cc = sck(&time_to_set_privileged); + report(!cc, "set clock cc=%d", cc); + + cc = stck(&time_verify); + report(!cc, "store clock cc=%d", cc); + report(time_verify > time_to_set_privileged, + "privileged set affected the clock"); + report_prefix_pop(); + + report_prefix_push("unprivileged"); + expect_pgm_int(); + enter_pstate(); + sck(&time_to_set_nonprivileged); + leave_pstate(); + check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); + + cc = stck(&time_verify); + report(!cc, "store clock cc=%d", cc); + report(time_verify > time_to_set_privileged, + "unprivileged set did not affect the clock"); + report_prefix_pop(); +} + +static void test_align(void) +{ + const int align_to = 8; + char unalign[sizeof(uint64_t) + align_to] __attribute__((aligned(8))); + + report_prefix_push("Unaligned operand"); + for (int i = 1; i < align_to; i *= 2) { + report_prefix_pushf("%d", i); + expect_pgm_int(); + sck((uint64_t *)(unalign + i)); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); + } + report_prefix_pop(); +} + +static void test_set(void) +{ + uint64_t start = 0, end = 0, time = 0xcafef00dbeef; + const uint64_t ticks_per_ms = 1000 << 12, ms_to_wait = 5; + int cc; + + report_prefix_push("set"); + + cc = sck(&time); + report(!cc, "set clock cc=%d", cc); + + cc = stck(&start); + report(!cc, "store start clock cc=%d", cc); + report(start >= time, "start >= set value"); + + mdelay(ms_to_wait); + + cc = stck(&end); + report(!cc, "store end clock cc=%d", cc); + report(end > time, "end > set value"); + + report(end - start > (ticks_per_ms * ms_to_wait), "Advances"); + + report_prefix_pop(); +} + +int main(void) +{ + report_prefix_push("sck"); + + if (uv_os_is_guest()) { + report_skip("Test unsupported under PV"); + goto out; + } + + test_align(); + test_set(); + test_priv(); + +out: + report_prefix_pop(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 1600e714..8b148fe3 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -136,3 +136,6 @@ file = firq.elf timeout = 20 extra_params = -smp 1,maxcpus=3 -cpu qemu -device qemu-s390x-cpu,core-id=2 -device qemu-s390x-cpu,core-id=1 accel = tcg + +[sck] +file = sck.elf From patchwork Fri Apr 1 11:16:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798165 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 C37ADC433FE for ; Fri, 1 Apr 2022 11:16:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345396AbiDALSm (ORCPT ); Fri, 1 Apr 2022 07:18:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239869AbiDALSZ (ORCPT ); Fri, 1 Apr 2022 07:18:25 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69120184608 for ; Fri, 1 Apr 2022 04:16:36 -0700 (PDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 231Ag4n2011753 for ; Fri, 1 Apr 2022 11:16:36 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=32/y951/ywGbPycWn/v0dvl70JvxYh0PFLP0C5aGyKg=; b=Ygw0320XAOvuL6XWRgeGKdFYBXqB+XG55nOJlBk8zxSoMYcWTr3gy+vlXJto1ol0kO4K WXN7XfmlPE6UGqQTuel4ZEi32FMuqlIegTJjcdxe4snmFd4/CbBGlU7Sd1oRccEYaduQ EEsy/V/TSD6XDDQUEirJCcxT0S52xDJ+XJQUtXXvilgi6+tP3+KZkC6p/m3ePkYVAThQ PIMEW9SuzevXHu1wwIOiS7OOVp/32A6Oy0dfH6mPK8WegguUQsJDoyhxfFQBhXUq9vDD CE2vF6NWPddsNKfDmyc4g3gTX/HXWM/e9wAK5kxA8uSwOYGP8AXbiyStW9NEcIv8ws4W VQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5yv50mr0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:35 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231B7QT8005746 for ; Fri, 1 Apr 2022 11:16:35 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5yv50mq6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:35 +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 231B87Cf013029; Fri, 1 Apr 2022 11:16:33 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03ams.nl.ibm.com with ESMTP id 3f1tf9mv0g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:33 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGUkh33096190 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:30 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F395B4C06E; Fri, 1 Apr 2022 11:16:29 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 95DEF4C063; Fri, 1 Apr 2022 11:16:29 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:29 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr , Pierre Morel Subject: [kvm-unit-tests GIT PULL 10/27] s390x: Add tests for STCRW Date: Fri, 1 Apr 2022 13:16:03 +0200 Message-Id: <20220401111620.366435-11-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Nmh9wG4WtLlXq0cTuXlmyVCoQAxbwxV_ X-Proofpoint-GUID: PDwyfu2V0ZehCn-p3H87LOzAZjZwv3vn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 bulkscore=0 clxscore=1015 spamscore=0 adultscore=0 lowpriorityscore=0 mlxscore=0 impostorscore=0 phishscore=0 mlxlogscore=983 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr The test consists of two parts: First a simple check to ensure we enforce an aligned address. We test misalignment by 1 and 2 bytes. The second part tests the handling of pending Channel Reports (CR). We first assume no CR is initally pending and check STCRW returns accordingly. Then, we generate a CR by resetting a Channel Path using RCHP and make sure this results in exactly one CRW being generated which has a Reporting-Source Code (RSC) corresponding to the Channel Path facility. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Reviewed-by: Pierre Morel Signed-off-by: Claudio Imbrenda --- lib/s390x/css.h | 17 ++++++++++ lib/s390x/css_lib.c | 60 +++++++++++++++++++++++++++++++++ s390x/css.c | 82 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 159 insertions(+) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index 0db8a281..a6a68577 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -266,6 +266,20 @@ static inline int rchp(unsigned long chpid) return cc; } +static inline int stcrw(uint32_t *crw) +{ + int cc; + + asm volatile( + " stcrw %[crw]\n" + " ipm %[cc]\n" + " srl %[cc],28" + : [cc] "=d" (cc) + : [crw] "Q" (*crw) + : "cc", "memory"); + return cc; +} + /* Debug functions */ char *dump_pmcw_flags(uint16_t f); char *dump_scsw_flags(uint32_t f); @@ -294,6 +308,9 @@ int css_residual_count(unsigned int schid); void enable_io_isc(uint8_t isc); int wait_and_check_io_completion(int schid); +int css_find_installed_chpid(int sid, uint8_t *chpid_out); +int css_generate_crw(int sid); + /* * CHSC definitions */ diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c index 80e9e078..a9f5097f 100644 --- a/lib/s390x/css_lib.c +++ b/lib/s390x/css_lib.c @@ -504,3 +504,63 @@ void enable_io_isc(uint8_t isc) value = (uint64_t)isc << 24; lctlg(6, value); } + +static int is_path_installed(struct schib *schib, int chp_idx) +{ + return schib->pmcw.pim & BIT(7 - chp_idx); +} + +/* + * css_find_installed_chpid: find any installed CHPID + * @sid: subsystem-identification word + * @chpid_out: store the found chpid here, left alone if none found + * + * returns 0 on success, -1 if no chpid found any other value + * indicates the condition code of a failing STSCH instruction + */ +int css_find_installed_chpid(int sid, uint8_t *chpid_out) +{ + int cc; + + cc = stsch(sid, &schib); + if (cc) { + report_fail("%s: sch %08x failed with cc=%d", __func__, sid, cc); + return cc; + } + + for (int i = 0; i < ARRAY_SIZE(schib.pmcw.chpid); i++) { + if (is_path_installed(&schib, i)) { + *chpid_out = schib.pmcw.chpid[i]; + return 0; + } + } + + return -1; +} + +/* + * css_generate_crw: Generate a CRW by issuing RCHP on any channel path + * @sid: subsystem-identification word + * + * returns 0 when a CRW was generated, -1 if no chpid found. + */ +int css_generate_crw(int sid) +{ + int ret, cc; + uint8_t chpid; + + report_prefix_push("Generate CRW"); + + ret = css_find_installed_chpid(sid, &chpid); + if (ret) { + report_fail("No CHPID found: ret=%d", ret); + return -1; + } + + cc = rchp(chpid); + report(!cc, "rhcp cc != 0"); + + report_prefix_pop(); + + return 0; +} diff --git a/s390x/css.c b/s390x/css.c index 396007ed..fcc264ee 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -388,6 +388,87 @@ static void test_msch(void) schib.pmcw.flags = old_pmcw_flags; } +static void check_stcrw_no_crw_available(void) +{ + uint32_t crw = 0xfeedc0fe; + int cc; + + report_prefix_push("No CRW available"); + cc = stcrw(&crw); + report(cc == 1, "cc == 1"); + report(!crw, "stored zeroes in crw"); + report_prefix_pop(); +} + +static int check_stcrw_crw_available(void) +{ + const uint32_t magic = 0xfeedc0fe; + uint32_t crw = magic; + int cc; + + report_prefix_push("CRW available"); + cc = stcrw(&crw); + report(!cc, "cc is zero"); + report(crw != magic, "stored crw"); + report_prefix_pop(); + + return crw; +} + +static uint32_t crw_get_rsc(uint32_t crw) +{ + const int rsc_begin = 4; + const int rsc_end = 8; + + return (crw & GENMASK(31 - rsc_begin, 31 - rsc_end)) >> 24; +} + +#define CRW_RSC_CHP 4 +static void test_stcrw(void) +{ + const int align_to = 4; + int res; + uint32_t crw; + + if (!test_device_sid) { + report_skip("No device"); + return; + } + + report_prefix_push("Unaligned"); + for (int i = 1; i < align_to; i *= 2) { + report_prefix_pushf("%d", i); + + expect_pgm_int(); + stcrw((uint32_t *)(alignment_test_page + i)); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + + report_prefix_pop(); + } + report_prefix_pop(); + + report_prefix_push("No CRW available initally"); + check_stcrw_no_crw_available(); + report_prefix_pop(); + + res = css_generate_crw(test_device_sid); + if (res) { + report_skip("Couldn't generate CRW"); + report_prefix_pop(); + return; + } + + crw = check_stcrw_crw_available(); + + report_prefix_push("CRW available"); + report(crw_get_rsc(crw) == CRW_RSC_CHP, "CRW has Channel Path RSC"); + report_prefix_pop(); + + report_prefix_push("No more CRWs pending"); + check_stcrw_no_crw_available(); + report_prefix_pop(); +} + static struct { const char *name; void (*func)(void); @@ -401,6 +482,7 @@ static struct { { "measurement block format0", test_schm_fmt0 }, { "measurement block format1", test_schm_fmt1 }, { "msch", test_msch }, + { "stcrw", test_stcrw }, { NULL, NULL } }; From patchwork Fri Apr 1 11:16:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798167 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 11416C433FE for ; Fri, 1 Apr 2022 11:16:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345400AbiDALSo (ORCPT ); Fri, 1 Apr 2022 07:18:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345393AbiDALS0 (ORCPT ); Fri, 1 Apr 2022 07:18:26 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FFBE185444 for ; Fri, 1 Apr 2022 04:16:37 -0700 (PDT) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 231AKdQg040313 for ; Fri, 1 Apr 2022 11:16:36 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=8Kd5T/pM7rqJEPTdhBZEM19qnsuqWaVvllLr5VgBC7g=; b=Ecopz4cpWS8El9PoXlMYhsw8ONKVaAUpgqssEFRq+e1m9qMCXXsAnGWqUfH/5GGN+nYd aLvzEHNexa25MIUGknKuYYeaPF14XMy0/MOUaJqP+ETh5Psz7H7Hnlc6ENp7BpdvYaaJ BNdGr6ckPkNtmiu4M5phQh5AFI4Gm9YfmWg9jeuI5m7cGO1PBP1Hn5oR4QB97edZW99K 6SpTS6SyfdQ5T9VpUIIHBQomkm6jpnjRM2BVb2VBVYC0mE8K82NI6KYKlAAAwJ9Y20QM Ic2S+WReEAxfjQoHMoV9tmQLVUvrauv2AjIgEhgugeDOQOlmDfx7jf/3otxsSdCh3qFJ zA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5yj0s162-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:36 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231AQETS017923 for ; Fri, 1 Apr 2022 11:16:35 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5yj0s15a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:35 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 231B8gIB014294; Fri, 1 Apr 2022 11:16:33 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03fra.de.ibm.com with ESMTP id 3f1tf92vdr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:33 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGUgY51314946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:30 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7BA5E4C05A; Fri, 1 Apr 2022 11:16:30 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 19CFB4C05C; Fri, 1 Apr 2022 11:16:30 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:30 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr , Pierre Morel Subject: [kvm-unit-tests GIT PULL 11/27] s390x: Add more tests for SSCH Date: Fri, 1 Apr 2022 13:16:04 +0200 Message-Id: <20220401111620.366435-12-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ob4dkGeZNX0uzUZocOCj_zufCi9Zqtny X-Proofpoint-ORIG-GUID: nwlGx0O9Cg5rj2l5ajl7xJkrg-_9K35Z X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_04,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr We already have some coverage of SSCH due to its use in start_ccw1_chain() in css_lib, but two more cases deserve our attention: - unaligned operand address. We check for misalignment by 1 and 2 bytes. - an invalid ORB structure. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Reviewed-by: Pierre Morel Signed-off-by: Claudio Imbrenda --- s390x/css.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/s390x/css.c b/s390x/css.c index fcc264ee..7fe5283c 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -469,6 +469,38 @@ static void test_stcrw(void) report_prefix_pop(); } +static void test_ssch(void) +{ + const int align_to = 4; + struct orb orb; + + if (!test_device_sid) { + report_skip("No device"); + return; + } + + report_prefix_push("Unaligned"); + for (int i = 1; i < align_to; i *= 2) { + report_prefix_pushf("%d", i); + + expect_pgm_int(); + ssch(test_device_sid, (struct orb *)(alignment_test_page + i)); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + + report_prefix_pop(); + } + report_prefix_pop(); + + report_prefix_push("Invalid ORB"); + + memset(&orb, 0xff, sizeof(orb)); + expect_pgm_int(); + ssch(test_device_sid, &orb); + check_pgm_int_code(PGM_INT_CODE_OPERAND); + + report_prefix_pop(); +} + static struct { const char *name; void (*func)(void); @@ -483,6 +515,7 @@ static struct { { "measurement block format1", test_schm_fmt1 }, { "msch", test_msch }, { "stcrw", test_stcrw }, + { "ssch", test_ssch }, { NULL, NULL } }; From patchwork Fri Apr 1 11:16:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798168 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 612BBC433F5 for ; Fri, 1 Apr 2022 11:16:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345459AbiDALSp (ORCPT ); Fri, 1 Apr 2022 07:18:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345395AbiDALS0 (ORCPT ); Fri, 1 Apr 2022 07:18:26 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88C7B185453 for ; Fri, 1 Apr 2022 04:16:37 -0700 (PDT) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2318LFxJ011048 for ; Fri, 1 Apr 2022 11:16:37 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=BcmswbvSfgcn217kMBVri6pVGTwuYR9Mo+GTrMYy8SE=; b=tgx8+i4wXAP7hfL142UUUG9DmcYjsL6rNpQdkb22Fsdilvrpoc2P8Ezhb/udzOQhaHMQ P53OKwvL4ZiW6zaAudnk5qL8t5AT4AREoVD/tb0wYF7LfIznTNPbyTN4X+4beCNUU+sr Qcu2xsyVpwoSw00Bm8EKnh4IgNTmz7vbiJuC/NPBIp2C8INq70XYD2CakRiya67EyUho X3Js6mOcQ9l/pXtR4A9CG4hP800hm3FhaLYg3NT4Rdqb6EeWp2lKEJgQjNJVRqwbqSvn UuqQ6KukLexYhEBy/SV3CH+50VGhddALjirtsXf6JVMrhg87jkiNLlhFDMybpcmXBPCH ZQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f556u9q1p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:37 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231Aq0vH015729 for ; Fri, 1 Apr 2022 11:16:36 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f556u9q13-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:36 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 231B8qCx014328; Fri, 1 Apr 2022 11:16:34 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03fra.de.ibm.com with ESMTP id 3f1tf92vds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:34 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGbbu35127624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:37 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD2194C05E; Fri, 1 Apr 2022 11:16:30 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8DA894C063; Fri, 1 Apr 2022 11:16:30 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:30 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr , Pierre Morel Subject: [kvm-unit-tests GIT PULL 12/27] s390x: Add more tests for STSCH Date: Fri, 1 Apr 2022 13:16:05 +0200 Message-Id: <20220401111620.366435-13-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: _Bt-LvjHh59_ZAW3k1oCb9aPgvPQUr2i X-Proofpoint-ORIG-GUID: AJ0gmYSOIRS-LAFz5uj8f7NMx4omXrDe 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.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 adultscore=0 spamscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 phishscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr css_lib extensively uses STSCH, but two more cases deserve their own tests: - unaligned address for SCHIB. We check for misalignment by 1 and 2 bytes. - channel not operational - bit 47 in SID not set - bit 5 of PMCW flags. As per the principles of operation, bit 5 of the PMCW flags shall be ignored by msch and always stored as zero by stsch. Older QEMU versions require this bit to always be zero on msch, which is why this test may fail. A fix is available in QEMU master commit 2df59b73e086 ("s390x/css: fix PMCW invalid mask"). Here's the QEMU PMCW invalid mask fix: https://lists.nongnu.org/archive/html/qemu-s390x/2021-12/msg00100.html Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Acked-by: Janosch Frank Reviewed-by: Pierre Morel Signed-off-by: Claudio Imbrenda --- s390x/css.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/s390x/css.c b/s390x/css.c index 7fe5283c..dd84e670 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -501,6 +501,86 @@ static void test_ssch(void) report_prefix_pop(); } +static void test_stsch(void) +{ + const int align_to = 4; + struct schib schib; + int cc; + + if (!test_device_sid) { + report_skip("No device"); + return; + } + + report_prefix_push("Unaligned"); + for (int i = 1; i < align_to; i *= 2) { + report_prefix_pushf("%d", i); + + expect_pgm_int(); + stsch(test_device_sid, (struct schib *)(alignment_test_page + i)); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + + report_prefix_pop(); + } + report_prefix_pop(); + + report_prefix_push("Invalid subchannel number"); + cc = stsch(0x0001ffff, &schib); + report(cc == 3, "Channel not operational"); + report_prefix_pop(); + + /* + * No matter if multiple-subchannel-set facility is installed, bit 47 + * always needs to be 1. + */ + report_prefix_push("Bit 47 in SID is zero"); + expect_pgm_int(); + stsch(0x0000ffff, &schib); + check_pgm_int_code(PGM_INT_CODE_OPERAND); + report_prefix_pop(); +} + +/* + * According to architecture MSCH does ignore bit 5 of the second word + * but STSCH will store bit 5 as zero. + */ +static void test_pmcw_bit5(void) +{ + int cc; + uint16_t old_pmcw_flags; + + cc = stsch(test_device_sid, &schib); + if (cc) { + report_fail("stsch: sch %08x failed with cc=%d", test_device_sid, cc); + return; + } + old_pmcw_flags = schib.pmcw.flags; + + report_prefix_push("Bit 5 set"); + + schib.pmcw.flags = old_pmcw_flags | BIT(15 - 5); + cc = msch(test_device_sid, &schib); + report(!cc, "MSCH cc == 0"); + + cc = stsch(test_device_sid, &schib); + report(!cc, "STSCH cc == 0"); + report(!(schib.pmcw.flags & BIT(15 - 5)), "STSCH PMCW Bit 5 is clear"); + + report_prefix_pop(); + + report_prefix_push("Bit 5 clear"); + + schib.pmcw.flags = old_pmcw_flags & ~BIT(15 - 5); + cc = msch(test_device_sid, &schib); + report(!cc, "MSCH cc == 0"); + + cc = stsch(test_device_sid, &schib); + report(!cc, "STSCH cc == 0"); + report(!(schib.pmcw.flags & BIT(15 - 5)), "STSCH PMCW Bit 5 is clear"); + + report_prefix_pop(); +} + static struct { const char *name; void (*func)(void); @@ -516,6 +596,8 @@ static struct { { "msch", test_msch }, { "stcrw", test_stcrw }, { "ssch", test_ssch }, + { "stsch", test_stsch }, + { "pmcw bit 5 ignored", test_pmcw_bit5 }, { NULL, NULL } }; From patchwork Fri Apr 1 11:16:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798166 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 1D5D9C433EF for ; Fri, 1 Apr 2022 11:16:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345425AbiDALSn (ORCPT ); Fri, 1 Apr 2022 07:18:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232569AbiDALS0 (ORCPT ); Fri, 1 Apr 2022 07:18:26 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BB29185471 for ; Fri, 1 Apr 2022 04:16:38 -0700 (PDT) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2319oFVh010942 for ; Fri, 1 Apr 2022 11:16:37 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=YTk8AnK9BYf+Ox7glXSCm2vMW/9L73jTtS0xYzaQb34=; b=WuqPHC9iS8hj9tcJSOVklrksoEF0QzEut02autFrf1wA+pSxYB66ayRsXdWMBZqcWOlX gGv2eVjSNQXiZNe80J3ikaM7CynVHp1vSKXjnXMv57i8E+G+hEO+jTAoP8qYvyiUgI92 o7o4BDEcSdB5ElthRkS5zoWMOahdY/0/39FEw48jTLdLYLZTi5czPMc0LPDqSO4ynkAE RxPF9DOtEq3bOCOAtXfWqjVHXbWAYOR6VjtH6IPxE+0ytdG+VYX5ezcJknHpacgYn4FO IdL7bJo1nP8y8Y8CV6x9OGDjqW+cWmSEcEPgo9aFKqh43ahtpqjYg6hvBGmv761xe+U4 vw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y3y1rpc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:37 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231B9aCC027766 for ; Fri, 1 Apr 2022 11:16:37 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y3y1rnr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:36 +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 231B7eng012923; Fri, 1 Apr 2022 11:16:34 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03ams.nl.ibm.com with ESMTP id 3f1tf9mv0h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:34 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGbtJ34800046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:37 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 665A74C05E; Fri, 1 Apr 2022 11:16:31 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0871F4C064; Fri, 1 Apr 2022 11:16:31 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:30 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr , Pierre Morel Subject: [kvm-unit-tests GIT PULL 13/27] s390x: Add tests for TSCH Date: Fri, 1 Apr 2022 13:16:06 +0200 Message-Id: <20220401111620.366435-14-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: QeTm0VXC2xXJa-p_a1Yex8enFOAQALXI X-Proofpoint-ORIG-GUID: Fn6E8HsCnHeO3rDcp8CinYw19ZaOlGmJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 impostorscore=0 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr TSCH has two special cases which need to be tested: - unaligned address. We test for misalignment by 1 and 2 bytes. - channel not operational - bit 47 in SID not set Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Reviewed-by: Pierre Morel Signed-off-by: Claudio Imbrenda --- s390x/css.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/s390x/css.c b/s390x/css.c index dd84e670..a333e55a 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -581,6 +581,41 @@ static void test_pmcw_bit5(void) report_prefix_pop(); } +static void test_tsch(void) +{ + const int align_to = 4; + struct irb irb; + int cc; + + if (!test_device_sid) { + report_skip("No device"); + return; + } + + report_prefix_push("Unaligned"); + for (int i = 1; i < align_to; i *= 2) { + report_prefix_pushf("%d", i); + + expect_pgm_int(); + tsch(test_device_sid, (struct irb *)(alignment_test_page + i)); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + + report_prefix_pop(); + } + report_prefix_pop(); + + report_prefix_push("Invalid subchannel number"); + cc = tsch(0x0001ffff, &irb); + report(cc == 3, "Channel not operational"); + report_prefix_pop(); + + report_prefix_push("Bit 47 in SID is zero"); + expect_pgm_int(); + tsch(0x0000ffff, &irb); + check_pgm_int_code(PGM_INT_CODE_OPERAND); + report_prefix_pop(); +} + static struct { const char *name; void (*func)(void); @@ -598,6 +633,7 @@ static struct { { "ssch", test_ssch }, { "stsch", test_stsch }, { "pmcw bit 5 ignored", test_pmcw_bit5 }, + { "tsch", test_tsch }, { NULL, NULL } }; From patchwork Fri Apr 1 11:16:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798171 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 255A2C433F5 for ; Fri, 1 Apr 2022 11:17:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345134AbiDALSv (ORCPT ); Fri, 1 Apr 2022 07:18:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345403AbiDALS1 (ORCPT ); Fri, 1 Apr 2022 07:18:27 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BAEA185949 for ; Fri, 1 Apr 2022 04:16:38 -0700 (PDT) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2318lL11005220 for ; Fri, 1 Apr 2022 11:16:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=uY8VWNdcgF2C6mDbRWuj32gkAZzMr7aty7y6WiZ8REQ=; b=NcgWP/W6ylm8PzoqRiF2cCtJ5nSIvMp/szM1RvH1Iw8SJxCfbT1sTJvwt0QvY7MQFZaC y4QaZXlLztYJwQ35n8rrabq8VmId+bR+4ZJMO5WCCZTn5QOEPwinE0zvwadxuE9r5Zr5 1dbbwsnc18KsmaPBDkw+Uqeu2XPikqhqHvFiW7RqP20Q43XQGc1earx7fkHUDNYKGLD5 FlyUebNweGM0yW5HPd4zkCdg1zSfHKXvdCRkv7NMm9OQOX4ERwVnw56N6ASlWkkdeh7S Y+LeIfM2Qb4wDQcMTK5oqTXD/z95lc3E25DeOhnfTBzGJ78n/mGMnkSpAVeBiJVGwQpN kQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5x6gauqf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:37 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231AlXsq007233 for ; Fri, 1 Apr 2022 11:16:37 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5x6gaupn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:37 +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 231B8dLl027950; Fri, 1 Apr 2022 11:16:35 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04ams.nl.ibm.com with ESMTP id 3f1tf94v6c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:35 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGcu837028156 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:38 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C75494C059; Fri, 1 Apr 2022 11:16:31 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A50C4C062; Fri, 1 Apr 2022 11:16:31 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:31 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 14/27] s390x: Add EPSW test Date: Fri, 1 Apr 2022 13:16:07 +0200 Message-Id: <20220401111620.366435-15-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: vxF4da9LixZEZ_nDGdtjiw1fKKHVSJNo X-Proofpoint-GUID: 0ba-FzzYteJC2AOScgm6gAKrzbXwAzm9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 spamscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr EPSW is only intercepted in certain cases. One of these cases is if we have a CRW pending and machine check interrupts are masked. This can be achieved by issuing a RCHP on a valid channel path. This is why we need the CSS lib and an IO device in this test and hence need to skip it when not running under QEMU. Three special cases deserve our attention: - upper 32 bits of both operands are never modified, - second operand is not modified if it is zero. - when both operands are zero, bits 0-11 and 13-31 of the PSW are stored in r0. We also verify we get the correct contents when the second operand is zero. To do so, we save the data stored at the first operand in the first case as a reference. As we don't mess with the PSW, the only thing that might change is the Condition Code (CC) due to some instruction in between, so we zero it out using zero_out_cc_from_epsw_op1(). This test must be fenced when running in non-QEMU. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Signed-off-by: Claudio Imbrenda --- s390x/Makefile | 1 + s390x/epsw.c | 113 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 4 ++ 3 files changed, 118 insertions(+) create mode 100644 s390x/epsw.c diff --git a/s390x/Makefile b/s390x/Makefile index a76b78e5..25449708 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -27,6 +27,7 @@ tests += $(TEST_DIR)/edat.elf tests += $(TEST_DIR)/mvpg-sie.elf tests += $(TEST_DIR)/spec_ex-sie.elf tests += $(TEST_DIR)/firq.elf +tests += $(TEST_DIR)/epsw.elf pv-tests += $(TEST_DIR)/pv-diags.elf diff --git a/s390x/epsw.c b/s390x/epsw.c new file mode 100644 index 00000000..192115cf --- /dev/null +++ b/s390x/epsw.c @@ -0,0 +1,113 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * EPSW Interception Tests + * + * Copyright IBM Corp. 2022 + * + * Authors: + * Nico Boehr + */ +#include +#include +#include + +static uint32_t zero_out_cc_from_epsw_op1(uint32_t epsw_op1) +{ + return epsw_op1 & ~GENMASK(31 - 18, 31 - 20); +} + +static void generate_crw(void) +{ + int test_device_sid = css_enumerate(); + int cc, ret; + + if (!(test_device_sid & SCHID_ONE)) { + report_fail("No I/O device found"); + return; + } + + cc = css_enable(test_device_sid, IO_SCH_ISC); + report(cc == 0, "Enable subchannel %08x", test_device_sid); + + ret = css_generate_crw(test_device_sid); + if (ret) + report_fail("Couldn't generate CRW"); +} + +static void test_epsw(void) +{ + const uint64_t MAGIC1 = 0x1234567890abcdefUL; + const uint64_t MAGIC2 = 0xcafedeadbeeffaceUL; + + uint64_t op1 = MAGIC1; + uint64_t op2 = MAGIC2; + uint32_t prev_epsw_op1; + + /* + * having machine check interrupts masked and pending CRW ensures + * EPSW is intercepted under KVM + */ + generate_crw(); + + report_prefix_push("both operands given"); + asm volatile( + "epsw %0, %1\n" + : "+&d" (op1), "+&a" (op2)); + report(upper_32_bits(op1) == upper_32_bits(MAGIC1) && + upper_32_bits(op2) == upper_32_bits(MAGIC2), + "upper 32 bits unmodified"); + report(lower_32_bits(op1) != lower_32_bits(MAGIC1) && + lower_32_bits(op2) != lower_32_bits(MAGIC2), + "lower 32 bits modified"); + prev_epsw_op1 = zero_out_cc_from_epsw_op1(lower_32_bits(op1)); + report_prefix_pop(); + + report_prefix_push("second operand 0"); + op1 = MAGIC1; + op2 = MAGIC2; + asm volatile( + " lgr 0,%[op2]\n" + " epsw %[op1], 0\n" + " lgr %[op2],0\n" + : [op2] "+&d" (op2), [op1] "+&a" (op1) + : + : "0"); + report(upper_32_bits(op1) == upper_32_bits(MAGIC1), + "upper 32 bits of first operand unmodified"); + report(zero_out_cc_from_epsw_op1(lower_32_bits(op1)) == prev_epsw_op1, + "first operand matches previous reading"); + report(op2 == MAGIC2, "r0 unmodified"); + report_prefix_pop(); + + report_prefix_push("both operands 0"); + op1 = MAGIC1; + asm volatile( + " lgr 0,%[op1]\n" + " epsw 0, 0\n" + " lgr %[op1],0\n" + : [op1] "+&d" (op1) + : + : "0"); + report(upper_32_bits(op1) == upper_32_bits(MAGIC1), + "upper 32 bits of first operand unmodified"); + report(zero_out_cc_from_epsw_op1(lower_32_bits(op1)) == prev_epsw_op1, + "first operand matches previous reading"); + report_prefix_pop(); +} + +int main(int argc, char **argv) +{ + if (!vm_is_kvm() && !vm_is_tcg()) { + report_skip("Not running under QEMU"); + goto done; + } + + report_prefix_push("epsw"); + + test_epsw(); + +done: + report_prefix_pop(); + + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 8b148fe3..aeb82246 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -139,3 +139,7 @@ accel = tcg [sck] file = sck.elf + +[epsw] +file = epsw.elf +extra_params = -device virtio-net-ccw From patchwork Fri Apr 1 11:16:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798170 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 1D050C433FE for ; Fri, 1 Apr 2022 11:17:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345488AbiDALSu (ORCPT ); Fri, 1 Apr 2022 07:18:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345420AbiDALS1 (ORCPT ); Fri, 1 Apr 2022 07:18:27 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A40E18595D for ; Fri, 1 Apr 2022 04:16:38 -0700 (PDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2319CrWp016949 for ; Fri, 1 Apr 2022 11:16:37 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=vEmLwCfDLQMgmvKMBGOXVM2Y4mOCOtB/BNGHhOz6PCc=; b=XH0RdxUl+DR7YcZfO7eI4Pgl0fn8Pat8vgaggQqpX2urCsv23u+1cBItp0JqlHWqJODd EOMYaZ85vwzxiDMlwyBB6RLTkDA6cZSKAywJL8gIqLG61d9DWqh2H9JFXG2Ud2fkoiHA 8xAwRxK708wVZwEGAx7LF6ITm2lFKqqXNLF4GijhGL4gi7A75oNB5DIKcFKIf+G2UMyq nl3n0cM+F1sjYcmyWtLHwEwIgNsIrpsvC0a1tiw6CLaQH44WDdpBYNDlFDX7Q8NOx/sH fzr66ck/RAmJsA/ylv9DroLhpppKPqrhigxHjogco/sDCrtu9XWJskHaMf674UrUBbVy NQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3f5xjete9w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:37 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231AvW0a000409 for ; Fri, 1 Apr 2022 11:16:37 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 3f5xjete9e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:37 +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 231B83lB012942; Fri, 1 Apr 2022 11:16:35 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 3f1tf9mv0j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:35 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231B4SY449217924 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:04:28 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3801C4C06D; Fri, 1 Apr 2022 11:16:32 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E2D1F4C05A; Fri, 1 Apr 2022 11:16:31 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:31 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 15/27] s390x: smp: add tests for several invalid SIGP orders Date: Fri, 1 Apr 2022 13:16:08 +0200 Message-Id: <20220401111620.366435-16-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: gGPW-LLHnjmEPPqE3IqWmWGzJhWpllZA X-Proofpoint-ORIG-GUID: HWl3tvm6A9cmckERtgEj5fK2Dxj_30Fs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_04,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 mlxscore=0 suspectscore=0 adultscore=0 malwarescore=0 phishscore=0 spamscore=0 clxscore=1015 bulkscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr Add tests with for intercepted SIGP orders with invalid values: - SIGP_STOP with invalid CPU address - SIGP_START with invalid CPU address - SIGP_CPU_RESET with invalid CPU address - SIGP_STOP_AND_STORE_STATUS with invalid CPU address - SIGP_STORE_STATUS_AT_ADDRESS with invalid CPU address - invalid order - invalid order with invalid CPU address Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Signed-off-by: Claudio Imbrenda --- s390x/smp.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/s390x/smp.c b/s390x/smp.c index 81e02195..cfced18a 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -19,6 +19,47 @@ #include static int testflag = 0; +#define INVALID_CPU_ADDRESS -4711 +#define INVALID_ORDER_CODE 0xFF +struct sigp_invalid_cases { + int order; + char message[100]; +}; +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" }, + { 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" }, +}; +static const struct sigp_invalid_cases cases_valid_cpu_addr[] = { + { INVALID_ORDER_CODE, "invalid order code" }, +}; + +static void test_invalid(void) +{ + const struct sigp_invalid_cases *c; + uint32_t status; + int cc; + int i; + + report_prefix_push("invalid parameters"); + + for (i = 0; i < ARRAY_SIZE(cases_invalid_cpu_addr); i++) { + c = &cases_invalid_cpu_addr[i]; + cc = sigp(INVALID_CPU_ADDRESS, c->order, 0, &status); + report(cc == 3, c->message); + } + + for (i = 0; i < ARRAY_SIZE(cases_valid_cpu_addr); i++) { + c = &cases_valid_cpu_addr[i]; + cc = smp_sigp(1, c->order, 0, &status); + report(cc == 1, c->message); + } + + report_prefix_pop(); +} static void wait_for_flag(void) { @@ -136,10 +177,16 @@ static void test_store_status(void) { struct cpu_status *status = alloc_pages_flags(1, AREA_DMA31); uint32_t r; + int cc; report_prefix_push("store status at address"); memset(status, 0, PAGE_SIZE * 2); + report_prefix_push("invalid CPU address"); + cc = sigp(INVALID_CPU_ADDRESS, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, &r); + report(cc == 3, "returned with CC = 3"); + report_prefix_pop(); + report_prefix_push("running"); smp_cpu_restart(1); smp_sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, &r); @@ -344,6 +391,7 @@ int main(void) smp_cpu_stop(1); test_start(); + test_invalid(); test_restart(); test_stop(); test_stop_store_status(); From patchwork Fri Apr 1 11:16:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798169 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 6FDF3C433EF for ; Fri, 1 Apr 2022 11:17:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345458AbiDALSr (ORCPT ); Fri, 1 Apr 2022 07:18:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345421AbiDALS1 (ORCPT ); Fri, 1 Apr 2022 07:18:27 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3D81185962 for ; Fri, 1 Apr 2022 04:16:38 -0700 (PDT) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2319o9l1010848 for ; Fri, 1 Apr 2022 11:16:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=rbdd2JKDv/q1Tp0c9JcKHrSe+ByYif2HQEyyg++1lps=; b=hr0/8wZCbvlUodtX2zQdp+j7Po7+07wqjUe28ysEZT55d3OTaD8tdzVBFJg4zits6VFi 9Gphdr6jyt/t4wucPOK+XLOGj7JHIlZUUjYuTf1inCC5fIxTmxVriwsOlJtzwYyYQST3 T8aEgJlT3eUPuMC/fFActjySO34d7QW6p7R/99BkbCvvXW1dSlVnVT0dhEdTuZZ9hdkm /tY7voZd1tE+uFDLo80YSRCkcEuGwgWzzkw5mGWe8G8wy8fyNDYDd9OVz+cIQw3pc4Qm RpxDk6Rf6YUd+RU1tJUcnpOr17VGOqne9A7m1W/3AzYDOZDdsZliGOL0qC9jDel2qHXU EA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y3y1rpy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:38 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231AtwAA005110 for ; Fri, 1 Apr 2022 11:16:38 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y3y1rp4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:37 +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 231B90DI028416; Fri, 1 Apr 2022 11:16:35 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 3f1tf94v6d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:35 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231B4SFT51183986 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:04:28 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A58BF4C05E; Fri, 1 Apr 2022 11:16:32 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 55BD14C066; Fri, 1 Apr 2022 11:16:32 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:32 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 16/27] s390x: smp: stop already stopped CPU Date: Fri, 1 Apr 2022 13:16:09 +0200 Message-Id: <20220401111620.366435-17-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: pc_GSo31daHc1M70isj9S35kfVOxacrQ X-Proofpoint-ORIG-GUID: Cp94BAgw-R5FCgixWEf9d3HeJj79yARc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 impostorscore=0 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr As per the PoP, the SIGP STOP order is only effective when the CPU is in the operating state. Hence, we should have a test which tries to stop an already stopped CPU. Even though the SIGP order might be processed asynchronously, we assert the CPU stays stopped. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Reviewed-by: Janosch Frank Signed-off-by: Claudio Imbrenda --- s390x/smp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/s390x/smp.c b/s390x/smp.c index cfced18a..fcced84f 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -140,6 +140,11 @@ static void test_stop(void) report(!rc, "return code"); report(smp_cpu_stopped(1), "cpu stopped"); + report_prefix_push("stop stopped CPU"); + report(!smp_cpu_stop(1), "STOP succeeds"); + report(smp_cpu_stopped(1), "CPU is stopped"); + report_prefix_pop(); + report_prefix_pop(); } From patchwork Fri Apr 1 11:16:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798172 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 6B094C433EF for ; Fri, 1 Apr 2022 11:17:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345414AbiDALSw (ORCPT ); Fri, 1 Apr 2022 07:18:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345391AbiDALS2 (ORCPT ); Fri, 1 Apr 2022 07:18:28 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15CCA1868AB for ; Fri, 1 Apr 2022 04:16:40 -0700 (PDT) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2319j1Lh007322 for ; Fri, 1 Apr 2022 11:16:39 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=2S4EMHm0Ca/wGsV6iNJC8p07QeUCfY0kKxIeZFhKOOU=; b=aSStLGQvm3Xs6M2XbO3wGm4VuKaSIBo3Sx+CUOj3tN8mNKOnsL8wBM65LSuKSJu/HFRB RyYLyrprYT7NBkAdyMdPmheIO2k6+ysPSUO1d/b302I62rA3tDz4UwxtYOCy962EpOAa ZrYRPQ5Fzz1Lw+Yh32r3QniCXDvbovBd+0K8BBMjgEK7HYED4jSoUCDuHkkNMi864gsP s/Ofbjfey9P5hyo36FTh33+qI1navK4erpQS0aTXM6oSQXxHNxFfITQ6ddcFBIuc48Zd O08mgl25ogaw2eYrAw1AlRswUsoUZXvJCuKVEHVvTImeyK8sCea3dAIBdBXGNrcDxqAf PA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y1j9tw1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:39 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231ArW8E000304 for ; Fri, 1 Apr 2022 11:16:39 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y1j9tv0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:39 +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 231B7R3T020794; Fri, 1 Apr 2022 11:16:36 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04fra.de.ibm.com with ESMTP id 3f1tf92wqn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:36 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGXr231260950 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:33 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1F1A54C05E; Fri, 1 Apr 2022 11:16:33 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C25344C040; Fri, 1 Apr 2022 11:16:32 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:32 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 17/27] s390x: smp: add tests for SET_PREFIX Date: Fri, 1 Apr 2022 13:16:10 +0200 Message-Id: <20220401111620.366435-18-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: MEGUwIUMft0RXaZ9cGXVlLIUzuFPk_Ch X-Proofpoint-GUID: v7H3ujSZEQ1TkwaWOxmBFZACOXVIwRFW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_04,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 clxscore=1015 adultscore=0 phishscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr We cover the following cases: - running CPU - illegal CPU id The order should be rejected in both cases. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Signed-off-by: Claudio Imbrenda --- s390x/smp.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/s390x/smp.c b/s390x/smp.c index fcced84f..2015f82c 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -37,6 +37,8 @@ static const struct sigp_invalid_cases cases_valid_cpu_addr[] = { { INVALID_ORDER_CODE, "invalid order code" }, }; +static uint32_t cpu1_prefix; + static void test_invalid(void) { const struct sigp_invalid_cases *c; @@ -213,6 +215,76 @@ static void test_store_status(void) report_prefix_pop(); } +static void loop(void) +{ + while (1) + ; +} + +static void stpx_and_set_flag(void) +{ + asm volatile ( + " stpx %[prefix]\n" + : [prefix] "=Q" (cpu1_prefix) + : + : + ); + + set_flag(1); +} + +static void test_set_prefix(void) +{ + struct lowcore *new_lc = alloc_pages_flags(1, AREA_DMA31); + struct cpu *cpu1 = smp_cpu_from_idx(1); + uint32_t status = 0; + struct psw new_psw; + int cc; + + report_prefix_push("set prefix"); + + assert(new_lc); + + memcpy(new_lc, cpu1->lowcore, sizeof(struct lowcore)); + new_lc->restart_new_psw.addr = (unsigned long)loop; + + report_prefix_push("running"); + set_flag(0); + new_psw.addr = (unsigned long)stpx_and_set_flag; + new_psw.mask = extract_psw_mask(); + smp_cpu_start(1, new_psw); + wait_for_flag(); + cpu1_prefix = 0xFFFFFFFF; + + cc = smp_sigp(1, SIGP_SET_PREFIX, (unsigned long)new_lc, &status); + report(cc == 1, "CC = 1"); + report(status == SIGP_STATUS_INCORRECT_STATE, "status = INCORRECT_STATE"); + + /* + * If the prefix of the other CPU was changed it will enter an endless + * loop. Otherwise, it should eventually set the flag. + */ + smp_cpu_stop(1); + set_flag(0); + smp_cpu_restart(1); + wait_for_flag(); + report(cpu1_prefix == (uint64_t)cpu1->lowcore, "prefix unchanged"); + + report_prefix_pop(); + + report_prefix_push("invalid CPU address"); + + cc = sigp(INVALID_CPU_ADDRESS, SIGP_SET_PREFIX, (unsigned long)new_lc, &status); + report(cc == 3, "CC = 3"); + + report_prefix_pop(); + + free_pages(new_lc); + + report_prefix_pop(); + +} + static void ecall(void) { unsigned long mask; @@ -401,6 +473,7 @@ int main(void) test_stop(); test_stop_store_status(); test_store_status(); + test_set_prefix(); test_ecall(); test_emcall(); test_sense_running(); From patchwork Fri Apr 1 11:16:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798174 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 0DB13C433F5 for ; Fri, 1 Apr 2022 11:17:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242976AbiDALS4 (ORCPT ); Fri, 1 Apr 2022 07:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345429AbiDALS3 (ORCPT ); Fri, 1 Apr 2022 07:18:29 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B54B81868BF for ; Fri, 1 Apr 2022 04:16:40 -0700 (PDT) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 231BDQL0022899 for ; Fri, 1 Apr 2022 11:16:40 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=QSsH4Z2r0SBHcbfuMUc1Zc83TeNjF+nF0mCNnDiUxn4=; b=PiNcRwWQT5OEkrsSrxyQY09m5MUdhgk1fV4CsGBUfeF4RSmbVq/xh+YqcQdAOoHp7Ocj 8aFe8va38DTHNhl5cqdGz06zabsLFxivsPiB9qXk72nolEq6Iqx2bOrK0wTrXBUe9i2b ThK06t6Jt+Rtvid9xAAW9cN39V0vbK4kh65UU2ztYDEwf8uiSVmNKHE74DKlAno+DG4O On5CR1JBgqqU7LYk7JS0ic0Bc/itqAntF9lHuFcT5EdNYO9eEBfuDxyPwUwf4pkuz8mE N6bHtqGqb9nriEnDCno/KGim9KOWOF5VNwiW7AZKPB0J6miEegPvKbcDgvLPLP7Ow6iK sg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3f60awr26q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:39 +0000 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231BDhBh023259 for ; Fri, 1 Apr 2022 11:16:39 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0b-001b2d01.pphosted.com with ESMTP id 3f60awr26a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:39 +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 231B93ZY023444; Fri, 1 Apr 2022 11:16:37 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma01fra.de.ibm.com with ESMTP id 3f1tf8tvs5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:37 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGXhL35783082 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:34 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 84F164C05A; Fri, 1 Apr 2022 11:16:33 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3245D4C040; Fri, 1 Apr 2022 11:16:33 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:33 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 18/27] s390x: smp: add test for EMERGENCY_SIGNAL with invalid CPU address Date: Fri, 1 Apr 2022 13:16:11 +0200 Message-Id: <20220401111620.366435-19-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 6rTwbrVV16XsfuNHUjrrbfHbC6dzgF3w X-Proofpoint-GUID: wWmEoCvJvPCK7Jd7hsQR8USKTGbNqGi8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=930 clxscore=1015 mlxscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr In this case, we expect the order to be rejected. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Signed-off-by: Claudio Imbrenda --- s390x/smp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/s390x/smp.c b/s390x/smp.c index 2015f82c..c204d0b9 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -338,6 +338,7 @@ static void emcall(void) static void test_emcall(void) { struct psw psw; + int cc; psw.mask = extract_psw_mask(); psw.addr = (unsigned long)emcall; @@ -350,6 +351,14 @@ static void test_emcall(void) smp_sigp(1, SIGP_EMERGENCY_SIGNAL, 0, NULL); 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(); } From patchwork Fri Apr 1 11:16:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798175 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 ADCB9C433EF for ; Fri, 1 Apr 2022 11:17:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345471AbiDALS6 (ORCPT ); Fri, 1 Apr 2022 07:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345431AbiDALS3 (ORCPT ); Fri, 1 Apr 2022 07:18:29 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2614186F83 for ; Fri, 1 Apr 2022 04:16:40 -0700 (PDT) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2319noig006652 for ; Fri, 1 Apr 2022 11:16:40 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=lWcgMYQHu3kxXQ8mFwqZdEXsvqpQpk1pNBgJRl32bBc=; b=p1+0FMVHEhTvkECeXbUb07ZXqSCwdl68P63pkMs4AT7LC/0btrUlfefh5gg8xDrQaJVp PeN33vyrGUsHBIcTYvsPFoRmYZMIh4bSvZFkhwRO/wSbh50/UbQkGbOvKN01XHBLajqB lOAQhPm9n/LhdhDdnJphpkTaa2XBwoEoSxicYOnqc+2L/k5o4SKPAAeY6vJZ9cMndWN8 fJ5Co7WYwZLzI1N51CNp10IOdKI8bCchb83GRt2YJSWzDRVA9j2Sr7OYnDywWjWncEzs y1fz1CzR7id2dnmeIBZk+0GvK7Yk8HuRQo9GTPxIyo5K0RxdT8gXtu+YVACh1CTFCKsb pQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y3y1rqr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:40 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231ANHqi021930 for ; Fri, 1 Apr 2022 11:16:40 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y3y1rpv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:39 +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 231B7ss8012931; Fri, 1 Apr 2022 11:16:37 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03ams.nl.ibm.com with ESMTP id 3f1tf9mv0p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:37 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGYo845613330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:34 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 060AD4C07A; Fri, 1 Apr 2022 11:16:34 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A4D984C062; Fri, 1 Apr 2022 11:16:33 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:33 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 19/27] s390x: smp: add tests for CONDITIONAL EMERGENCY Date: Fri, 1 Apr 2022 13:16:12 +0200 Message-Id: <20220401111620.366435-20-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ji98iM3-KP2HLiaczVv33_a_H3AM7xji X-Proofpoint-ORIG-GUID: k-0qF81PQRXFDSrrzOQLZlJ38HD_SASC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 impostorscore=0 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr Add a test for the conditional emergency signal. We cover the following cases: - invalid CPU address. Should lead to the order being rejected. - the order is accepted and an emergency signal is delivered. We make sure this is the case by disabling the CPU's PSW for IO interruptions. Note we intentionally don't cover the case where the signal isn't delivered. As per the PoP, implementations are allowed to make the signal an unconditional one when the condition determination is precluded. This test is unsupported under PV. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Signed-off-by: Claudio Imbrenda --- s390x/smp.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/s390x/smp.c b/s390x/smp.c index c204d0b9..1dffbd7b 100644 --- a/s390x/smp.c +++ b/s390x/smp.c @@ -16,6 +16,7 @@ #include #include +#include #include static int testflag = 0; @@ -362,6 +363,47 @@ static void test_emcall(void) 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; + } + + 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); + + 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) { report_prefix_push("sense_running"); @@ -485,6 +527,7 @@ int main(void) test_set_prefix(); test_ecall(); test_emcall(); + test_cond_emcall(); test_sense_running(); test_reset(); test_reset_initial(); From patchwork Fri Apr 1 11:16:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798173 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 99BEAC433EF for ; Fri, 1 Apr 2022 11:17:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240530AbiDALSy (ORCPT ); Fri, 1 Apr 2022 07:18:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345440AbiDALSa (ORCPT ); Fri, 1 Apr 2022 07:18:30 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E90C186FAA for ; Fri, 1 Apr 2022 04:16:41 -0700 (PDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2318Jx3h005513 for ; Fri, 1 Apr 2022 11:16:41 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=f26zNlyJJ3F4gbGkbKYOgaKIYlyS1r0jTQDHaVkVL9g=; b=OxTXpexMF2hzkSLe+gZ1BgRtRuqNfKRfc8rrMSOK1OBUcbU+wT8lYdoYElqR0PioFF/9 aEEDNReriK1WCR/c8wLbXu77AIn1h8ZnGUPzphiFQd1vVyoUbpVh3dFDEmL1C4+aLEX3 1yWbYbNHhmV0iwSr5p0+ZzmkoBiqXAFXbV3AyDgMD5wmSmAxn7dmUSqmnANDwSWXWaSK KBdvNL4nBX9qCHCsmGdHZx615keaykggu/HBAn+rvSQH/OmZwGToCWc9dYJyER4r+RtG vIJf0YZxIGM6Wvu3LsbZZMj2sJEKaJedl9BcOYmXZe5TCcIg6DIRvQd6p0BeYi7ek4Pq 0g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5wsq3bhr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:41 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231B8HTD011507 for ; Fri, 1 Apr 2022 11:16:40 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5wsq3bgv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:40 +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 231B8w0m020878; Fri, 1 Apr 2022 11:16:38 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 3f1t3j2xv8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:37 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGY6k45613336 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:34 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A41A4C062; Fri, 1 Apr 2022 11:16:34 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 195D14C084; Fri, 1 Apr 2022 11:16:34 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:34 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr , Janis Schoetterl-Glausch Subject: [kvm-unit-tests GIT PULL 20/27] s390x: add TPROT tests Date: Fri, 1 Apr 2022 13:16:13 +0200 Message-Id: <20220401111620.366435-21-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 06o4ng6Vdf8DExn7r45dKacw9ZezSAmd X-Proofpoint-ORIG-GUID: vMznzXxSlKMlKzpeQSBa3I61soiFfqFN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_04,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 mlxlogscore=982 spamscore=0 lowpriorityscore=0 impostorscore=0 mlxscore=0 suspectscore=0 clxscore=1015 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr Add tests for TEST PROTECTION. We cover the following cases: - page is read/write - page is readonly - lowcore protection - page is not present - translation specification exception We don't cover storage keys and the case where the page can be neither read nor written right now. This test mainly applies to the TCG case. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Reviewed-by: Janis Schoetterl-Glausch Signed-off-by: Claudio Imbrenda --- s390x/Makefile | 1 + s390x/tprot.c | 108 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 ++ 3 files changed, 112 insertions(+) create mode 100644 s390x/tprot.c diff --git a/s390x/Makefile b/s390x/Makefile index 25449708..93475972 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -3,6 +3,7 @@ tests += $(TEST_DIR)/intercept.elf tests += $(TEST_DIR)/emulator.elf tests += $(TEST_DIR)/sieve.elf tests += $(TEST_DIR)/sthyi.elf +tests += $(TEST_DIR)/tprot.elf tests += $(TEST_DIR)/skey.elf tests += $(TEST_DIR)/diag10.elf tests += $(TEST_DIR)/diag308.elf diff --git a/s390x/tprot.c b/s390x/tprot.c new file mode 100644 index 00000000..460a0db7 --- /dev/null +++ b/s390x/tprot.c @@ -0,0 +1,108 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * TEST PROTECTION tests + * + * Copyright IBM Corp. 2022 + * + * Authors: + * Nico Boehr + */ + +#include +#include +#include +#include +#include "mmu.h" +#include +#include + +static uint8_t pagebuf[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); + +static void test_tprot_rw(void) +{ + int cc; + + report_prefix_push("Page read/writeable"); + + cc = tprot((unsigned long)pagebuf, 0); + report(cc == 0, "CC = 0"); + + report_prefix_pop(); +} + +static void test_tprot_ro(void) +{ + int cc; + + report_prefix_push("Page readonly"); + + protect_dat_entry(pagebuf, PAGE_ENTRY_P, 5); + + cc = tprot((unsigned long)pagebuf, 0); + report(cc == 1, "CC = 1"); + + unprotect_dat_entry(pagebuf, PAGE_ENTRY_P, 5); + + report_prefix_pop(); +} + +static void test_tprot_low_addr_prot(void) +{ + int cc; + + report_prefix_push("low-address protection"); + + low_prot_enable(); + cc = tprot(0, 0); + low_prot_disable(); + report(cc == 1, "CC = 1"); + + report_prefix_pop(); +} + +static void test_tprot_transl_unavail(void) +{ + int cc; + + report_prefix_push("Page translation unavailable"); + + protect_dat_entry(pagebuf, PAGE_ENTRY_I, 5); + + cc = tprot((unsigned long)pagebuf, 0); + report(cc == 3, "CC = 3"); + + unprotect_dat_entry(pagebuf, PAGE_ENTRY_I, 5); + + report_prefix_pop(); +} + +static void test_tprot_transl_pte_bit52_set(void) +{ + report_prefix_push("PTE Bit 52 set"); + + protect_dat_entry(pagebuf, BIT(63 - 52), 5); + + expect_pgm_int(); + tprot((unsigned long)pagebuf, 0); + check_pgm_int_code(PGM_INT_CODE_TRANSLATION_SPEC); + + unprotect_dat_entry(pagebuf, BIT(63 - 52), 5); + + report_prefix_pop(); +} + +int main(void) +{ + report_prefix_push("tprot"); + + setup_vm(); + + test_tprot_rw(); + test_tprot_ro(); + test_tprot_low_addr_prot(); + test_tprot_transl_unavail(); + test_tprot_transl_pte_bit52_set(); + + report_prefix_pop(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index aeb82246..743013b2 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -143,3 +143,6 @@ file = sck.elf [epsw] file = epsw.elf extra_params = -device virtio-net-ccw + +[tprot] +file = tprot.elf From patchwork Fri Apr 1 11:16:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798176 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 0285AC4332F for ; Fri, 1 Apr 2022 11:17:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345413AbiDALTA (ORCPT ); Fri, 1 Apr 2022 07:19:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345444AbiDALSb (ORCPT ); Fri, 1 Apr 2022 07:18:31 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF08B1877C0 for ; Fri, 1 Apr 2022 04:16:41 -0700 (PDT) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 231AKGEH039376 for ; Fri, 1 Apr 2022 11:16:41 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=2EoOWhS0a39fPVtxj96o+mx8iMKKB3uzPfipQIpr8sY=; b=AofxaX+ffAw9MFw/Po8eI/Iuj/hCeeRW1ogNUEqeDjukBtB0rf6HGhmWP07yG5sZuzlE qMcyefZTaJ5xdhzYCHBhfP5RJT9srm5At3LVUGxXBcw/m2ENNv/bvmtbdJr3KoSvTV25 Ak/12pA/eQ5pCti25L2FdJLVmlpbvXQW+kkxwVugrE1TnrI98XTebUTzX4QMauXUIFNy aArVMUdU4CyQJlyzsiijEPW0+nBADUE2uTvtItsnqC0dOUhXgtH7VvZErC9RkcnAKR9/ rz939MY76RqLYZ0n422P5YWHRdlSiP6yvuUvQdAdO/CqyGMkXw/b3nDI9VSwoAutvJcr 9A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5yj0s180-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:40 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231ATCiS026556 for ; Fri, 1 Apr 2022 11:16:40 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5yj0s173-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:40 +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 231B7Pwu020761; Fri, 1 Apr 2022 11:16:38 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma04fra.de.ibm.com with ESMTP id 3f1tf92wqq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:37 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGYfH22938094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:35 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CFD554C05A; Fri, 1 Apr 2022 11:16:34 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 873AC4C06D; Fri, 1 Apr 2022 11:16:34 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:34 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 21/27] s390x: stsi: check zero and ignored bits in r0 and r1 Date: Fri, 1 Apr 2022 13:16:14 +0200 Message-Id: <20220401111620.366435-22-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: OXrUP4s5Kk3rVkdKYP0LF3IyougBKWhn X-Proofpoint-ORIG-GUID: TMLdtsVCnTtc1lBoyHlZkP3Uz_qYiujO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_04,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=919 impostorscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr We previously only checked for two zero bits, one in r0 and one in r1. Let's check all the bits which must be zero and which are ignored to extend the coverage. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Signed-off-by: Claudio Imbrenda --- s390x/stsi.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/s390x/stsi.c b/s390x/stsi.c index dccc53e7..94a579dc 100644 --- a/s390x/stsi.c +++ b/s390x/stsi.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -19,19 +20,40 @@ static uint8_t pagebuf[PAGE_SIZE * 2] __attribute__((aligned(PAGE_SIZE * 2))); static void test_specs(void) { + int i; + int cc; + report_prefix_push("specification"); - report_prefix_push("inv r0"); - expect_pgm_int(); - stsi(pagebuf, 0, 1 << 8, 0); - check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); - report_prefix_pop(); + for (i = 36; i <= 55; i++) { + report_prefix_pushf("set invalid r0 bit %d", i); + expect_pgm_int(); + stsi(pagebuf, 0, BIT(63 - i), 0); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); + } - report_prefix_push("inv r1"); - expect_pgm_int(); - stsi(pagebuf, 1, 0, 1 << 16); - check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); - report_prefix_pop(); + for (i = 32; i <= 47; i++) { + report_prefix_pushf("set invalid r1 bit %d", i); + expect_pgm_int(); + stsi(pagebuf, 1, 0, BIT(63 - i)); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); + } + + for (i = 0; i < 32; i++) { + report_prefix_pushf("r0 bit %d ignored", i); + cc = stsi(pagebuf, 3, 2 | BIT(63 - i), 2); + report(!cc, "CC = 0"); + report_prefix_pop(); + } + + for (i = 0; i < 32; i++) { + report_prefix_pushf("r1 bit %d ignored", i); + cc = stsi(pagebuf, 3, 2, 2 | BIT(63 - i)); + report(!cc, "CC = 0"); + report_prefix_pop(); + } report_prefix_push("unaligned"); expect_pgm_int(); From patchwork Fri Apr 1 11:16:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798177 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 D0829C433F5 for ; Fri, 1 Apr 2022 11:17:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345469AbiDALTB (ORCPT ); Fri, 1 Apr 2022 07:19:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345441AbiDALSb (ORCPT ); Fri, 1 Apr 2022 07:18:31 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F96D186FBC for ; Fri, 1 Apr 2022 04:16:41 -0700 (PDT) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 231An34g008396 for ; Fri, 1 Apr 2022 11:16:40 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=+YUjl0r7Uz8jv0emyR1TDh9NGW4z6s5MuCruGecpzKg=; b=iShFiCy5llsPnXLKxlqLN4OpJ1YvbPwg+ZtcoW80FT6iOay1toXQxbUizsSN9Y/ZUes6 TVWvRxabLSz2E/VNMrfoDOXy4k0MiZYcJZkqcofldeeq/AQUnkK858H0WAbM1aoHwGKz 4kzYPhXa8eEC3Nn0Gf4UNXxUHVnmG79/Wr0h9oRwoUNC2GKyDLTMFJ7/4IXdRMAA76Dy qC9YMqd5PHv28il98Xes5/tMJlrbajvifFLYyyAGchoBX1oG/2GVBjFqubE7CR1rbsRF tASzrfN9Q8Fw33I1N9gOeR3vTed61/sLiaPNn0JxDSaJFJ6tQNxdh5ik8dqoPzBA+fmB ag== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3f5yyq8j5s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:40 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231BA7n7022173 for ; Fri, 1 Apr 2022 11:16:40 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 3f5yyq8j5d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:40 +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 231B90DK028416; Fri, 1 Apr 2022 11:16:38 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 3f1tf94v6g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:38 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGZfi22020574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:35 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4BE7E4C05C; Fri, 1 Apr 2022 11:16:35 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF5524C05E; Fri, 1 Apr 2022 11:16:34 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:34 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests GIT PULL 22/27] s390x: snippets: c: Load initial cr0 Date: Fri, 1 Apr 2022 13:16:15 +0200 Message-Id: <20220401111620.366435-23-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: O4FYaS6aZkzNDoaByoZQtNorWH-QebXj X-Proofpoint-ORIG-GUID: Hok0yxJJMhZT12K1YgwMWjc4ZyfWp9fd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_04,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 malwarescore=0 spamscore=0 suspectscore=0 adultscore=0 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=873 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank As soon as we use C we need to set the AFP bit in cr0 so we can use all fprs. Signed-off-by: Janosch Frank Reviewed-by: Claudio Imbrenda Signed-off-by: Claudio Imbrenda --- s390x/snippets/c/cstart.S | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/s390x/snippets/c/cstart.S b/s390x/snippets/c/cstart.S index aaa5380c..a7d4cd42 100644 --- a/s390x/snippets/c/cstart.S +++ b/s390x/snippets/c/cstart.S @@ -12,6 +12,8 @@ .section .init .globl start start: + larl %r1, initial_cr0 + lctlg %c0, %c0, 0(%r1) /* XOR all registers with themselves to clear them fully. */ .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 xgr \i,\i @@ -34,3 +36,7 @@ exit: /* For now let's only use cpu 0 in snippets so this will always work. */ xgr %r0, %r0 sigp %r2, %r0, SIGP_STOP + +initial_cr0: + /* enable AFP-register control, so FP regs (+BFP instr) can be used */ + .quad 0x0000000000040000 From patchwork Fri Apr 1 11:16:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798181 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 2D6FCC433FE for ; Fri, 1 Apr 2022 11:17:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345507AbiDALTH (ORCPT ); Fri, 1 Apr 2022 07:19:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345457AbiDALSf (ORCPT ); Fri, 1 Apr 2022 07:18:35 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A05931877F7 for ; Fri, 1 Apr 2022 04:16:41 -0700 (PDT) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2319j3DB007734 for ; Fri, 1 Apr 2022 11:16:41 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=c5SFzfQf7kPWAzQreYEcrFgHzA3W7E8LW8DsMlnJOXU=; b=RFjBi7NHxPo5rkzlmxOj0Nxet/xhA4zvAseEvWpXw5t6U/WEGoe98uBTFEIebFN/4AAp UWpcwNXkwDFTEx2aKVK7Yl2L8S0nEd6JkQ4JVsymK+QLSzalOvfwsEJ8aq2jAX5HuXIr qY9fMrfgyJDvgjbRP6xzR2bIM01heMNgbCHnU6wY/VJ8C5x6Ug8KUQ3VUi7nCOYg7y8h RnbFWDya6s0+xeiCUZ4AolH9LdnjzyBIInsAqeE7vMEQT1e/Am6Mpip0KsqWRIkO/Gww rvB+Ul16o2BL3zwbCOtIsJdQAUlAVWjTUyXmJxGIvZyd+KYAc5ybDtjkI7K+mZl4sDYN dg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y1j9twx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:41 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231AiDhl004436 for ; Fri, 1 Apr 2022 11:16:41 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y1j9tw0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:41 +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 231B7jrh019695; Fri, 1 Apr 2022 11:16:38 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06ams.nl.ibm.com with ESMTP id 3f3rs3qun4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:38 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGZfv37093830 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:35 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B04704C05C; Fri, 1 Apr 2022 11:16:35 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 604B14C05E; Fri, 1 Apr 2022 11:16:35 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:35 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests GIT PULL 23/27] s390x: remove spurious includes Date: Fri, 1 Apr 2022 13:16:16 +0200 Message-Id: <20220401111620.366435-24-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Q8oyTR2dqZUW0a0o-xKJ3tThdkbFRtQC X-Proofpoint-GUID: 2ZZ7AHqepKlAB1if-SvbJIeussaqlLPu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_04,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 clxscore=1015 adultscore=0 phishscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 mlxlogscore=785 lowpriorityscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Remove unused includes of vm.h Signed-off-by: Claudio Imbrenda Reviewed-by: Janosch Frank --- s390x/mvpg-sie.c | 1 - s390x/pv-diags.c | 1 - s390x/spec_ex-sie.c | 1 - 3 files changed, 3 deletions(-) diff --git a/s390x/mvpg-sie.c b/s390x/mvpg-sie.c index 8ae9a52a..46a2edb6 100644 --- a/s390x/mvpg-sie.c +++ b/s390x/mvpg-sie.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include diff --git a/s390x/pv-diags.c b/s390x/pv-diags.c index 110547ad..6899b859 100644 --- a/s390x/pv-diags.c +++ b/s390x/pv-diags.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/s390x/spec_ex-sie.c b/s390x/spec_ex-sie.c index 5dea4115..d8e25e75 100644 --- a/s390x/spec_ex-sie.c +++ b/s390x/spec_ex-sie.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include From patchwork Fri Apr 1 11:16:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798182 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 290C1C433EF for ; Fri, 1 Apr 2022 11:17:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344748AbiDALTI (ORCPT ); Fri, 1 Apr 2022 07:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345427AbiDALSf (ORCPT ); Fri, 1 Apr 2022 07:18:35 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A04921877F4 for ; Fri, 1 Apr 2022 04:16:42 -0700 (PDT) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 231BAaSt005632 for ; Fri, 1 Apr 2022 11:16:41 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=fOdyq1T8GEGnPA083uI+90zv9OGvJ3mMlVVAgn5wrgI=; b=qnKo2h2A7VygyQR1Lh/FK9LDBfJvX5iyHd3mkI+RbiIlGjV2hFpmVmxtSF1F5JyPHcfB MgEzrS/XUpPkx4WloIOth73C/T+lYjIShVVu76bnrVWFMmUkuBlwa1z9I/KagZB9UgSQ VTy3UexTNqcFOnAI5RuWf3kVNvgzFS64muftltY+2ic2a46IgGvVWoFbxY1KIglfIVmt tF1UDdb1wJ2I/JzolCPCfKl9DHqV+WMtylSYfecM9UKWbdmrZUFSt2XSPdSkwU4sNlw0 INzgngj0D/G3vq0q9HeBS3OAdXuB8qHI/zVr/siPoDsbATSHzmDLyqI3U3riSvnzRgoj Gw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5wpv3k90-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:41 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231AgK6X014172 for ; Fri, 1 Apr 2022 11:16:41 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5wpv3k8c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:41 +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 231B7ss9012931; Fri, 1 Apr 2022 11:16:39 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 3f1tf9mv0q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:39 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGaI342991950 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:36 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1670B4C063; Fri, 1 Apr 2022 11:16:36 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C2D8B4C062; Fri, 1 Apr 2022 11:16:35 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:35 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests GIT PULL 24/27] s390x: skey: remove check for old z/VM version Date: Fri, 1 Apr 2022 13:16:17 +0200 Message-Id: <20220401111620.366435-25-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 0jZXUGsYjBJhvVFvDoSiYMIKwcEyxETU X-Proofpoint-GUID: agNe7c_A9l6tpj7fOt8xKVibWrVAoEf4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 priorityscore=1501 mlxscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Remove the check for z/VM 6.x, since it is not needed anymore. Signed-off-by: Claudio Imbrenda Reviewed-by: Janosch Frank --- s390x/skey.c | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/s390x/skey.c b/s390x/skey.c index 58a55436..edad53e9 100644 --- a/s390x/skey.c +++ b/s390x/skey.c @@ -65,33 +65,9 @@ static void test_set(void) "set key test"); } -/* Returns true if we are running under z/VM 6.x */ -static bool check_for_zvm6(void) -{ - int dcbt; /* Descriptor block count */ - int nr; - static const unsigned char zvm6[] = { - /* This is "z/VM 6" in EBCDIC */ - 0xa9, 0x61, 0xe5, 0xd4, 0x40, 0x40, 0x40, 0x40, 0xf6 - }; - - if (stsi(pagebuf, 3, 2, 2)) - return false; - - dcbt = pagebuf[31] & 0xf; - - for (nr = 0; nr < dcbt; nr++) { - if (!memcmp(&pagebuf[32 + nr * 64 + 24], zvm6, sizeof(zvm6))) - return true; - } - - return false; -} - static void test_priv(void) { union skey skey; - bool is_zvm6 = check_for_zvm6(); memset(pagebuf, 0, PAGE_SIZE * 2); report_prefix_push("privileged"); @@ -106,15 +82,10 @@ static void test_priv(void) report(skey.str.acc != 3, "skey did not change on exception"); report_prefix_push("iske"); - if (is_zvm6) { - /* There is a known bug with z/VM 6, so skip the test there */ - report_skip("not working on z/VM 6"); - } else { - expect_pgm_int(); - enter_pstate(); - get_storage_key(pagebuf); - check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); - } + expect_pgm_int(); + enter_pstate(); + get_storage_key(pagebuf); + check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); report_prefix_pop(); report_prefix_pop(); From patchwork Fri Apr 1 11:16:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798180 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 C2B4CC433F5 for ; Fri, 1 Apr 2022 11:17:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345431AbiDALTF (ORCPT ); Fri, 1 Apr 2022 07:19:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345455AbiDALSf (ORCPT ); Fri, 1 Apr 2022 07:18:35 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0E54187B8E for ; Fri, 1 Apr 2022 04:16:42 -0700 (PDT) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 231BDqg8005595 for ; Fri, 1 Apr 2022 11:16:41 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=fCJNq6maFgrcKbEcQ4jHn2HBAEZs7i5re9R/P+N3/1g=; b=k82q3jVIi6WYCfWITRTQbHChFNIeJy3PlSDuPCyWffBGNsV5e32iMjovQpxVXa/WM1mi VSee1uPxHcnqvDbIrxTdtba6cZLmWtE3yzKufljIUzu+u1Nyo2TVnufxQPK9pb/eO2qB 4MBPpeYzo6ffK0O60F0UKjpaKICnAjoajQIQuYsfg6Zl2QicdqdfhPn3emEFnBdXMbfE W9+tAAScWBOJzTmrD2XbB3BI1or1c1Hm1q3+hIntRc+cAtxyN1cVUpHW/Bp8a0+Kym/H N2E8dvMnYQAub+Yd7AYftRB+q7SqRFj1QQ0h6r26Z1XW3HFZZHLC3wmer5EAGgjjdTfI iA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5wpv3k93-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:41 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231Avrsn008468 for ; Fri, 1 Apr 2022 11:16:41 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5wpv3k8e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:41 +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 231B90DL028416; Fri, 1 Apr 2022 11:16:39 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04ams.nl.ibm.com with ESMTP id 3f1tf94v6j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:39 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGaZm27001298 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:36 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 799194C064; Fri, 1 Apr 2022 11:16:36 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2AF954C040; Fri, 1 Apr 2022 11:16:36 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:36 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests GIT PULL 25/27] lib: s390x: rename and refactor vm.[ch] Date: Fri, 1 Apr 2022 13:16:18 +0200 Message-Id: <20220401111620.366435-26-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: dwnd0cSsK7BKncIZ7GIvi9NyvVO08E7n X-Proofpoint-GUID: DfJOAo8spNjuTa2BzSQcSiifOODUwB_h X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 priorityscore=1501 mlxscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 spamscore=0 impostorscore=0 bulkscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Refactor and rename vm.[ch] to hardware.[ch] * Rename vm.[ch] to hardware.[ch] * Consolidate all detection functions into detect_host, which returns what host system the test is running on * Rename vm_is_* functions to host_is_*, which are then just wrappers around detect_host Signed-off-by: Claudio Imbrenda Reviewed-by: Janosch Frank --- s390x/Makefile | 2 +- lib/s390x/hardware.h | 40 +++++++++++++++++++ lib/s390x/vm.h | 15 -------- lib/s390x/hardware.c | 69 +++++++++++++++++++++++++++++++++ lib/s390x/vm.c | 92 -------------------------------------------- s390x/cpumodel.c | 4 +- s390x/epsw.c | 4 +- s390x/mvpg.c | 4 +- 8 files changed, 116 insertions(+), 114 deletions(-) create mode 100644 lib/s390x/hardware.h delete mode 100644 lib/s390x/vm.h create mode 100644 lib/s390x/hardware.c delete mode 100644 lib/s390x/vm.c diff --git a/s390x/Makefile b/s390x/Makefile index 93475972..8ff84db5 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -81,7 +81,7 @@ cflatobjs += lib/s390x/sclp-console.o cflatobjs += lib/s390x/interrupt.o cflatobjs += lib/s390x/mmu.o cflatobjs += lib/s390x/smp.o -cflatobjs += lib/s390x/vm.o +cflatobjs += lib/s390x/hardware.o cflatobjs += lib/s390x/css_dump.o cflatobjs += lib/s390x/css_lib.o cflatobjs += lib/s390x/malloc_io.o diff --git a/lib/s390x/hardware.h b/lib/s390x/hardware.h new file mode 100644 index 00000000..e5910ea5 --- /dev/null +++ b/lib/s390x/hardware.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Functions to retrieve information about the host system. + * + * Copyright (c) 2020 Red Hat Inc + * Copyright 2022 IBM Corp. + * + * Authors: + * Claudio Imbrenda + */ + +#ifndef _S390X_HARDWARE_H_ +#define _S390X_HARDWARE_H_ +#include + +enum s390_host { + HOST_IS_UNKNOWN, + HOST_IS_LPAR, + HOST_IS_KVM, + HOST_IS_TCG +}; + +enum s390_host detect_host(void); + +static inline bool host_is_tcg(void) +{ + return detect_host() == HOST_IS_TCG; +} + +static inline bool host_is_kvm(void) +{ + return detect_host() == HOST_IS_KVM; +} + +static inline bool host_is_lpar(void) +{ + return detect_host() == HOST_IS_LPAR; +} + +#endif /* _S390X_HARDWARE_H_ */ diff --git a/lib/s390x/vm.h b/lib/s390x/vm.h deleted file mode 100644 index 4456b48c..00000000 --- a/lib/s390x/vm.h +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Functions to retrieve VM-specific information - * - * Copyright (c) 2020 Red Hat Inc - */ - -#ifndef _S390X_VM_H_ -#define _S390X_VM_H_ - -bool vm_is_tcg(void); -bool vm_is_kvm(void); -bool vm_is_lpar(void); - -#endif /* _S390X_VM_H_ */ diff --git a/lib/s390x/hardware.c b/lib/s390x/hardware.c new file mode 100644 index 00000000..2bcf9c4c --- /dev/null +++ b/lib/s390x/hardware.c @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Functions to retrieve information about the host system. + * + * Copyright (c) 2020 Red Hat Inc + * Copyright 2022 IBM Corp. + * + * Authors: + * Thomas Huth + * Claudio Imbrenda + */ + +#include +#include +#include +#include "hardware.h" +#include "stsi.h" + +/* The string "QEMU" in EBCDIC */ +static const uint8_t qemu_ebcdic[] = { 0xd8, 0xc5, 0xd4, 0xe4 }; +/* The string "KVM/" in EBCDIC */ +static const uint8_t kvm_ebcdic[] = { 0xd2, 0xe5, 0xd4, 0x61 }; + +static enum s390_host do_detect_host(void *buf) +{ + struct sysinfo_3_2_2 *stsi_322 = buf; + + if (stsi_get_fc() == 2) + return HOST_IS_LPAR; + + if (stsi_get_fc() != 3) + return HOST_IS_UNKNOWN; + + if (!stsi(buf, 1, 1, 1)) { + /* + * If the manufacturer string is "QEMU" in EBCDIC, then we + * are on TCG (otherwise the string is "IBM" in EBCDIC) + */ + if (!memcmp((char *)buf + 32, qemu_ebcdic, sizeof(qemu_ebcdic))) + return HOST_IS_TCG; + } + + if (!stsi(buf, 3, 2, 2)) { + /* + * If the manufacturer string is "KVM/" in EBCDIC, then we + * are on KVM. + */ + if (!memcmp(&stsi_322->vm[0].cpi, kvm_ebcdic, sizeof(kvm_ebcdic))) + return HOST_IS_KVM; + } + + return HOST_IS_UNKNOWN; +} + +enum s390_host detect_host(void) +{ + static enum s390_host host = HOST_IS_UNKNOWN; + static bool initialized = false; + void *buf; + + if (initialized) + return host; + + buf = alloc_page(); + host = do_detect_host(buf); + free_page(buf); + initialized = true; + return host; +} diff --git a/lib/s390x/vm.c b/lib/s390x/vm.c deleted file mode 100644 index 33fb1c45..00000000 --- a/lib/s390x/vm.c +++ /dev/null @@ -1,92 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Functions to retrieve VM-specific information - * - * Copyright (c) 2020 Red Hat Inc - * - * Authors: - * Thomas Huth - */ - -#include -#include -#include -#include "vm.h" -#include "stsi.h" - -/** - * Detect whether we are running with TCG (instead of KVM) - */ -bool vm_is_tcg(void) -{ - const char qemu_ebcdic[] = { 0xd8, 0xc5, 0xd4, 0xe4 }; - static bool initialized = false; - static bool is_tcg = false; - uint8_t *buf; - - if (initialized) - return is_tcg; - - if (stsi_get_fc() != 3) { - initialized = true; - return is_tcg; - } - - buf = alloc_page(); - assert(buf); - - if (stsi(buf, 1, 1, 1)) - goto out; - - /* - * If the manufacturer string is "QEMU" in EBCDIC, then we - * are on TCG (otherwise the string is "IBM" in EBCDIC) - */ - is_tcg = !memcmp(&buf[32], qemu_ebcdic, sizeof(qemu_ebcdic)); - initialized = true; -out: - free_page(buf); - return is_tcg; -} - -/** - * Detect whether we are running with KVM - */ -bool vm_is_kvm(void) -{ - /* EBCDIC for "KVM/" */ - const uint8_t kvm_ebcdic[] = { 0xd2, 0xe5, 0xd4, 0x61 }; - static bool initialized; - static bool is_kvm; - struct sysinfo_3_2_2 *stsi_322; - - if (initialized) - return is_kvm; - - if (stsi_get_fc() != 3 || vm_is_tcg()) { - initialized = true; - return is_kvm; - } - - stsi_322 = alloc_page(); - assert(stsi_322); - - if (stsi(stsi_322, 3, 2, 2)) - goto out; - - /* - * If the manufacturer string is "KVM/" in EBCDIC, then we - * are on KVM. - */ - is_kvm = !memcmp(&stsi_322->vm[0].cpi, kvm_ebcdic, sizeof(kvm_ebcdic)); - initialized = true; -out: - free_page(stsi_322); - return is_kvm; -} - -bool vm_is_lpar(void) -{ - return stsi_get_fc() == 2; -} - diff --git a/s390x/cpumodel.c b/s390x/cpumodel.c index 23ccf842..5c0b73e0 100644 --- a/s390x/cpumodel.c +++ b/s390x/cpumodel.c @@ -10,7 +10,7 @@ */ #include -#include +#include #include #include #include @@ -118,7 +118,7 @@ int main(void) for (i = 0; i < ARRAY_SIZE(dep); i++) { report_prefix_pushf("%d implies %d", dep[i].facility, dep[i].implied); if (test_facility(dep[i].facility)) { - report_xfail(dep[i].expected_tcg_fail && vm_is_tcg(), + report_xfail(dep[i].expected_tcg_fail && host_is_tcg(), test_facility(dep[i].implied), "implication not correct"); } else { diff --git a/s390x/epsw.c b/s390x/epsw.c index 192115cf..5b73f4b3 100644 --- a/s390x/epsw.c +++ b/s390x/epsw.c @@ -9,7 +9,7 @@ */ #include #include -#include +#include static uint32_t zero_out_cc_from_epsw_op1(uint32_t epsw_op1) { @@ -97,7 +97,7 @@ static void test_epsw(void) int main(int argc, char **argv) { - if (!vm_is_kvm() && !vm_is_tcg()) { + if (!host_is_kvm() && !host_is_tcg()) { report_skip("Not running under QEMU"); goto done; } diff --git a/s390x/mvpg.c b/s390x/mvpg.c index 2b7c6cc9..62f0fc5a 100644 --- a/s390x/mvpg.c +++ b/s390x/mvpg.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include /* Used to build the appropriate test values for register 0 */ #define KFC(x) ((x) << 10) @@ -251,7 +251,7 @@ static void test_mmu_prot(void) fresh += PAGE_SIZE; /* Known issue in TCG: CCO flag is not honoured */ - if (vm_is_tcg()) { + if (host_is_tcg()) { report_prefix_push("TCG"); report_skip("destination invalid"); report_skip("source invalid"); From patchwork Fri Apr 1 11:16:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798179 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 00BA5C433FE for ; Fri, 1 Apr 2022 11:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345491AbiDALTE (ORCPT ); Fri, 1 Apr 2022 07:19:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345451AbiDALSf (ORCPT ); Fri, 1 Apr 2022 07:18:35 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0ACA1877FF for ; Fri, 1 Apr 2022 04:16:43 -0700 (PDT) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2318tXZ5008580 for ; Fri, 1 Apr 2022 11:16:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=Hk7jCuI9ezhjIg/8wY3JH0tZ6Tz5LizZU+YcN1Dfiys=; b=SY/ZNZ6iW/GnqICREZwjIg0MSsljzBdKrJ5feKJDS4heqGt9x23rcFEWT/r9WND4Cq1E WSNmDG44ZBpah09tIVz8ZAVuhJjzxq1WdpQno9NQCXNsBedb1vQhKhVo9YZenIp2zSCD nEUgo8/O0AoQ0t07unVm6hmU9GaXE4ulf3EYmKhdNQ0iwaPsJbff/QH4N5lpR1Q00w+h 07nt1eZYrnkqq9UmAdVlpzq75ltWRHovxB3vFHi6rm6J9O2SN01COJ7b6aNnifOLBR4D U2n6uwPx+3BMH3J38kmO/1bOD3sl8NZ6+3LkGtP0PKzRBuZNqGRv9gZmYjbsAnsr21Gx gw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5xab2tcn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:42 +0000 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 2319wAig027539 for ; Fri, 1 Apr 2022 11:16:42 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5xab2tbx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:42 +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 231B7Pwv020761; Fri, 1 Apr 2022 11:16:40 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04fra.de.ibm.com with ESMTP id 3f1tf92wqr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:40 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGbAH33227094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:37 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D7DFC4C040; Fri, 1 Apr 2022 11:16:36 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8BEF14C06D; Fri, 1 Apr 2022 11:16:36 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:36 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests GIT PULL 26/27] lib: s390x: functions for machine models Date: Fri, 1 Apr 2022 13:16:19 +0200 Message-Id: <20220401111620.366435-27-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Lz4Mngf3wnDwrEjpGL_xFQ7vMTXzSlBM X-Proofpoint-GUID: ygtux8NARI6VTxbdztbreYql46IXhlYb X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_03,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 spamscore=0 suspectscore=0 impostorscore=0 clxscore=1015 adultscore=0 mlxlogscore=635 phishscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org * move existing macros for machine models to hardware.h * add machine_is_* functions Signed-off-by: Claudio Imbrenda Reviewed-by: Janosch Frank --- lib/s390x/asm/arch_def.h | 3 --- lib/s390x/hardware.h | 10 ++++++++++ s390x/uv-host.c | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h index 40626d72..8d860ccf 100644 --- a/lib/s390x/asm/arch_def.h +++ b/lib/s390x/asm/arch_def.h @@ -219,9 +219,6 @@ static inline unsigned short stap(void) return cpu_address; } -#define MACHINE_Z15A 0x8561 -#define MACHINE_Z15B 0x8562 - static inline uint16_t get_machine_id(void) { uint64_t cpuid; diff --git a/lib/s390x/hardware.h b/lib/s390x/hardware.h index e5910ea5..af20be18 100644 --- a/lib/s390x/hardware.h +++ b/lib/s390x/hardware.h @@ -13,6 +13,9 @@ #define _S390X_HARDWARE_H_ #include +#define MACHINE_Z15 0x8561 +#define MACHINE_Z15T02 0x8562 + enum s390_host { HOST_IS_UNKNOWN, HOST_IS_LPAR, @@ -37,4 +40,11 @@ static inline bool host_is_lpar(void) return detect_host() == HOST_IS_LPAR; } +static inline bool machine_is_z15(void) +{ + uint16_t machine = get_machine_id(); + + return machine == MACHINE_Z15 || machine == MACHINE_Z15T02; +} + #endif /* _S390X_HARDWARE_H_ */ diff --git a/s390x/uv-host.c b/s390x/uv-host.c index de2e4850..d3018e3c 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -111,7 +112,6 @@ static void test_config_destroy(void) static void test_cpu_destroy(void) { int rc; - uint16_t machineid = get_machine_id(); struct uv_cb_nodata uvcb = { .header.len = sizeof(uvcb), .header.cmd = UVC_CMD_DESTROY_SEC_CPU, @@ -126,7 +126,7 @@ static void test_cpu_destroy(void) "hdr invalid length"); uvcb.header.len += 8; - if (machineid != MACHINE_Z15A && machineid != MACHINE_Z15B) { + if (!machine_is_z15()) { uvcb.handle += 1; rc = uv_call(0, (uint64_t)&uvcb); report(rc == 1 && uvcb.header.rc == UVC_RC_INV_CHANDLE, "invalid handle"); From patchwork Fri Apr 1 11:16:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12798178 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 3F9FBC433EF for ; Fri, 1 Apr 2022 11:17:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345487AbiDALTC (ORCPT ); Fri, 1 Apr 2022 07:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345448AbiDALSe (ORCPT ); Fri, 1 Apr 2022 07:18:34 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A10CD187B97 for ; Fri, 1 Apr 2022 04:16:43 -0700 (PDT) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2319j6AW007942 for ; Fri, 1 Apr 2022 11:16:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=xldSF39mUuRll1043UB57opeZCqbLkGfiTZQPtI7n9g=; b=nD/J2jypxnqBEUZ6tIf+WV2OSdu9NdXW0ybioacxwk18jw5FmxITeHw4E/eZijPujUCm KINp9jaJC5LR30fqQKKbUWTXufbALw+upueRW+W0JUI1MlBBBSDCrGrsVRmDeZ0AquqF 7cyw/z4G28XuE835VU6hD47fRhNhmOPpsgbYvGi9lUBCPRyoeBbbrKH4nSlYLX10FsOK rtLMEPA5NdYVtYujwkd/zpoxntOko4vqScoXSUD8uXzEYLcauy4bb/vR6ppNYWhsfUON U8CkOGgxBpDqF0To+C+xXZrnyEwAocMijD+nCnDDK9lZxxLXg3l094ALbSGICv/uVzvB fw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y1j9txq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 01 Apr 2022 11:16:43 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 231BEPQM005068 for ; Fri, 1 Apr 2022 11:16:42 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f5y1j9twr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:42 +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 231B98ib022203; Fri, 1 Apr 2022 11:16:40 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma02fra.de.ibm.com with ESMTP id 3f1tf92wa3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Apr 2022 11:16:40 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 231BGbIQ43319722 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Apr 2022 11:16:37 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3FE774C066; Fri, 1 Apr 2022 11:16:37 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E9E2C4C06D; Fri, 1 Apr 2022 11:16:36 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.3.73]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 Apr 2022 11:16:36 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests GIT PULL 27/27] lib: s390x: stidp wrapper and move get_machine_id Date: Fri, 1 Apr 2022 13:16:20 +0200 Message-Id: <20220401111620.366435-28-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401111620.366435-1-imbrenda@linux.ibm.com> References: <20220401111620.366435-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: bf8TnckajjUgBQRAbZpapvYCfA2kya-t X-Proofpoint-GUID: ImkJxq3-y6lL35z0N0_g77ME4QqTb4HU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-01_04,2022-03-31_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 clxscore=1015 adultscore=0 phishscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 mlxlogscore=919 lowpriorityscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204010050 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Refactor get_machine_id in arch_def.h into a simple wrapper around stidp, add back get_machine_id in hardware.h using the stidp wrapper. Signed-off-by: Claudio Imbrenda Reviewed-by: Janosch Frank --- lib/s390x/asm/arch_def.h | 4 +--- lib/s390x/hardware.h | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h index 8d860ccf..bab3c374 100644 --- a/lib/s390x/asm/arch_def.h +++ b/lib/s390x/asm/arch_def.h @@ -219,13 +219,11 @@ static inline unsigned short stap(void) return cpu_address; } -static inline uint16_t get_machine_id(void) +static inline uint64_t stidp(void) { uint64_t cpuid; asm volatile("stidp %0" : "=Q" (cpuid)); - cpuid = cpuid >> 16; - cpuid &= 0xffff; return cpuid; } diff --git a/lib/s390x/hardware.h b/lib/s390x/hardware.h index af20be18..01eeb261 100644 --- a/lib/s390x/hardware.h +++ b/lib/s390x/hardware.h @@ -25,6 +25,11 @@ enum s390_host { enum s390_host detect_host(void); +static inline uint16_t get_machine_id(void) +{ + return stidp() >> 16; +} + static inline bool host_is_tcg(void) { return detect_host() == HOST_IS_TCG;