From patchwork Tue Jul 11 14:15:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308806 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 486B6EB64DD for ; Tue, 11 Jul 2023 14:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233516AbjGKOQw (ORCPT ); Tue, 11 Jul 2023 10:16:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233452AbjGKOQm (ORCPT ); Tue, 11 Jul 2023 10:16:42 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A4F3199F for ; Tue, 11 Jul 2023 07:16:30 -0700 (PDT) Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BEEXXv003988; Tue, 11 Jul 2023 14:16:22 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=1w8oDebDIlf1n3ms42PasCHjBC07q5/awiRBfsM9bz0=; b=NjLTGt8pS/KzIHFt64fJVzI/2c0VN8EJIw9UEsEvPuSMczImfS6ZfvhdaXzZSNhvxChi WPwnWk2TcbuKu1t5i93QALUY4wmymQhCfLohxeEEcDlNcELwZ28evt+1A76/RvBXOLDS M9qSfFnf8m31MIyA2sgCGWPJHvV5miOewnv3vYpXVThTF4c7H64++SxEDqyZgAxKk8ov U/s01oT+hMXO7RZFqmn8pSWNVKt94pNxpUbzim1qyn40CyR6PWPqjw1UicBg4xhFpJfA eS2H2JZim7EVfty5oH4/p3uOFiyOirvEYj+PTH2VenZCv9t7jbfFMuBaFqOsbw0uYWIV jA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8nvr3bx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:20 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BEFPl4008179; Tue, 11 Jul 2023 14:16:17 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8nvr37y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:17 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B4cixi018978; Tue, 11 Jul 2023 14:16:14 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3rpy2e1u3t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:13 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGAsu7602708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:10 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ADC1220040; Tue, 11 Jul 2023 14:16:10 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC52320049; Tue, 11 Jul 2023 14:16:09 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:09 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Nina Schoetterl-Glausch Subject: [PATCH 01/22] lib: s390x: mmu: fix conflicting types for get_dat_entry Date: Tue, 11 Jul 2023 16:15:34 +0200 Message-ID: <20230711141607.40742-2-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: s5vxgWiCWnm7qb1Mxy5SJ6mTI34w2BsA X-Proofpoint-GUID: cPGB8k_PgYBjsySAW-LyL_RrW3UYkpsB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 mlxlogscore=749 adultscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This causes compilation to fail with GCC 13: gcc -std=gnu99 -ffreestanding -I/kut/lib -I/kut/lib/s390x -Ilib -O2 -march=zEC12 -mbackchain -fno-delete-null-pointer-checks -g -MMD -MF lib/s390x/.mmu.d -fno-strict-aliasing -fno-common -Wall -Wwrite-strings -Wempty-body -Wuninitialized -Wignored-qualifiers -Wno-missing-braces -Werror -fomit-frame-pointer -fno-stack-protector -Wno-frame-address -fno-pic -no-pie -Wclobbered -Wunused-but-set-parameter -Wmissing-parameter-type -Wold-style-declaration -Woverride-init -Wmissing-prototypes -Wstrict-prototypes -I/kut/lib -I/kut/lib/s390x -Ilib -c -o lib/s390x/mmu.o lib/s390x/mmu.c lib/s390x/mmu.c:132:7: error: conflicting types for ‘get_dat_entry’ due to enum/integer mismatch; have ‘void *(pgd_t *, void *, enum pgt_level)’ [-Werror=enum-int-mismatch] 132 | void *get_dat_entry(pgd_t *pgtable, void *vaddr, enum pgt_level level) | ^~~~~~~~~~~~~ In file included from lib/s390x/mmu.c:16: lib/s390x/mmu.h:96:7: note: previous declaration of ‘get_dat_entry’ with type ‘void *(pgd_t *, void *, unsigned int)’ 96 | void *get_dat_entry(pgd_t *pgtable, void *vaddr, unsigned int level); | ^~~~~~~~~~~~~ Reviewed-by: Thomas Huth Reviewed-by: Nina Schoetterl-Glausch Reviewed-by: Claudio Imbrenda Signed-off-by: Nico Boehr --- lib/s390x/mmu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/s390x/mmu.h b/lib/s390x/mmu.h index 15f88e4..dadc2e6 100644 --- a/lib/s390x/mmu.h +++ b/lib/s390x/mmu.h @@ -93,6 +93,6 @@ static inline void unprotect_page(void *vaddr, unsigned long prot) unprotect_dat_entry(vaddr, prot, pgtable_level_pte); } -void *get_dat_entry(pgd_t *pgtable, void *vaddr, unsigned int level); +void *get_dat_entry(pgd_t *pgtable, void *vaddr, enum pgt_level level); #endif /* _ASMS390X_MMU_H_ */ From patchwork Tue Jul 11 14:15:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308811 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 678CCEB64DC for ; Tue, 11 Jul 2023 14:17:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232659AbjGKORA (ORCPT ); Tue, 11 Jul 2023 10:17:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232635AbjGKOQ4 (ORCPT ); Tue, 11 Jul 2023 10:16:56 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C090F1701 for ; Tue, 11 Jul 2023 07:16:40 -0700 (PDT) Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BDlcFO027045; Tue, 11 Jul 2023 14:16:31 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=gM4I86yYwBWAsKizR4IoxK1mTOaXSZVBWaAqCofz4yI=; b=ZHjsO1wa5VeHW+/acR5O+eQ4Uq4rqAUmGHQLxqpsS+0N3DKowVbpAgaQglHFhVMLc+u3 HQE1dGfsx9+35AAJl1W4st/f33i2MOaKvSq7rykWv9G6rSM2pHNwPB8YrpS6ZKK/Ad21 HfEgzBX2U5jP1743SvDQJtKPq6pl1tuD4cnHTSxb1dc7v/szJWgsOBMctDuKr7wq+W9R jKzo1xeas8fUnEbgNgcFVA8AfZn7aPvzbxuPgk4gHAbFnh65zGw4QOiX60ijtR22PQJS R9hG2VggW0Oc0QweiiAa4uzQtgmq10bUNFmLcdk84iHWPulOiFAL/7ATVsF0+0Swpg3L +g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs89a13eb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:29 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BDnRQI031728; Tue, 11 Jul 2023 14:16:18 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs89a13c8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:18 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B902cd016714; Tue, 11 Jul 2023 14:16:14 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma06fra.de.ibm.com (PPS) with ESMTPS id 3rpy2e9cd8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:14 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGBtk41026074 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:11 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4471C2004E; Tue, 11 Jul 2023 14:16:11 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C6FDB2004D; Tue, 11 Jul 2023 14:16:10 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:10 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 02/22] runtime: don't run pv-host tests when gen-se-header is unavailable Date: Tue, 11 Jul 2023 16:15:35 +0200 Message-ID: <20230711141607.40742-3-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 5D2hKde5t4gBwApfh_mqddPQEnctb5nF X-Proofpoint-ORIG-GUID: PaHYSJZ-q92PsNMLyM6UNGmftTsWWGqx X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 suspectscore=0 bulkscore=0 malwarescore=0 phishscore=0 priorityscore=1501 mlxscore=0 impostorscore=0 clxscore=1015 mlxlogscore=991 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When the gen-se-header tool is not given as an argument to configure, all tests which act as a PV host will not be built by the makefiles. run_tests.sh will fail when a test binary is missing. This means when we add the pv-host tests to unittest.cfg we will have FAILs when gen-se-header is missing. Since it is desirable to have the tests in unittest.cfg, add a new group pv-host which designates tests that act as a PV host. These will only run if the gen-se-header tool is available. The pv-host group is currently not used, but will be with Janoschs series "s390x: Add PV SIE intercepts and ipl tests" here: https://lore.kernel.org/all/20230502115931.86280-1-frankja@linux.ibm.com/ Reviewed-by: Thomas Huth Signed-off-by: Nico Boehr --- scripts/runtime.bash | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/runtime.bash b/scripts/runtime.bash index 54f8ade..0a87aac 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -98,6 +98,11 @@ function run() return fi + if [ -z "$GEN_SE_HEADER" ] && find_word "pv-host" "$groups"; then + print_result "SKIP" $testname "" "no gen-se-header available for pv-host test" + return + fi + if [ -z "$only_group" ] && find_word nodefault "$groups" && skip_nodefault; then print_result "SKIP" $testname "" "test marked as manual run only" From patchwork Tue Jul 11 14:15:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308819 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 AD227EB64DC for ; Tue, 11 Jul 2023 14:17:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233570AbjGKORo (ORCPT ); Tue, 11 Jul 2023 10:17:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233600AbjGKORa (ORCPT ); Tue, 11 Jul 2023 10:17:30 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAB1A19AE for ; Tue, 11 Jul 2023 07:17:20 -0700 (PDT) Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BEEXB0004048; Tue, 11 Jul 2023 14:16:22 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=lPNMhDK+rukTx7OJjBPxruiRslVRHgEs548oc+7hh/I=; b=jryYHy3ERRAuKoAOF/eoudoeT61TUNmVUhpqqW4vjuggvOYvHD2CVLyXxYWQ8ldxl/En uwTvATAcBC8WOdCd4z3UYxtawDNXnfEwvRQ1d/zs1brpwLywliU9r2TkgtypAFVwEXmE oo5ZmfE5QSsUt8rcl5mav2xgwLSa0lI/RfRxa+etH0ZlYCIqqlBptAVj7fmeweCFejRw gylmOf3fhQQepQjYVlE3SgR9ivLFqkWhQEe2dTtEYtzsA5wyaOEaeb7wSZl3ascsXT++ OpqljHEKOBS34R2e6v0JQ5rIA013004swbfAGu/5pkC05v0NMqBxgjEUw5fWyqpi3i0Y yg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8nvr3es-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:21 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BEFWrW008806; Tue, 11 Jul 2023 14:16:19 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8nvr39j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:19 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B9Y37j031173; Tue, 11 Jul 2023 14:16:15 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3rpye59tqg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:15 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGB4V27984232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:12 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA30D20049; Tue, 11 Jul 2023 14:16:11 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5DBDC20043; Tue, 11 Jul 2023 14:16:11 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:11 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 03/22] lib: s390x: sie: Fix sie_get_validity() no validity handling Date: Tue, 11 Jul 2023 16:15:36 +0200 Message-ID: <20230711141607.40742-4-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: gF_x05sJ6KWw1gNQ0DKk3D0_WNz0RUE5 X-Proofpoint-GUID: fD8Hmo6Em6Ix3BWHgmEvoQuFxgpvsLDP X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 mlxlogscore=849 adultscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank Rather than asserting, we can return a value that's designated as a programming only value to indicate that there has been no validity. The SIE instruction will never write 0xffff as a validity code so let's just use that constant. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230619083329.22680-2-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/sie.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c index 9241b4b..b44febd 100644 --- a/lib/s390x/sie.c +++ b/lib/s390x/sie.c @@ -23,7 +23,13 @@ void sie_expect_validity(struct vm *vm) uint16_t sie_get_validity(struct vm *vm) { - assert(vm->sblk->icptcode == ICPT_VALIDITY); + /* + * 0xffff will never be returned by SIE, so we can indicate a + * missing validity via this value. + */ + if (vm->sblk->icptcode != ICPT_VALIDITY) + return 0xffff; + return vm->sblk->ipb >> 16; } From patchwork Tue Jul 11 14:15:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308809 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 5A2ECEB64DD for ; Tue, 11 Jul 2023 14:16:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231970AbjGKOQ4 (ORCPT ); Tue, 11 Jul 2023 10:16:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233549AbjGKOQq (ORCPT ); Tue, 11 Jul 2023 10:16:46 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1117F199A for ; Tue, 11 Jul 2023 07:16:35 -0700 (PDT) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BDusdm002279; Tue, 11 Jul 2023 14:16:26 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=eMUwnJwLL8O5UnpxdSMWsboh/sMAvjdKnvPZgauyY3s=; b=C2ptZGzRCeYlqICv0l9mzGpX8gf/X0aTR6ijp2+2Q7o9NuoEAlrPosyUKXJmMHxjCkIh PK9wKaHVSKkmlW6z/eUpcp9ImskS3537xnN2AdmVqehOr/Tgr3UXO9JIjZuK4iCHw6y+ zsQuuGrv73fGblMZGL89xHfLR5qIHnwCNtfO25ZeMK4SY2TEV1OEM1wU/wGrztjsBG5Q OWWfKx+c+rAbeZdAo0l/OBXdsZhnusgyqP2ymSybvShO5EBuZvM8z0b93QrA0VyXJ5Ev RSbD0zSZkhmP+yQqn6vUCAQVeWGi+tuEBn2VSbSBMqppkWHlosiRg40LRVn8pB2wRyF/ /g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8de0quh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:26 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BE61Rb024289; Tue, 11 Jul 2023 14:16:20 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8de0qre-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:20 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B5ULdq019711; Tue, 11 Jul 2023 14:16:16 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma05fra.de.ibm.com (PPS) with ESMTPS id 3rpye59c72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:15 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGCjP9896496 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:12 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A40A20049; Tue, 11 Jul 2023 14:16:12 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F39CD20043; Tue, 11 Jul 2023 14:16:11 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:11 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 04/22] lib: s390x: uv: Introduce UV validity function Date: Tue, 11 Jul 2023 16:15:37 +0200 Message-ID: <20230711141607.40742-5-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: iPsfodWHkUKdGDjzU528_T5FrHXVK3hL X-Proofpoint-GUID: rWN85C1bv5GukPc__C1jtANHXrnjjU20 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 suspectscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank PV related validities are in the 0x20** range but the last byte might be implementation specific, so everytime we check for a UV validity we need to mask the last byte. Let's add a function that checks for a UV validity and returns a boolean. Signed-off-by: Janosch Frank Reviewed-by: Claudio Imbrenda Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230619083329.22680-3-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/uv.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/s390x/uv.h b/lib/s390x/uv.h index 5fe29bd..78b979b 100644 --- a/lib/s390x/uv.h +++ b/lib/s390x/uv.h @@ -35,4 +35,11 @@ static inline void uv_setup_asces(void) lctlg(13, asce); } +static inline bool uv_validity_check(struct vm *vm) +{ + uint16_t vir = sie_get_validity(vm); + + return vm->sblk->icptcode == ICPT_VALIDITY && (vir & 0xff00) == 0x2000; +} + #endif /* UV_H */ From patchwork Tue Jul 11 14:15:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308805 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 AD3EEEB64DC for ; Tue, 11 Jul 2023 14:16:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232727AbjGKOQt (ORCPT ); Tue, 11 Jul 2023 10:16:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232708AbjGKOQl (ORCPT ); Tue, 11 Jul 2023 10:16:41 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A4DA198C for ; Tue, 11 Jul 2023 07:16:30 -0700 (PDT) Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BECdac014734; Tue, 11 Jul 2023 14:16:21 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=HrwgG9DB8fsgzucjL1d7q0x2YU8y3KIuAO6r2nFPTw0=; b=H0ZK3Jul4STm8Best+5GmnUni6aZyqW7Fit/HGRwZVmrq8JeUOcxzvWWap2rjP6V4NSB 87DLH0YO0vCWkuA9igqwnzngmGfXDIP877EJQWZ8gYVPRWF0ksm5WZ6JRntwOR2MQyPA Z6egK0ng6PY6L5ao/1BmXsiaD7m0mopkAG8DyU+FVXyXU3/ZImcYy/bKCnk3baVVMg1T eDvMa/CKHfBr7SBoH4q26qMySABSgpY2cy3K8Z3J+YLURd4ipHv9Vvz7ni7uG/uGvkbu xSCJo3jzmjKFVWsN1v7vGtlYzryemWAX6Sb025DHfDecOcj9zoe5YJyX/uWRziJ4a06U Iw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8my05uf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:20 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BEEVTV024351; Tue, 11 Jul 2023 14:16:19 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8my05ss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:19 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B6wun0021820; Tue, 11 Jul 2023 14:16:16 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma02fra.de.ibm.com (PPS) with ESMTPS id 3rpye5hcj6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:16 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGDPP21955242 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:13 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 127482004D; Tue, 11 Jul 2023 14:16:13 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9378420043; Tue, 11 Jul 2023 14:16:12 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:12 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 05/22] lib: s390x: uv: Add intercept data check library function Date: Tue, 11 Jul 2023 16:15:38 +0200 Message-ID: <20230711141607.40742-6-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: I_jVd0-_WEX7laVlXym4xyjCo5AcjEeK X-Proofpoint-ORIG-GUID: fk3w80NRT4na2CO1qm2xwIeiEwQFm4BD X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 malwarescore=0 spamscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank When working with guests it's essential to check the SIE intercept data for the correct values. Fortunately on PV guests these values are constants so we can create check functions which test for the constants. While we're at it let's make pv-diags.c use this new function. Signed-off-by: Janosch Frank Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20230619083329.22680-4-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/pv_icptdata.h | 42 +++++++++++++++++++++++++++++++++++++++++ s390x/pv-diags.c | 14 ++++++-------- 2 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 lib/s390x/pv_icptdata.h diff --git a/lib/s390x/pv_icptdata.h b/lib/s390x/pv_icptdata.h new file mode 100644 index 0000000..4746117 --- /dev/null +++ b/lib/s390x/pv_icptdata.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Commonly used checks for PV SIE intercept data + * + * Copyright IBM Corp. 2023 + * Author: Janosch Frank + */ + +#ifndef _S390X_PV_ICPTDATA_H_ +#define _S390X_PV_ICPTDATA_H_ + +#include + +/* + * Checks the diagnose instruction intercept data for consistency with + * the constants defined by the PV SIE architecture + * + * Supports: 0x44, 0x9c, 0x288, 0x308, 0x500 + */ +static bool pv_icptdata_check_diag(struct vm *vm, int diag) +{ + int icptcode; + + switch (diag) { + case 0x44: + case 0x9c: + case 0x288: + case 0x308: + icptcode = ICPT_PV_NOTIFY; + break; + case 0x500: + icptcode = ICPT_PV_INSTR; + break; + default: + /* If a new diag is introduced add it to the cases above! */ + assert(0); + } + + return vm->sblk->icptcode == icptcode && vm->sblk->ipa == 0x8302 && + vm->sblk->ipb == 0x50000000 && vm->save_area.guest.grs[5] == diag; +} +#endif diff --git a/s390x/pv-diags.c b/s390x/pv-diags.c index 5165937..096ac61 100644 --- a/s390x/pv-diags.c +++ b/s390x/pv-diags.c @@ -9,6 +9,7 @@ */ #include #include +#include #include #include #include @@ -31,8 +32,7 @@ static void test_diag_500(void) size_gbin, size_hdr, SNIPPET_UNPACK_OFF); sie(&vm); - report(vm.sblk->icptcode == ICPT_PV_INSTR && vm.sblk->ipa == 0x8302 && - vm.sblk->ipb == 0x50000000 && vm.save_area.guest.grs[5] == 0x500, + report(pv_icptdata_check_diag(&vm, 0x500), "intercept values"); report(vm.save_area.guest.grs[1] == 1 && vm.save_area.guest.grs[2] == 2 && @@ -45,9 +45,8 @@ static void test_diag_500(void) */ vm.sblk->iictl = IICTL_CODE_OPERAND; sie(&vm); - report(vm.sblk->icptcode == ICPT_PV_NOTIFY && vm.sblk->ipa == 0x8302 && - vm.sblk->ipb == 0x50000000 && vm.save_area.guest.grs[5] == 0x9c - && vm.save_area.guest.grs[0] == PGM_INT_CODE_OPERAND, + report(pv_icptdata_check_diag(&vm, 0x9c) && + vm.save_area.guest.grs[0] == PGM_INT_CODE_OPERAND, "operand exception"); /* @@ -58,9 +57,8 @@ static void test_diag_500(void) vm.sblk->iictl = IICTL_CODE_SPECIFICATION; /* Inject PGM, next exit should be 9c */ sie(&vm); - report(vm.sblk->icptcode == ICPT_PV_NOTIFY && vm.sblk->ipa == 0x8302 && - vm.sblk->ipb == 0x50000000 && vm.save_area.guest.grs[5] == 0x9c - && vm.save_area.guest.grs[0] == PGM_INT_CODE_SPECIFICATION, + report(pv_icptdata_check_diag(&vm, 0x9c) && + vm.save_area.guest.grs[0] == PGM_INT_CODE_SPECIFICATION, "specification exception"); /* No need for cleanup, just tear down the VM */ From patchwork Tue Jul 11 14:15:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308807 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 B7D20EB64DC for ; Tue, 11 Jul 2023 14:16:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233533AbjGKOQx (ORCPT ); Tue, 11 Jul 2023 10:16:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233535AbjGKOQp (ORCPT ); Tue, 11 Jul 2023 10:16:45 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3B751989 for ; Tue, 11 Jul 2023 07:16:32 -0700 (PDT) Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BEF1Sn031644; Tue, 11 Jul 2023 14:16:23 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=sdO356FLpMBoNnzawuemZ4/KnwSpcXiMMJSodrHTaUQ=; b=DBgBi0LQBZuz3xnEdSjjbABNaoKYPvMtegpxslpO22kGZC2kQLBzNfWd/5AOJ2qN0TqZ CI97d3r0exf7kE+mMue/0p/4b40Uikem52hwdbM2eNkmLL8ZX5Go8jdd8cFr9S0HUgfb sjVOhN5t/9YU+8I5ZzxHF8RxOs8YWqYN1A8SWTSX8wfgVJKKNHEux0cvo4N7qPnjFVxv YbAZElyKb5a4KOnZOn469DNbiD/58jz5S026ewgEr7xp3IPBFerg8coVobGbXpJBvTux NrXmUCuO2idJKcw/RWhfTeoWGT/SCWVuXIgIkwsG8jNPnqa1KSytn15Hdv9Nc7p7OmNG QA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8p482fn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:23 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BEFbIb002215; Tue, 11 Jul 2023 14:16:21 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8p4829x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:21 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B5uOlt030259; Tue, 11 Jul 2023 14:16:17 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3rpye59tty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:17 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGDQ07930254 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:13 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D24A20049; Tue, 11 Jul 2023 14:16:13 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C32A2005A; Tue, 11 Jul 2023 14:16:13 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:13 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 06/22] s390x: pv-diags: Drop snippet from snippet names Date: Tue, 11 Jul 2023 16:15:39 +0200 Message-ID: <20230711141607.40742-7-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: baVdty1daqnPyBenBVX_qPnJBK78pTkU X-Proofpoint-ORIG-GUID: g-nzaIZf0U-LTrXAXLLJJ23lCgVaFAkw X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=999 mlxscore=0 impostorscore=0 adultscore=0 suspectscore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank It's a bit redundant. Signed-off-by: Janosch Frank Reviewed-by: Claudio Imbrenda Acked-by: Nico Boehr Link: https://lore.kernel.org/r/20230619083329.22680-5-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/Makefile | 6 +-- .../{snippet-pv-diag-288.S => pv-diag-288.S} | 0 .../{snippet-pv-diag-500.S => pv-diag-500.S} | 0 ...nippet-pv-diag-yield.S => pv-diag-yield.S} | 0 s390x/pv-diags.c | 48 +++++++++---------- 5 files changed, 27 insertions(+), 27 deletions(-) rename s390x/snippets/asm/{snippet-pv-diag-288.S => pv-diag-288.S} (100%) rename s390x/snippets/asm/{snippet-pv-diag-500.S => pv-diag-500.S} (100%) rename s390x/snippets/asm/{snippet-pv-diag-yield.S => pv-diag-yield.S} (100%) diff --git a/s390x/Makefile b/s390x/Makefile index a80db53..8d1cfc7 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -122,9 +122,9 @@ snippet_lib = $(snippet_asmlib) lib/auxinfo.o $(TEST_DIR)/mvpg-sie.elf: snippets = $(SNIPPET_DIR)/c/mvpg-snippet.gbin $(TEST_DIR)/spec_ex-sie.elf: snippets = $(SNIPPET_DIR)/c/spec_ex.gbin -$(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/snippet-pv-diag-yield.gbin -$(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/snippet-pv-diag-288.gbin -$(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/snippet-pv-diag-500.gbin +$(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-yield.gbin +$(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-288.gbin +$(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-500.gbin ifneq ($(GEN_SE_HEADER),) snippets += $(pv-snippets) diff --git a/s390x/snippets/asm/snippet-pv-diag-288.S b/s390x/snippets/asm/pv-diag-288.S similarity index 100% rename from s390x/snippets/asm/snippet-pv-diag-288.S rename to s390x/snippets/asm/pv-diag-288.S diff --git a/s390x/snippets/asm/snippet-pv-diag-500.S b/s390x/snippets/asm/pv-diag-500.S similarity index 100% rename from s390x/snippets/asm/snippet-pv-diag-500.S rename to s390x/snippets/asm/pv-diag-500.S diff --git a/s390x/snippets/asm/snippet-pv-diag-yield.S b/s390x/snippets/asm/pv-diag-yield.S similarity index 100% rename from s390x/snippets/asm/snippet-pv-diag-yield.S rename to s390x/snippets/asm/pv-diag-yield.S diff --git a/s390x/pv-diags.c b/s390x/pv-diags.c index 096ac61..fa4e553 100644 --- a/s390x/pv-diags.c +++ b/s390x/pv-diags.c @@ -18,17 +18,17 @@ static struct vm vm; static void test_diag_500(void) { - extern const char SNIPPET_NAME_START(asm, snippet_pv_diag_500)[]; - extern const char SNIPPET_NAME_END(asm, snippet_pv_diag_500)[]; - extern const char SNIPPET_HDR_START(asm, snippet_pv_diag_500)[]; - extern const char SNIPPET_HDR_END(asm, snippet_pv_diag_500)[]; - int size_hdr = SNIPPET_HDR_LEN(asm, snippet_pv_diag_500); - int size_gbin = SNIPPET_LEN(asm, snippet_pv_diag_500); + extern const char SNIPPET_NAME_START(asm, pv_diag_500)[]; + extern const char SNIPPET_NAME_END(asm, pv_diag_500)[]; + extern const char SNIPPET_HDR_START(asm, pv_diag_500)[]; + extern const char SNIPPET_HDR_END(asm, pv_diag_500)[]; + int size_hdr = SNIPPET_HDR_LEN(asm, pv_diag_500); + int size_gbin = SNIPPET_LEN(asm, pv_diag_500); report_prefix_push("diag 0x500"); - snippet_pv_init(&vm, SNIPPET_NAME_START(asm, snippet_pv_diag_500), - SNIPPET_HDR_START(asm, snippet_pv_diag_500), + snippet_pv_init(&vm, SNIPPET_NAME_START(asm, pv_diag_500), + SNIPPET_HDR_START(asm, pv_diag_500), size_gbin, size_hdr, SNIPPET_UNPACK_OFF); sie(&vm); @@ -70,17 +70,17 @@ static void test_diag_500(void) static void test_diag_288(void) { - extern const char SNIPPET_NAME_START(asm, snippet_pv_diag_288)[]; - extern const char SNIPPET_NAME_END(asm, snippet_pv_diag_288)[]; - extern const char SNIPPET_HDR_START(asm, snippet_pv_diag_288)[]; - extern const char SNIPPET_HDR_END(asm, snippet_pv_diag_288)[]; - int size_hdr = SNIPPET_HDR_LEN(asm, snippet_pv_diag_288); - int size_gbin = SNIPPET_LEN(asm, snippet_pv_diag_288); + extern const char SNIPPET_NAME_START(asm, pv_diag_288)[]; + extern const char SNIPPET_NAME_END(asm, pv_diag_288)[]; + extern const char SNIPPET_HDR_START(asm, pv_diag_288)[]; + extern const char SNIPPET_HDR_END(asm, pv_diag_288)[]; + int size_hdr = SNIPPET_HDR_LEN(asm, pv_diag_288); + int size_gbin = SNIPPET_LEN(asm, pv_diag_288); report_prefix_push("diag 0x288"); - snippet_pv_init(&vm, SNIPPET_NAME_START(asm, snippet_pv_diag_288), - SNIPPET_HDR_START(asm, snippet_pv_diag_288), + snippet_pv_init(&vm, SNIPPET_NAME_START(asm, pv_diag_288), + SNIPPET_HDR_START(asm, pv_diag_288), size_gbin, size_hdr, SNIPPET_UNPACK_OFF); sie(&vm); @@ -111,17 +111,17 @@ static void test_diag_288(void) static void test_diag_yield(void) { - extern const char SNIPPET_NAME_START(asm, snippet_pv_diag_yield)[]; - extern const char SNIPPET_NAME_END(asm, snippet_pv_diag_yield)[]; - extern const char SNIPPET_HDR_START(asm, snippet_pv_diag_yield)[]; - extern const char SNIPPET_HDR_END(asm, snippet_pv_diag_yield)[]; - int size_hdr = SNIPPET_HDR_LEN(asm, snippet_pv_diag_yield); - int size_gbin = SNIPPET_LEN(asm, snippet_pv_diag_yield); + extern const char SNIPPET_NAME_START(asm, pv_diag_yield)[]; + extern const char SNIPPET_NAME_END(asm, pv_diag_yield)[]; + extern const char SNIPPET_HDR_START(asm, pv_diag_yield)[]; + extern const char SNIPPET_HDR_END(asm, pv_diag_yield)[]; + int size_hdr = SNIPPET_HDR_LEN(asm, pv_diag_yield); + int size_gbin = SNIPPET_LEN(asm, pv_diag_yield); report_prefix_push("diag yield"); - snippet_pv_init(&vm, SNIPPET_NAME_START(asm, snippet_pv_diag_yield), - SNIPPET_HDR_START(asm, snippet_pv_diag_yield), + snippet_pv_init(&vm, SNIPPET_NAME_START(asm, pv_diag_yield), + SNIPPET_HDR_START(asm, pv_diag_yield), size_gbin, size_hdr, SNIPPET_UNPACK_OFF); /* 0x44 */ From patchwork Tue Jul 11 14:15:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308816 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 D1159C001DC for ; Tue, 11 Jul 2023 14:17:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233551AbjGKORJ (ORCPT ); Tue, 11 Jul 2023 10:17:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230375AbjGKORB (ORCPT ); Tue, 11 Jul 2023 10:17:01 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF2791738 for ; Tue, 11 Jul 2023 07:16:46 -0700 (PDT) Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BDlnr8027343; Tue, 11 Jul 2023 14:16:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=Jvmqtgnsg94K1mBm3bXsB2cNFDN8HY6UyGkWbODMrZ8=; b=qEFvSwCIIpYs2PAI5B7wRGRzlTJD9vxdTI+2SX2iWQlhEgQFoWIcCz71P3qeAhDcfL+F i1mjC5NqSHilTqeESWwzFcDcssZJTJB27X/10TEtFPj+T7lvZJvUX7zlRcOQlyTu3t8B isT/EgJZ+83+vLJezw26g+5864oGxjol/NoCERb9S+seeb8wl4A1xrTdzStfsw9omf4n FKFnq1o73eUDZCB2GE9WTISPYDXrKIAdsSaRnCjdIAcu+IJrFiGbRyXnPufeEksw14ud srITyLG+7HG9C00Hwy2kt7Mwujw+mXFc73sYaiPMD+XaNq9JOtgROb726usTLFNNNHBY eg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs89a13qy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:43 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BE59qJ024685; Tue, 11 Jul 2023 14:16:33 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs89a13dx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:33 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B5uOlu030259; Tue, 11 Jul 2023 14:16:17 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3rpye59tu0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:17 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGEUX35193276 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:14 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 32F332004D; Tue, 11 Jul 2023 14:16:14 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B68692004B; Tue, 11 Jul 2023 14:16:13 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:13 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 07/22] lib: s390x: uv: Add pv host requirement check function Date: Tue, 11 Jul 2023 16:15:40 +0200 Message-ID: <20230711141607.40742-8-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: C5ecVjaNeOJbGoIgln-ZfCXX4gTEGQye X-Proofpoint-ORIG-GUID: dg1_xFovjnTtfJ5iewPiRyg-S5J1s122 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 suspectscore=0 bulkscore=0 malwarescore=0 phishscore=0 priorityscore=1501 mlxscore=0 impostorscore=0 clxscore=1015 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank When running PV guests some of the UV memory needs to be allocated with > 31 bit addresses which means tests with PV guests will always need a lot more memory than other tests. Additionally facilities nr 158 and sclp.sief2 need to be available. Let's add a function that checks for these requirements and prints a helpful skip message. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230619083329.22680-6-frankja@linux.ibm.com [ nrb: replace 1024*1024 with SZ_1M as requested by author ] Signed-off-by: Nico Boehr --- lib/s390x/snippet.h | 7 +++++++ lib/s390x/uv.h | 1 + lib/s390x/uv.c | 20 ++++++++++++++++++++ s390x/pv-diags.c | 8 +------- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/lib/s390x/snippet.h b/lib/s390x/snippet.h index 5704599..11ec54c 100644 --- a/lib/s390x/snippet.h +++ b/lib/s390x/snippet.h @@ -30,6 +30,13 @@ #define SNIPPET_HDR_LEN(type, file) \ ((uintptr_t)SNIPPET_HDR_END(type, file) - (uintptr_t)SNIPPET_HDR_START(type, file)) +/* + * Some of the UV memory needs to be allocated with >31 bit + * addresses which means we need a lot more memory than other + * tests. + */ +#define SNIPPET_PV_MIN_MEM_SIZE (SZ_1M * 2200UL) + #define SNIPPET_PV_TWEAK0 0x42UL #define SNIPPET_PV_TWEAK1 0UL #define SNIPPET_UNPACK_OFF 0 diff --git a/lib/s390x/uv.h b/lib/s390x/uv.h index 78b979b..286933c 100644 --- a/lib/s390x/uv.h +++ b/lib/s390x/uv.h @@ -7,6 +7,7 @@ bool uv_os_is_guest(void); bool uv_os_is_host(void); +bool uv_host_requirement_checks(void); bool uv_query_test_call(unsigned int nr); const struct uv_cb_qui *uv_get_query_data(void); void uv_init(void); diff --git a/lib/s390x/uv.c b/lib/s390x/uv.c index 383271a..23a8617 100644 --- a/lib/s390x/uv.c +++ b/lib/s390x/uv.c @@ -18,6 +18,7 @@ #include #include #include +#include static struct uv_cb_qui uvcb_qui = { .header.cmd = UVC_CMD_QUI, @@ -38,6 +39,25 @@ bool uv_os_is_host(void) return test_facility(158) && uv_query_test_call(BIT_UVC_CMD_INIT_UV); } +bool uv_host_requirement_checks(void) +{ + if (!test_facility(158)) { + report_skip("UV Call facility unavailable"); + return false; + } + if (!sclp_facilities.has_sief2) { + report_skip("SIEF2 facility unavailable"); + return false; + } + if (get_ram_size() < SNIPPET_PV_MIN_MEM_SIZE) { + report_skip("Not enough memory. This test needs about %ld MB of memory", + SNIPPET_PV_MIN_MEM_SIZE / SZ_1M); + return false; + } + + return true; +} + bool uv_query_test_call(unsigned int nr) { /* Query needs to be called first */ diff --git a/s390x/pv-diags.c b/s390x/pv-diags.c index fa4e553..3193ad9 100644 --- a/s390x/pv-diags.c +++ b/s390x/pv-diags.c @@ -149,14 +149,8 @@ static void test_diag_yield(void) int main(void) { report_prefix_push("pv-diags"); - if (!test_facility(158)) { - report_skip("UV Call facility unavailable"); + if (!uv_host_requirement_checks()) goto done; - } - if (!sclp_facilities.has_sief2) { - report_skip("SIEF2 facility unavailable"); - goto done; - } uv_setup_asces(); snippet_setup_guest(&vm, true); From patchwork Tue Jul 11 14:15:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308820 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 B04ECEB64DC for ; Tue, 11 Jul 2023 14:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229961AbjGKORq (ORCPT ); Tue, 11 Jul 2023 10:17:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231741AbjGKORc (ORCPT ); Tue, 11 Jul 2023 10:17:32 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAC0519AF for ; Tue, 11 Jul 2023 07:17:20 -0700 (PDT) Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BEExr3031451; Tue, 11 Jul 2023 14:16:25 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=7IW72iTLxon9KuqOR8IMFOns3ibecSClaPy/uwxqxw8=; b=Imj9kgXeum2JwfH7Njzf2ijtMQ538rjdBxIt2zwk9ZFlBqGU3OLsbzlHmJDavhFfeP6j 5M3B8ou5UdysVJzruGBfaRCROBT4m1khYNuslfJZGfVG49Oi0s6+PuUmMxML9ljpFwE/ I3WHeE7ERFasDXAa4chwmPMJnbfoMdktLwndiQ8lL0Y9opfENYqI2ZgnrLVaWtR5EgGB nqDPWVYIqvnGbxK5NwJb5epNje+aZZfyfBTWmaEge+QomlIgqJJj3/9tVwZsDNxRrBXO kldx0LPQtjsMKD1CYSCN7EDzm56veds2Ue8HjL0CcIic5SaUuu89EH0qIfkVxMLhFG76 xQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8p482fh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:24 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BEFBYl032729; Tue, 11 Jul 2023 14:16:21 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8p482an-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:20 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36BEDFJ2009180; Tue, 11 Jul 2023 14:16:18 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3rqk4mg14k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:17 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGEhH33686056 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:15 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CAD7220040; Tue, 11 Jul 2023 14:16:14 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4DF3E2004B; Tue, 11 Jul 2023 14:16:14 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:14 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 08/22] s390x: pv: Add sie entry intercept and validity test Date: Tue, 11 Jul 2023 16:15:41 +0200 Message-ID: <20230711141607.40742-9-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: V3OlFKMPEB0m8FUKGwcOTJzbcoM1fXRN X-Proofpoint-ORIG-GUID: tsLtDuWFuvbOAYFqXDBs-pQzYiE_R_T5 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=999 mlxscore=0 impostorscore=0 adultscore=0 suspectscore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank The lowcore is an important part of any s390 cpu so we need to make sure it's always available when we virtualize one. For non-PV guests that would mean ensuring that the lowcore page is read and writable by the guest. For PV guests we additionally need to make sure that the page is owned by the guest as it is only allowed to access them if that's the case. The code 112 SIE intercept tells us if the lowcore pages aren't secure anymore. Let's check if that intercept is reported by SIE if we export the lowcore pages. Additionally check if that's also the case if the guest shares the lowcore which will make it readable to the host but ownership of the page should not change. Also we check for validities in these conditions: * Manipulated cpu timer * Double SIE for same vcpu * Re-use of VCPU handle from another secure configuration * ASCE re-use Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230619083329.22680-7-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/Makefile | 5 + s390x/snippets/asm/icpt-loop.S | 15 + s390x/snippets/asm/loop.S | 13 + s390x/snippets/asm/pv-icpt-112.S | 81 +++++ s390x/snippets/asm/pv-icpt-vir-timing.S | 21 ++ s390x/pv-icptcode.c | 376 ++++++++++++++++++++++++ s390x/unittests.cfg | 6 + 7 files changed, 517 insertions(+) create mode 100644 s390x/snippets/asm/icpt-loop.S create mode 100644 s390x/snippets/asm/loop.S create mode 100644 s390x/snippets/asm/pv-icpt-112.S create mode 100644 s390x/snippets/asm/pv-icpt-vir-timing.S create mode 100644 s390x/pv-icptcode.c diff --git a/s390x/Makefile b/s390x/Makefile index 8d1cfc7..67be536 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -42,6 +42,7 @@ tests += $(TEST_DIR)/exittime.elf tests += $(TEST_DIR)/ex.elf pv-tests += $(TEST_DIR)/pv-diags.elf +pv-tests += $(TEST_DIR)/pv-icptcode.elf ifneq ($(HOST_KEY_DOCUMENT),) ifneq ($(GEN_SE_HEADER),) @@ -125,6 +126,10 @@ $(TEST_DIR)/spec_ex-sie.elf: snippets = $(SNIPPET_DIR)/c/spec_ex.gbin $(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-yield.gbin $(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-288.gbin $(TEST_DIR)/pv-diags.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-500.gbin +$(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-icpt-112.gbin +$(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/icpt-loop.gbin +$(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/loop.gbin +$(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-icpt-vir-timing.gbin ifneq ($(GEN_SE_HEADER),) snippets += $(pv-snippets) diff --git a/s390x/snippets/asm/icpt-loop.S b/s390x/snippets/asm/icpt-loop.S new file mode 100644 index 0000000..2aa59c0 --- /dev/null +++ b/s390x/snippets/asm/icpt-loop.S @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Infinite loop snippet which can be used to test manipulated SIE + * control block intercepts. E.g. when manipulating the PV handles. + * + * Copyright (c) 2023 IBM Corp + * + * Authors: + * Janosch Frank + */ +.section .text +xgr %r0, %r0 +retry: +diag 0,0,0x44 +j retry diff --git a/s390x/snippets/asm/loop.S b/s390x/snippets/asm/loop.S new file mode 100644 index 0000000..a75bf00 --- /dev/null +++ b/s390x/snippets/asm/loop.S @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Infinite loop snippet with no exit + * + * Copyright (c) 2023 IBM Corp + * + * Authors: + * Janosch Frank + */ +.section .text + +retry: +j retry diff --git a/s390x/snippets/asm/pv-icpt-112.S b/s390x/snippets/asm/pv-icpt-112.S new file mode 100644 index 0000000..d9545ff --- /dev/null +++ b/s390x/snippets/asm/pv-icpt-112.S @@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Intercept 112 PV snippet + * + * We setup and share a prefix at 0x0 and 0x8000 which the hypervisor + * test will try to export and then execute a SIE entry which + * should result in a 112 SIE intercept. + * + * Copyright (c) 2023 IBM Corp + * + * Authors: + * Janosch Frank + */ +#include + +.section .text +xgr %r0, %r0 +xgr %r1, %r1 + +/* Let's tell the hypervisor we're ready to start */ +diag 0,0,0x44 + +/* + * Hypervisor will export the lowcore and try a SIE entry which should + * result in a 112. It will then import the lowcore again and we + * should continue with the code below. + */ + +/* Share the lowcore */ +larl %r1, share +.insn rrf,0xB9A40000,0,1,0,0 +xgr %r1, %r1 + +/* Let's tell the hypervisor we're ready to start shared testing */ +diag 0,0,0x44 + +/* Host: icpt: PV instruction diag 0x44 */ +/* Host: icpt: 112 */ + +/* Copy the invalid PGM new PSW to the new lowcore */ +larl %r1, prfx +l %r2, 0(%r1) +mvc GEN_LC_PGM_NEW_PSW(16, %r2), GEN_LC_PGM_NEW_PSW(%r0) + +/* Change the prefix to 0x8000 and re-try */ +xgr %r1, %r1 +xgr %r2, %r2 +larl %r2, prfx +spx 0(%r2) + +/* Host: icpt: PV instruction notification SPX*/ +/* Host: icpt: 112 */ + +/* Share the new lowcore */ +larl %r3, share_addr +stg %r2, 0(%r3) +larl %r2, share +.insn rrf,0xB9A40000,0,2,0,0 + +/* Let's tell the hypervisor we're ready to start shared testing */ +diag 0,0,0x44 + +/* Host: icpt: PV instruction diag 0x44 */ +/* Host: icpt: 112 */ + +/* Test re-entry */ +lghi %r1, 42 +diag 1,0,0x9c + +/* Host: icpt: PV instruction diag 0x9c */ + +.align 8 +share: + .quad 0x0030100000000000 + .quad 0x0, 0x0, 0x0 +share_addr: + .quad 0x0 + .quad 0x0 +.align 4 +prfx: + .long 0x00008000 diff --git a/s390x/snippets/asm/pv-icpt-vir-timing.S b/s390x/snippets/asm/pv-icpt-vir-timing.S new file mode 100644 index 0000000..939134a --- /dev/null +++ b/s390x/snippets/asm/pv-icpt-vir-timing.S @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Sets a cpu timer which the host can manipulate to check if it will + * receive a validity + * + * Copyright (c) 2023 IBM Corp + * + * Authors: + * Janosch Frank + */ +.section .text +larl %r1, time_val +spt 0 (%r1) +diag 0, 0, 0x44 +lghi %r1, 42 +diag 1, 0, 0x9c + + +.align 8 +time_val: + .quad 0x280de80000 diff --git a/s390x/pv-icptcode.c b/s390x/pv-icptcode.c new file mode 100644 index 0000000..d7c47d6 --- /dev/null +++ b/s390x/pv-icptcode.c @@ -0,0 +1,376 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * PV virtualization interception tests for intercepts that are not + * caused by an instruction. + * + * Copyright (c) 2023 IBM Corp + * + * Authors: + * Janosch Frank + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static struct vm vm, vm2; + +/* + * The hypervisor should not be able to decrease the cpu timer by an + * amount that is higher than the amount of time spent outside of + * SIE. + * + * Warning: A lot of things influence time so decreasing the timer by + * a more significant amount than the difference to have a safety + * margin is advised. + */ +static void test_validity_timing(void) +{ + extern const char SNIPPET_NAME_START(asm, pv_icpt_vir_timing)[]; + extern const char SNIPPET_NAME_END(asm, pv_icpt_vir_timing)[]; + extern const char SNIPPET_HDR_START(asm, pv_icpt_vir_timing)[]; + extern const char SNIPPET_HDR_END(asm, pv_icpt_vir_timing)[]; + int size_hdr = SNIPPET_HDR_LEN(asm, pv_icpt_vir_timing); + int size_gbin = SNIPPET_LEN(asm, pv_icpt_vir_timing); + uint64_t time_exit, time_entry, tmp; + + report_prefix_push("manipulated cpu time"); + snippet_pv_init(&vm, SNIPPET_NAME_START(asm, pv_icpt_vir_timing), + SNIPPET_HDR_START(asm, pv_icpt_vir_timing), + size_gbin, size_hdr, SNIPPET_UNPACK_OFF); + + sie(&vm); + report(pv_icptdata_check_diag(&vm, 0x44), "spt done"); + stck(&time_exit); + tmp = vm.sblk->cputm; + mb(); + + /* Cpu timer counts down so adding a ms should lead to a validity */ + vm.sblk->cputm += S390_CLOCK_SHIFT_US * 1000; + sie_expect_validity(&vm); + sie(&vm); + report(uv_validity_check(&vm), "validity entry cput > exit cput"); + vm.sblk->cputm = tmp; + + /* + * We are not allowed to decrement the timer more than the + * time spent outside of SIE + */ + stck(&time_entry); + vm.sblk->cputm -= (time_entry - time_exit) + S390_CLOCK_SHIFT_US * 1000; + sie_expect_validity(&vm); + sie(&vm); + report(uv_validity_check(&vm), "validity entry cput < time spent outside SIE"); + vm.sblk->cputm = tmp; + + uv_destroy_guest(&vm); + report_prefix_pop(); +} + +static void run_loop(void) +{ + sie(&vm); + sigp_retry(stap(), SIGP_STOP, 0, NULL); +} + +static void test_validity_already_running(void) +{ + extern const char SNIPPET_NAME_START(asm, loop)[]; + extern const char SNIPPET_NAME_END(asm, loop)[]; + extern const char SNIPPET_HDR_START(asm, loop)[]; + extern const char SNIPPET_HDR_END(asm, loop)[]; + int size_hdr = SNIPPET_HDR_LEN(asm, loop); + int size_gbin = SNIPPET_LEN(asm, loop); + struct psw psw = { + .mask = PSW_MASK_64, + .addr = (uint64_t)run_loop, + }; + + report_prefix_push("already running"); + if (smp_query_num_cpus() < 3) { + report_skip("need at least 3 cpus for this test"); + goto out; + } + + snippet_pv_init(&vm, SNIPPET_NAME_START(asm, loop), + SNIPPET_HDR_START(asm, loop), + size_gbin, size_hdr, SNIPPET_UNPACK_OFF); + + smp_cpu_setup(1, psw); + sie_expect_validity(&vm); + smp_cpu_setup(2, psw); + while (vm.sblk->icptcode != ICPT_VALIDITY) { + mb(); + } + + /* + * One cpu will enter SIE and one will receive the validity. + * We rely on the expectation that the cpu in SIE won't exit + * until we had a chance to observe the validity as the exit + * would overwrite the validity. + * + * In general that expectation is valid but HW/FW can in + * theory still exit to handle their interrupts. + */ + report(uv_validity_check(&vm), "validity"); + smp_cpu_stop(1); + smp_cpu_stop(2); + uv_destroy_guest(&vm); + +out: + report_prefix_pop(); +} + +/* Tests if a vcpu handle from another configuration results in a validity intercept. */ +static void test_validity_handle_not_in_config(void) +{ + extern const char SNIPPET_NAME_START(asm, icpt_loop)[]; + extern const char SNIPPET_NAME_END(asm, icpt_loop)[]; + extern const char SNIPPET_HDR_START(asm, icpt_loop)[]; + extern const char SNIPPET_HDR_END(asm, icpt_loop)[]; + int size_hdr = SNIPPET_HDR_LEN(asm, icpt_loop); + int size_gbin = SNIPPET_LEN(asm, icpt_loop); + + report_prefix_push("handle not in config"); + /* Setup our primary vm */ + snippet_pv_init(&vm, SNIPPET_NAME_START(asm, icpt_loop), + SNIPPET_HDR_START(asm, icpt_loop), + size_gbin, size_hdr, SNIPPET_UNPACK_OFF); + + /* Setup secondary vm */ + snippet_setup_guest(&vm2, true); + snippet_pv_init(&vm2, SNIPPET_NAME_START(asm, icpt_loop), + SNIPPET_HDR_START(asm, icpt_loop), + size_gbin, size_hdr, SNIPPET_UNPACK_OFF); + + vm.sblk->pv_handle_cpu = vm2.sblk->pv_handle_cpu; + sie_expect_validity(&vm); + sie(&vm); + report(uv_validity_check(&vm), "switched cpu handle"); + vm.sblk->pv_handle_cpu = vm.uv.vcpu_handle; + + vm.sblk->pv_handle_config = vm2.uv.vm_handle; + sie_expect_validity(&vm); + sie(&vm); + report(uv_validity_check(&vm), "switched configuration handle"); + vm.sblk->pv_handle_config = vm.uv.vm_handle; + + /* Destroy the second vm, since we don't need it for further tests */ + uv_destroy_guest(&vm2); + sie_guest_destroy(&vm2); + + uv_destroy_guest(&vm); + report_prefix_pop(); +} + +/* Tests if a wrong vm or vcpu handle results in a validity intercept. */ +static void test_validity_seid(void) +{ + extern const char SNIPPET_NAME_START(asm, icpt_loop)[]; + extern const char SNIPPET_NAME_END(asm, icpt_loop)[]; + extern const char SNIPPET_HDR_START(asm, icpt_loop)[]; + extern const char SNIPPET_HDR_END(asm, icpt_loop)[]; + int size_hdr = SNIPPET_HDR_LEN(asm, icpt_loop); + int size_gbin = SNIPPET_LEN(asm, icpt_loop); + int fails = 0; + int i; + + report_prefix_push("handles"); + snippet_pv_init(&vm, SNIPPET_NAME_START(asm, icpt_loop), + SNIPPET_HDR_START(asm, icpt_loop), + size_gbin, size_hdr, SNIPPET_UNPACK_OFF); + + for (i = 0; i < 64; i++) { + vm.sblk->pv_handle_config ^= 1UL << i; + sie_expect_validity(&vm); + sie(&vm); + if (!uv_validity_check(&vm)) { + report_fail("SIE accepted wrong VM SEID, changed bit %d", + 63 - i); + fails++; + } + vm.sblk->pv_handle_config ^= 1UL << i; + } + report(!fails, "No wrong vm handle accepted"); + + fails = 0; + for (i = 0; i < 64; i++) { + vm.sblk->pv_handle_cpu ^= 1UL << i; + sie_expect_validity(&vm); + sie(&vm); + if (!uv_validity_check(&vm)) { + report_fail("SIE accepted wrong CPU SEID, changed bit %d", + 63 - i); + fails++; + } + vm.sblk->pv_handle_cpu ^= 1UL << i; + } + report(!fails, "No wrong cpu handle accepted"); + + uv_destroy_guest(&vm); + report_prefix_pop(); +} + +/* + * Tests if we get a validity intercept if the CR1 asce at SIE entry + * is not the same as the one given at the UV creation of the VM. + */ +static void test_validity_asce(void) +{ + extern const char SNIPPET_NAME_START(asm, pv_icpt_112)[]; + extern const char SNIPPET_NAME_END(asm, pv_icpt_112)[]; + extern const char SNIPPET_HDR_START(asm, pv_icpt_112)[]; + extern const char SNIPPET_HDR_END(asm, pv_icpt_112)[]; + int size_hdr = SNIPPET_HDR_LEN(asm, pv_icpt_112); + int size_gbin = SNIPPET_LEN(asm, pv_icpt_112); + uint64_t asce_old, asce_new; + void *pgd_new, *pgd_old; + + report_prefix_push("asce"); + snippet_pv_init(&vm, SNIPPET_NAME_START(asm, pv_icpt_112), + SNIPPET_HDR_START(asm, pv_icpt_112), + size_gbin, size_hdr, SNIPPET_UNPACK_OFF); + + asce_old = vm.save_area.guest.asce; + pgd_new = memalign_pages_flags(PAGE_SIZE, PAGE_SIZE * 4, 0); + pgd_old = (void *)(asce_old & PAGE_MASK); + + /* Copy the contents of the top most table */ + memcpy(pgd_new, pgd_old, PAGE_SIZE * 4); + + /* Create the replacement ASCE */ + asce_new = __pa(pgd_new) | ASCE_DT_REGION1 | REGION_TABLE_LENGTH | ASCE_P; + vm.save_area.guest.asce = asce_new; + + sie_expect_validity(&vm); + sie(&vm); + report(uv_validity_check(&vm), "wrong CR1 validity"); + + /* Restore the old ASCE */ + vm.save_area.guest.asce = asce_old; + + /* Try if we can still do an entry with the correct asce */ + sie(&vm); + report(pv_icptdata_check_diag(&vm, 0x44), "re-entry with valid CR1"); + uv_destroy_guest(&vm); + free_pages(pgd_new); + report_prefix_pop(); +} + +static void run_icpt_122_tests(unsigned long lc_off) +{ + uv_export(vm.sblk->mso + lc_off); + sie(&vm); + report(vm.sblk->icptcode == ICPT_PV_PREF, "Intercept 112 for page 0"); + uv_import(vm.uv.vm_handle, vm.sblk->mso + lc_off); + + uv_export(vm.sblk->mso + lc_off + PAGE_SIZE); + sie(&vm); + report(vm.sblk->icptcode == ICPT_PV_PREF, "Intercept 112 for page 1"); + uv_import(vm.uv.vm_handle, vm.sblk->mso + lc_off + PAGE_SIZE); +} + +static void run_icpt_122_tests_prefix(unsigned long prefix) +{ + uint32_t *ptr = 0; + + report_prefix_pushf("0x%lx", prefix); + report_prefix_push("unshared"); + run_icpt_122_tests(prefix); + report_prefix_pop(); + + /* + * Guest will share the lowcore and we need to check if that + * makes a difference (which it should not). + */ + report_prefix_push("shared"); + + sie(&vm); + /* Guest indicates that it has been setup via the diag 0x44 */ + assert(pv_icptdata_check_diag(&vm, 0x44)); + /* If the pages have not been shared these writes will cause exceptions */ + ptr = (uint32_t *)prefix; + WRITE_ONCE(ptr, 0); + ptr = (uint32_t *)(prefix + offsetof(struct lowcore, ars_sa[0])); + WRITE_ONCE(ptr, 0); + + run_icpt_122_tests(prefix); + + /* shared*/ + report_prefix_pop(); + /* prefix hex value */ + report_prefix_pop(); +} + +static void test_icpt_112(void) +{ + extern const char SNIPPET_NAME_START(asm, pv_icpt_112)[]; + extern const char SNIPPET_NAME_END(asm, pv_icpt_112)[]; + extern const char SNIPPET_HDR_START(asm, pv_icpt_112)[]; + extern const char SNIPPET_HDR_END(asm, pv_icpt_112)[]; + int size_hdr = SNIPPET_HDR_LEN(asm, pv_icpt_112); + int size_gbin = SNIPPET_LEN(asm, pv_icpt_112); + + unsigned long lc_off = 0; + + report_prefix_push("prefix"); + + snippet_pv_init(&vm, SNIPPET_NAME_START(asm, pv_icpt_112), + SNIPPET_HDR_START(asm, pv_icpt_112), + size_gbin, size_hdr, SNIPPET_UNPACK_OFF); + + /* Setup of the guest's state for 0x0 prefix */ + sie(&vm); + assert(pv_icptdata_check_diag(&vm, 0x44)); + + /* Test on standard 0x0 prefix */ + run_icpt_122_tests_prefix(0); + + /* Setup of the guest's state for 0x8000 prefix */ + lc_off = 0x8000; + uv_import(vm.uv.vm_handle, vm.sblk->mso + lc_off); + uv_import(vm.uv.vm_handle, vm.sblk->mso + lc_off + PAGE_SIZE); + /* Guest will set prefix to 0x8000 */ + sie(&vm); + /* SPX generates a PV instruction notification */ + assert(vm.sblk->icptcode == ICPT_PV_NOTIFY && vm.sblk->ipa == 0xb210); + assert(*(u32 *)vm.sblk->sidad == 0x8000); + + /* Test on 0x8000 prefix */ + run_icpt_122_tests_prefix(0x8000); + + /* Try a re-entry after everything has been imported again */ + sie(&vm); + report(pv_icptdata_check_diag(&vm, 0x9c) && + vm.save_area.guest.grs[0] == 42, + "re-entry successful"); + report_prefix_pop(); + uv_destroy_guest(&vm); +} + +int main(void) +{ + report_prefix_push("pv-icpts"); + if (!uv_host_requirement_checks()) + goto done; + + snippet_setup_guest(&vm, true); + test_icpt_112(); + test_validity_asce(); + test_validity_seid(); + test_validity_handle_not_in_config(); + test_validity_already_running(); + test_validity_timing(); + sie_guest_destroy(&vm); + +done: + report_prefix_pop(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index b61faf0..df25b48 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -218,3 +218,9 @@ extra_params = -append '--parallel' [execute] file = ex.elf + +[pv-icptcode] +file = pv-icptcode.elf +smp = 3 +groups = pv-host +extra_params = -m 2200 From patchwork Tue Jul 11 14:15:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308813 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 958AEEB64DC for ; Tue, 11 Jul 2023 14:17:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232558AbjGKORD (ORCPT ); Tue, 11 Jul 2023 10:17:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231618AbjGKOQ6 (ORCPT ); Tue, 11 Jul 2023 10:16:58 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB7251711 for ; Tue, 11 Jul 2023 07:16:42 -0700 (PDT) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BDups1001814; Tue, 11 Jul 2023 14: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 : content-transfer-encoding : mime-version; s=pp1; bh=xukQPVlw0z3kiiqWbL5Ns22GC+gV5qt2t3p2QZL1iwk=; b=cnrQKmXabJPKwsaG7ij0FMshZvlBRO+MBnC2SpNmhMkENgX6FUQ7YHpJTVoWSTKRa/gf oQEasaV2OqfOwDHHaS3vXwy9xvRXjbDYRdiJkkVInb1YOE3Rt0VJSO/uBCXQ8P5d6tCM K1xlmPz+D0mMdMkbVxhElfXHOGyDuS2YYMsUuNu7iPvjtET0qU4KIOadtSabjZfCEc48 ox3misRAMtq2kSjhsCJhk2OJ8JdWStCkvDF05G+g94PY7qUbyF9AO4Us1/cHhKOBR40y Ll4AecX+3XJ1FeyT8/0h12k/qv0QjVXvZKTXaWEyz8kMQtAb8oJVbONyIUFT2CV0mHUU +w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8de0r0a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:30 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BE6I6E026058; Tue, 11 Jul 2023 14:16:27 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8de0qtk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:26 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B848mo008781; Tue, 11 Jul 2023 14:16:19 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3rpye51c2y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:18 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGFhi48038208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:15 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 707FC2004B; Tue, 11 Jul 2023 14:16:15 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E43E220049; Tue, 11 Jul 2023 14:16:14 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:14 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 09/22] s390x: pv: Add IPL reset tests Date: Tue, 11 Jul 2023 16:15:42 +0200 Message-ID: <20230711141607.40742-10-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ocX1Mj7A29jSYx_C-F00v_1fx1l2L1DM X-Proofpoint-GUID: n1_dSjPPVKKiqxvVXv8MZCPK3HUvHWAX X-Proofpoint-UnRewURL: 24 URL's were un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 suspectscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank The diag308 requires extensive cooperation between the hypervisor and the Ultravisor so the Ultravisor can make sure all necessary reset steps have been done. Let's check if we get the correct validity errors. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230619083329.22680-8-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/Makefile | 2 + s390x/snippets/asm/pv-diag-308.S | 51 +++++++++++ s390x/pv-ipl.c | 143 +++++++++++++++++++++++++++++++ s390x/unittests.cfg | 5 ++ 4 files changed, 201 insertions(+) create mode 100644 s390x/snippets/asm/pv-diag-308.S create mode 100644 s390x/pv-ipl.c diff --git a/s390x/Makefile b/s390x/Makefile index 67be536..b5b9481 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -43,6 +43,7 @@ tests += $(TEST_DIR)/ex.elf pv-tests += $(TEST_DIR)/pv-diags.elf pv-tests += $(TEST_DIR)/pv-icptcode.elf +pv-tests += $(TEST_DIR)/pv-ipl.elf ifneq ($(HOST_KEY_DOCUMENT),) ifneq ($(GEN_SE_HEADER),) @@ -130,6 +131,7 @@ $(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-icpt-112.gbin $(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/icpt-loop.gbin $(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/loop.gbin $(TEST_DIR)/pv-icptcode.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-icpt-vir-timing.gbin +$(TEST_DIR)/pv-ipl.elf: pv-snippets += $(SNIPPET_DIR)/asm/pv-diag-308.gbin ifneq ($(GEN_SE_HEADER),) snippets += $(pv-snippets) diff --git a/s390x/snippets/asm/pv-diag-308.S b/s390x/snippets/asm/pv-diag-308.S new file mode 100644 index 0000000..70aea58 --- /dev/null +++ b/s390x/snippets/asm/pv-diag-308.S @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Diagnose 0x308 snippet used for PV IPL and reset testing + * + * Copyright (c) 2023 IBM Corp + * + * Authors: + * Janosch Frank + */ +#include +.section .text + +/* + * Entry + * Execute the diag500 which will set the diag 308 subcode in gr2 + */ +diag 0, 0, 0x500 + +/* + * A valid PGM new PSW can be a real problem since we never fall out + * of SIE and therefore effectively loop forever. 0 is a valid PSW + * therefore we re-use the reset_psw as this has the short PSW + * bit set which is invalid for a long PSW like the exception new + * PSWs. + * + * For subcode 0/1 there are no PGMs to consider. + */ +lgrl %r5, reset_psw +stg %r5, GEN_LC_PGM_NEW_PSW + +/* Set up the reset psw at 0x0 */ +lgrl %r5, reset_psw +larl %r6, done +ogr %r5, %r6 +stg %r5, 0 + +/* Diag 308, subcode is in gr2 */ +diag %r0, %r2, 0x308 + +/* Should never be executed because of the reset PSW */ +diag 0, 0, 0x44 + +/* Pass on a special value indicating success */ +done: +lghi %r1, 42 +diag %r1, 0, 0x9c + + + .align 8 +reset_psw: + .quad 0x0008000180000000 diff --git a/s390x/pv-ipl.c b/s390x/pv-ipl.c new file mode 100644 index 0000000..cc46e7f --- /dev/null +++ b/s390x/pv-ipl.c @@ -0,0 +1,143 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * PV diagnose 308 (IPL) tests + * + * Copyright (c) 2023 IBM Corp + * + * Authors: + * Janosch Frank + */ +#include +#include +#include +#include +#include +#include +#include + +static struct vm vm; + +static void test_diag_308(int subcode) +{ + extern const char SNIPPET_NAME_START(asm, pv_diag_308)[]; + extern const char SNIPPET_NAME_END(asm, pv_diag_308)[]; + extern const char SNIPPET_HDR_START(asm, pv_diag_308)[]; + extern const char SNIPPET_HDR_END(asm, pv_diag_308)[]; + int size_hdr = SNIPPET_HDR_LEN(asm, pv_diag_308); + int size_gbin = SNIPPET_LEN(asm, pv_diag_308); + uint16_t rc, rrc; + int cc; + + report_prefix_pushf("subcode %d", subcode); + snippet_pv_init(&vm, SNIPPET_NAME_START(asm, pv_diag_308), + SNIPPET_HDR_START(asm, pv_diag_308), + size_gbin, size_hdr, SNIPPET_UNPACK_OFF); + + /* First exit is a diag 0x500 */ + sie(&vm); + assert(pv_icptdata_check_diag(&vm, 0x500)); + + /* + * The snippet asked us for the subcode and we answer by + * putting the value in gr2. + * SIE will copy gr2 to the guest + */ + vm.save_area.guest.grs[2] = subcode; + + /* Continue after diag 0x500, next icpt should be the 0x308 */ + sie(&vm); + assert(pv_icptdata_check_diag(&vm, 0x308)); + assert(vm.save_area.guest.grs[2] == subcode); + + /* + * We need to perform several UV calls to emulate the subcode + * 0/1. Failing to do that should result in a validity. + * + * - Mark all cpus as stopped + * - Unshare all memory + * - Prepare the reset + * - Reset the cpus + * - Load the reset PSW + */ + sie_expect_validity(&vm); + sie(&vm); + report(uv_validity_check(&vm), "validity, no action"); + + /* Mark the CPU as stopped so we can unshare and reset */ + cc = uv_set_cpu_state(vm.sblk->pv_handle_cpu, PV_CPU_STATE_STP); + report(!cc, "Set cpu stopped"); + + sie_expect_validity(&vm); + sie(&vm); + report(uv_validity_check(&vm), "validity, stopped"); + + /* Unshare all memory */ + cc = uv_cmd_nodata(vm.sblk->pv_handle_config, + UVC_CMD_SET_UNSHARED_ALL, &rc, &rrc); + report(cc == 0 && rc == 1, "Unshare all"); + + sie_expect_validity(&vm); + sie(&vm); + report(uv_validity_check(&vm), "validity, stopped, unshared"); + + /* Prepare the CPU reset */ + cc = uv_cmd_nodata(vm.sblk->pv_handle_config, + UVC_CMD_PREPARE_RESET, &rc, &rrc); + report(cc == 0 && rc == 1, "Prepare reset call"); + + sie_expect_validity(&vm); + sie(&vm); + report(uv_validity_check(&vm), "validity, stopped, unshared, prep reset"); + + /* + * Do the reset on the initiating cpu + * + * Reset clear for subcode 0 + * Reset initial for subcode 1 + */ + if (subcode == 0) { + cc = uv_cmd_nodata(vm.sblk->pv_handle_cpu, + UVC_CMD_CPU_RESET_CLEAR, &rc, &rrc); + report(cc == 0 && rc == 1, "Clear reset cpu"); + } else { + cc = uv_cmd_nodata(vm.sblk->pv_handle_cpu, + UVC_CMD_CPU_RESET_INITIAL, &rc, &rrc); + report(cc == 0 && rc == 1, "Initial reset cpu"); + } + + sie_expect_validity(&vm); + sie(&vm); + report(uv_validity_check(&vm), "validity, stopped, unshared, prep reset, cpu reset"); + + /* Load the PSW from 0x0 */ + cc = uv_set_cpu_state(vm.sblk->pv_handle_cpu, PV_CPU_STATE_OPR_LOAD); + report(!cc, "Set cpu load"); + + /* + * Check if we executed the iaddr of the reset PSW, we should + * see a diagnose 0x9c PV instruction notification. + */ + sie(&vm); + report(pv_icptdata_check_diag(&vm, 0x9c) && + vm.save_area.guest.grs[0] == 42, + "continue after load"); + + uv_destroy_guest(&vm); + report_prefix_pop(); +} + +int main(void) +{ + report_prefix_push("uv-sie"); + if (!uv_host_requirement_checks()) + goto done; + + snippet_setup_guest(&vm, true); + test_diag_308(0); + test_diag_308(1); + sie_guest_destroy(&vm); + +done: + report_prefix_pop(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index df25b48..26bab34 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -224,3 +224,8 @@ file = pv-icptcode.elf smp = 3 groups = pv-host extra_params = -m 2200 + +[pv-ipl] +file = pv-ipl.elf +groups = pv-host +extra_params = -m 2200 From patchwork Tue Jul 11 14:15:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308808 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 D51AAC001DC for ; Tue, 11 Jul 2023 14:16:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231211AbjGKOQz (ORCPT ); Tue, 11 Jul 2023 10:16:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233454AbjGKOQq (ORCPT ); Tue, 11 Jul 2023 10:16:46 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26DD1B0 for ; Tue, 11 Jul 2023 07:16:34 -0700 (PDT) Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BECf9T016982; Tue, 11 Jul 2023 14:16:25 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=mFJy8yJ21R3z6Hn7TL/AIvv94gBR4zzo6Eh+kqy/yO8=; b=FYfso79MaQDg6VksOdnurNE6zKR5WhJplQVR7noPj0pBWBdaz4+QBQyMro/zPEjzfuvh IdmZ0021ETodivHPvygejkNEiX7CfjXPsTVGQ0GPR3V/WeGmBZkpf2dX33hz0xPatMjh DysZ2sJgkifqHnsCphecGqcQm53bp/3SHcoxuO3qawXdNwMkJCtv561VNodMIKhtzDU0 IOBvBeRcuwZF8YNoRZA2bnOZ8xlwoxaOrZlRxFEnaPhkKhuLQDUai7WPWsmDyKmmHHZY 7Sng440vkq35WGOTMAm9bWsVV9TLd9lO9WVQuZgwzOFwIbT7pzsadwHOvkRT9xLSQW5L Ag== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8my85x0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:24 +0000 Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BED4Zu021085; Tue, 11 Jul 2023 14:16:24 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8my85ta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:24 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36BBSqSA028231; Tue, 11 Jul 2023 14:16:19 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma01fra.de.ibm.com (PPS) with ESMTPS id 3rpye51c02-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:19 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGGt766388306 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:16 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F0CA20049; Tue, 11 Jul 2023 14:16:16 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8937B20043; Tue, 11 Jul 2023 14:16:15 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:15 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 10/22] s390x: pv-diags: Add the test to unittests.conf Date: Tue, 11 Jul 2023 16:15:43 +0200 Message-ID: <20230711141607.40742-11-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: g0myZLEu4F_Ex7-y11arPQoa8mcGAIzA X-Proofpoint-ORIG-GUID: Q5aXdpjt7Tt6nP7_gCKL8bZPY2G88qUz X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 spamscore=0 phishscore=0 suspectscore=0 mlxscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank Better to have it run into a skip than to not run it at all. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230619083329.22680-9-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/unittests.cfg | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 26bab34..49b3cee 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -229,3 +229,8 @@ extra_params = -m 2200 file = pv-ipl.elf groups = pv-host extra_params = -m 2200 + +[pv-diags] +file = pv-diags.elf +groups = pv-host +extra_params = -m 2200 From patchwork Tue Jul 11 14:15:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308823 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 8E761EB64DD for ; Tue, 11 Jul 2023 14:19:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230482AbjGKOT0 (ORCPT ); Tue, 11 Jul 2023 10:19:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbjGKOTZ (ORCPT ); Tue, 11 Jul 2023 10:19:25 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E045F1BD1 for ; Tue, 11 Jul 2023 07:18:49 -0700 (PDT) Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BECdn3016914; Tue, 11 Jul 2023 14:18:46 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=Dsd59hDva96Ve5BaiGn+8bOUaBdGtxOqifFqjX1yotk=; b=QnZziDgHNOfJftxma7pJMj+Op8MgBtHXLt/noBwzEmzfkXzgYpvY4PMY0s7QtML2VnNn Wt2xySGZFomdfSdzoOeeZp0dfzu0MaiykDxAuN+0ub/msq/KuZYPQZZuxADLnAhJB3Mo 3TfDqWeDcG9XqX6pAyjdCJzHmRhmlFu5clsvGtmB82ppePf06nU9CmLkiaRb1Gt6mCjN rFj83Dq+eyztdBysERyhrPMRK9VaT5WhTcr0/Rm9l6piU1t3/300ZJK7rSxrUB1TRmTq fLxS/mD2dgbQ7QobxURciKR7kqrXTShInTISPCGdnbuLJCgA2PmA77nNeU7HrePvViuS JQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8my8983-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:18:45 +0000 Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BECnrh017818; Tue, 11 Jul 2023 14:18:43 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8my894t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:18:43 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B3PA15002283; Tue, 11 Jul 2023 14:16:20 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3rpye59tu1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:20 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGGMP54919460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:16 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A152C20049; Tue, 11 Jul 2023 14:16:16 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2876820043; Tue, 11 Jul 2023 14:16:16 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:16 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 11/22] s390x: uv-host: Fix UV init test memory allocation Date: Tue, 11 Jul 2023 16:15:44 +0200 Message-ID: <20230711141607.40742-12-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: shoxfBpVFjLTpu-OPWp6DCZeq2X0m7DI X-Proofpoint-ORIG-GUID: voXuMe9dgOkCYss_bkOnb4oYCqjOhDKu X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 spamscore=0 phishscore=0 suspectscore=0 mlxscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank The init memory has to be above 2G and 1M aligned but we're currently aligning on 2G which means the allocations need a lot of unused memory. Also the second block of memory was never actually used for the double init test since its address is never put into the uvcb. Let's fix that. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230622075054.3190-2-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/uv-host.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index 33e6eec..9dfaebd 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -500,14 +500,17 @@ static void test_config_create(void) static void test_init(void) { int rc; - uint64_t mem; + uint64_t tmp; - /* Donated storage needs to be over 2GB */ - mem = (uint64_t)memalign_pages_flags(SZ_1M, uvcb_qui.uv_base_stor_len, AREA_NORMAL); + /* + * Donated storage needs to be over 2GB, AREA_NORMAL does that + * on s390x. + */ + tmp = (uint64_t)memalign_pages_flags(SZ_1M, uvcb_qui.uv_base_stor_len, AREA_NORMAL); uvcb_init.header.len = sizeof(uvcb_init); uvcb_init.header.cmd = UVC_CMD_INIT_UV; - uvcb_init.stor_origin = mem; + uvcb_init.stor_origin = tmp; uvcb_init.stor_len = uvcb_qui.uv_base_stor_len; report_prefix_push("init"); @@ -528,14 +531,14 @@ static void test_init(void) rc = uv_call(0, (uint64_t)&uvcb_init); report(rc == 1 && (uvcb_init.header.rc == 0x104 || uvcb_init.header.rc == 0x105), "storage origin invalid"); - uvcb_init.stor_origin = mem; + uvcb_init.stor_origin = tmp; if (uvcb_init.stor_len >= HPAGE_SIZE) { uvcb_init.stor_origin = get_max_ram_size() - HPAGE_SIZE; rc = uv_call(0, (uint64_t)&uvcb_init); report(rc == 1 && uvcb_init.header.rc == 0x105, "storage + length invalid"); - uvcb_init.stor_origin = mem; + uvcb_init.stor_origin = tmp; } else { report_skip("storage + length invalid, stor_len < HPAGE_SIZE"); } @@ -544,7 +547,7 @@ static void test_init(void) rc = uv_call(0, (uint64_t)&uvcb_init); report(rc == 1 && uvcb_init.header.rc == 0x108, "storage below 2GB"); - uvcb_init.stor_origin = mem; + uvcb_init.stor_origin = tmp; smp_cpu_setup(1, PSW_WITH_CUR_MASK(cpu_loop)); rc = uv_call(0, (uint64_t)&uvcb_init); @@ -555,10 +558,12 @@ static void test_init(void) rc = uv_call(0, (uint64_t)&uvcb_init); report(rc == 0 && uvcb_init.header.rc == UVC_RC_EXECUTED, "successful"); - mem = (uint64_t)memalign(1UL << 31, uvcb_qui.uv_base_stor_len); + tmp = uvcb_init.stor_origin; + uvcb_init.stor_origin = (uint64_t)memalign_pages_flags(HPAGE_SIZE, uvcb_qui.uv_base_stor_len, AREA_NORMAL); rc = uv_call(0, (uint64_t)&uvcb_init); report(rc == 1 && uvcb_init.header.rc == 0x101, "double init"); - free((void *)mem); + free((void *)uvcb_init.stor_origin); + uvcb_init.stor_origin = tmp; report_prefix_pop(); } From patchwork Tue Jul 11 14:15:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308827 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 2896FEB64DC for ; Tue, 11 Jul 2023 14:19:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232112AbjGKOTo (ORCPT ); Tue, 11 Jul 2023 10:19:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232241AbjGKOTl (ORCPT ); Tue, 11 Jul 2023 10:19:41 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EE7510FD for ; Tue, 11 Jul 2023 07:19:18 -0700 (PDT) Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BE8sG8025789; Tue, 11 Jul 2023 14:17:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=DYozoPaaQH/BIdzajwQUzfnudE4xdMtLdLnmO8IdTsM=; b=YQh/fhxdo02DxlXEXsre8sEymvziDG2Qqo8dIywugATBa6D5d5i1XxC59b/s6jzj6oCk NOFzA3SBEfCtHfMJwEWHNCcC8l4PFJ9tu0seVm5xPq8yXIYCrS4JjAoFhQ/INJXVswl2 GDqb1BIEPmsqWrrfPRzJaJA4F3da46r2bcwDqHoJug5uZBQ/Xgew3KpTd1LO455fN47m 8HTqltlQvK9tprCrsgo8cyk3t/whkUxzBiL2+RMFmcuffRq9aDBqd9pHaw0JISJyQaHj HiYsPQJqj7Clq3ggH2qAYCTowuuO0noQPEn0L6p6RG+3kYyXa3dhiIz+37SlPzUaYJaU zA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8bbrw98-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:17:06 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BE9JlF030015; Tue, 11 Jul 2023 14:16:35 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8bbrvvu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:35 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B3Mnqk014041; Tue, 11 Jul 2023 14:16:20 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma02fra.de.ibm.com (PPS) with ESMTPS id 3rpye5hcj7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:20 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGHf149414522 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:17 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 465CC2004B; Tue, 11 Jul 2023 14:16:17 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BB84C20043; Tue, 11 Jul 2023 14:16:16 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:16 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 12/22] s390x: uv-host: Check for sufficient amount of memory Date: Tue, 11 Jul 2023 16:15:45 +0200 Message-ID: <20230711141607.40742-13-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: K_YWTnBNQt05PJ_6ceADLdm6HPFCK4y8 X-Proofpoint-GUID: DPvjVxcWOGDxbpXJ3oPSSgz9gWJHPCxq X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 adultscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank The UV init storage needs to be above 2G so we need a little over 2G of memory when running the test. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230622075054.3190-3-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/uv-host.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index 9dfaebd..ee8e44d 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -720,6 +721,13 @@ int main(void) test_invalid(); test_uv_uninitialized(); test_query(); + + if (get_ram_size() < SNIPPET_PV_MIN_MEM_SIZE) { + report_skip("Not enough memory. This test needs about %ld MB of memory", + SNIPPET_PV_MIN_MEM_SIZE / SZ_1M); + goto done; + } + test_init(); setup_vmem(); From patchwork Tue Jul 11 14:15:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308821 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 3B4D2EB64DD for ; Tue, 11 Jul 2023 14:19:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230261AbjGKOTO (ORCPT ); Tue, 11 Jul 2023 10:19:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230237AbjGKOTE (ORCPT ); Tue, 11 Jul 2023 10:19:04 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8798F199C for ; Tue, 11 Jul 2023 07:18:23 -0700 (PDT) Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BE8sbp025777; Tue, 11 Jul 2023 14:17:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=65xpI0iKnu7DL8gVIyblXBf2a77pDc5WgeColMsHdHM=; b=BlQoeZXRnDLrloQ3gDSr2TuMx+CM4xfZVrkLJI1Xls9vnHpCkH96MgwKlZy/w5XOIbzw w/KIPLBJ8v4hnRc90NLO6JJv4oMmYr9cimiyZOLTB612cTHDCXD491lXMKwvN+sPvD/m fePnXLqgTEphcLEYgjbdgE+cRvS4/sUW/qABLwiE3bWJ3rxx9iLwEXjhiOZOpwXLXzSX MFgnVbTgZvGZdhFYJuyx4TzPQxVs6B5JN03f/VePxVND3aphXnyTeND2pJVKnHtyppud 8OPgaIHjyYhqSE9iC3+L1DmbH3SYPV4I61rKB6T5hTOVLIDzvUbaAZfKGrjyDPxNyuwW MA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8bbrw9g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:17:06 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BE9MfV030478; Tue, 11 Jul 2023 14:16:36 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8bbrvwc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:35 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B9vbkt015539; Tue, 11 Jul 2023 14:16:21 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3rpy2e1u3x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:21 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGHJM36307258 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:18 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCDD720043; Tue, 11 Jul 2023 14:16:17 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 60B682004D; Tue, 11 Jul 2023 14:16:17 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:17 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 13/22] s390x: uv-host: Beautify code Date: Tue, 11 Jul 2023 16:15:46 +0200 Message-ID: <20230711141607.40742-14-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 698VMD3MwiAyZybyQLWMNOpspNxPg7Fs X-Proofpoint-GUID: E-2xK7C_MRgotN5K5-h1fjZfhkUQ30uN X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 adultscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank Fixup top comment and add missing space. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230622075054.3190-4-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/uv-host.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index ee8e44d..08ef266 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Guest Ultravisor Call tests + * Host Ultravisor Call tests * * Copyright (c) 2021 IBM Corp * @@ -34,7 +34,7 @@ static struct uv_cb_csc uvcb_csc; extern int diag308_load_reset(u64 code); -struct cmd_list{ +struct cmd_list { const char *name; uint16_t cmd; uint16_t len; From patchwork Tue Jul 11 14:15:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308825 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 E6DC2EB64DC for ; Tue, 11 Jul 2023 14:19:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231496AbjGKOTk (ORCPT ); Tue, 11 Jul 2023 10:19:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231917AbjGKOTg (ORCPT ); Tue, 11 Jul 2023 10:19:36 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C9DD171C for ; Tue, 11 Jul 2023 07:19:12 -0700 (PDT) Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BE8mgs025553; Tue, 11 Jul 2023 14:18:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=BzB+fE34ZU0OL/jOwYuFuIJaWj6scI0Ii5qik+Ir5Qw=; b=CciFnHY6FkliqylHxcapGUPbARiAYbeBHZrjU3vj6KOH54nrhfsZ5lfA99DWI0milamb dlq9zHDnvDkEfzRNkFe0/bCaNr9hZrlxvb1Mc//3bGyF9QcKo6cTzisghZD+F9J/ZMN1 lrO/UAxXDJlxrmff/vDVrC7p4R1OoiHnOi4bcmO6x5iX4MQWpN+LJ5CBEe5KHkktZSd6 Tkk7+6jUoCa0QKNw1mrsazKk1mM0HnD9wKwU1OhjU4dTH5q3IDfhoeJKlCW4g1dVH8t+ SRpO+XoQi9E3FMrnYpGOOTUSuNQy+4CILQ6NjKpmuGxYDixSzSziL76sgsR+C1VfpRYx nQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8bbrwwp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:18:00 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BE9H1E029797; Tue, 11 Jul 2023 14:17:07 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8bbrvwh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:17:07 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B5uOlv030259; Tue, 11 Jul 2023 14:16:21 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3rpye59tu2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:21 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGIdu26804502 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:18 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 751FA20043; Tue, 11 Jul 2023 14:16:18 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00FDC20049; Tue, 11 Jul 2023 14:16:18 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:17 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 14/22] s390x: uv-host: Add cpu number check to test_init Date: Tue, 11 Jul 2023 16:15:47 +0200 Message-ID: <20230711141607.40742-15-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: w8U2BnAaQJ1VNHGovyZkd8oPWdEchwQJ X-Proofpoint-GUID: MHCGwTkc7ZLQA-wtehoaJOgcSLoILC2d X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 adultscore=0 suspectscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank We should only run a test that needs more than one cpu if a sufficient number of cpus are available. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230622075054.3190-5-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/uv-host.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index 08ef266..c04cdd7 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -550,11 +550,15 @@ static void test_init(void) "storage below 2GB"); uvcb_init.stor_origin = tmp; - smp_cpu_setup(1, PSW_WITH_CUR_MASK(cpu_loop)); - rc = uv_call(0, (uint64_t)&uvcb_init); - report(rc == 1 && uvcb_init.header.rc == 0x102, - "too many running cpus"); - smp_cpu_stop(1); + if (smp_query_num_cpus() > 1) { + smp_cpu_setup(1, PSW_WITH_CUR_MASK(cpu_loop)); + rc = uv_call(0, (uint64_t)&uvcb_init); + report(rc == 1 && uvcb_init.header.rc == 0x102, + "too many running cpus"); + smp_cpu_stop(1); + } else { + report_skip("Not enough cpus for 0x102 test"); + } rc = uv_call(0, (uint64_t)&uvcb_init); report(rc == 0 && uvcb_init.header.rc == UVC_RC_EXECUTED, "successful"); From patchwork Tue Jul 11 14:15:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308817 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 888D0EB64DD for ; Tue, 11 Jul 2023 14:17:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232654AbjGKORL (ORCPT ); Tue, 11 Jul 2023 10:17:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232772AbjGKORD (ORCPT ); Tue, 11 Jul 2023 10:17:03 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92C1A173C for ; Tue, 11 Jul 2023 07:16:49 -0700 (PDT) Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BEEUm5003832; Tue, 11 Jul 2023 14:16:46 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=r9QPjCOQV2d5Z7OvDSHYXyz1ER2QVSoQ0iAkN5rG5gA=; b=VDHZM3gDpU4jrJ/ny/EVXNNZGoiQ6YTAbee63SeN61aa2djKSQTNFb+IZGQPfV/9ATY3 qo+DT+7A2e4G/E6f5rui6Vsg/+1+sUSrJ7nN3N5KLK8CCOAZXcuP5wI8uoVPKBXrTK6D n0w4ZGF4OJN3x/M9ZLaEuWNbuY/pTHxyCcsmkrVAw2lcbNm3JM1lMwGB26gnU8L/rG6a Hmcvts/mAr9lWPL12OhIPt/ILHkXeQmUU8EdLt+hzI49cij06cdVrYVjMEdobm/8trq0 KSEkh94zhcJGULLuxPwBSasz3RPpM13TjymZt8D/qF1UQwG+LQeLOZnaRCOB6RH5r4UG TQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8nvr49k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:45 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BEG5o5012726; Tue, 11 Jul 2023 14:16:35 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8nvr3ms-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:34 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36BDmUti005988; Tue, 11 Jul 2023 14:16:22 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3rpy2e1u3y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:22 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGJLl31981998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:19 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 133682004E; Tue, 11 Jul 2023 14:16:19 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9107720049; Tue, 11 Jul 2023 14:16:18 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:18 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 15/22] s390x: uv-host: Remove create guest variable storage prefix check Date: Tue, 11 Jul 2023 16:15:48 +0200 Message-ID: <20230711141607.40742-16-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: OSkJUcxqAE5tbQGRYZJO-72Bnpvfn_92 X-Proofpoint-GUID: lbwpDM0vNAW3dVKfVTpTwr23JybJ79gU X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 mlxlogscore=999 adultscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank The test fails and we currently dont know why, so let's remove it so we can add it again once we understand the problem. Signed-off-by: Janosch Frank Link: https://lore.kernel.org/r/20230622075054.3190-6-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/uv-host.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index c04cdd7..4112b4b 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -435,15 +434,6 @@ static void test_config_create(void) "base storage origin contains lowcore"); uvcb_cgc.conf_base_stor_origin = tmp; - if (smp_query_num_cpus() == 1) { - sigp_retry(1, SIGP_SET_PREFIX, - uvcb_cgc.conf_var_stor_origin + PAGE_SIZE, NULL); - rc = uv_call(0, (uint64_t)&uvcb_cgc); - report(uvcb_cgc.header.rc == 0x10e && rc == 1 && - !uvcb_cgc.guest_handle, "variable storage area contains lowcore"); - sigp_retry(1, SIGP_SET_PREFIX, 0x0, NULL); - } - tmp = uvcb_cgc.guest_sca; uvcb_cgc.guest_sca = 0; rc = uv_call(0, (uint64_t)&uvcb_cgc); From patchwork Tue Jul 11 14:15:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308814 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 99216EB64DD for ; Tue, 11 Jul 2023 14:17:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231186AbjGKORF (ORCPT ); Tue, 11 Jul 2023 10:17:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232112AbjGKOQ7 (ORCPT ); Tue, 11 Jul 2023 10:16:59 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5661C199C for ; Tue, 11 Jul 2023 07:16:44 -0700 (PDT) Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BEEVwC003872; Tue, 11 Jul 2023 14: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=rA7j/5R+SWMopdzxMYKZ96rF+UOex91DZQJsNGoG6tI=; b=gJRfOXcErpZyay2y81n5kj85xuTnaF0qoNSuTngG1o2okY/YRoROl+V/mtOnd0TVdUYB PclAkuft6sLU9qG6kpNdYjopOurh9Wi3NtN7ovFlOyMNd236rsVVKiSGjHeAoUR6xfam 7QgI2DAKteK6xttw8+S2O++GN9oGUEHc/JyRFS4iRb6Zq365+DOSnFDn9RmyrbWrI5Eg Fj0VqFArUpOPccFV2spwJ0rW3DJy0LsQwjRCqgVAamXRAknOvJK7a37lCbkRHVNE6+Dv xVXOMCnPZplyoh1blEhOW0hrqH215DNbl9CI4FyxKymbXPtS8JYt7M/Ja83FRRCFTXdr Cw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8nvr3ss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:34 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BEFAVP006831; Tue, 11 Jul 2023 14:16:26 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8nvr3ma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:26 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36BEFVGY019726; Tue, 11 Jul 2023 14:16:22 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3rqmu0r142-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:22 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGJ3H31982004 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:19 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB12820043; Tue, 11 Jul 2023 14:16:19 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 31B8120040; Tue, 11 Jul 2023 14:16:19 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:19 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 16/22] s390x: uv-host: Properly handle config creation errors Date: Tue, 11 Jul 2023 16:15:49 +0200 Message-ID: <20230711141607.40742-17-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 7zJbd5cmu1kWv299KGNX7GwBZdBu7IX4 X-Proofpoint-GUID: D0CRNi9uTCsjW5BW5bMsLsc04QFn8keI X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 mlxlogscore=962 adultscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank If the first bit is set on a error rc, the hypervisor will need to destroy the config before trying again. Let's properly handle those cases so we're not using stale data. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230622075054.3190-7-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/asm/uv.h | 1 + s390x/uv-host.c | 65 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/lib/s390x/asm/uv.h b/lib/s390x/asm/uv.h index 3892046..e9fb19a 100644 --- a/lib/s390x/asm/uv.h +++ b/lib/s390x/asm/uv.h @@ -24,6 +24,7 @@ #define UVC_RC_NO_RESUME 0x0007 #define UVC_RC_INV_GHANDLE 0x0020 #define UVC_RC_INV_CHANDLE 0x0021 +#define UVC_RC_DSTR_NEEDED_FLG 0x8000 #define UVC_CMD_QUI 0x0001 #define UVC_CMD_INIT_UV 0x000f diff --git a/s390x/uv-host.c b/s390x/uv-host.c index 4112b4b..65a9c6d 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -370,6 +370,42 @@ static void test_cpu_create(void) report_prefix_pop(); } +/* + * If the first bit of the rc is set we need to destroy the + * configuration before testing other create config errors. + */ +static void cgc_destroy_if_needed(struct uv_cb_cgc *uvcb) +{ + uint16_t rc, rrc; + + if (uvcb->header.rc != UVC_RC_EXECUTED && + !(uvcb->header.rc & UVC_RC_DSTR_NEEDED_FLG)) + return; + + assert(uvcb->guest_handle); + assert(!uv_cmd_nodata(uvcb->guest_handle, UVC_CMD_DESTROY_SEC_CONF, + &rc, &rrc)); + + /* We need to zero it for the next test */ + uvcb->guest_handle = 0; +} + +static bool cgc_check_data(struct uv_cb_cgc *uvcb, uint16_t rc_expected) +{ + /* This function purely checks for error rcs */ + if (uvcb->header.rc == UVC_RC_EXECUTED) + return false; + + /* + * We should only receive a handle when the rc is 1 or the + * first bit is set. + */ + if (!(uvcb->header.rc & UVC_RC_DSTR_NEEDED_FLG) && uvcb->guest_handle) + report_abort("Received a handle when we didn't expect one"); + + return (uvcb->header.rc & ~UVC_RC_DSTR_NEEDED_FLG) == rc_expected; +} + static void test_config_create(void) { int rc; @@ -394,58 +430,67 @@ static void test_config_create(void) rc = uv_call(0, (uint64_t)&uvcb_cgc); report(uvcb_cgc.header.rc == UVC_RC_INV_LEN && rc == 1 && !uvcb_cgc.guest_handle, "hdr invalid length"); + cgc_destroy_if_needed(&uvcb_cgc); uvcb_cgc.header.len += 8; uvcb_cgc.guest_stor_origin = uvcb_qui.max_guest_stor_addr + (1UL << 20) * 2 + 1; rc = uv_call(0, (uint64_t)&uvcb_cgc); - report(uvcb_cgc.header.rc == 0x101 && rc == 1, + report(cgc_check_data(&uvcb_cgc, 0x101) && rc == 1, "MSO > max guest addr"); + cgc_destroy_if_needed(&uvcb_cgc); uvcb_cgc.guest_stor_origin = 0; uvcb_cgc.guest_stor_origin = uvcb_qui.max_guest_stor_addr - (1UL << 20); rc = uv_call(0, (uint64_t)&uvcb_cgc); - report(uvcb_cgc.header.rc == 0x102 && rc == 1, + report(cgc_check_data(&uvcb_cgc, 0x102) && rc == 1, "MSO + MSL > max guest addr"); + cgc_destroy_if_needed(&uvcb_cgc); uvcb_cgc.guest_stor_origin = 0; uvcb_cgc.guest_asce &= ~ASCE_P; rc = uv_call(0, (uint64_t)&uvcb_cgc); - report(uvcb_cgc.header.rc == 0x105 && rc == 1, + report(cgc_check_data(&uvcb_cgc, 0x105) && rc == 1, "ASCE private bit missing"); + cgc_destroy_if_needed(&uvcb_cgc); uvcb_cgc.guest_asce |= ASCE_P; uvcb_cgc.guest_asce |= 0x20; rc = uv_call(0, (uint64_t)&uvcb_cgc); - report(uvcb_cgc.header.rc == 0x105 && rc == 1, + report(cgc_check_data(&uvcb_cgc, 0x105) && rc == 1, "ASCE bit 58 set"); + cgc_destroy_if_needed(&uvcb_cgc); uvcb_cgc.guest_asce &= ~0x20; tmp = uvcb_cgc.conf_base_stor_origin; uvcb_cgc.conf_base_stor_origin = get_max_ram_size() + 8; rc = uv_call(0, (uint64_t)&uvcb_cgc); - report(uvcb_cgc.header.rc == 0x108 && rc == 1, + report(cgc_check_data(&uvcb_cgc, 0x108) && rc == 1, "base storage origin > available memory"); + cgc_destroy_if_needed(&uvcb_cgc); uvcb_cgc.conf_base_stor_origin = tmp; tmp = uvcb_cgc.conf_base_stor_origin; uvcb_cgc.conf_base_stor_origin = 0x1000; rc = uv_call(0, (uint64_t)&uvcb_cgc); - report(uvcb_cgc.header.rc == 0x109 && rc == 1, - "base storage origin contains lowcore"); + report(cgc_check_data(&uvcb_cgc, 0x109) && rc == 1, + "base storage origin contains lowcore %x", uvcb_cgc.header.rc); + cgc_destroy_if_needed(&uvcb_cgc); uvcb_cgc.conf_base_stor_origin = tmp; tmp = uvcb_cgc.guest_sca; uvcb_cgc.guest_sca = 0; rc = uv_call(0, (uint64_t)&uvcb_cgc); - report(uvcb_cgc.header.rc == 0x10c && rc == 1, + report(cgc_check_data(&uvcb_cgc, 0x10c) && rc == 1, "sca == 0"); + cgc_destroy_if_needed(&uvcb_cgc); uvcb_cgc.guest_sca = tmp; tmp = uvcb_cgc.guest_sca; uvcb_cgc.guest_sca = get_max_ram_size() + PAGE_SIZE * 4; rc = uv_call(0, (uint64_t)&uvcb_cgc); - report(uvcb_cgc.header.rc == 0x10d && rc == 1, + report(cgc_check_data(&uvcb_cgc, 0x10d) && rc == 1, "sca inaccessible"); + cgc_destroy_if_needed(&uvcb_cgc); uvcb_cgc.guest_sca = tmp; rc = uv_call(0, (uint64_t)&uvcb_cgc); @@ -464,6 +509,7 @@ static void test_config_create(void) uvcb_cgc.guest_handle = 0; rc = uv_call(0, (uint64_t)&uvcb_cgc); report(uvcb_cgc.header.rc >= 0x100 && rc == 1, "reuse uvcb"); + cgc_destroy_if_needed(&uvcb_cgc); uvcb_cgc.guest_handle = tmp; /* Copy over most data from uvcb_cgc, so we have the ASCE that was used. */ @@ -481,6 +527,7 @@ static void test_config_create(void) rc = uv_call(0, (uint64_t)&uvcb); report(uvcb.header.rc >= 0x104 && rc == 1 && !uvcb.guest_handle, "reuse ASCE"); + cgc_destroy_if_needed(&uvcb); free((void *)uvcb.conf_base_stor_origin); free((void *)uvcb.conf_var_stor_origin); From patchwork Tue Jul 11 14:15:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308822 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 14B2BEB64DD for ; Tue, 11 Jul 2023 14:19:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231218AbjGKOTU (ORCPT ); Tue, 11 Jul 2023 10:19:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230125AbjGKOTR (ORCPT ); Tue, 11 Jul 2023 10:19:17 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71149E69 for ; Tue, 11 Jul 2023 07:18:35 -0700 (PDT) Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BE6K17019651; Tue, 11 Jul 2023 14:17:26 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=9wx2DhqGDTpXc2kmU8czI7vafJpYYo5eEIx6NJ1IrDk=; b=e1mK8nipEgL3KjjbjojCkLsvs0qqJ9uJK8ighC06WqDkwOC4wOvYO8FdzOeiW5LihquW JlhyZF0jbVpiHt6iWHRDrH5d098IkW0amzrys4g5IOEZYPHkfQwiWJlenq1JQAshZPmm siCFkfCV/kOefVUFnIzngukH8Iip99eJpT9o/xwRa+D8UXZ4lP0q88kDBJs5j6M91cXY BjmXywL/JJ6JUINEM34pVLkdrkEAOOyzDiCHB1TBPO7TapmBWv3VfQjQXAT4+cYFeWi+ U5pLifOi+c7MhldFIABeY97YwPn93000/dMmn/rGcE46Wzoqq1YrAUfK3MrMrkE4GmyQ WA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8aah8vc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:17:25 +0000 Received: from m0353723.ppops.net (m0353723.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BDoX4n021503; Tue, 11 Jul 2023 14:16:46 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8aah8c2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:46 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B8QxS0022234; Tue, 11 Jul 2023 14:16:23 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3rpye59tu3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:23 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGKlT28312048 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:20 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D17D20043; Tue, 11 Jul 2023 14:16:20 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C44F120040; Tue, 11 Jul 2023 14:16:19 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:19 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 17/22] s390x: uv-host: Fence access checks when UV debug is enabled Date: Tue, 11 Jul 2023 16:15:50 +0200 Message-ID: <20230711141607.40742-18-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: YRQ2S6LaaClcVVXFaOA8jf8rdqR8d-xQ X-Proofpoint-ORIG-GUID: ALm3P457AbgD4L_mxS-SCmZVt4m5Iqnf X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 bulkscore=0 clxscore=1015 phishscore=0 adultscore=0 impostorscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank The debug print directly accesses the UV header which will result in a second accesses exception which will abort the test. Let's fence the access tests instead. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230622075054.3190-8-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/uv-host.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index 65a9c6d..55b4644 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -164,6 +164,15 @@ static void test_access(void) report_prefix_push("access"); + /* + * If debug is enabled info from the uv header is printed + * which would lead to a second exception and a test abort. + */ + if (UVC_ERR_DEBUG) { + report_skip("Debug doesn't work with access tests"); + goto out; + } + report_prefix_push("non-crossing"); protect_page(uvcb, PAGE_ENTRY_I); for (i = 0; cmds[i].name; i++) { @@ -196,6 +205,7 @@ static void test_access(void) uvcb += 1; unprotect_page(uvcb, PAGE_ENTRY_I); +out: free_pages(pages); report_prefix_pop(); } From patchwork Tue Jul 11 14:15:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308815 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 E0E59EB64DC for ; Tue, 11 Jul 2023 14:17:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233452AbjGKORG (ORCPT ); Tue, 11 Jul 2023 10:17:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229939AbjGKORB (ORCPT ); Tue, 11 Jul 2023 10:17:01 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC4DC19B2 for ; Tue, 11 Jul 2023 07:16:45 -0700 (PDT) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BDuqjn001838; Tue, 11 Jul 2023 14: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 : content-transfer-encoding : mime-version; s=pp1; bh=+kQ5tf3JyevbaVtzVA3tjfbhSfGGa2i0KmGT/k4O8VM=; b=C0gcNr974FBzbQ4i+2mXzQkVgLj9UYGYByrPZwh2kUrcgX0e2JrWmOnwhKM1Aq2RWro7 GsRORe0CRrDjyreoEXKmr36ChVfa0tScadAD16Y7gsBsR7mdGIdzwiNIE6Oq3E/hrTkG 2Nkp6qdF2DdYnL410Mem+zRox+La4+Gi2jIF0jjS2QvTN5w0ONo8AxTvm6ppvgt+fsAs OLsFLroaZ9XERQc4uuK9gtuxIDagRsgTzmSGFcNhfo/6OwhMaMKwefdbl17W8ONgmWUC CLpQM9dFehiVrTVqxMpSUDJCtWBYvOG1qogdbD07W+EiD+OvxMEyvLHMetWYgHOkcXaP tA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8de0rc1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:42 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BE6Gtf025842; Tue, 11 Jul 2023 14: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 (PPS) with ESMTPS id 3rs8de0qxj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:40 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36BDmUtj005988; Tue, 11 Jul 2023 14:16:24 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3rpy2e1u41-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:24 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGLl128312052 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:21 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1DBC720043; Tue, 11 Jul 2023 14:16:21 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 979EC20040; Tue, 11 Jul 2023 14:16:20 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:20 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com Subject: [PATCH 18/22] s390x: uv-host: Add the test to unittests.conf Date: Tue, 11 Jul 2023 16:15:51 +0200 Message-ID: <20230711141607.40742-19-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: twXRld3e1cYZlw3MDbgYFXP7ZWKEVdlq X-Proofpoint-GUID: EyXMU5ZJ9np-aYufT5CpdwlK0tyt_HK1 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 suspectscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank Better to skip than to not run it at all. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230622075054.3190-9-frankja@linux.ibm.com [ nrb: fixup whitespace ] Signed-off-by: Nico Boehr --- s390x/unittests.cfg | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 49b3cee..b081345 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -234,3 +234,9 @@ extra_params = -m 2200 file = pv-diags.elf groups = pv-host extra_params = -m 2200 + +[uv-host] +file = uv-host.elf +smp = 2 +groups = pv-host +extra_params = -m 2200 From patchwork Tue Jul 11 14:15:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308810 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 559FFC001DC for ; Tue, 11 Jul 2023 14:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232951AbjGKOQ5 (ORCPT ); Tue, 11 Jul 2023 10:16:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232278AbjGKOQt (ORCPT ); Tue, 11 Jul 2023 10:16:49 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6683819AA for ; Tue, 11 Jul 2023 07:16:36 -0700 (PDT) Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BECh23017147; Tue, 11 Jul 2023 14:16:27 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=O/5ScFUz9wRThzQTY3i8yeYKDjfdJb7tkxNV5o3g/Q0=; b=add7+yvvtYIvFMsK6rPHqiZWEfHOfZ43glpxG4ET+IquSdnn+R5bCjTdJuJgis1HGDlE JEDhtlQgcbw4g71iKgeM4RPiL5VITASIhf/X+jqR5Ft8pWWfwqneDBev8cy7K/EVzLCf nSm+QgbrWil6MUO5YtkYqA1CZ/YtElLzmw9+/hVs/81Yy40LT1w6EMIZ80smTsLdVEpv ICrpNp00CMzymv7bWVeCFMF/VdtozfGh+Yg63UZ3byreR5mxewotrHdE9Jex8Xlr9tGj RL1zBWNwZYwIKsvFV2t3LCxlyAu3b25rCJ/Hrhhzn17Q/ThEgZrtRLr1xe0a+ZSsA6rY Lg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8my8606-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:27 +0000 Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BEEF56026857; Tue, 11 Jul 2023 14:16:26 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8my85x9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:26 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36BEFiNJ019772; Tue, 11 Jul 2023 14:16:24 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3rqmu0r144-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:24 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGLMN20906692 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:21 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B5D3420043; Tue, 11 Jul 2023 14:16:21 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 37ABB20040; Tue, 11 Jul 2023 14:16:21 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:21 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Pierre Morel Subject: [PATCH 19/22] s390x: sclp: treat system as single processor when read_info is NULL Date: Tue, 11 Jul 2023 16:15:52 +0200 Message-ID: <20230711141607.40742-20-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 7vI_kP7TyoS-d9omefuY7ScSd6I8uyby X-Proofpoint-ORIG-GUID: 5uo6FVqm6qa1IdgMmtvEy3UaLAR3gYAp X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=573 bulkscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 spamscore=0 phishscore=0 suspectscore=0 mlxscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Pierre Morel When a test abort()s before SCLP read info is completed, the assertion on read_info in sclp_read_info() will fail. Since abort() eventually calls smp_teardown() which in turn calls sclp_get_cpu_num(), this will cause an infinite abort() chain, causing the test to hang. Fix this by considering the system single processor when read_info is missing. Signed-off-by: Pierre Morel Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230601164537.31769-2-pmorel@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/sclp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c index 390fde7..15662aa 100644 --- a/lib/s390x/sclp.c +++ b/lib/s390x/sclp.c @@ -119,8 +119,15 @@ void sclp_read_info(void) int sclp_get_cpu_num(void) { - assert(read_info); - return read_info->entries_cpu; + if (read_info) + return read_info->entries_cpu; + /* + * Don't abort here if read_info is NULL since abort() calls + * smp_teardown() which eventually calls this function and thus + * causes an infinite abort() chain, causing the test to hang. + * Since we obviously have at least one CPU, just return one. + */ + return 1; } CPUEntry *sclp_get_cpu_entries(void) From patchwork Tue Jul 11 14:15:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308812 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 48776C001DD for ; Tue, 11 Jul 2023 14:17:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233510AbjGKORB (ORCPT ); Tue, 11 Jul 2023 10:17:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232278AbjGKOQ5 (ORCPT ); Tue, 11 Jul 2023 10:16:57 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1605A10EF for ; Tue, 11 Jul 2023 07:16:42 -0700 (PDT) Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BEEUef003838; Tue, 11 Jul 2023 14: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 : content-transfer-encoding : mime-version; s=pp1; bh=lx3S5vy2A/5C5MW1IbsI8GeY7KL04Xg75pewCNpEaSI=; b=L3EvJP3l9nGyAZQhAe6pfq1j2N1ttvE9F7kghTL93e+KHhM8+0eqsXZyQUqF5Yp02k4d unCd3zGZdHdcvg/84W9JsflrhgSciGALCJUazJdVmXEUujU9BjR3ZMyK5wMPnvf26jGU TAWVO3OG+mrAKnSvznGg0UYvoogmKxGFx2JFtF7fG0VM+sSWyOD6wClWCw2FHUyXYTdk cK+9YasFfF9thaTUwFZ/Ilj8GrZeLaJs+WvZD9q+hacJBCkr1z11Gx5qqswsvVDks544 A9Yvico8qEw1kZwJz/0tKMF78AlUVa4IuyOgcy3udnS+FuqyNxonm9qZD+9xjnunfPUX iw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8nvr3uh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:31 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BEEpER005433; Tue, 11 Jul 2023 14:16:27 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8nvr3qp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:27 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36BEEfCD018517; Tue, 11 Jul 2023 14:16:25 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3rqmu0r145-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:25 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGMJE59048212 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:22 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 594F820043; Tue, 11 Jul 2023 14:16:22 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CE95B20040; Tue, 11 Jul 2023 14:16:21 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:21 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Pierre Morel Subject: [PATCH 20/22] s390x: sclp: Implement extended-length-SCCB facility Date: Tue, 11 Jul 2023 16:15:53 +0200 Message-ID: <20230711141607.40742-21-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: UnvTxWj4bA7yW1YxrfOhbI_WbiLX6Gte X-Proofpoint-GUID: xg1_uOba22QNcJXhZ9Jd2amTZ-t8-GCy X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 mlxlogscore=891 adultscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Pierre Morel When the extended-length-SCCB facility is present use a big buffer already at first try when calling sclp_read_scp_info() to avoid the SCLP_RC_INSUFFICIENT_SCCB_LENGTH error. Signed-off-by: Pierre Morel Link: https://lore.kernel.org/r/20230601164537.31769-3-pmorel@linux.ibm.com [ nrb: remove one call to sclp_read_scp_info() ] Signed-off-by: Nico Boehr --- lib/s390x/sclp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c index 15662aa..56d5c90 100644 --- a/lib/s390x/sclp.c +++ b/lib/s390x/sclp.c @@ -17,13 +17,14 @@ #include "sclp.h" #include #include +#include extern unsigned long stacktop; static uint64_t storage_increment_size; static uint64_t max_ram_size; static uint64_t ram_size; -char _read_info[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); +char _read_info[2 * PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); static ReadInfo *read_info; struct sclp_facilities sclp_facilities; @@ -113,7 +114,8 @@ static void sclp_read_scp_info(ReadInfo *ri, int length) void sclp_read_info(void) { - sclp_read_scp_info((void *)_read_info, SCCB_SIZE); + sclp_read_scp_info((void *)_read_info, + test_facility(140) ? sizeof(_read_info) : SCCB_SIZE); read_info = (ReadInfo *)_read_info; } From patchwork Tue Jul 11 14:15:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308818 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 57079EB64DC for ; Tue, 11 Jul 2023 14:17:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233535AbjGKORM (ORCPT ); Tue, 11 Jul 2023 10:17:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbjGKORB (ORCPT ); Tue, 11 Jul 2023 10:17:01 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8845619B5 for ; Tue, 11 Jul 2023 07:16:46 -0700 (PDT) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BEGCEt009972; Tue, 11 Jul 2023 14: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 : content-transfer-encoding : mime-version; s=pp1; bh=czcHP0OZs7yDTSwPOAR3mpy/V8UabklBvFiilwW5IW4=; b=Li6Ggdqc+UoCJzbYe8goJEHfYRDdVdYp9F+QvSX3vXPlyR0PN0Mo8bPItidBBtknMfFv KoVloOon5+Bwm7vb9dVphjOXVD18BE9L4KqzS8tvEWWaTq2e3+ejJhp6DjHaR3uXXcG6 SfWeH15jNxoP2KHNDcKtoLfQ+fLqeGoE+ZS2yO67Q1UFJBSTqG3mGhIdSKBlAYwxdb1B bc7y8J+7Oy2q+Z8VhZBHK4IKFK5ix9yhzFfG1mcNRFV/R81kJ6kx8DRMkZfalaqaVVd4 F68mPAw5TKFSe55lvuumvigVTSGky4yhYemjx+fOEQznnOy9vkGxaNIIKY19Z/9/mV6+ zw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8de0r9a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:42 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BE6Ked026441; Tue, 11 Jul 2023 14:16:36 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8de0qys-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:36 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36BCFmhF015101; Tue, 11 Jul 2023 14:16:26 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma02fra.de.ibm.com (PPS) with ESMTPS id 3rpye5hcj8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:26 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGNTW17957388 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:23 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F30742004B; Tue, 11 Jul 2023 14:16:22 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 72FB320040; Tue, 11 Jul 2023 14:16:22 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:22 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Pierre Morel Subject: [PATCH 21/22] s390x: topology: Check the Perform Topology Function Date: Tue, 11 Jul 2023 16:15:54 +0200 Message-ID: <20230711141607.40742-22-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: tBY9LupMJMUB3zd0SU97bV35EYkvWBxp X-Proofpoint-GUID: kaes2aFSpfcbqga0_RASL2JuWiHp5hs7 X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 suspectscore=0 adultscore=0 malwarescore=0 mlxlogscore=974 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Pierre Morel We check that the PTF instruction is working correctly when the cpu topology facility is available. For KVM only, we test changing of the polarity between horizontal and vertical and that a reset set the horizontal polarity. Signed-off-by: Pierre Morel Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230627082155.6375-2-pmorel@linux.ibm.com [ nrb: replace snprintf/report_prefix_push with report_prefix_pushf ] Signed-off-by: Nico Boehr --- s390x/Makefile | 1 + s390x/topology.c | 188 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 + 3 files changed, 192 insertions(+) create mode 100644 s390x/topology.c diff --git a/s390x/Makefile b/s390x/Makefile index b5b9481..706be79 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -40,6 +40,7 @@ tests += $(TEST_DIR)/panic-loop-pgm.elf tests += $(TEST_DIR)/migration-sck.elf tests += $(TEST_DIR)/exittime.elf tests += $(TEST_DIR)/ex.elf +tests += $(TEST_DIR)/topology.elf pv-tests += $(TEST_DIR)/pv-diags.elf pv-tests += $(TEST_DIR)/pv-icptcode.elf diff --git a/s390x/topology.c b/s390x/topology.c new file mode 100644 index 0000000..79f667f --- /dev/null +++ b/s390x/topology.c @@ -0,0 +1,188 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * CPU Topology + * + * Copyright IBM Corp. 2022 + * + * Authors: + * Pierre Morel + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PTF_REQ_HORIZONTAL 0 +#define PTF_REQ_VERTICAL 1 +#define PTF_CHECK 2 + +#define PTF_ERR_NO_REASON 0 +#define PTF_ERR_ALRDY_POLARIZED 1 +#define PTF_ERR_IN_PROGRESS 2 + +extern int diag308_load_reset(u64); + +static int ptf(unsigned long fc, unsigned long *rc) +{ + int cc; + + asm volatile( + " ptf %1 \n" + " ipm %0 \n" + " srl %0,28 \n" + : "=d" (cc), "+d" (fc) + : + : "cc"); + + *rc = fc >> 8; + return cc; +} + +static void check_privilege(int fc) +{ + unsigned long rc; + + report_prefix_pushf("Privileged fc %d", fc); + enter_pstate(); + expect_pgm_int(); + ptf(fc, &rc); + check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); + report_prefix_pop(); +} + +static void check_specifications(void) +{ + unsigned long error = 0; + unsigned long ptf_bits; + unsigned long rc; + int i; + + report_prefix_push("Specifications"); + + /* Function codes above 3 are undefined */ + for (i = 4; i < 255; i++) { + expect_pgm_int(); + ptf(i, &rc); + if (clear_pgm_int() != PGM_INT_CODE_SPECIFICATION) { + report_fail("FC %d did not yield specification exception", i); + error = 1; + } + } + report(!error, "Undefined function codes"); + + /* Reserved bits must be 0 */ + for (i = 8, error = 0; i < 64; i++) { + ptf_bits = 0x01UL << i; + expect_pgm_int(); + ptf(ptf_bits, &rc); + if (clear_pgm_int() != PGM_INT_CODE_SPECIFICATION) { + report_fail("Reserved bit %d did not yield specification exception", i); + error = 1; + } + } + + report(!error, "Reserved bits"); + + report_prefix_pop(); +} + +static void check_polarization_change(void) +{ + unsigned long rc; + int cc; + + report_prefix_push("Polarization change"); + + /* We expect a clean state through reset */ + report(diag308_load_reset(1), "load normal reset done"); + + /* + * Set vertical polarization to verify that RESET sets + * horizontal polarization back. + */ + cc = ptf(PTF_REQ_VERTICAL, &rc); + report(cc == 0, "Set vertical polarization."); + + report(diag308_load_reset(1), "load normal reset done"); + + cc = ptf(PTF_CHECK, &rc); + report(cc == 0, "Reset should clear topology report"); + + cc = ptf(PTF_REQ_HORIZONTAL, &rc); + report(cc == 2 && rc == PTF_ERR_ALRDY_POLARIZED, + "After RESET polarization is horizontal"); + + /* Flip between vertical and horizontal polarization */ + cc = ptf(PTF_REQ_VERTICAL, &rc); + report(cc == 0, "Change to vertical"); + + cc = ptf(PTF_CHECK, &rc); + report(cc == 1, "Should report"); + + cc = ptf(PTF_REQ_VERTICAL, &rc); + report(cc == 2 && rc == PTF_ERR_ALRDY_POLARIZED, "Double change to vertical"); + + cc = ptf(PTF_CHECK, &rc); + report(cc == 0, "Should not report"); + + cc = ptf(PTF_REQ_HORIZONTAL, &rc); + report(cc == 0, "Change to horizontal"); + + cc = ptf(PTF_CHECK, &rc); + report(cc == 1, "Should Report"); + + cc = ptf(PTF_REQ_HORIZONTAL, &rc); + report(cc == 2 && rc == PTF_ERR_ALRDY_POLARIZED, "Double change to horizontal"); + + cc = ptf(PTF_CHECK, &rc); + report(cc == 0, "Should not report"); + + report_prefix_pop(); +} + +static void test_ptf(void) +{ + check_privilege(PTF_REQ_HORIZONTAL); + check_privilege(PTF_REQ_VERTICAL); + check_privilege(PTF_CHECK); + check_specifications(); + check_polarization_change(); +} + +static struct { + const char *name; + void (*func)(void); +} tests[] = { + { "PTF", test_ptf }, + { NULL, NULL } +}; + +int main(int argc, char *argv[]) +{ + int i; + + report_prefix_push("CPU Topology"); + + if (!test_facility(11)) { + report_skip("Topology facility not present"); + goto end; + } + + report_info("Virtual machine level %ld", stsi_get_fc()); + + for (i = 0; tests[i].name; i++) { + report_prefix_push(tests[i].name); + tests[i].func(); + report_prefix_pop(); + } + +end: + report_prefix_pop(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index b081345..5898879 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -240,3 +240,6 @@ file = uv-host.elf smp = 2 groups = pv-host extra_params = -m 2200 + +[topology] +file = topology.elf From patchwork Tue Jul 11 14:15:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13308824 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 77C50EB64DC for ; Tue, 11 Jul 2023 14:19:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230360AbjGKOT2 (ORCPT ); Tue, 11 Jul 2023 10:19:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbjGKOT0 (ORCPT ); Tue, 11 Jul 2023 10:19:26 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 380BA1BCF for ; Tue, 11 Jul 2023 07:18:49 -0700 (PDT) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36BDuqjp001838; Tue, 11 Jul 2023 14:16:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=YGGrcRcghkQSDgxaT7HQvK56TsEDTLIj7YLzvk08VRo=; b=Kh5nF23w43M3c6PAhTKEW1olorOsMIsUEpvX+lwjPFkEgAIq61ED5rJ/p2b8pGoJJIsy I0ZKIDI8RaoFl9P/ac/N/c1ykHsUL9qRo8pshBXN1ZN226Dx0AAiHhG8OyDvoyEzsXyT 1zKFW4XAqom6SeSUMfGlM4MDP+YjSi37/BxaPVjQ49AdAiA7whsejamGJQM5mrtL/BMY Wi4Y/0WYO6QIvM0E6I8n3jOvLQqbuU5LhUHu/+1S97vKJ41HnTQnzzC/HmU39MQF8h6+ SmiVI6otU0YONWuouHfbi7h4Gn+AGWYHhaAj2y0vQSg/SmiLmagGML/Oo+55TQ3M5sEl kw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rs8de0rb9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:43 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36BE6Keh026441; Tue, 11 Jul 2023 14: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 (PPS) with ESMTPS id 3rs8de0r0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:40 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36B4qrWX023832; Tue, 11 Jul 2023 14:16:27 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma04fra.de.ibm.com (PPS) with ESMTPS id 3rpye59c26-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Jul 2023 14:16:27 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36BEGNR410683078 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Jul 2023 14:16:23 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 94A342004B; Tue, 11 Jul 2023 14:16:23 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1A7F520040; Tue, 11 Jul 2023 14:16:23 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.171.51.229]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 11 Jul 2023 14:16:23 +0000 (GMT) From: Nico Boehr To: thuth@redhat.com, pbonzini@redhat.com, andrew.jones@linux.dev Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, imbrenda@linux.ibm.com, Pierre Morel Subject: [PATCH 22/22] s390x: topology: Checking Configuration Topology Information Date: Tue, 11 Jul 2023 16:15:55 +0200 Message-ID: <20230711141607.40742-23-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711141607.40742-1-nrb@linux.ibm.com> References: <20230711141607.40742-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 9URc4vwwtFcO_LkY9n3un43a7AKjP9wU X-Proofpoint-GUID: wQLM9n3A5Ly_mmS7AMxY3ipVKsoK5xot X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-11_08,2023-07-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 suspectscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307110127 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Pierre Morel STSI with function code 15 is used to store the CPU configuration topology. We retrieve the maximum nested level with SCLP and use the topology tree provided by sockets and cores only to stay compatible with qemu topology before topology extension with drawers and books. arguments. We check : - if the topology stored is coherent between the QEMU -smp parameters and kernel parameters. - the number of CPUs - the maximum number of CPUs - the number of containers of each levels for every STSI(15.1.x) instruction allowed by the machine. Signed-off-by: Pierre Morel Reviewed-by: Nico Boehr Link: https://lore.kernel.org/r/20230627082155.6375-3-pmorel@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/sclp.h | 4 +- lib/s390x/stsi.h | 36 +++++ lib/s390x/sclp.c | 6 + s390x/topology.c | 326 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 4 + 5 files changed, 375 insertions(+), 1 deletion(-) diff --git a/lib/s390x/sclp.h b/lib/s390x/sclp.h index 853529b..6a611bc 100644 --- a/lib/s390x/sclp.h +++ b/lib/s390x/sclp.h @@ -150,7 +150,8 @@ typedef struct ReadInfo { SCCBHeader h; uint16_t rnmax; uint8_t rnsize; - uint8_t _reserved1[16 - 11]; /* 11-15 */ + uint8_t _reserved1[15 - 11]; /* 11-14 */ + uint8_t stsi_parm; /* 15-15 */ uint16_t entries_cpu; /* 16-17 */ uint16_t offset_cpu; /* 18-19 */ uint8_t _reserved2[24 - 20]; /* 20-23 */ @@ -341,5 +342,6 @@ int sclp_service_call(unsigned int command, void *sccb); void sclp_memory_setup(void); uint64_t get_ram_size(void); uint64_t get_max_ram_size(void); +uint64_t sclp_get_stsi_mnest(void); #endif /* _S390X_SCLP_H_ */ diff --git a/lib/s390x/stsi.h b/lib/s390x/stsi.h index bebc492..1351a6f 100644 --- a/lib/s390x/stsi.h +++ b/lib/s390x/stsi.h @@ -29,4 +29,40 @@ struct sysinfo_3_2_2 { uint8_t ext_names[8][256]; }; +#define CPUS_TLE_RES_BITS 0x00fffffff8000000UL +struct topology_core { + uint8_t nl; + uint8_t reserved1[3]; + uint8_t reserved4:5; + uint8_t d:1; + uint8_t pp:2; + uint8_t type; + uint16_t origin; + uint64_t mask; +}; + +#define CONTAINER_TLE_RES_BITS 0x00ffffffffffff00UL +struct topology_container { + uint8_t nl; + uint8_t reserved[6]; + uint8_t id; +}; + +union topology_entry { + uint8_t nl; + struct topology_core cpu; + struct topology_container container; +}; + +#define CPU_TOPOLOGY_MAX_LEVEL 6 +struct sysinfo_15_1_x { + uint8_t reserved0[2]; + uint16_t length; + uint8_t mag[CPU_TOPOLOGY_MAX_LEVEL]; + uint8_t reserved0a; + uint8_t mnest; + uint8_t reserved0c[4]; + union topology_entry tle[]; +}; + #endif /* _S390X_STSI_H_ */ diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c index 56d5c90..2f902e3 100644 --- a/lib/s390x/sclp.c +++ b/lib/s390x/sclp.c @@ -247,3 +247,9 @@ uint64_t get_max_ram_size(void) { return max_ram_size; } + +uint64_t sclp_get_stsi_mnest(void) +{ + assert(read_info); + return read_info->stsi_parm; +} diff --git a/s390x/topology.c b/s390x/topology.c index 79f667f..6955823 100644 --- a/s390x/topology.c +++ b/s390x/topology.c @@ -17,6 +17,20 @@ #include #include #include +#include + +static uint8_t pagebuf[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); + +static int max_nested_lvl; +static int number_of_cpus; +static int cpus_in_masks; +static int max_cpus; + +/* + * Topology level as defined by architecture, all levels exists with + * a single container unless overwritten by the QEMU -smp parameter. + */ +static int expected_topo_lvl[CPU_TOPOLOGY_MAX_LEVEL] = { 1, 1, 1, 1, 1, 1 }; #define PTF_REQ_HORIZONTAL 0 #define PTF_REQ_VERTICAL 1 @@ -155,11 +169,321 @@ static void test_ptf(void) check_polarization_change(); } +/* + * stsi_check_maxcpus + * @info: Pointer to the stsi information + * + * The product of the numbers of containers per level + * is the maximum number of CPU allowed by the machine. + */ +static void stsi_check_maxcpus(struct sysinfo_15_1_x *info) +{ + int n, i; + + for (i = 0, n = 1; i < CPU_TOPOLOGY_MAX_LEVEL; i++) + n *= info->mag[i] ?: 1; + + report(n == max_cpus, "Calculated max CPUs: %d", n); +} + +/* + * stsi_check_mag + * @info: Pointer to the stsi information + * + * MAG field should match the architecture defined containers + * when MNEST as returned by SCLP matches MNEST of the SYSIB. + */ +static void stsi_check_mag(struct sysinfo_15_1_x *info) +{ + int i; + + report_prefix_push("MAG"); + + stsi_check_maxcpus(info); + + /* + * It is not clear how the MAG fields are calculated when mnest + * in the SYSIB 15.x is different from the maximum nested level + * in the SCLP info, so we skip here for now. + */ + if (max_nested_lvl != info->mnest) { + report_skip("No specification on layer aggregation"); + goto done; + } + + /* + * MAG up to max_nested_lvl must match the architecture + * defined containers. + */ + for (i = 0; i < max_nested_lvl; i++) + report(info->mag[CPU_TOPOLOGY_MAX_LEVEL - i - 1] == expected_topo_lvl[i], + "MAG %d field match %d == %d", + i + 1, + info->mag[CPU_TOPOLOGY_MAX_LEVEL - i - 1], + expected_topo_lvl[i]); + + /* Above max_nested_lvl the MAG field must be null */ + for (; i < CPU_TOPOLOGY_MAX_LEVEL; i++) + report(info->mag[CPU_TOPOLOGY_MAX_LEVEL - i - 1] == 0, + "MAG %d field match %d == %d", i + 1, + info->mag[CPU_TOPOLOGY_MAX_LEVEL - i - 1], 0); + +done: + report_prefix_pop(); +} + +/** + * check_tle: + * @tc: pointer to first TLE + * + * Recursively check the containers TLEs until we + * find a CPU TLE. + */ +static uint8_t *check_tle(void *tc) +{ + struct topology_container *container = tc; + struct topology_core *cpus; + int n; + + if (container->nl) { + report_info("NL: %d id: %d", container->nl, container->id); + + report(!(*(uint64_t *)tc & CONTAINER_TLE_RES_BITS), + "reserved bits %016lx", + *(uint64_t *)tc & CONTAINER_TLE_RES_BITS); + + return check_tle(tc + sizeof(*container)); + } + + report_info("NL: %d", container->nl); + cpus = tc; + + report(!(*(uint64_t *)tc & CPUS_TLE_RES_BITS), "reserved bits %016lx", + *(uint64_t *)tc & CPUS_TLE_RES_BITS); + + report(cpus->type == 0x03, "type IFL"); + + report_info("origin: %d", cpus->origin); + report_info("mask: %016lx", cpus->mask); + report_info("dedicated: %d entitlement: %d", cpus->d, cpus->pp); + + n = __builtin_popcountl(cpus->mask); + report(n <= expected_topo_lvl[0], "CPUs per mask: %d out of max %d", + n, expected_topo_lvl[0]); + cpus_in_masks += n; + + if (!cpus->d) + report_skip("Not dedicated"); + else + report(cpus->pp == 3 || cpus->pp == 0, "Dedicated CPUs are either vertically polarized or have high entitlement"); + + return tc + sizeof(*cpus); +} + +/** + * stsi_check_tle_coherency: + * @info: Pointer to the stsi information + * + * We verify that we get the expected number of Topology List Entry + * containers for a specific level. + */ +static void stsi_check_tle_coherency(struct sysinfo_15_1_x *info) +{ + void *tc, *end; + + report_prefix_push("TLE"); + cpus_in_masks = 0; + + tc = info->tle; + end = (void *)info + info->length; + + while (tc < end) + tc = check_tle(tc); + + report(cpus_in_masks == number_of_cpus, "CPUs in mask %d", + cpus_in_masks); + + report_prefix_pop(); +} + +/** + * stsi_get_sysib: + * @info: pointer to the STSI info structure + * @sel2: the selector giving the topology level to check + * + * Fill the sysinfo_15_1_x info structure and check the + * SYSIB header. + * + * Returns instruction validity. + */ +static int stsi_get_sysib(struct sysinfo_15_1_x *info, int sel2) +{ + int ret; + + report_prefix_pushf("SYSIB"); + + ret = stsi(pagebuf, 15, 1, sel2); + + if (max_nested_lvl >= sel2) { + report(!ret, "Valid instruction"); + report(sel2 == info->mnest, "Valid mnest"); + } else { + report(ret, "Invalid instruction"); + } + + report_prefix_pop(); + + return ret; +} + +/** + * check_sysinfo_15_1_x: + * @info: pointer to the STSI info structure + * @sel2: the selector giving the topology level to check + * + * Check if the validity of the STSI instruction and then + * calls specific checks on the information buffer. + */ +static void check_sysinfo_15_1_x(struct sysinfo_15_1_x *info, int sel2) +{ + int ret; + int cc; + unsigned long rc; + + report_prefix_pushf("15_1_%d", sel2); + + ret = stsi_get_sysib(info, sel2); + if (ret) { + report_skip("Selector 2 not supported by architecture"); + goto end; + } + + report_prefix_pushf("H"); + cc = ptf(PTF_REQ_HORIZONTAL, &rc); + if (cc != 0 && rc != PTF_ERR_ALRDY_POLARIZED) { + report_fail("Unable to set horizontal polarization"); + goto vertical; + } + + stsi_check_mag(info); + stsi_check_tle_coherency(info); + +vertical: + report_prefix_pop(); + report_prefix_pushf("V"); + + cc = ptf(PTF_REQ_VERTICAL, &rc); + if (cc != 0 && rc != PTF_ERR_ALRDY_POLARIZED) { + report_fail("Unable to set vertical polarization"); + goto end; + } + + stsi_check_mag(info); + stsi_check_tle_coherency(info); + report_prefix_pop(); + +end: + report_prefix_pop(); +} + +/* + * The Maximum Nested level is given by SCLP READ_SCP_INFO if the MNEST facility + * is available. + * If the MNEST facility is not available, sclp_get_stsi_mnest returns 0 and the + * Maximum Nested level is 2 + */ +#define S390_DEFAULT_MNEST 2 +static int sclp_get_mnest(void) +{ + return sclp_get_stsi_mnest() ?: S390_DEFAULT_MNEST; +} + +static int expected_num_cpus(void) +{ + int i; + int ncpus = 1; + + for (i = 0; i < CPU_TOPOLOGY_MAX_LEVEL; i++) + ncpus *= expected_topo_lvl[i] ?: 1; + + return ncpus; +} + +/** + * test_stsi: + * + * Retrieves the maximum nested topology level supported by the architecture + * and the number of CPUs. + * Calls the checking for the STSI instruction in sel2 reverse level order + * from 6 (CPU_TOPOLOGY_MAX_LEVEL) to 2 to have the most interesting level, + * the one triggering a topology-change-report-pending condition, level 2, + * at the end of the report. + * + */ +static void test_stsi(void) +{ + int sel2; + + max_cpus = expected_num_cpus(); + report_info("Architecture max CPUs: %d", max_cpus); + + max_nested_lvl = sclp_get_mnest(); + report_info("SCLP maximum nested level : %d", max_nested_lvl); + + number_of_cpus = sclp_get_cpu_num(); + report_info("SCLP number of CPU: %d", number_of_cpus); + + /* STSI selector 2 can takes values between 2 and 6 */ + for (sel2 = 6; sel2 >= 2; sel2--) + check_sysinfo_15_1_x((struct sysinfo_15_1_x *)pagebuf, sel2); +} + +/** + * parse_topology_args: + * @argc: number of arguments + * @argv: argument array + * + * This function initialize the architecture topology levels + * which should be the same as the one provided by the hypervisor. + * + * We use the current names found in IBM/Z literature, Linux and QEMU: + * cores, sockets/packages, books, drawers and nodes to facilitate the + * human machine interface but store the result in a machine abstract + * array of architecture topology levels. + * Note that when QEMU uses socket as a name for the topology level 1 + * Linux uses package or physical_package. + */ +static void parse_topology_args(int argc, char **argv) +{ + int i; + static const char * const levels[] = { "cores", "sockets", + "books", "drawers" }; + + for (i = 1; i < argc; i++) { + char *flag = argv[i]; + int level; + + if (flag[0] != '-') + report_abort("Argument is expected to begin with '-'"); + flag++; + for (level = 0; ARRAY_SIZE(levels); level++) { + if (!strcmp(levels[level], flag)) + break; + } + if (level == ARRAY_SIZE(levels)) + report_abort("Unknown parameter %s", flag); + + expected_topo_lvl[level] = atol(argv[++i]); + report_info("%s: %d", levels[level], expected_topo_lvl[level]); + } +} + static struct { const char *name; void (*func)(void); } tests[] = { { "PTF", test_ptf }, + { "STSI", test_stsi }, { NULL, NULL } }; @@ -169,6 +493,8 @@ int main(int argc, char *argv[]) report_prefix_push("CPU Topology"); + parse_topology_args(argc, argv); + if (!test_facility(11)) { report_skip("Topology facility not present"); goto end; diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 5898879..68e119e 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -243,3 +243,7 @@ extra_params = -m 2200 [topology] file = topology.elf + +[topology-2] +file = topology.elf +extra_params = -cpu max,ctop=on -smp sockets=31,cores=8,maxcpus=248 -append '-sockets 31 -cores 8'