From patchwork Fri Nov 10 13:52:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452416 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D49A91A5BC for ; Fri, 10 Nov 2023 13:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="YA5wzECk" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D6A13821A for ; Fri, 10 Nov 2023 05:54:21 -0800 (PST) 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 3AADaGG8001172; Fri, 10 Nov 2023 13:54:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=d75oRC1GW/6duzzGQJmxCn0I9FlvrezJL+Njah9YuX4=; b=YA5wzECkdCJ2bvrctWb6a1PACRbwYjv4GIaCvKKKkW0QgBhy2o94WuAaWG8EtLLWfpu3 nRCoK21Nax2dtxKTWc8qys5o0mZktsAVK5NSC0GjmH+ehnnHAfKwMXp5gCIdHjewdkD+ 2qByu5/81Kn0TfN9HpSgDFHYi0cMl/kXiWmWoDG0BzHgz8MHxZqrNxWFZRJEWX9a2agZ Y2BQD77vrBjkchE1x+NNjQ3fG9jJRu2imBbZdagaGOFw3mvLoUl818ySuUaCZGQtzIOt s8L6g8HxyZF/Q5lvUF3YjCTD5IPBbFt/1uZdcXeH4HY+ocbSsEr+2mXLmBRPZKV+EGik CA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9mrn9ra3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:09 +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 3AADoRxC017047; Fri, 10 Nov 2023 13:54:09 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 3u9mrn9r9k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:08 +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 3AADq3tU000652; Fri, 10 Nov 2023 13:54:07 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w23b7c8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:07 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADs4au55574838 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:04 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F2B02004B; Fri, 10 Nov 2023 13:54:04 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B9CC820043; Fri, 10 Nov 2023 13:54:02 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:02 +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: [kvm-unit-tests GIT PULL 01/26] s390x: spec_ex: load full register Date: Fri, 10 Nov 2023 14:52:10 +0100 Message-ID: <20231110135348.245156-2-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ZgXbSfu79sj029jHxBzT6NuLTWD4cq2C X-Proofpoint-GUID: 4zHxeZFnLCEUT7ZQLa4xEOiS82dSQtee X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 There may be contents left in the upper 32 bits of executed_addr; hence we should use a 64-bit load to make sure they are overwritten. Reviewed-by: Claudio Imbrenda Reviewed-by: Thomas Huth Link: https://lore.kernel.org/r/20230811112949.888903-1-nrb@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/spec_ex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s390x/spec_ex.c b/s390x/spec_ex.c index e3dd85d..72b9425 100644 --- a/s390x/spec_ex.c +++ b/s390x/spec_ex.c @@ -142,7 +142,7 @@ static int psw_odd_address(void) " larl %%r1,0f\n" " stg %%r1,%[fixup_addr]\n" " lpswe %[odd_psw]\n" - "0: lr %[executed_addr],%%r0\n" + "0: lgr %[executed_addr],%%r0\n" : [fixup_addr] "=&T" (fixup_psw.addr), [executed_addr] "=d" (executed_addr) : [odd_psw] "Q" (odd) From patchwork Fri Nov 10 13:52:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452418 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 204B51B296 for ; Fri, 10 Nov 2023 13:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="hcgyPCPk" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 784F73821F for ; Fri, 10 Nov 2023 05:54:22 -0800 (PST) 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 3AADelfQ024524; Fri, 10 Nov 2023 13:54:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=v2gxnusife7vqdnhBtE03HjM/kpUA4RM1Tp4SjWMCfo=; b=hcgyPCPkHinMDj9+GCzERlhjZwK/JLohgrmpuZvcB0aromLZrlWFrZJb4Tqk9korElwZ t5mw8BomhjdeiiM52EWa2739J9xXtwMpxrM58dWqw024+sbiacOOXsTPzWkRyaS/bu6v X4tdGCYHa4of4KDsmBhDpvvCyOHozIXArRC+Ip+FG073nkTaQdA8XrMszHlk59Vj0ZW1 uuLGCAaDgRW6ofOnI1fzSExDacYpu4Kmoe3vSzGv64fQTokzoOnylGNBv41dxm7xaWlp ncWyU0CiykmgYqxRC6k9ONOER9GkOeADQRGTvY92jPbS1JVFbYG0q2Wcx0Pk7sOJ86Dl KQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nkx0b5u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:11 +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 3AADi5x9004252; Fri, 10 Nov 2023 13:54:10 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nkx0b5m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:10 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AADTkkb014320; Fri, 10 Nov 2023 13:54:10 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w22b7vd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:09 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADs6hT15467202 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:06 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C2C1E2004B; Fri, 10 Nov 2023 13:54:06 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D71DC20043; Fri, 10 Nov 2023 13:54:04 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:04 +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: [kvm-unit-tests GIT PULL 02/26] s390x: run PV guests with confidential guest enabled Date: Fri, 10 Nov 2023 14:52:11 +0100 Message-ID: <20231110135348.245156-3-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: tmvrI5s2RdaM2E90WzC5GhrbzEDvJdtY X-Proofpoint-ORIG-GUID: PS3S6eSJ4lJYEGvbVlu_Rg2KB_4Z5rum X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 malwarescore=0 suspectscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 PV can only handle one page of SCLP read info, hence it can only support a maximum of 247 CPUs. To make sure we respect these limitations under PV, add a confidential guest device to QEMU when launching a PV guest. This fixes the topology-2 test failing under PV. Also refactor the run script a bit to reduce code duplication by moving the check whether we're running a PV guest to a function. Suggested-by: Nina Schoetterl-Glausch Reviewed-by: Nina Schoetterl-Glausch Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20230925135259.1685540-1-nrb@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/run | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/s390x/run b/s390x/run index dcbf3f0..e58fa4a 100755 --- a/s390x/run +++ b/s390x/run @@ -14,19 +14,34 @@ set_qemu_accelerator || exit $? qemu=$(search_qemu_binary) || exit $? -if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ] && [ "$ACCEL" = "tcg" ]; then +is_pv() { + if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ]; then + return 0 + fi + return 1 +} + +if is_pv && [ "$ACCEL" = "tcg" ]; then echo "Protected Virtualization isn't supported under TCG" exit 2 fi -if [ "${1: -7}" = ".pv.bin" ] || [ "${TESTNAME: -3}" = "_PV" ] && [ "$MIGRATION" = "yes" ]; then +if is_pv && [ "$MIGRATION" = "yes" ]; then echo "Migration isn't supported under Protected Virtualization" exit 2 fi M='-machine s390-ccw-virtio' M+=",accel=$ACCEL$ACCEL_PROPS" + +if is_pv; then + M+=",confidential-guest-support=pv0" +fi + command="$qemu -nodefaults -nographic $M" +if is_pv; then + command+=" -object s390-pv-guest,id=pv0" +fi command+=" -chardev stdio,id=con0 -device sclpconsole,chardev=con0" command+=" -kernel" command="$(panic_cmd) $(migration_cmd) $(timeout_cmd) $command" From patchwork Fri Nov 10 13:52:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452417 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A64751A73C for ; Fri, 10 Nov 2023 13:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="tXbwREHQ" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B4FC3821E for ; Fri, 10 Nov 2023 05:54:21 -0800 (PST) Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AADkPrr031322; Fri, 10 Nov 2023 13:54:14 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=nwjIEAO+F39T+ygc1Y/Yh+b5+YkSX1vNjbvIno7dAco=; b=tXbwREHQZwtvOMLhDrQH3s2qBjdFBs/SBd/LzfzYZxkg7iJYnTWPrlbFvHsT/lqZp1cL pRw8ag2HT0oju3OUto7uPhfTetiYBly5zm1skgP5R/3kUam8a0FXrHVOSwOxuDSNi7Yv DalkfboSlQar6ezpcv9nsD0oW9OBn7WrGRhQaVkpRVjLMhcfr/jFyVMrLpb7GguRXURC TPLOFoLptQOwV94gFxbg0hdLQaaPlsrg/Dl1MuDFccIi6+eHsuGVfcUeGDNojNH7rh4Q NqhX3J20LNfH7H34nj7fS8Udr40sEgNDUeTA3bI6sYKt++bTe6xRN93ECfTTLgktw6fK QA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9mpbaea6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:14 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AADkPMl031266; Fri, 10 Nov 2023 13:54:13 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9mpbae9n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:13 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AADeAcA014506; Fri, 10 Nov 2023 13:54:12 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w22b7vn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:12 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADs95p46727504 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:09 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ECD8C2004E; Fri, 10 Nov 2023 13:54:08 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2EF4020043; Fri, 10 Nov 2023 13:54:07 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:06 +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: [kvm-unit-tests GIT PULL 03/26] lib: s390x: hw: rework do_detect_host so we don't need allocation Date: Fri, 10 Nov 2023 14:52:12 +0100 Message-ID: <20231110135348.245156-4-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: QNxXATyVha2hAiLQj3_vI6FohMGOkkpT X-Proofpoint-ORIG-GUID: xPz0VxXF3Vs5Q4ULJzOdgd3NrozDh15B X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 mlxlogscore=999 clxscore=1015 lowpriorityscore=0 malwarescore=0 bulkscore=0 phishscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 From: Janosch Frank The current implementation needs to allocate a page for stsi 1.1.1 and 3.2.2. As such it's not usable before the allocator is set up. Unfortunately we might end up with detect_host calls before the allocator setup is done. For example in the SCLP console setup code. Let's allocate the stsi storage on the stack to solve that problem. Signed-off-by: Janosch Frank Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20231031095519.73311-2-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/hardware.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/s390x/hardware.c b/lib/s390x/hardware.c index 2bcf9c4..2175256 100644 --- a/lib/s390x/hardware.c +++ b/lib/s390x/hardware.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "hardware.h" #include "stsi.h" @@ -21,9 +22,10 @@ static const uint8_t qemu_ebcdic[] = { 0xd8, 0xc5, 0xd4, 0xe4 }; /* The string "KVM/" in EBCDIC */ static const uint8_t kvm_ebcdic[] = { 0xd2, 0xe5, 0xd4, 0x61 }; -static enum s390_host do_detect_host(void *buf) +static enum s390_host do_detect_host(void) { - struct sysinfo_3_2_2 *stsi_322 = buf; + uint8_t buf[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); + struct sysinfo_3_2_2 *stsi_322 = (struct sysinfo_3_2_2 *)buf; if (stsi_get_fc() == 2) return HOST_IS_LPAR; @@ -56,14 +58,11 @@ enum s390_host detect_host(void) { static enum s390_host host = HOST_IS_UNKNOWN; static bool initialized = false; - void *buf; if (initialized) return host; - buf = alloc_page(); - host = do_detect_host(buf); - free_page(buf); + host = do_detect_host(); initialized = true; return host; } From patchwork Fri Nov 10 13:52:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452424 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6CC21B27A for ; Fri, 10 Nov 2023 13:54:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="KwEiPV/W" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1775838220 for ; Fri, 10 Nov 2023 05:54:31 -0800 (PST) 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 3AADHjUJ018420; Fri, 10 Nov 2023 13:54: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=XdjLODomn8LX+WPnNbGl1STek+9izqbWL5RMnbFJw4U=; b=KwEiPV/W7MHBNPmJQ8Q1lQFSyfzgW86N0YK3t0sBHctBw6I4G4YxcMy9mZpxMxshXFWU WSjDDxED+fEaEE12s02EJeDxfsmmIROFwGauAo4NpsbZ+03TJ4rlESjf16BZ2rTVzCut et4K32SDQu4KsKnrau52jj/2rlAw/Dduqq+6u1pCvy/7VGi1cr4IO5ueLpM0nV0wJnkR /LKznzLc1QIOY44ZjAZ0loKx4LHXdtUt4hsSjAdecEEieqfnaPgt0avSip7+Fsm7isNq tL912alTQvFhMEoS2cCR+KJBWhLUkwHoL5eh0jqjAfeONX7WJzJSxko0PX4KUH7k5gZl NA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9n97s6y4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:22 +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 3AADJ9kl022709; Fri, 10 Nov 2023 13:54:21 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9n97s6wx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:21 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AAB3Cp1028299; Fri, 10 Nov 2023 13:54:20 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w22u73r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:20 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsEiC55574842 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:14 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2BE2C2004B; Fri, 10 Nov 2023 13:54:11 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5928420043; Fri, 10 Nov 2023 13:54:09 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54: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 Subject: [kvm-unit-tests GIT PULL 04/26] lib: s390x: sclp: Add compat handling for HMC ASCII consoles Date: Fri, 10 Nov 2023 14:52:13 +0100 Message-ID: <20231110135348.245156-5-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: dVSlD3XBRAvJKM9IZ7AwHIpkpd_8zu8l X-Proofpoint-GUID: 5i7kY6Y_8uUu2TZhraqARnYkYtB7LWHL X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 malwarescore=0 phishscore=0 priorityscore=1501 suspectscore=0 clxscore=1015 spamscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 From: Janosch Frank Without the \r the output of the HMC ASCII console takes a lot of additional effort to read in comparison to the line mode console. Additionally we add a console clear for the HMC ASCII console so that old messages from a previously running operating system are not polluting the console. Signed-off-by: Janosch Frank Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20231031095519.73311-3-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/sclp-console.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/s390x/sclp-console.c b/lib/s390x/sclp-console.c index 19c74e4..6c965b6 100644 --- a/lib/s390x/sclp-console.c +++ b/lib/s390x/sclp-console.c @@ -11,6 +11,7 @@ #include #include #include +#include "hardware.h" #include "sclp.h" /* @@ -85,6 +86,8 @@ static uint8_t _ascebc[256] = { 0x90, 0x3F, 0x3F, 0x3F, 0x3F, 0xEA, 0x3F, 0xFF }; +static bool lpar_ascii_compat; + static char lm_buff[120]; static unsigned char lm_buff_off; static struct spinlock lm_buff_lock; @@ -97,14 +100,29 @@ static void sclp_print_ascii(const char *str) { int len = strlen(str); WriteEventData *sccb = (void *)_sccb; + char *str_dest = (char *)&sccb->msg; + int src_ind, dst_ind; sclp_mark_busy(); memset(sccb, 0, sizeof(*sccb)); + + for (src_ind = 0, dst_ind = 0; + src_ind < len && dst_ind < (PAGE_SIZE / 2); + src_ind++, dst_ind++) { + str_dest[dst_ind] = str[src_ind]; + /* Add a \r to the \n for HMC ASCII console */ + if (str[src_ind] == '\n' && lpar_ascii_compat) { + dst_ind++; + str_dest[dst_ind] = '\r'; + } + } + + /* Len might have changed because of the compat behavior */ + len = dst_ind; sccb->h.length = offsetof(WriteEventData, msg) + len; sccb->h.function_code = SCLP_FC_NORMAL_WRITE; sccb->ebh.length = sizeof(EventBufferHeader) + len; sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA; - memcpy(&sccb->msg, str, len); sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb); } @@ -218,8 +236,13 @@ static void sclp_console_disable_read(void) void sclp_console_setup(void) { + lpar_ascii_compat = detect_host() == HOST_IS_LPAR; + /* We send ASCII and line mode. */ sclp_write_event_mask(0, SCLP_EVENT_MASK_MSG_ASCII | SCLP_EVENT_MASK_MSG); + /* Hard terminal reset to clear screen for HMC ASCII console */ + if (lpar_ascii_compat) + sclp_print_ascii("\ec"); } void sclp_print(const char *str) From patchwork Fri Nov 10 13:52:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452420 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E75381A732 for ; Fri, 10 Nov 2023 13:54:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="QtX4FM0A" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 541763821D for ; Fri, 10 Nov 2023 05:54:30 -0800 (PST) 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 3AADeF9O027646; Fri, 10 Nov 2023 13:54:19 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=ce6gVYV7PiiJzLq2PbHOazjELW14a6f83kuohnnrIcg=; b=QtX4FM0AMD4LSUNtkMrnfc9z7vqgpR5R3VDCMIxtcuAmaRYRtB5athVPP1rQ8+m9lUVw 6doH0CW/YLJsBX/HGrbH4taHOhEHYXGRABZaHhk6wp0PfLEpLtaebiLy+dV//q5MncQ4 1pbMxWHakn61mDChbGJbtZFc+NfmB27VkMev5ctSRMT9ZoUIOc/JChHm1NaxTAdJUFLo jZJQ2kG2TTaZJ5hqaAHhBonZua2GWHtTfApD1HY+UtmlbrKodzWHpLFoQtNDPo51rdXg EDIORur9B6SXXBx1aGfepPP2Vm6NL1iWl1O040sS0Jzk6z5Mf9ZU5LRLU48hCAc+ph8R xw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nkq0gdf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:18 +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 3AADfrd3032745; Fri, 10 Nov 2023 13:54:17 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 3u9nkq0gd6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:17 +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 3AABJBIs000675; Fri, 10 Nov 2023 13:54:17 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w23b7d4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:16 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsDDh13107742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:14 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D3D632004F; Fri, 10 Nov 2023 13:54:13 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8FD3F20043; Fri, 10 Nov 2023 13:54:11 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54: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: [kvm-unit-tests GIT PULL 05/26] lib: s390x: sclp: Add line mode input handling Date: Fri, 10 Nov 2023 14:52:14 +0100 Message-ID: <20231110135348.245156-6-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 7FUtMUGMBRmqGkVe2eXqI1ssmZBwCm73 X-Proofpoint-ORIG-GUID: nqg7216hX-k1yv3gnzSwyMS8-TS4SLKi X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 From: Janosch Frank Time to add line-mode input so we can use input handling under LPAR if there's no access to a ASCII console. Line-mode IO is pretty wild and the documentation could be improved a lot. Hence I've copied the input parsing functions from Linux. For some reason output is a type 2 event but input is a type 1 event. This also means that the input and output structures are different from each other. The input can consist of multiple structures which don't contain text data before the input text data is reached. Hence we need a bunch of search functions to retrieve a pointer to the text data. Signed-off-by: Janosch Frank Link: https://lore.kernel.org/r/20231031095519.73311-4-frankja@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/sclp.h | 26 +++++- lib/s390x/sclp-console.c | 181 ++++++++++++++++++++++++++++++++++----- 2 files changed, 186 insertions(+), 21 deletions(-) diff --git a/lib/s390x/sclp.h b/lib/s390x/sclp.h index 6a611bc..22f120d 100644 --- a/lib/s390x/sclp.h +++ b/lib/s390x/sclp.h @@ -226,6 +226,7 @@ typedef struct SCCB { } __attribute__((packed)) SCCB; /* SCLP event types */ +#define SCLP_EVENT_OP_CMD 0x01 #define SCLP_EVENT_ASCII_CONSOLE_DATA 0x1a #define SCLP_EVENT_SIGNAL_QUIESCE 0x1d @@ -233,6 +234,7 @@ typedef struct SCCB { #define SCLP_EVENT_MASK_SIGNAL_QUIESCE 0x00000008 #define SCLP_EVENT_MASK_MSG_ASCII 0x00000040 #define SCLP_EVENT_MASK_MSG 0x40000000 +#define SCLP_EVENT_MASK_OPCMD 0x80000000 #define SCLP_UNCONDITIONAL_READ 0x00 #define SCLP_SELECTIVE_READ 0x01 @@ -296,6 +298,23 @@ struct mdb { struct mto mto; } __attribute__((packed)); +/* vector keys and ids */ +#define GDS_ID_MDSMU 0x1310 +#define GDS_ID_CPMSU 0x1212 +#define GDS_ID_TEXTCMD 0x1320 +#define GDS_KEY_SELFDEFTEXTMSG 0x31 +#define EBC_MDB 0xd4c4c240 + +struct gds_vector { + uint16_t length; + uint16_t gds_id; +} __attribute__((packed)); + +struct gds_subvector { + uint8_t length; + uint8_t key; +} __attribute__((packed)); + typedef struct EventBufferHeader { uint16_t length; uint8_t type; @@ -320,12 +339,17 @@ typedef struct ReadEventData { #define SCLP_EVENT_ASCII_TYPE_DATA_STREAM_FOLLOWS 0 typedef struct ReadEventDataAsciiConsole { - SCCBHeader h; EventBufferHeader ebh; uint8_t type; char data[]; } __attribute__((packed)) ReadEventDataAsciiConsole; +struct ReadEventDataLMConsole { + SCCBHeader h; + EventBufferHeader ebh; + struct gds_vector v[]; +}; + extern char _sccb[]; void sclp_setup_int(void); void sclp_handle_ext(void); diff --git a/lib/s390x/sclp-console.c b/lib/s390x/sclp-console.c index 6c965b6..5de3325 100644 --- a/lib/s390x/sclp-console.c +++ b/lib/s390x/sclp-console.c @@ -1,8 +1,13 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ /* - * SCLP ASCII access driver + * SCLP line mode and ASCII console driver + * Some parts taken from the Linux kernel. * * Copyright (c) 2013 Alexander Graf + * + * Copyright IBM Corp. 1999 + * Author(s): Martin Peschke + * Martin Schwidefsky */ #include @@ -86,6 +91,41 @@ static uint8_t _ascebc[256] = { 0x90, 0x3F, 0x3F, 0x3F, 0x3F, 0xEA, 0x3F, 0xFF }; +static const uint8_t _ebcasc[] = { + 0x00, 0x01, 0x02, 0x03, 0x07, 0x09, 0x07, 0x7F, + 0x07, 0x07, 0x07, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x07, 0x0A, 0x08, 0x07, + 0x18, 0x19, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x1C, 0x07, 0x07, 0x0A, 0x17, 0x1B, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x05, 0x06, 0x07, + 0x07, 0x07, 0x16, 0x07, 0x07, 0x07, 0x07, 0x04, + 0x07, 0x07, 0x07, 0x07, 0x14, 0x15, 0x07, 0x1A, + 0x20, 0xFF, 0x83, 0x84, 0x85, 0xA0, 0x07, 0x86, + 0x87, 0xA4, 0x5B, 0x2E, 0x3C, 0x28, 0x2B, 0x21, + 0x26, 0x82, 0x88, 0x89, 0x8A, 0xA1, 0x8C, 0x07, + 0x8D, 0xE1, 0x5D, 0x24, 0x2A, 0x29, 0x3B, 0x5E, + 0x2D, 0x2F, 0x07, 0x8E, 0x07, 0x07, 0x07, 0x8F, + 0x80, 0xA5, 0x07, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, + 0x07, 0x90, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x70, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, + 0x07, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0xAE, 0xAF, 0x07, 0x07, 0x07, 0xF1, + 0xF8, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, + 0x71, 0x72, 0xA6, 0xA7, 0x91, 0x07, 0x92, 0x07, + 0xE6, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7A, 0xAD, 0xAB, 0x07, 0x07, 0x07, 0x07, + 0x9B, 0x9C, 0x9D, 0xFA, 0x07, 0x07, 0x07, 0xAC, + 0xAB, 0x07, 0xAA, 0x7C, 0x07, 0x07, 0x07, 0x07, + 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x07, 0x93, 0x94, 0x95, 0xA2, 0x07, + 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, + 0x51, 0x52, 0x07, 0x96, 0x81, 0x97, 0xA3, 0x98, + 0x5C, 0xF6, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5A, 0xFD, 0x07, 0x99, 0x07, 0x07, 0x07, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x07, 0x07, 0x9A, 0x07, 0x07, 0x07, +}; + static bool lpar_ascii_compat; static char lm_buff[120]; @@ -226,7 +266,8 @@ static void sclp_write_event_mask(int receive_mask, int send_mask) static void sclp_console_enable_read(void) { - sclp_write_event_mask(SCLP_EVENT_MASK_MSG_ASCII, SCLP_EVENT_MASK_MSG_ASCII | SCLP_EVENT_MASK_MSG); + sclp_write_event_mask(SCLP_EVENT_MASK_MSG_ASCII | SCLP_EVENT_MASK_OPCMD, + SCLP_EVENT_MASK_MSG_ASCII | SCLP_EVENT_MASK_MSG); } static void sclp_console_disable_read(void) @@ -264,37 +305,137 @@ void sclp_print(const char *str) sclp_print_lm(str); } -static int console_refill_read_buffer(void) +static char *console_read_ascii(struct EventBufferHeader *ebh, int *len) { + struct ReadEventDataAsciiConsole *evdata = (void *)ebh; const int max_event_buffer_len = SCCB_SIZE - offsetof(ReadEventDataAsciiConsole, ebh); - ReadEventDataAsciiConsole *sccb = (void *)_sccb; - const int event_buffer_ascii_recv_header_len = sizeof(sccb->ebh) + sizeof(sccb->type); - int ret = -1; + const int event_buffer_ascii_recv_header_len = offsetof(ReadEventDataAsciiConsole, data); + + assert(ebh->length <= max_event_buffer_len); + assert(ebh->length > event_buffer_ascii_recv_header_len); + + *len = ebh->length - event_buffer_ascii_recv_header_len; + return evdata->data; +} + + +static struct gds_vector *sclp_find_gds_vector(void *start, void *end, uint16_t id) +{ + struct gds_vector *v; + + for (v = start; (void *)v < end; v = (void *)v + v->length) + if (v->gds_id == id) + return v; + return NULL; +} + +static struct gds_subvector *sclp_eval_selfdeftextmsg(struct gds_subvector *sv) +{ + void *end; + + end = (void *)sv + sv->length; + for (sv = sv + 1; (void *)sv < end; sv = (void *)sv + sv->length) + if (sv->key == 0x30) + return sv; + return NULL; +} + +static struct gds_subvector *sclp_eval_textcmd(struct gds_vector *v) +{ + struct gds_subvector *sv; + void *end; + + end = (void *)v + v->length; + for (sv = (struct gds_subvector *)(v + 1); (void *)sv < end; + sv = (void *)sv + sv->length) + if (sv->key == GDS_KEY_SELFDEFTEXTMSG) + return sclp_eval_selfdeftextmsg(sv); + return NULL; +} + +static struct gds_subvector *sclp_eval_cpmsu(struct gds_vector *v) +{ + void *end; + + end = (void *)v + v->length; + for (v = v + 1; (void *)v < end; v = (void *)v + v->length) + if (v->gds_id == GDS_ID_TEXTCMD) + return sclp_eval_textcmd(v); + return NULL; +} + +static struct gds_subvector *sclp_eval_mdsmu(struct gds_vector *v) +{ + v = sclp_find_gds_vector(v + 1, (void *)v + v->length, GDS_ID_CPMSU); + if (v) + return sclp_eval_cpmsu(v); + return NULL; +} + +static char *console_read_lm(struct EventBufferHeader *ebh, int *len) +{ + struct gds_vector *v = (void *)ebh + sizeof(*ebh); + struct gds_subvector *sv; + + v = sclp_find_gds_vector(v, (void *)ebh + ebh->length, + GDS_ID_MDSMU); + if (!v) + return NULL; + + sv = sclp_eval_mdsmu(v); + if (!sv) + return NULL; + + *len = sv->length - (sizeof(*sv)); + return (char *)(sv + 1); +} + +static void ebc_to_asc(char *data, int len) +{ + int i; + + for (i = 0; i < len; i++) + data[i] = _ebcasc[(uint8_t)data[i]]; +} + +static int console_refill_read_buffer(void) +{ + struct SCCBHeader *sccb = (struct SCCBHeader *)_sccb; + struct EventBufferHeader *ebh = (void *)_sccb + sizeof(struct SCCBHeader); + char *data; + int ret = -1, len; sclp_console_enable_read(); sclp_mark_busy(); - memset(sccb, 0, SCCB_SIZE); - sccb->h.length = PAGE_SIZE; - sccb->h.function_code = SCLP_UNCONDITIONAL_READ; - sccb->h.control_mask[2] = SCLP_CM2_VARIABLE_LENGTH_RESPONSE; + memset(_sccb, 0, SCCB_SIZE); + sccb->length = PAGE_SIZE; + sccb->function_code = SCLP_UNCONDITIONAL_READ; + sccb->control_mask[2] = SCLP_CM2_VARIABLE_LENGTH_RESPONSE; sclp_service_call(SCLP_CMD_READ_EVENT_DATA, sccb); - if (sccb->h.response_code == SCLP_RC_NO_EVENT_BUFFERS_STORED || - sccb->ebh.type != SCLP_EVENT_ASCII_CONSOLE_DATA || - sccb->type != SCLP_EVENT_ASCII_TYPE_DATA_STREAM_FOLLOWS) { - ret = -1; + if (sccb->response_code == SCLP_RC_NO_EVENT_BUFFERS_STORED) goto out; - } - assert(sccb->ebh.length <= max_event_buffer_len); - assert(sccb->ebh.length > event_buffer_ascii_recv_header_len); + switch (ebh->type) { + case SCLP_EVENT_OP_CMD: + data = console_read_lm(ebh, &len); + if (data) + ebc_to_asc(data, len); + break; + case SCLP_EVENT_ASCII_CONSOLE_DATA: + data = console_read_ascii(ebh, &len); + break; + default: + goto out; + } - read_buf_length = sccb->ebh.length - event_buffer_ascii_recv_header_len; + if (!data) + goto out; - assert(read_buf_length <= sizeof(read_buf)); - memcpy(read_buf, sccb->data, read_buf_length); + assert(len <= sizeof(read_buf)); + memcpy(read_buf, data, len); read_index = 0; ret = 0; From patchwork Fri Nov 10 13:52:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452419 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 615681A72B for ; Fri, 10 Nov 2023 13:54:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="DENmvaXt" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ED533821E for ; Fri, 10 Nov 2023 05:54:29 -0800 (PST) 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 3AADaKcB001450; Fri, 10 Nov 2023 13:54: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=u381LJxo4IZIaULGFVH+XDkA8mtFPi9CMzLicjJ5JPk=; b=DENmvaXtYfPLcKX15xJkFT5aJ8eLsLMRyApCO24Yhe9bVNvA9QQNGXRa8SfKTAcoKm0V /P0hOvVucv3eBDUH86oF8Fo8NfJwi6ZhL5ViuXeuh2wQSkXVpmxeTB02BG1j2e6p6Teo mqO9oBqjT81OMmQfneKqXczJpsDwj6ihKNoc4oGKOV/qGzzeGx+zf0PDi79ZEf1Nvkl7 esukKMmJRH+r6q7s+TW7Qz50Za6ZwguZRJYsLlDOjRovQnEA03dQKtQ++CPm+GB+wf9r 4AIdYwQr1+PK/GWwXx9p8Lkzo4ozq/dTvLIlmE+bbtGGEapaXYBY6I/Eio0JfYp+Ct4i RA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9mrn9rgm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:21 +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 3AADqYiL022564; Fri, 10 Nov 2023 13:54:20 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9mrn9rfv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:20 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AAB4RVK014372; Fri, 10 Nov 2023 13:54:19 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w22b7w5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:19 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsGUk37683840 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:16 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2741420043; Fri, 10 Nov 2023 13:54:16 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3EC182004F; Fri, 10 Nov 2023 13:54:14 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54: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: [kvm-unit-tests GIT PULL 06/26] s390x: spec_ex-sie: refactor to use snippet API Date: Fri, 10 Nov 2023 14:52:15 +0100 Message-ID: <20231110135348.245156-7-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: rq0EWCVaUlfKkHi-cy3GuXhccGdDvVJ4 X-Proofpoint-GUID: -BlHLTGFDgU8CZDVGXoxIEGJmOirP40J X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 spec_ex-sie uses a snippet, but allocated the memory on its own without obvious reason to do so. Refactor the test to use snippet_init(). Reviewed-by: Janosch Frank Link: https://lore.kernel.org/r/20231106170849.1184162-2-nrb@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/spec_ex-sie.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/s390x/spec_ex-sie.c b/s390x/spec_ex-sie.c index 5fa135b..fe2f23e 100644 --- a/s390x/spec_ex-sie.c +++ b/s390x/spec_ex-sie.c @@ -17,19 +17,18 @@ #include static struct vm vm; -extern const char SNIPPET_NAME_START(c, spec_ex)[]; -extern const char SNIPPET_NAME_END(c, spec_ex)[]; static bool strict; static void setup_guest(void) { - char *guest; - int binary_size = SNIPPET_LEN(c, spec_ex); + extern const char SNIPPET_NAME_START(c, spec_ex)[]; + extern const char SNIPPET_NAME_END(c, spec_ex)[]; setup_vm(); - guest = alloc_pages(8); - memcpy(guest, SNIPPET_NAME_START(c, spec_ex), binary_size); - sie_guest_create(&vm, (uint64_t) guest, HPAGE_SIZE); + + snippet_setup_guest(&vm, false); + snippet_init(&vm, SNIPPET_NAME_START(c, spec_ex), + SNIPPET_LEN(c, spec_ex), SNIPPET_UNPACK_OFF); } static void reset_guest(void) From patchwork Fri Nov 10 13:52:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452423 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50A4F1C694 for ; Fri, 10 Nov 2023 13:54:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="bNfMD/Vb" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35C0E3821E for ; Fri, 10 Nov 2023 05:54:32 -0800 (PST) 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 3AADek51024482; Fri, 10 Nov 2023 13:54:30 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=OanHKiMZlZkDg6m8yXWYZT9lvhD43fkTASwQXL9Gqhs=; b=bNfMD/VbV4qB+OPJmeOqJW2cczW36us82lL/J+BJJEtL8wXPXdVOQurv2XRsn3pU8Es0 PrLKKpnsDfcFI+DN2eZJ3j08py3KbmHGIGJAe+nNuHx8TBwmWimRlytJcUZ3qFf/wI4w dlpJ54ZEaYj30ZHYBp2IJ2vMrQzLltGP6NOJ4u+OfvuowHE7tTV1xZI0WHyYkqQa4UOr mptsfiWoNFVCZYngT13xr1PiWDkEeq10l80DRCJNK5VduIx0DBhNrTa88a3LxJ/GWf1K +bB9T6mFJR082v5WkrLQWK6kLqPM4+Gw9D66ZVNw00GWHDuPDIF0haXhutscUN+POQL4 6Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nkx0ber-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:29 +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 3AADs7EU007741; Fri, 10 Nov 2023 13:54:28 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nkx0bec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:28 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AAB1nEK003455; Fri, 10 Nov 2023 13:54:28 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3u7w22b6q9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:28 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsJjv65929478 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:19 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 949CB20043; Fri, 10 Nov 2023 13:54:18 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7AC292004B; Fri, 10 Nov 2023 13:54:16 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54: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: [kvm-unit-tests GIT PULL 07/26] s390x: sie: ensure guests are aligned to 2GB Date: Fri, 10 Nov 2023 14:52:16 +0100 Message-ID: <20231110135348.245156-8-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: udgiM4IXW0MZNx4ElFRuromYMGIkF8bW X-Proofpoint-ORIG-GUID: imi9zpIJ3dOIii2OdQMQenSM8k0JmpDa X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 malwarescore=0 suspectscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 Until now, kvm-unit-tests has aligned guests to 1 MB in the host virtual address space. Unfortunately, some s390x environments require guests to be 2GB aligned in the host virtual address space, preventing kvm-unit-tests which act as a hypervisor from running there. We can't easily put guests at address 0, since we want to be able to run with MSO/MSL without having to maintain separate page tables for the guest physical memory. 2GB is also not a good choice, since the alloc_pages allocator will place its metadata there when the host has more than 2GB of memory. In addition, we also want a bit of space after the end of the host physical memory to be able to catch accesses beyond the end of physical memory. The vmalloc allocator unfortunately allocates memory starting at the highest virtual address which is not suitable for guest memory either due to additional constraints of some environments. The physical page allocator in memalign_pages() is also not a optimal choice, since every test running SIE would then require at least 4GB+1MB of physical memory. This results in a few quite complex allocation requirements, hence add a new function sie_guest_alloc() which allocates memory for a guest and then establishes a properly aligned virtual space mapping. Rework snippet test and sie tests to use the new sie_guest_alloc() function. Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20231106170849.1184162-3-nrb@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/sie.h | 2 ++ lib/s390x/snippet.h | 9 +++------ lib/s390x/sie.c | 42 ++++++++++++++++++++++++++++++++++++++++++ s390x/sie.c | 4 ++-- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h index 147cb0f..c1724cf 100644 --- a/lib/s390x/sie.h +++ b/lib/s390x/sie.h @@ -285,4 +285,6 @@ void sie_guest_sca_create(struct vm *vm); void sie_guest_create(struct vm *vm, uint64_t guest_mem, uint64_t guest_mem_len); void sie_guest_destroy(struct vm *vm); +uint8_t *sie_guest_alloc(uint64_t guest_size); + #endif /* _S390X_SIE_H_ */ diff --git a/lib/s390x/snippet.h b/lib/s390x/snippet.h index 11ec54c..910849a 100644 --- a/lib/s390x/snippet.h +++ b/lib/s390x/snippet.h @@ -125,14 +125,11 @@ static inline void snippet_pv_init(struct vm *vm, const char *gbin, /* Allocates and sets up a snippet based guest */ static inline void snippet_setup_guest(struct vm *vm, bool is_pv) { - u8 *guest; - - /* Allocate 1MB as guest memory */ - guest = alloc_pages(8); - memset(guest, 0, HPAGE_SIZE); + const unsigned long guest_size = SZ_1M; + uint8_t *guest_start = sie_guest_alloc(guest_size); /* Initialize the vm struct and allocate control blocks */ - sie_guest_create(vm, (uint64_t)guest, HPAGE_SIZE); + sie_guest_create(vm, (uint64_t)guest_start, guest_size); if (is_pv) { /* FMT4 needs a ESCA */ diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c index b44febd..97a093b 100644 --- a/lib/s390x/sie.c +++ b/lib/s390x/sie.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include void sie_expect_validity(struct vm *vm) { @@ -111,6 +113,46 @@ void sie_guest_create(struct vm *vm, uint64_t guest_mem, uint64_t guest_mem_len) vm->sblk->crycbd = (uint32_t)(uintptr_t)vm->crycb; } +/** + * sie_guest_alloc() - Allocate memory for a guest and map it in virtual address + * space such that it is properly aligned. + * @guest_size: the desired size of the guest in bytes. + */ +uint8_t *sie_guest_alloc(uint64_t guest_size) +{ + static unsigned long guest_counter = 1; + u8 *guest_phys, *guest_virt; + unsigned long i; + pgd_t *root; + + setup_vm(); + root = (pgd_t *)(stctg(1) & PAGE_MASK); + + /* + * Start of guest memory in host virtual space needs to be aligned to + * 2GB for some environments. It also can't be at 2GB since the memory + * allocator stores its page_states metadata there. + * Thus we use the next multiple of 4GB after the end of physical + * mapping. This also leaves space after end of physical memory so the + * page immediately after physical memory is guaranteed not to be + * present. + */ + guest_virt = (uint8_t *)ALIGN(get_ram_size() + guest_counter * 4UL * SZ_1G, SZ_2G); + guest_counter++; + + guest_phys = alloc_pages(get_order(guest_size) - 12); + /* + * Establish a new mapping of the guest memory so it can be 2GB aligned + * without actually requiring 2GB physical memory. + */ + for (i = 0; i < guest_size; i += PAGE_SIZE) { + install_page(root, __pa(guest_phys + i), guest_virt + i); + } + memset(guest_virt, 0, guest_size); + + return guest_virt; +} + /* Frees the memory that was gathered on initialization */ void sie_guest_destroy(struct vm *vm) { diff --git a/s390x/sie.c b/s390x/sie.c index cd3cea1..ce5b606 100644 --- a/s390x/sie.c +++ b/s390x/sie.c @@ -89,8 +89,8 @@ static void setup_guest(void) { setup_vm(); - /* Allocate 1MB as guest memory */ - guest = alloc_pages(8); + guest = sie_guest_alloc(SZ_1M); + /* The first two pages are the lowcore */ guest_instr = guest + PAGE_SIZE * 2; From patchwork Fri Nov 10 13:52:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452425 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 923511CA81 for ; Fri, 10 Nov 2023 13:54:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="PAf030SX" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A7BA3821D for ; Fri, 10 Nov 2023 05:54:35 -0800 (PST) Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AADTsTk004571; Fri, 10 Nov 2023 13:54: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=Ee0kq4Fg66iJ+E+cgrX/gBFJdLxh+UhfN0n4sX9tr7M=; b=PAf030SX2xjeMM9tGmyuUVj1LKVsrdCh34nGq0GzoDpWC2yr7IUDSHzAS9TQGrF/kZC0 AOYX7/sz9qAc5gwLrnEwogcHAAiZksYuZSgIM38+O0T4T0rRiSmwtMeNhO/TO/I9hqF8 m9f8cXD0cMZk5TnMTKmY0B3NchK31ftoULfrSbSDZbD+Eo7FhFdMj8nSCPpQYVlbBq+V 6qHTCz1MNfxyGbdgg6SVk9tDQfPTTYB8zwzgHlQowFvCpSy8mwUGrFeJx9nDzYMYd1Wz OUYvGAIpgAb7pdh5ZA5BshK4eOu9kBRdkYiwbovhVCj79ljdfvpzmQRwmzFfKLwlFIQi bQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9md2308y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:26 +0000 Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AADUGlT006756; Fri, 10 Nov 2023 13:54:25 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9md2308k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:25 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AAB0C4I028363; Fri, 10 Nov 2023 13:54:24 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w22u741-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:24 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsKkt15467208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:20 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C0CBE20043; Fri, 10 Nov 2023 13:54:20 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 007F92004B; Fri, 10 Nov 2023 13:54:19 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54: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: [kvm-unit-tests GIT PULL 08/26] s390x: mvpg-sie: fix virtual-physical address confusion Date: Fri, 10 Nov 2023 14:52:17 +0100 Message-ID: <20231110135348.245156-9-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: isCumLuA_iBnWGjtr6JlXMLKtRnJtJBJ X-Proofpoint-GUID: 1g5uAzaAsDCcwnsvHH-wxJedR46bZBMl X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 suspectscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 The addresses reported for the partial execution of mvpg instruction are physical addresses. Now that MSO is a virtual address, we can't simply compare the PEI fields in the sie block with MSO, but need to do an additional translation step. Add the necessary virtual-physical translations. Link: https://lore.kernel.org/r/20231106170849.1184162-4-nrb@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/mvpg-sie.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/s390x/mvpg-sie.c b/s390x/mvpg-sie.c index 99f4859..d182b49 100644 --- a/s390x/mvpg-sie.c +++ b/s390x/mvpg-sie.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,9 @@ static struct vm vm; static uint8_t *src; +static phys_addr_t src_phys; static uint8_t *dst; +static phys_addr_t dst_phys; static uint8_t *cmp; static void test_mvpg_pei(void) @@ -38,8 +41,8 @@ static void test_mvpg_pei(void) protect_page(src, PAGE_ENTRY_I); sie(&vm); report(vm.sblk->icptcode == ICPT_PARTEXEC, "Partial execution"); - report((uintptr_t)**pei_src == (uintptr_t)src + PAGE_ENTRY_I, "PEI_SRC correct"); - report((uintptr_t)**pei_dst == (uintptr_t)dst, "PEI_DST correct"); + report((uintptr_t)**pei_src == (uintptr_t)src_phys + PAGE_ENTRY_I, "PEI_SRC correct"); + report((uintptr_t)**pei_dst == (uintptr_t)dst_phys, "PEI_DST correct"); unprotect_page(src, PAGE_ENTRY_I); report(!memcmp(cmp, dst, PAGE_SIZE), "Destination intact"); /* @@ -60,8 +63,8 @@ static void test_mvpg_pei(void) protect_page(dst, PAGE_ENTRY_I); sie(&vm); report(vm.sblk->icptcode == ICPT_PARTEXEC, "Partial execution"); - report((uintptr_t)**pei_src == (uintptr_t)src, "PEI_SRC correct"); - report((uintptr_t)**pei_dst == (uintptr_t)dst + PAGE_ENTRY_I, "PEI_DST correct"); + report((uintptr_t)**pei_src == (uintptr_t)src_phys, "PEI_SRC correct"); + report((uintptr_t)**pei_dst == (uintptr_t)dst_phys + PAGE_ENTRY_I, "PEI_DST correct"); /* Needed for the memcmp and general cleanup */ unprotect_page(dst, PAGE_ENTRY_I); report(!memcmp(cmp, dst, PAGE_SIZE), "Destination intact"); @@ -82,8 +85,10 @@ static void setup_guest(void) { extern const char SNIPPET_NAME_START(c, mvpg_snippet)[]; extern const char SNIPPET_NAME_END(c, mvpg_snippet)[]; + pgd_t *root; setup_vm(); + root = (pgd_t *)(stctg(1) & PAGE_MASK); snippet_setup_guest(&vm, false); snippet_init(&vm, SNIPPET_NAME_START(c, mvpg_snippet), @@ -94,6 +99,9 @@ static void setup_guest(void) src = (uint8_t *) vm.sblk->mso + PAGE_SIZE * 6; dst = (uint8_t *) vm.sblk->mso + PAGE_SIZE * 5; + src_phys = virt_to_pte_phys(root, src); + dst_phys = virt_to_pte_phys(root, dst); + cmp = alloc_page(); memset(cmp, 0, PAGE_SIZE); } From patchwork Fri Nov 10 13:52:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452421 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 070731B27B for ; Fri, 10 Nov 2023 13:54:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Gx+se9Zj" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A99038222 for ; Fri, 10 Nov 2023 05:54:32 -0800 (PST) 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 3AADgJE9019290; Fri, 10 Nov 2023 13:54:28 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=W4FXWD14CBCeGz7nGDTtjhDRtlyr08DItxOsiaLHaAA=; b=Gx+se9Zj3/0YHtXckLG7EEvmaGMf/WFDwLfLTugV+BJBn9w9V6rbVn33zgBrcB0SYfTl jzgEfNzM8+72QeGj/Jq5Yc3tkf19xJah0fOeO2hHBLEScSdBaZAyqcRwiEic6O5JVfQX PHK0HxewoxkkUswRLs9H8VJnfYwUfmcTrm9rOcZnRIyIRwffdKtukgwctBJ0JYT/8gLx HOt7NCfgk6Pn4msq5NOktUCwqnPNviap6iwpvkfiYSTIe7ZrsAP0hNHDFEReMw4c8Jsu dxYXN6OlYeZyhejYQDZD+cZPdIf0Iu8cuNtvp+WsoqwtWMhFFQK7sp2dnz1nEB1OUywf KQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9mrn9rmy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:28 +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 3AADj2ls003358; Fri, 10 Nov 2023 13:54:28 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 3u9mrn9rkx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:27 +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 3AABJBIw000675; Fri, 10 Nov 2023 13:54:26 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w23b7dn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:26 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsMfD16319136 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:23 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D29C02004B; Fri, 10 Nov 2023 13:54:22 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E6B220043; Fri, 10 Nov 2023 13:54:21 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54: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, Nina Schoetterl-Glausch Subject: [kvm-unit-tests GIT PULL 09/26] s390x: topology: Introduce enums for polarization & cpu type Date: Fri, 10 Nov 2023 14:52:18 +0100 Message-ID: <20231110135348.245156-10-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: x0YeYKKP_vhp_gvBDBkmG5WzTrNvQazH X-Proofpoint-GUID: lcEtxpsG6wdYo5NbGGYdGjdk8P-w5CE_ X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 From: Nina Schoetterl-Glausch Thereby get rid of magic values. Reviewed-by: Nico Boehr Reviewed-by: Janosch Frank Signed-off-by: Nina Schoetterl-Glausch Link: https://lore.kernel.org/r/20231030160349.458764-2-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/stsi.h | 11 +++++++++++ s390x/topology.c | 6 ++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/s390x/stsi.h b/lib/s390x/stsi.h index 1351a6f..2f6182c 100644 --- a/lib/s390x/stsi.h +++ b/lib/s390x/stsi.h @@ -41,6 +41,17 @@ struct topology_core { uint64_t mask; }; +enum topology_polarization { + POLARIZATION_HORIZONTAL = 0, + POLARIZATION_VERTICAL_LOW = 1, + POLARIZATION_VERTICAL_MEDIUM = 2, + POLARIZATION_VERTICAL_HIGH = 3, +}; + +enum cpu_type { + CPU_TYPE_IFL = 3, +}; + #define CONTAINER_TLE_RES_BITS 0x00ffffffffffff00UL struct topology_container { uint8_t nl; diff --git a/s390x/topology.c b/s390x/topology.c index 6955823..6ab8c8d 100644 --- a/s390x/topology.c +++ b/s390x/topology.c @@ -261,7 +261,7 @@ static uint8_t *check_tle(void *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(cpus->type == CPU_TYPE_IFL, "type IFL"); report_info("origin: %d", cpus->origin); report_info("mask: %016lx", cpus->mask); @@ -275,7 +275,9 @@ static uint8_t *check_tle(void *tc) 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"); + report(cpus->pp == POLARIZATION_VERTICAL_HIGH || + cpus->pp == POLARIZATION_HORIZONTAL, + "Dedicated CPUs are either vertically polarized or have high entitlement"); return tc + sizeof(*cpus); } From patchwork Fri Nov 10 13:52:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452427 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71C3A1DDC9 for ; Fri, 10 Nov 2023 13:54:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="lbpLpI07" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B51F3821E for ; Fri, 10 Nov 2023 05:54:36 -0800 (PST) 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 3AADaHN1001202; Fri, 10 Nov 2023 13:54:28 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=IDsH00daCSOoQ2R8Vi86KayPD/dZnKskQPhRrvM7IyI=; b=lbpLpI07cMTKSyJP9NXuwBW9i69BPwa/kHFBWg6V6qcu9vERn/l6BwxnvHXqrn25DzqX DVPuKsoA1TuC3ukTOBmWeGLfR8NSFsmXxQclrhna86x8UeI3PUOK1zj5WvMPn5ztTjU8 M1w37EVrkisp9r0FjQQwpLgGw9ENC9vtQ+aphZAje9by5tCFTa+jG4dxPJyYU+D/UAXc 5BxgYHzuyZbRtkv75eoSsY3vkGcMRpWWja78tkJTJK2/er53MKkNAu2jfjjLoH06SSss 328HUBSgJ3ORsj66BnKBfZ1tAKvBBSD7r+a7fuZI5fBBwK6LhdRvb22mYZGYSWe1mvOH TQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9mrn9rm7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:27 +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 3AADdHLc012301; Fri, 10 Nov 2023 13:54:27 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9mrn9rkq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:27 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AABTBtO003435; Fri, 10 Nov 2023 13:54:26 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3u7w22b6q1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:26 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsNsv40239406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:23 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 62CE32005A; Fri, 10 Nov 2023 13:54:23 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E67B72004F; Fri, 10 Nov 2023 13:54:22 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54: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, Nina Schoetterl-Glausch Subject: [kvm-unit-tests GIT PULL 10/26] s390x: topology: Fix report message Date: Fri, 10 Nov 2023 14:52:19 +0100 Message-ID: <20231110135348.245156-11-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: n6cp718kvzotrqN2UFqOxLA99GAtp3UV X-Proofpoint-GUID: FhQowMPSq41TQic2eHVlWjgz_Rv6osg6 X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 From: Nina Schoetterl-Glausch A polarization value of 0 means horizontal polarization. Reviewed-by: Nico Boehr Reviewed-by: Janosch Frank Signed-off-by: Nina Schoetterl-Glausch Link: https://lore.kernel.org/r/20231030160349.458764-3-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s390x/topology.c b/s390x/topology.c index 6ab8c8d..1c4a86f 100644 --- a/s390x/topology.c +++ b/s390x/topology.c @@ -277,7 +277,7 @@ static uint8_t *check_tle(void *tc) else report(cpus->pp == POLARIZATION_VERTICAL_HIGH || cpus->pp == POLARIZATION_HORIZONTAL, - "Dedicated CPUs are either vertically polarized or have high entitlement"); + "Dedicated CPUs are either horizontally polarized or have high entitlement"); return tc + sizeof(*cpus); } From patchwork Fri Nov 10 13:52:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452422 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74BB81B290 for ; Fri, 10 Nov 2023 13:54:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="d+b19awo" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E50B338221 for ; Fri, 10 Nov 2023 05:54:31 -0800 (PST) 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 3AADnjfg014912; Fri, 10 Nov 2023 13:54:29 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=5re8vL1wcJ6n+39+kO8kJVf94EXNT2Pz6AA0pVTMI40=; b=d+b19awotB0cuQHQ8Fpe1NehHjFlkqjrvlP7RqIEUIKguUSrDabRNK7BY3jJDULPOo95 zCYuOq81V+gM1m0O8yw9hwtrmJ01ltbIsdXdpzh7c2O4keNyP5NbIXh1RW30Zr5zrvGO lP/a/LlwfNlLXz64UXBMCPaDHscwSmO4bcZRUZtxYgEoOogrwwqYTWpQW9iI+lSLGs+8 tERQ+9Gt4Iw8YAD4/SdE608Q5t06T5utabNbCZZgCvjAxJxZ19zDCPZvcAn2jPmgRYVF MZ4xRNQImtSY5aoBlvY/XGsgH95SrLFqPI/CUM/ZFpDOXvfEEFxVrFV53DXJ3EBY7+v1 sw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nrag5a7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:29 +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 3AADnja9014907; Fri, 10 Nov 2023 13:54:29 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nrag59g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:28 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AAB3vBG019224; Fri, 10 Nov 2023 13:54:28 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3u7w24b6fb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:27 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsPZm5112542 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:25 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 369C420040; Fri, 10 Nov 2023 13:54:25 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 771C42004F; Fri, 10 Nov 2023 13:54:23 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54: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, Nina Schoetterl-Glausch Subject: [kvm-unit-tests GIT PULL 11/26] s390x: topology: Use function parameter in stsi_get_sysib Date: Fri, 10 Nov 2023 14:52:20 +0100 Message-ID: <20231110135348.245156-12-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: TOyXd3IjR-KZ3xp1CNVnxEzQH3Z-WnD8 X-Proofpoint-ORIG-GUID: 1LqiIp-CeOexL1mwedwSI1sKVLXaRKXP X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=805 phishscore=0 malwarescore=0 suspectscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 lowpriorityscore=0 mlxscore=0 spamscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 From: Nina Schoetterl-Glausch Actually use the function parameter we're give instead of a hardcoded access to the static variable pagebuf. Reviewed-by: Janosch Frank Reviewed-by: Nico Boehr Signed-off-by: Nina Schoetterl-Glausch Link: https://lore.kernel.org/r/20231030160349.458764-4-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s390x/topology.c b/s390x/topology.c index 1c4a86f..032e80d 100644 --- a/s390x/topology.c +++ b/s390x/topology.c @@ -324,7 +324,7 @@ static int stsi_get_sysib(struct sysinfo_15_1_x *info, int sel2) report_prefix_pushf("SYSIB"); - ret = stsi(pagebuf, 15, 1, sel2); + ret = stsi(info, 15, 1, sel2); if (max_nested_lvl >= sel2) { report(!ret, "Valid instruction"); From patchwork Fri Nov 10 13:52:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452429 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A98FC2032A for ; Fri, 10 Nov 2023 13:54:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="gbeRwMUL" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6DCA38221 for ; Fri, 10 Nov 2023 05:54:39 -0800 (PST) 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 3AADneT1014760; Fri, 10 Nov 2023 13:54: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=Zbdtvsbo4bNo5YpTf6ZGYjMPAgquvlgaxWhhoPtluOs=; b=gbeRwMULNYnJQj/CigjLjMK47UUeqsSboRTNXfKPQZ4Ul4nC7f80cpDtgARw9VTi2/pc MpPSzCodd+vwMc/4LU0sPXS1orBa1nsvky2r8d0spuc53kEhRZg6DYPNz0IxC7NTBuTB YjJcq7AYaGjBN2dFY7epfCmxHaLSgF/9eXR7/MjaBTweOwj59Jg9XYmpQT8siLTlZWhW csE7RG7gc8rVzvzZLwqMk+iUDBoxMaAQnga/yv1OGciCJ9ATBcg74GhYHOpbyen3fHKl wYvNCykqvJtczPYnw32ew7Jk4FQrtsuvR/7hwMMHbHu5ANrOC7Qe2zrq2anNkXxeqsQg 0A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nrag5bj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54: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 3AADokx2017862; Fri, 10 Nov 2023 13:54:31 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nrag5b2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:31 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AADKDeP019261; Fri, 10 Nov 2023 13:54:30 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3u7w24b6fj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:30 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsRFS16187990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:27 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 91B8720040; Fri, 10 Nov 2023 13:54:27 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A2DBB20043; Fri, 10 Nov 2023 13:54:25 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:25 +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: [kvm-unit-tests GIT PULL 12/26] s390x: topology: Fix parsing loop Date: Fri, 10 Nov 2023 14:52:21 +0100 Message-ID: <20231110135348.245156-13-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: KV3I3zeKJQNyiE1YbzeNQAYWxYncqPBL X-Proofpoint-ORIG-GUID: FUMvz_X3f9wzMvcC9VldDv4fK80oDxXa X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=752 phishscore=0 malwarescore=0 suspectscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 lowpriorityscore=0 mlxscore=0 spamscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 From: Nina Schoetterl-Glausch Without a comparison the loop is infinite. Reviewed-by: Nico Boehr Reviewed-by: Janosch Frank Signed-off-by: Nina Schoetterl-Glausch Link: https://lore.kernel.org/r/20231030160349.458764-5-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s390x/topology.c b/s390x/topology.c index 032e80d..c8ad4bc 100644 --- a/s390x/topology.c +++ b/s390x/topology.c @@ -468,7 +468,7 @@ static void parse_topology_args(int argc, char **argv) if (flag[0] != '-') report_abort("Argument is expected to begin with '-'"); flag++; - for (level = 0; ARRAY_SIZE(levels); level++) { + for (level = 0; level < ARRAY_SIZE(levels); level++) { if (!strcmp(levels[level], flag)) break; } From patchwork Fri Nov 10 13:52:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452426 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05E961DFC3 for ; Fri, 10 Nov 2023 13:54:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="DdO3zGJI" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC87B3821F for ; Fri, 10 Nov 2023 05:54:36 -0800 (PST) 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 3AADcTDX019708; Fri, 10 Nov 2023 13:54: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=BCJuUFFmK7x5BcRlcu6r5h3eAUfECslHDot8LF1fDmY=; b=DdO3zGJIWc0I1dVJQWX0+mLUr4fcRDfwLQeubUiLMtXSRVNGSDZWRmEokc4sW07WxIvs YR8OdKzWHUtpwReHZ4cp5tv8FIFWlNlifaNCJqx3foC+CRfdIXLFfl9XO5aucafSNWBp lG65jfU7E4CaN07fTGSxqzQT2ACTDe2ADBoeDCgl5uPjPk0t7FeHfVWJXJfsWf90Ls+8 7r3dEZzg5/ODkhVcbkYz+Q84/98sQZPHoq5R22eEiK0hm0t3Ud+L9BU7OPbA5LhcbPRb XXaWQo0vPF9fRWI6+k5CiuV/l/i3V+MWqgdRJBPToqgIHG+FJq+fRFsaiqVYY1YEs1La 3A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9n9790n9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:34 +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 3AADI4VI009469; Fri, 10 Nov 2023 13:54:34 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 3u9n9790mw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:33 +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 3AADcWJJ004183; Fri, 10 Nov 2023 13:54:33 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3u7w21b79b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:32 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsTEg21627402 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:29 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ADFBF2004B; Fri, 10 Nov 2023 13:54:29 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A59A920043; Fri, 10 Nov 2023 13:54:27 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:27 +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: [kvm-unit-tests GIT PULL 13/26] s390x: topology: Make some report messages unique Date: Fri, 10 Nov 2023 14:52:22 +0100 Message-ID: <20231110135348.245156-14-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 6Y6hpORStfHPIATp_GDffyJ3vam9FQsG X-Proofpoint-ORIG-GUID: LoOfp7OPaqNBZml_Kndl7OyLSD0SyNV9 X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 priorityscore=1501 adultscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 From: Nina Schoetterl-Glausch When we test something, i.e. do a report() we want unique messages, otherwise, from the test output, it will appear as if the same test was run multiple times, possible with different PASS/FAIL values. Convert some reports that don't actually test anything topology specific into asserts. Refine the report message for others. Reviewed-by: Janosch Frank Reviewed-by: Nico Boehr Signed-off-by: Nina Schoetterl-Glausch Link: https://lore.kernel.org/r/20231030160349.458764-6-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/topology.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/s390x/topology.c b/s390x/topology.c index c8ad4bc..03bc3d3 100644 --- a/s390x/topology.c +++ b/s390x/topology.c @@ -114,7 +114,7 @@ static void check_polarization_change(void) report_prefix_push("Polarization change"); /* We expect a clean state through reset */ - report(diag308_load_reset(1), "load normal reset done"); + assert(diag308_load_reset(1)); /* * Set vertical polarization to verify that RESET sets @@ -123,7 +123,7 @@ static void check_polarization_change(void) cc = ptf(PTF_REQ_VERTICAL, &rc); report(cc == 0, "Set vertical polarization."); - report(diag308_load_reset(1), "load normal reset done"); + assert(diag308_load_reset(1)); cc = ptf(PTF_CHECK, &rc); report(cc == 0, "Reset should clear topology report"); @@ -137,25 +137,25 @@ static void check_polarization_change(void) report(cc == 0, "Change to vertical"); cc = ptf(PTF_CHECK, &rc); - report(cc == 1, "Should report"); + report(cc == 1, "Should report change after horizontal -> vertical"); 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"); + report(cc == 0, "Should not report change after vertical -> vertical"); cc = ptf(PTF_REQ_HORIZONTAL, &rc); report(cc == 0, "Change to horizontal"); cc = ptf(PTF_CHECK, &rc); - report(cc == 1, "Should Report"); + report(cc == 1, "Should report change after vertical -> horizontal"); 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(cc == 0, "Should not report change after horizontal -> horizontal"); report_prefix_pop(); } From patchwork Fri Nov 10 13:52:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452428 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B7F31DFFE for ; Fri, 10 Nov 2023 13:54:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="bzPhXB2b" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DA2F3821D for ; Fri, 10 Nov 2023 05:54:39 -0800 (PST) Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AADquU5018748; Fri, 10 Nov 2023 13:54:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=cVf06QYK2Q9dGfJhMgTuIUAR0j/8x0C9cN7vYrng+WU=; b=bzPhXB2bnFXxatFkMMldNlIdK+qk48Amt5xaAR9kRmCQQvCoZCvq7yR0t6Z/WNC2Jhdx BFBdK+Pcygt/CNOvIA84p3nhX77gv3/sNsOXhDSO5YFK7stcWqbLqxDz9lsmaBWcJRvz EfNdyu961kWG70mrPoQCqyFOem8VvVMGZF0j4qqHWJf5RUU3d85PNs8t1v8i4wG64ZCf +AgtKaPrZw/epPNyfgUWSHz6cwWBZzGdxKRJ3xMOieMsEOJ8yC/cEEBW6IV+RGnxhPsz SMj/gnx5rQYclqTdV8KU1t2Dc7QIkHU7LmXPBjknSSYMlY3nDw8VCepnJPTYWh2+i2Tl 7g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nsjr1e1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:36 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AADsR3a022935; Fri, 10 Nov 2023 13:54:36 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nsjr1cx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:36 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AAB7js2014325; Fri, 10 Nov 2023 13:54:35 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w22b7x9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:34 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsVAJ19923592 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:32 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA74920043; Fri, 10 Nov 2023 13:54:31 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1309C20040; Fri, 10 Nov 2023 13:54:30 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:29 +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: [kvm-unit-tests GIT PULL 14/26] s390x: topology: Refine stsi header test Date: Fri, 10 Nov 2023 14:52:23 +0100 Message-ID: <20231110135348.245156-15-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: o6QhvyQZc0An5SXuutfP2p0nsrWXL5DI X-Proofpoint-ORIG-GUID: 7SzTE_m0wW4LP55g2hS0jrIZleQl-xEo X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 clxscore=1015 impostorscore=0 malwarescore=0 priorityscore=1501 phishscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 From: Nina Schoetterl-Glausch Add checks for length field. Also minor refactor. Reviewed-by: Nico Boehr Reviewed-by: Janosch Frank Signed-off-by: Nina Schoetterl-Glausch Link: https://lore.kernel.org/r/20231030160349.458764-7-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/topology.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/s390x/topology.c b/s390x/topology.c index 03bc3d3..6a5f100 100644 --- a/s390x/topology.c +++ b/s390x/topology.c @@ -187,18 +187,23 @@ static void stsi_check_maxcpus(struct sysinfo_15_1_x *info) } /* - * stsi_check_mag + * stsi_check_header * @info: Pointer to the stsi information + * @sel2: stsi selector 2 value * * 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) +static void stsi_check_header(struct sysinfo_15_1_x *info, int sel2) { int i; - report_prefix_push("MAG"); + report_prefix_push("Header"); + /* Header is 16 bytes, each TLE 8 or 16, therefore alignment must be 8 at least */ + report(IS_ALIGNED(info->length, 8), "Length %d multiple of 8", info->length); + report(info->length < PAGE_SIZE, "Length %d in bounds", info->length); + report(sel2 == info->mnest, "Valid mnest"); stsi_check_maxcpus(info); /* @@ -328,7 +333,6 @@ static int stsi_get_sysib(struct sysinfo_15_1_x *info, int sel2) if (max_nested_lvl >= sel2) { report(!ret, "Valid instruction"); - report(sel2 == info->mnest, "Valid mnest"); } else { report(ret, "Invalid instruction"); } @@ -367,7 +371,7 @@ static void check_sysinfo_15_1_x(struct sysinfo_15_1_x *info, int sel2) goto vertical; } - stsi_check_mag(info); + stsi_check_header(info, sel2); stsi_check_tle_coherency(info); vertical: @@ -380,7 +384,7 @@ vertical: goto end; } - stsi_check_mag(info); + stsi_check_header(info, sel2); stsi_check_tle_coherency(info); report_prefix_pop(); From patchwork Fri Nov 10 13:52:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452430 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80D6C208D0 for ; Fri, 10 Nov 2023 13:54:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="RLP1sgvT" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C689D3821E for ; Fri, 10 Nov 2023 05:54:40 -0800 (PST) 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 3AADHk9x018462; Fri, 10 Nov 2023 13:54:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=1Xj4xbcc3bKIui5x+xGz3QgQlvzMDuYX7Kap45pl74M=; b=RLP1sgvTiBjViXMcUKOO2mGj+yZbmjBdWVyQXkVCA9pbJ5Jf/pvJvq5VO0/RZJ8UClXL O149zOCzACltDbXrArfGU111KmHUZT2VQCAyB024zS2U5y4gzUBsuWmK1OqHrfLZ9tf5 bwVYhRwMGVmQ7tEVxF1QLxu98fuA1l1gTLJkeKqdUOL/3JYt5YsWGtAJDSQYKRYaL3qb wN/t+WPbCj6u+rWMsVwQCJ5oKyxJFg4XuFkg5hswjmSNCHxMJraeJN9TAbH4mxoIE0ur 1bpsdHVdov7KqUcql4sZQUF79lgeKb22MzwssIDVV3u/ENE7Z1ouakxUm7uCU4ODlWTg Fw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9n97s77v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:38 +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 3AADJmph028350; Fri, 10 Nov 2023 13:54:37 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 3u9n97s778-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:37 +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 3AABGMkw004144; Fri, 10 Nov 2023 13:54:37 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3u7w21b79q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:36 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsYUH13107758 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:34 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 32B3B20043; Fri, 10 Nov 2023 13:54:34 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4363A20040; Fri, 10 Nov 2023 13:54:32 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:32 +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: [kvm-unit-tests GIT PULL 15/26] s390x: topology: Rename topology_core to topology_cpu Date: Fri, 10 Nov 2023 14:52:24 +0100 Message-ID: <20231110135348.245156-16-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: lRG_7G9AeOu9JdCpNlZhXNxvw3Prjnh1 X-Proofpoint-GUID: xOutU8eRiOIheaEp6_1xLZoGS4wB5fLI X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 malwarescore=0 phishscore=0 priorityscore=1501 suspectscore=0 clxscore=1015 spamscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 From: Nina Schoetterl-Glausch This is more in line with the nomenclature in the PoP. Reviewed-by: Janosch Frank Reviewed-by: Nico Boehr Signed-off-by: Nina Schoetterl-Glausch Link: https://lore.kernel.org/r/20231030160349.458764-8-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/stsi.h | 4 ++-- s390x/topology.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/s390x/stsi.h b/lib/s390x/stsi.h index 2f6182c..1e9d095 100644 --- a/lib/s390x/stsi.h +++ b/lib/s390x/stsi.h @@ -30,7 +30,7 @@ struct sysinfo_3_2_2 { }; #define CPUS_TLE_RES_BITS 0x00fffffff8000000UL -struct topology_core { +struct topology_cpu { uint8_t nl; uint8_t reserved1[3]; uint8_t reserved4:5; @@ -61,7 +61,7 @@ struct topology_container { union topology_entry { uint8_t nl; - struct topology_core cpu; + struct topology_cpu cpu; struct topology_container container; }; diff --git a/s390x/topology.c b/s390x/topology.c index 6a5f100..df158ae 100644 --- a/s390x/topology.c +++ b/s390x/topology.c @@ -247,7 +247,7 @@ done: static uint8_t *check_tle(void *tc) { struct topology_container *container = tc; - struct topology_core *cpus; + struct topology_cpu *cpus; int n; if (container->nl) { From patchwork Fri Nov 10 13:52:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452431 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0183E328D4 for ; Fri, 10 Nov 2023 13:54:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="eD+y+6UQ" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DF9E3821D for ; Fri, 10 Nov 2023 05:54:42 -0800 (PST) Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AADqtaw018722; Fri, 10 Nov 2023 13:54:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=FoSX7lUsNXa/v7qOHvbEMgur7RgMTlyEpicsBiGqu6Q=; b=eD+y+6UQzay7JO7d+bCLnIOUlEeQmiZNpwmhJzJ2HMpImPOEDZz7V1QNsNw6p91sydPc fGuyQMBkS6z5YZpB4F00C2fKDXjikEs+OxeFDfbt6nPxxGIqF5FNriHcJAPsAQKvEsQF DcpFhmGksbqKurFUx96iOsIm6hjYMBmaUjsB4vv5gnpPfLCisVLVJgQT/GL148QTqH9V uT20pmkyGB36TJTF4NhLLNxxPhbGDY7aPtpGRM2pnLPw7ioAfFBKrNMjJe7wG2HUAu8F 33YdzposhlvdQTXFsoV/g+qMb8lZZwsU8j8IMrK5dzt7M47Ry374Ml6W461fMNoj/GFD 7g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nsjr1gs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:39 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AADqvDr018764; Fri, 10 Nov 2023 13:54:39 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 3u9nsjr1fk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:39 +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 3AABGpGA000662; Fri, 10 Nov 2023 13:54:37 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w23b7eq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:37 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsYTC16188000 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:34 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B514220043; Fri, 10 Nov 2023 13:54:34 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4558320040; Fri, 10 Nov 2023 13:54:34 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:34 +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: [kvm-unit-tests GIT PULL 16/26] s390x: topology: Rewrite topology list test Date: Fri, 10 Nov 2023 14:52:25 +0100 Message-ID: <20231110135348.245156-17-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: tZ5kTXoTFywvPH8pgBB6B0157BWcBTf2 X-Proofpoint-ORIG-GUID: mIWBGiLHAdC2igNMAbV5Uvc-Yc48chBF X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=904 mlxscore=0 bulkscore=0 adultscore=0 clxscore=1015 impostorscore=0 malwarescore=0 priorityscore=1501 phishscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 From: Nina Schoetterl-Glausch Rewrite recursion with separate functions for checking containers, containers containing CPUs and CPUs. This improves comprehension and allows for more tests. We now also test for ordering of CPU TLEs and number of child entries. Acked-by: Janosch Frank Signed-off-by: Nina Schoetterl-Glausch Link: https://lore.kernel.org/r/20231030160349.458764-9-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/stsi.h | 36 +++++---- s390x/topology.c | 202 ++++++++++++++++++++++++++++++----------------- 2 files changed, 149 insertions(+), 89 deletions(-) diff --git a/lib/s390x/stsi.h b/lib/s390x/stsi.h index 1e9d095..f2290ca 100644 --- a/lib/s390x/stsi.h +++ b/lib/s390x/stsi.h @@ -30,15 +30,18 @@ struct sysinfo_3_2_2 { }; #define CPUS_TLE_RES_BITS 0x00fffffff8000000UL -struct topology_cpu { - 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; +union topology_cpu { + uint64_t raw[2]; + struct { + 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; + }; }; enum topology_polarization { @@ -53,16 +56,19 @@ enum cpu_type { }; #define CONTAINER_TLE_RES_BITS 0x00ffffffffffff00UL -struct topology_container { - uint8_t nl; - uint8_t reserved[6]; - uint8_t id; +union topology_container { + uint64_t raw; + struct { + uint8_t nl; + uint8_t reserved[6]; + uint8_t id; + }; }; union topology_entry { uint8_t nl; - struct topology_cpu cpu; - struct topology_container container; + union topology_cpu cpu; + union topology_container container; }; #define CPU_TOPOLOGY_MAX_LEVEL 6 diff --git a/s390x/topology.c b/s390x/topology.c index df158ae..01021eb 100644 --- a/s390x/topology.c +++ b/s390x/topology.c @@ -2,7 +2,7 @@ /* * CPU Topology * - * Copyright IBM Corp. 2022 + * Copyright IBM Corp. 2022, 2023 * * Authors: * Pierre Morel @@ -23,7 +23,6 @@ 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; /* @@ -238,108 +237,163 @@ done: } /** - * check_tle: - * @tc: pointer to first TLE + * stsi_get_sysib: + * @info: pointer to the STSI info structure + * @sel2: the selector giving the topology level to check * - * Recursively check the containers TLEs until we - * find a CPU TLE. + * Fill the sysinfo_15_1_x info structure and check the + * SYSIB header. + * + * Returns instruction validity. */ -static uint8_t *check_tle(void *tc) +static int stsi_get_sysib(struct sysinfo_15_1_x *info, int sel2) { - struct topology_container *container = tc; - struct topology_cpu *cpus; - int n; + int ret; - if (container->nl) { - report_info("NL: %d id: %d", container->nl, container->id); + report_prefix_pushf("SYSIB"); - report(!(*(uint64_t *)tc & CONTAINER_TLE_RES_BITS), - "reserved bits %016lx", - *(uint64_t *)tc & CONTAINER_TLE_RES_BITS); + ret = stsi(info, 15, 1, sel2); - return check_tle(tc + sizeof(*container)); + if (max_nested_lvl >= sel2) { + report(!ret, "Valid instruction"); + } else { + report(ret, "Invalid instruction"); } - report_info("NL: %d", container->nl); - cpus = tc; + report_prefix_pop(); - report(!(*(uint64_t *)tc & CPUS_TLE_RES_BITS), "reserved bits %016lx", - *(uint64_t *)tc & CPUS_TLE_RES_BITS); + return ret; +} - report(cpus->type == CPU_TYPE_IFL, "type IFL"); +static int check_cpu(union topology_cpu *cpu, + union topology_container *parent) +{ + report_prefix_pushf("%d:%d:%d:%d", cpu->d, cpu->pp, cpu->type, cpu->origin); - report_info("origin: %d", cpus->origin); - report_info("mask: %016lx", cpus->mask); - report_info("dedicated: %d entitlement: %d", cpus->d, cpus->pp); + report(!(cpu->raw[0] & CPUS_TLE_RES_BITS), "reserved bits %016lx", + cpu->raw[0] & CPUS_TLE_RES_BITS); - 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; + report(cpu->type == CPU_TYPE_IFL, "type IFL"); - if (!cpus->d) - report_skip("Not dedicated"); - else - report(cpus->pp == POLARIZATION_VERTICAL_HIGH || - cpus->pp == POLARIZATION_HORIZONTAL, + if (cpu->d) + report(cpu->pp == POLARIZATION_VERTICAL_HIGH || + cpu->pp == POLARIZATION_HORIZONTAL, "Dedicated CPUs are either horizontally polarized or have high entitlement"); + else + report_skip("Not dedicated"); + + report_prefix_pop(); - return tc + sizeof(*cpus); + return __builtin_popcountl(cpu->mask); } -/** - * 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) +static union topology_container *check_child_cpus(struct sysinfo_15_1_x *info, + union topology_container *cont, + union topology_cpu *child, + unsigned int *cpus_in_masks) { - void *tc, *end; + void *last = ((void *)info) + info->length; + union topology_cpu *prev_cpu = NULL; + bool correct_ordering = true; + unsigned int cpus = 0; + int i; - report_prefix_push("TLE"); - cpus_in_masks = 0; + for (i = 0; (void *)&child[i] < last && child[i].nl == 0; prev_cpu = &child[i++]) { + cpus += check_cpu(&child[i], cont); + if (prev_cpu) { + if (prev_cpu->type > child[i].type) { + report_info("Incorrect ordering wrt type for child %d", i); + correct_ordering = false; + } + if (prev_cpu->type < child[i].type) + continue; + if (prev_cpu->pp < child[i].pp) { + report_info("Incorrect ordering wrt polarization for child %d", i); + correct_ordering = false; + } + if (prev_cpu->pp > child[i].pp) + continue; + if (!prev_cpu->d && child[i].d) { + report_info("Incorrect ordering wrt dedication for child %d", i); + correct_ordering = false; + } + if (prev_cpu->d && !child[i].d) + continue; + if (prev_cpu->origin > child[i].origin) { + report_info("Incorrect ordering wrt origin for child %d", i); + correct_ordering = false; + } + } + } + report(correct_ordering, "children correctly ordered"); + report(cpus <= expected_topo_lvl[0], "%d children <= max of %d", + cpus, expected_topo_lvl[0]); + *cpus_in_masks += cpus; - tc = info->tle; - end = (void *)info + info->length; + return (union topology_container *)&child[i]; +} - while (tc < end) - tc = check_tle(tc); +static union topology_container *check_container(struct sysinfo_15_1_x *info, + union topology_container *cont, + union topology_entry *child, + unsigned int *cpus_in_masks); - report(cpus_in_masks == number_of_cpus, "CPUs in mask %d", - cpus_in_masks); +static union topology_container *check_child_containers(struct sysinfo_15_1_x *info, + union topology_container *cont, + union topology_container *child, + unsigned int *cpus_in_masks) +{ + void *last = ((void *)info) + info->length; + union topology_container *entry; + int i; - report_prefix_pop(); + for (i = 0, entry = child; (void *)entry < last && entry->nl == cont->nl - 1; i++) { + entry = check_container(info, entry, (union topology_entry *)(entry + 1), + cpus_in_masks); + } + if (max_nested_lvl == info->mnest) + report(i <= expected_topo_lvl[cont->nl - 1], "%d children <= max of %d", + i, expected_topo_lvl[cont->nl - 1]); + + return entry; } -/** - * 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) +static union topology_container *check_container(struct sysinfo_15_1_x *info, + union topology_container *cont, + union topology_entry *child, + unsigned int *cpus_in_masks) { - int ret; + union topology_container *entry; - report_prefix_pushf("SYSIB"); + report_prefix_pushf("%d", cont->id); - ret = stsi(info, 15, 1, sel2); + report(cont->nl - 1 == child->nl, "Level %d one above child level %d", + cont->nl, child->nl); + report(!(cont->raw & CONTAINER_TLE_RES_BITS), "reserved bits %016lx", + cont->raw & CONTAINER_TLE_RES_BITS); - if (max_nested_lvl >= sel2) { - report(!ret, "Valid instruction"); - } else { - report(ret, "Invalid instruction"); - } + if (cont->nl > 1) + entry = check_child_containers(info, cont, &child->container, cpus_in_masks); + else + entry = check_child_cpus(info, cont, &child->cpu, cpus_in_masks); report_prefix_pop(); + return entry; +} - return ret; +static void check_topology_list(struct sysinfo_15_1_x *info, int sel2) +{ + union topology_container dummy = { .nl = sel2, .id = 0 }; + unsigned int cpus_in_masks = 0; + + report_prefix_push("TLE"); + + check_container(info, &dummy, info->tle, &cpus_in_masks); + report(cpus_in_masks == number_of_cpus, + "Number of CPUs %d equals %d CPUs in masks", + number_of_cpus, cpus_in_masks); + + report_prefix_pop(); } /** @@ -372,7 +426,7 @@ static void check_sysinfo_15_1_x(struct sysinfo_15_1_x *info, int sel2) } stsi_check_header(info, sel2); - stsi_check_tle_coherency(info); + check_topology_list(info, sel2); vertical: report_prefix_pop(); @@ -385,7 +439,7 @@ vertical: } stsi_check_header(info, sel2); - stsi_check_tle_coherency(info); + check_topology_list(info, sel2); report_prefix_pop(); end: From patchwork Fri Nov 10 13:52:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452432 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1437F3717F for ; Fri, 10 Nov 2023 13:54:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="fzFMUQW+" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20E9538224 for ; Fri, 10 Nov 2023 05:54:43 -0800 (PST) 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 3AADHO6p017719; Fri, 10 Nov 2023 13:54:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=K7Iy8LlS1dUK0JjoQpkmPfvo1DjY8lLTbh33pd1A5WY=; b=fzFMUQW+wpb+7wx+E86+yHt0jQePqNyPIc0QpcoXjELFicrrNSklJdEjQNtsZBGxYMeg kMEH1oj8N0sm90plyLT7x3ozaBQCIKZmFJDBZmYdBQcqiy+sg3VVSfm93AvDg95Dnu8s 3dOiV5Xmu7XYxeZKkMgbDqqFm4l41nPHu8Ly7QWWc8HvA8bZ+n/rgqvhpAsQ6IT2nrRF kmvGN06tvg7gkQqJEM4IEFiQXw3c5cnrgYIDv/mXk/6PkxtCipF301HpwmxH5iJEF6O6 jEm34KeswnneYjOjCGzvO0rduBg85exnzRKo5XiScvvEGsP35TLfMvM64qgr/tgWbAP6 3w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9n97s790-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:40 +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 3AADJmpj028350; Fri, 10 Nov 2023 13:54:39 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9n97s78c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:39 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AADaIO3014340; Fri, 10 Nov 2023 13:54:38 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w22b7xj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:38 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsZBT39846374 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:35 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 32DD220040; Fri, 10 Nov 2023 13:54:35 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C6C4A2004E; Fri, 10 Nov 2023 13:54:34 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:34 +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: [kvm-unit-tests GIT PULL 17/26] scripts: Implement multiline strings for extra_params Date: Fri, 10 Nov 2023 14:52:26 +0100 Message-ID: <20231110135348.245156-18-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: yMVIPi_87ZFxFsOZ9LboH8Bvce9SBe9_ X-Proofpoint-GUID: 5v8lNtFKBMdR1uMsuzRvefcZzwWKDDH3 X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 malwarescore=0 phishscore=0 priorityscore=1501 suspectscore=0 clxscore=1015 spamscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 From: Nina Schoetterl-Glausch Implement a rudimentary form only. extra_params can get long when passing a lot of arguments to qemu. Multiline strings help with readability of the .cfg file. Multiline strings begin and end with """, which must occur on separate lines. For example: extra_params = """-cpu max,ctop=on -smp cpus=1,cores=16,maxcpus=128 \ -append '-drawers 2 -books 2 -sockets 2 -cores 16' \ -device max-s390x-cpu,core-id=31,drawer-id=0,book-id=0,socket-id=0""" The command string built with extra_params is eval'ed by the runtime script, so the newlines need to be escaped with \. Reviewed-by: Thomas Huth Signed-off-by: Nina Schoetterl-Glausch Link: https://lore.kernel.org/r/20231030160349.458764-10-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- scripts/common.bash | 16 ++++++++++++++++ scripts/runtime.bash | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/common.bash b/scripts/common.bash index 7b983f7..b9413d6 100644 --- a/scripts/common.bash +++ b/scripts/common.bash @@ -36,6 +36,22 @@ function for_each_unittest() kernel=$TEST_DIR/${BASH_REMATCH[1]} elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then smp=${BASH_REMATCH[1]} + elif [[ $line =~ ^extra_params\ *=\ *'"""'(.*)$ ]]; then + opts=${BASH_REMATCH[1]}$'\n' + while read -r -u $fd; do + #escape backslash newline, but not double backslash + if [[ $opts =~ [^\\]*(\\*)$'\n'$ ]]; then + if (( ${#BASH_REMATCH[1]} % 2 == 1 )); then + opts=${opts%\\$'\n'} + fi + fi + if [[ "$REPLY" =~ ^(.*)'"""'[:blank:]*$ ]]; then + opts+=${BASH_REMATCH[1]} + break + else + opts+=$REPLY$'\n' + fi + done elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then opts=${BASH_REMATCH[1]} elif [[ $line =~ ^groups\ *=\ *(.*)$ ]]; then diff --git a/scripts/runtime.bash b/scripts/runtime.bash index ada8ffd..fc156f2 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -15,7 +15,7 @@ extract_summary() # We assume that QEMU is going to work if it tried to load the kernel premature_failure() { - local log="$(eval $(get_cmdline _NO_FILE_4Uhere_) 2>&1)" + local log="$(eval "$(get_cmdline _NO_FILE_4Uhere_)" 2>&1)" echo "$log" | grep "_NO_FILE_4Uhere_" | grep -q -e "could not \(load\|open\) kernel" -e "error loading" && @@ -168,7 +168,7 @@ function run() # extra_params in the config file may contain backticks that need to be # expanded, so use eval to start qemu. Use "> >(foo)" instead of a pipe to # preserve the exit status. - summary=$(eval $cmdline 2> >(RUNTIME_log_stderr $testname) \ + summary=$(eval "$cmdline" 2> >(RUNTIME_log_stderr $testname) \ > >(tee >(RUNTIME_log_stdout $testname $kernel) | extract_summary)) ret=$? [ "$KUT_STANDALONE" != "yes" ] && echo > >(RUNTIME_log_stdout $testname $kernel) From patchwork Fri Nov 10 13:52:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452434 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E73A736B1D for ; Fri, 10 Nov 2023 13:54:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="tu89auA1" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9481438221 for ; Fri, 10 Nov 2023 05:54:42 -0800 (PST) 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 3AADkZpZ017553; Fri, 10 Nov 2023 13:54:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=E2FGw/iZ3TgxIchk14iadgte2VsbK4rKmFKavuiu/5M=; b=tu89auA1ZcoJfksxDM0sN4Iu/tGt+houMX3EgdoN5M+viR+wLdA4QAnUYDTHszRo9MHf lJNkIzmANwC4ZrSvJPFy9mIN2/rOvp24c9gQSVYOploFeu5RNSBhl6FaO3OWaIQppndl Y2HNt8l31zM40mYGfMOYjU4kZppc7SyMO5KhHbxsiA8DraUkX/AFmin/CCtDc/FODb/F 7pVIfAT7025RD7i5EzUMPgInqdxW2ukhhwHt2yLSkVBSbgJEsnoML7Sdn7Pa5gA4YU/F 98160bY3dOpY14/fECpaDcRhRouqEI8LyezPDUVhKlvu2jy3v78cMKDxwRAFYuN3CZgM 5Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9n6uhff4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:40 +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 3AADmSuL026540; Fri, 10 Nov 2023 13:54:39 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9n6uhfen-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:39 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AADsB2L019256; Fri, 10 Nov 2023 13:54:38 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3u7w24b6g9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:38 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsZT921496330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:36 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B6AF520040; Fri, 10 Nov 2023 13:54:35 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 47F6220043; Fri, 10 Nov 2023 13:54:35 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:35 +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: [kvm-unit-tests GIT PULL 18/26] s390x: topology: Add complex topology test Date: Fri, 10 Nov 2023 14:52:27 +0100 Message-ID: <20231110135348.245156-19-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: HpORnAwbH6E6DstC53oda50XopthvhEt X-Proofpoint-ORIG-GUID: 87mbED1TDoDuaqaqyzRVsnahh7VErLyw X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=999 spamscore=0 bulkscore=0 malwarescore=0 impostorscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 From: Nina Schoetterl-Glausch Run the topology test case with a complex topology configuration. Randomly generated with: python -c 'import random ds=bs=ss=2 cs=16 cids=list(range(1,ds*bs*ss*cs)) random.shuffle(cids) i = 0 for d in range(ds): for b in range(bs): for s in range(ss): for c in range(cs): if (d,b,s,c) != (0,0,0,0): ded=["false","true"][random.randrange(0,2)] ent="high" if ded == "true" else ["low", "medium", "high"][random.randrange(0,3)] print(f"-device max-s390x-cpu,core-id={cids[i]},drawer-id={d},book-id={b},socket-id={s},entitlement={ent},dedicated={ded}") i+=1' Signed-off-by: Nina Schoetterl-Glausch Link: https://lore.kernel.org/r/20231030160349.458764-11-nsg@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/unittests.cfg | 133 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 68e119e..b08b0fb 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -247,3 +247,136 @@ 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' + +[topology-3] +file = topology.elf +extra_params = """-cpu max,ctop=on -smp cpus=1,drawers=2,books=2,sockets=2,cores=16,maxcpus=128 \ +-append '-drawers 2 -books 2 -sockets 2 -cores 16' \ +-device max-s390x-cpu,core-id=31,drawer-id=0,book-id=0,socket-id=0,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=11,drawer-id=0,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=95,drawer-id=0,book-id=0,socket-id=0,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=73,drawer-id=0,book-id=0,socket-id=0,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=78,drawer-id=0,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=13,drawer-id=0,book-id=0,socket-id=0,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=40,drawer-id=0,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=101,drawer-id=0,book-id=0,socket-id=0,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=29,drawer-id=0,book-id=0,socket-id=0,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=56,drawer-id=0,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=92,drawer-id=0,book-id=0,socket-id=0,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=30,drawer-id=0,book-id=0,socket-id=0,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=118,drawer-id=0,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=71,drawer-id=0,book-id=0,socket-id=0,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=93,drawer-id=0,book-id=0,socket-id=0,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=16,drawer-id=0,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=5,drawer-id=0,book-id=0,socket-id=1,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=42,drawer-id=0,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=98,drawer-id=0,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=44,drawer-id=0,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=23,drawer-id=0,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=65,drawer-id=0,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=102,drawer-id=0,book-id=0,socket-id=1,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=57,drawer-id=0,book-id=0,socket-id=1,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=125,drawer-id=0,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=127,drawer-id=0,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=82,drawer-id=0,book-id=0,socket-id=1,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=14,drawer-id=0,book-id=0,socket-id=1,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=91,drawer-id=0,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=12,drawer-id=0,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=8,drawer-id=0,book-id=0,socket-id=1,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=112,drawer-id=0,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=109,drawer-id=0,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=19,drawer-id=0,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=96,drawer-id=0,book-id=1,socket-id=0,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=67,drawer-id=0,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=80,drawer-id=0,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=108,drawer-id=0,book-id=1,socket-id=0,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=34,drawer-id=0,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=18,drawer-id=0,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=39,drawer-id=0,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=53,drawer-id=0,book-id=1,socket-id=0,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=46,drawer-id=0,book-id=1,socket-id=0,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=3,drawer-id=0,book-id=1,socket-id=0,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=76,drawer-id=0,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=15,drawer-id=0,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=7,drawer-id=0,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=81,drawer-id=0,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=1,drawer-id=0,book-id=1,socket-id=1,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=113,drawer-id=0,book-id=1,socket-id=1,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=38,drawer-id=0,book-id=1,socket-id=1,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=90,drawer-id=0,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=117,drawer-id=0,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=62,drawer-id=0,book-id=1,socket-id=1,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=85,drawer-id=0,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=49,drawer-id=0,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=24,drawer-id=0,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=107,drawer-id=0,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=103,drawer-id=0,book-id=1,socket-id=1,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=33,drawer-id=0,book-id=1,socket-id=1,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=51,drawer-id=0,book-id=1,socket-id=1,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=21,drawer-id=0,book-id=1,socket-id=1,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=72,drawer-id=0,book-id=1,socket-id=1,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=63,drawer-id=1,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=105,drawer-id=1,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=74,drawer-id=1,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=50,drawer-id=1,book-id=0,socket-id=0,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=60,drawer-id=1,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=22,drawer-id=1,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=43,drawer-id=1,book-id=0,socket-id=0,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=48,drawer-id=1,book-id=0,socket-id=0,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=35,drawer-id=1,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=58,drawer-id=1,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=106,drawer-id=1,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=123,drawer-id=1,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=122,drawer-id=1,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=9,drawer-id=1,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=10,drawer-id=1,book-id=0,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=25,drawer-id=1,book-id=0,socket-id=0,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=116,drawer-id=1,book-id=0,socket-id=1,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=26,drawer-id=1,book-id=0,socket-id=1,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=17,drawer-id=1,book-id=0,socket-id=1,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=20,drawer-id=1,book-id=0,socket-id=1,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=59,drawer-id=1,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=54,drawer-id=1,book-id=0,socket-id=1,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=70,drawer-id=1,book-id=0,socket-id=1,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=88,drawer-id=1,book-id=0,socket-id=1,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=6,drawer-id=1,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=52,drawer-id=1,book-id=0,socket-id=1,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=55,drawer-id=1,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=124,drawer-id=1,book-id=0,socket-id=1,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=61,drawer-id=1,book-id=0,socket-id=1,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=84,drawer-id=1,book-id=0,socket-id=1,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=68,drawer-id=1,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=86,drawer-id=1,book-id=0,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=4,drawer-id=1,book-id=1,socket-id=0,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=75,drawer-id=1,book-id=1,socket-id=0,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=115,drawer-id=1,book-id=1,socket-id=0,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=28,drawer-id=1,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=120,drawer-id=1,book-id=1,socket-id=0,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=41,drawer-id=1,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=87,drawer-id=1,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=119,drawer-id=1,book-id=1,socket-id=0,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=114,drawer-id=1,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=104,drawer-id=1,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=27,drawer-id=1,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=121,drawer-id=1,book-id=1,socket-id=0,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=126,drawer-id=1,book-id=1,socket-id=0,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=37,drawer-id=1,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=32,drawer-id=1,book-id=1,socket-id=0,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=94,drawer-id=1,book-id=1,socket-id=0,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=110,drawer-id=1,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=77,drawer-id=1,book-id=1,socket-id=1,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=36,drawer-id=1,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=66,drawer-id=1,book-id=1,socket-id=1,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=83,drawer-id=1,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=47,drawer-id=1,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=99,drawer-id=1,book-id=1,socket-id=1,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=79,drawer-id=1,book-id=1,socket-id=1,entitlement=low,dedicated=false \ +-device max-s390x-cpu,core-id=100,drawer-id=1,book-id=1,socket-id=1,entitlement=medium,dedicated=false \ +-device max-s390x-cpu,core-id=89,drawer-id=1,book-id=1,socket-id=1,entitlement=high,dedicated=false \ +-device max-s390x-cpu,core-id=2,drawer-id=1,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=45,drawer-id=1,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=69,drawer-id=1,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=64,drawer-id=1,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=97,drawer-id=1,book-id=1,socket-id=1,entitlement=high,dedicated=true \ +-device max-s390x-cpu,core-id=111,drawer-id=1,book-id=1,socket-id=1,entitlement=medium,dedicated=false \ +""" From patchwork Fri Nov 10 13:52:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452435 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D42E374E9 for ; Fri, 10 Nov 2023 13:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Uf+AwPgy" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADEE238222 for ; Fri, 10 Nov 2023 05:54:42 -0800 (PST) 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 3AADaIiS001242; Fri, 10 Nov 2023 13:54:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=JRwNitP9Q8s5uPXMvAc7TxFaNNqtcdxC3wVI86SH8d8=; b=Uf+AwPgyTDLaLGv/YKyfKE7XO0xBOsqEEjciTHU3F1gyS2am44QcZp1QLLcv/kLtITUp mxZRQ5dKlGEJQLSSU1kXqCSOLbW+PGkhgbhzcLSgKdCgBHvZNk7Ge3M7khpZIWOOo8E6 4RaufGKAz+TZZu11Jf8SGk1uSY2ExPiA6WWDbQF9ejqTFncUiZJj7x4orvUAcC+vuqY+ MFiv2IUdMfmnM5nynduPtXRiTZtyXW1e28UBCSdTAyuHLMgwaf1ezcn+kfrgoeAeEvoQ fIiOVgUBvKl8q316NTAgt/Szvyob8sP76n4/M9NLV7rwneVWOX6ye4d571DTdYqREaFu Jg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9mrn9rx5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:40 +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 3AADgjL3022782; Fri, 10 Nov 2023 13:54:39 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9mrn9rwh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:39 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AABH9Id019429; Fri, 10 Nov 2023 13:54:39 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3u7w24b6gb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:38 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsaN164618924 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:36 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E8F020040; Fri, 10 Nov 2023 13:54:36 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CADD12004B; Fri, 10 Nov 2023 13:54:35 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:35 +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: [kvm-unit-tests GIT PULL 19/26] lib: s390x: introduce bitfield for PSW mask Date: Fri, 10 Nov 2023 14:52:28 +0100 Message-ID: <20231110135348.245156-20-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 2-6gq2VTJon_kJKx3xSTNI7hlkSmssSR X-Proofpoint-GUID: ut_gb2es7qiiYqUTL_5tidNyDabkX4HE X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=626 mlxscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 Changing the PSW mask is currently little clumsy, since there is only the PSW_MASK_* defines. This makes it hard to change e.g. only the address space in the current PSW without a lot of bit fiddling. Introduce a bitfield for the PSW mask. This makes this kind of modifications much simpler and easier to read. Reviewed-by: Thomas Huth Reviewed-by: Claudio Imbrenda Reviewed-by: Janosch Frank Link: https://lore.kernel.org/r/20231106163738.1116942-2-nrb@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/asm/arch_def.h | 25 ++++++++++++++++++++++++- s390x/selftest.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h index bb26e00..f629b6d 100644 --- a/lib/s390x/asm/arch_def.h +++ b/lib/s390x/asm/arch_def.h @@ -37,9 +37,32 @@ struct stack_frame_int { }; struct psw { - uint64_t mask; + union { + uint64_t mask; + struct { + uint64_t reserved00:1; + uint64_t per:1; + uint64_t reserved02:3; + uint64_t dat:1; + uint64_t io:1; + uint64_t ext:1; + uint64_t key:4; + uint64_t reserved12:1; + uint64_t mchk:1; + uint64_t wait:1; + uint64_t pstate:1; + uint64_t as:2; + uint64_t cc:2; + uint64_t prg_mask:4; + uint64_t reserved24:7; + uint64_t ea:1; + uint64_t ba:1; + uint64_t reserved33:31; + }; + }; uint64_t addr; }; +_Static_assert(sizeof(struct psw) == 16, "PSW size"); #define PSW(m, a) ((struct psw){ .mask = (m), .addr = (uint64_t)(a) }) diff --git a/s390x/selftest.c b/s390x/selftest.c index 13fd36b..92ed4e5 100644 --- a/s390x/selftest.c +++ b/s390x/selftest.c @@ -74,6 +74,39 @@ static void test_malloc(void) report_prefix_pop(); } +static void test_psw_mask(void) +{ + uint64_t expected_key = 0xf; + struct psw test_psw = PSW(0, 0); + + report_prefix_push("PSW mask"); + test_psw.mask = PSW_MASK_DAT; + report(test_psw.dat, "DAT matches expected=0x%016lx actual=0x%016lx", PSW_MASK_DAT, test_psw.mask); + + test_psw.mask = PSW_MASK_IO; + report(test_psw.io, "IO matches expected=0x%016lx actual=0x%016lx", PSW_MASK_IO, test_psw.mask); + + test_psw.mask = PSW_MASK_EXT; + report(test_psw.ext, "EXT matches expected=0x%016lx actual=0x%016lx", PSW_MASK_EXT, test_psw.mask); + + test_psw.mask = expected_key << (63 - 11); + report(test_psw.key == expected_key, "PSW Key matches expected=0x%lx actual=0x%x", expected_key, test_psw.key); + + test_psw.mask = 1UL << (63 - 13); + report(test_psw.mchk, "MCHK matches"); + + test_psw.mask = PSW_MASK_WAIT; + report(test_psw.wait, "Wait matches expected=0x%016lx actual=0x%016lx", PSW_MASK_WAIT, test_psw.mask); + + test_psw.mask = PSW_MASK_PSTATE; + report(test_psw.pstate, "Pstate matches expected=0x%016lx actual=0x%016lx", PSW_MASK_PSTATE, test_psw.mask); + + test_psw.mask = PSW_MASK_64; + report(test_psw.ea && test_psw.ba, "BA/EA matches expected=0x%016lx actual=0x%016lx", PSW_MASK_64, test_psw.mask); + + report_prefix_pop(); +} + int main(int argc, char**argv) { report_prefix_push("selftest"); @@ -89,6 +122,7 @@ int main(int argc, char**argv) test_fp(); test_pgm_int(); test_malloc(); + test_psw_mask(); return report_summary(); } From patchwork Fri Nov 10 13:52:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452437 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3DE5B38DCD for ; Fri, 10 Nov 2023 13:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Ls3dTuyV" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2780038225 for ; Fri, 10 Nov 2023 05:54:44 -0800 (PST) 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 3AADeHnp027718; Fri, 10 Nov 2023 13:54:42 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=MQnjJ5a2gSsPI1cj+gv88R7ha4Ia2YBmoZqstaxV/nc=; b=Ls3dTuyVkeWld5GAK//JnyIhcRA3S3yxfHM5vdblwSjge6M9UczOWAs4NKx+Wli7pr8k 15s6SNgDjR9jsERAiIBd+9NPlouenSQ5+6r1mbAhhyu+c1Wj/QziWqdCFcLss0P3Bga2 XcEfrRg/R87fEzrncb6OrERYQHplTl85jjkRekZC5lBU+QGEAeRrW0clq6IMZGSNwVyE l5Cxi2lq9t9m5P6KuBWIawE7zEUliUpGlVBysS9QNMGGZ9HIXFC9bYSuEu+eiO/QiAgu F7A6hap9t1vhw4Lb0Kh976Xde49zNxKOi6PEz/9dsuXGX1FwECRS7fHuxjHIyz8ejNzW UQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nkq0gtw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:41 +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 3AADf4nE029454; Fri, 10 Nov 2023 13:54:41 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nkq0gtj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:41 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AAAueFi014332; Fri, 10 Nov 2023 13:54:40 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w22b7xm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:40 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsat764618926 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:36 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9A75720040; Fri, 10 Nov 2023 13:54:36 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4221820043; Fri, 10 Nov 2023 13:54:36 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:36 +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: [kvm-unit-tests GIT PULL 20/26] s390x: add function to set DAT mode for all interrupts Date: Fri, 10 Nov 2023 14:52:29 +0100 Message-ID: <20231110135348.245156-21-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: -YI-d04WPbF7FK4sWGZjLBxzPrcWHJUu X-Proofpoint-ORIG-GUID: EDCM03pG2EVaIDbmw1rh5HqyluMszq7o X-Proofpoint-UnRewURL: 8 URL's were un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=456 adultscore=0 suspectscore=0 phishscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 When toggling DAT or switch address space modes, it is likely that interrupts should be handled in the same DAT or address space mode. Add a function which toggles DAT and address space mode for all interruptions, except restart interrupts. Reviewed-by: Thomas Huth Reviewed-by: Janosch Frank Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20231106163738.1116942-3-nrb@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/asm/arch_def.h | 10 ++++++---- lib/s390x/asm/interrupt.h | 2 ++ lib/s390x/interrupt.c | 35 +++++++++++++++++++++++++++++++++++ lib/s390x/mmu.c | 5 +++-- 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h index f629b6d..5beaf15 100644 --- a/lib/s390x/asm/arch_def.h +++ b/lib/s390x/asm/arch_def.h @@ -84,10 +84,12 @@ struct cpu { bool in_interrupt_handler; }; -#define AS_PRIM 0 -#define AS_ACCR 1 -#define AS_SECN 2 -#define AS_HOME 3 +enum address_space { + AS_PRIM = 0, + AS_ACCR = 1, + AS_SECN = 2, + AS_HOME = 3 +}; #define PSW_MASK_DAT 0x0400000000000000UL #define PSW_MASK_IO 0x0200000000000000UL diff --git a/lib/s390x/asm/interrupt.h b/lib/s390x/asm/interrupt.h index 35c1145..d01f8a8 100644 --- a/lib/s390x/asm/interrupt.h +++ b/lib/s390x/asm/interrupt.h @@ -83,6 +83,8 @@ void expect_ext_int(void); uint16_t clear_pgm_int(void); void check_pgm_int_code(uint16_t code); +void irq_set_dat_mode(bool use_dat, enum address_space as); + /* Activate low-address protection */ static inline void low_prot_enable(void) { diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c index 3f993a3..e990c18 100644 --- a/lib/s390x/interrupt.c +++ b/lib/s390x/interrupt.c @@ -9,6 +9,7 @@ */ #include #include +#include #include #include #include @@ -104,6 +105,40 @@ void register_ext_cleanup_func(void (*f)(struct stack_frame_int *)) THIS_CPU->ext_cleanup_func = f; } +/** + * irq_set_dat_mode - Set the DAT mode of all interrupt handlers, except for + * restart. + * @use_dat: specifies whether to use DAT or not + * @as: specifies the address space mode to use. Not set if use_dat is false. + * + * This will update the DAT mode and address space mode of all interrupt new + * PSWs. + * + * Since enabling DAT needs initialized CRs and the restart new PSW is often used + * to initialize CRs, the restart new PSW is never touched to avoid the chicken + * and egg situation. + */ +void irq_set_dat_mode(bool use_dat, enum address_space as) +{ + struct psw* irq_psws[] = { + OPAQUE_PTR(GEN_LC_EXT_NEW_PSW), + OPAQUE_PTR(GEN_LC_SVC_NEW_PSW), + OPAQUE_PTR(GEN_LC_PGM_NEW_PSW), + OPAQUE_PTR(GEN_LC_MCCK_NEW_PSW), + OPAQUE_PTR(GEN_LC_IO_NEW_PSW), + }; + struct psw *psw; + + assert(as == AS_PRIM || as == AS_ACCR || as == AS_SECN || as == AS_HOME); + + for (size_t i = 0; i < ARRAY_SIZE(irq_psws); i++) { + psw = irq_psws[i]; + psw->dat = use_dat; + if (use_dat) + psw->as = as; + } +} + static void fixup_pgm_int(struct stack_frame_int *stack) { /* If we have an error on SIE we directly move to sie_exit */ diff --git a/lib/s390x/mmu.c b/lib/s390x/mmu.c index b474d70..9a179d6 100644 --- a/lib/s390x/mmu.c +++ b/lib/s390x/mmu.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "mmu.h" @@ -41,8 +42,8 @@ static void mmu_enable(pgd_t *pgtable) /* enable dat (primary == 0 set as default) */ enable_dat(); - /* we can now also use DAT unconditionally in our PGM handler */ - lowcore.pgm_new_psw.mask |= PSW_MASK_DAT; + /* we can now also use DAT in all interrupt handlers */ + irq_set_dat_mode(true, AS_PRIM); } /* From patchwork Fri Nov 10 13:52:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452433 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A292374E5 for ; Fri, 10 Nov 2023 13:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="lfzFjCWA" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A5523821E for ; Fri, 10 Nov 2023 05:54:43 -0800 (PST) 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 3AADkVhO017037; Fri, 10 Nov 2023 13:54:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=Mn5hVjoQICUNPX7+/vMpRauU1BHCYda+hVI8xOd0/Bc=; b=lfzFjCWAAQZPL7om+UkkVLZslMLidYoqmWQBH2AEKuILBKNfr4lQ59V9a+tUN9y8k+K3 /IOF925AJyRJhuMVZ8e5f3G7ZUVX89Au9hR8vVIhrM3UbKTrdD39v4y3fWswAAWaf2Wj jISadu0syYAZS4ch7to4ICmGC9X7jmKS0OicW7f6WH53ehcH7lDQ9gwC6F+a8crToP32 FZ+uyrgq3o3E1xPHith9tUlmGMWQJ5Z+LOrfPCY8kSVjPlw3U8iE6cUbXu9PH/sDJtz+ UzWYwF8wxmtfVEZmunmXSgG2FFcW3CfF8fuDTWS38ivQPBuhW6Qp2a2wcsEb+bONslDg 9A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9n6uhffk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:41 +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 3AADl6og020837; Fri, 10 Nov 2023 13:54:40 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 3u9n6uhff8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:40 +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 3AAB6V6t004129; Fri, 10 Nov 2023 13:54:39 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3u7w21b79y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:39 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsbMl45482456 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:37 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1046B20040; Fri, 10 Nov 2023 13:54:37 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AD5F52004B; Fri, 10 Nov 2023 13:54:36 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:36 +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: [kvm-unit-tests GIT PULL 21/26] s390x: sie: switch to home space mode before entering SIE Date: Fri, 10 Nov 2023 14:52:30 +0100 Message-ID: <20231110135348.245156-22-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 5n8lbJwrLQ4QZGtBZHOq0ESidfp6Wxru X-Proofpoint-ORIG-GUID: j5FajkPnlCchrECGXnQrg0WT-9s2BZCS X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=999 spamscore=0 bulkscore=0 malwarescore=0 impostorscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 This is to prepare for running guests without MSO/MSL, which is currently not possible. We already have code in sie64a to setup a guest primary ASCE before entering SIE, so we can in theory switch to the page tables which translate gpa to hpa. But the host is running in primary space mode already, so changing the primary ASCE before entering SIE will also affect the host's code and data. To make this switch useful, the host should run in a different address space mode. Hence, set up and change to home address space mode before installing the guest ASCE. The home space ASCE is just copied over from the primary space ASCE, so no functional change is intended, also for tests that want to use MSO/MSL. If a test intends to use a different primary space ASCE, it can now just set the guest.asce in the save_area. Reviewed-by: Thomas Huth Reviewed-by: Janosch Frank Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20231106163738.1116942-4-nrb@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/asm/arch_def.h | 1 + lib/s390x/sie.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h index 5beaf15..745a338 100644 --- a/lib/s390x/asm/arch_def.h +++ b/lib/s390x/asm/arch_def.h @@ -92,6 +92,7 @@ enum address_space { }; #define PSW_MASK_DAT 0x0400000000000000UL +#define PSW_MASK_HOME 0x0000C00000000000UL #define PSW_MASK_IO 0x0200000000000000UL #define PSW_MASK_EXT 0x0100000000000000UL #define PSW_MASK_KEY 0x00F0000000000000UL diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c index 97a093b..b8ee43e 100644 --- a/lib/s390x/sie.c +++ b/lib/s390x/sie.c @@ -54,6 +54,8 @@ void sie_handle_validity(struct vm *vm) void sie(struct vm *vm) { + uint64_t old_cr13; + if (vm->sblk->sdf == 2) memcpy(vm->sblk->pv_grregs, vm->save_area.guest.grs, sizeof(vm->save_area.guest.grs)); @@ -61,6 +63,24 @@ void sie(struct vm *vm) /* Reset icptcode so we don't trip over it below */ vm->sblk->icptcode = 0; + /* + * Set up home address space to match primary space. Instead of running + * in home space all the time, we switch every time in sie() because: + * - tests that depend on running in primary space mode don't need to be + * touched + * - it avoids regressions in tests + * - switching every time makes it easier to extend this in the future, + * for example to allow tests to run in whatever space they want + */ + old_cr13 = stctg(13); + lctlg(13, stctg(1)); + + /* switch to home space so guest tables can be different from host */ + psw_mask_set_bits(PSW_MASK_HOME); + + /* also handle all interruptions in home space while in SIE */ + irq_set_dat_mode(true, AS_HOME); + while (vm->sblk->icptcode == 0) { sie64a(vm->sblk, &vm->save_area); sie_handle_validity(vm); @@ -68,6 +88,12 @@ void sie(struct vm *vm) vm->save_area.guest.grs[14] = vm->sblk->gg14; vm->save_area.guest.grs[15] = vm->sblk->gg15; + irq_set_dat_mode(true, AS_PRIM); + psw_mask_clear_bits(PSW_MASK_HOME); + + /* restore the old CR 13 */ + lctlg(13, old_cr13); + if (vm->sblk->sdf == 2) memcpy(vm->save_area.guest.grs, vm->sblk->pv_grregs, sizeof(vm->save_area.guest.grs)); From patchwork Fri Nov 10 13:52:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452436 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E769F38DC2 for ; Fri, 10 Nov 2023 13:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="o37cCGy2" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1083D38226 for ; Fri, 10 Nov 2023 05:54:45 -0800 (PST) Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AADqKe2017246; Fri, 10 Nov 2023 13:54: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=N2PIdxQAZpfw+VlE3EuuEnYNabnmkqKyef2yiXTTP1o=; b=o37cCGy2+T3vJB9ZzpJ43N9S8DHI7g6bL9c2VfKBirZtMyszoKGqx3lJxzyQvGRyQgHw RKPUhfVVgAlnlvf8Z+qkMVJV3NBsrAufSS2KOHr2TNYiGhH3A0uveU/K/P/kh9MfRTXp OD0UPDOoIqGEPMnKoAINN/i2WHdc8gBgWqGDOn2omHorAF0qNCi9cgymB4PmN+IfL39G VZKQp1wVjoCjIBzR1rXJDODY6MaFtQr1lchqFuWaiSGwnoloMxmmPly1tQZmYkHW9Ggu U1YG4u23f8/tlaDIMHY8bifgWCSlpDtDf6zSdwKoNM670JHik7Af6VX8LUHp2QZdmJgP NA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nsjr1jn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:42 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AADrGNp019912; Fri, 10 Nov 2023 13:54:42 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nsjr1hs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:41 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AAB3Cp3028299; Fri, 10 Nov 2023 13:54:40 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w22u75e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:40 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsbaY44237212 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:37 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 78CAC20040; Fri, 10 Nov 2023 13:54:37 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 216F020043; Fri, 10 Nov 2023 13:54:37 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:37 +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: [kvm-unit-tests GIT PULL 22/26] s390x: lib: don't forward PSW when handling exception in SIE Date: Fri, 10 Nov 2023 14:52:31 +0100 Message-ID: <20231110135348.245156-23-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: TI2pdzFMnU1VGCFHgqZvymgO2AOdDD4H X-Proofpoint-ORIG-GUID: wkLvHCYyD5Lhv1E0BCaFvjw1I9OK8KKe X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 clxscore=1015 impostorscore=0 malwarescore=0 priorityscore=1501 phishscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 When we're handling a pgm int in SIE, we want to return to the SIE cleanup after handling the exception. That's why we set pgm_old_psw to the sie_exit label in fixup_pgm_int. On nullifing pgm ints, fixup_pgm_int will also forward the old PSW such that we don't cause an pgm int again. However, when we want to return to the sie_exit label, this is not needed (since we've manually set pgm_old_psw). Instead, forwarding the PSW might cause us to skip an instruction or end up in the middle of an instruction. So, let's just skip the rest of the fixup in case we're inside SIE. Note that we're intentionally not fixing up the PSW in the guest; that's best left to the test at hand by registering their own psw fixup. Reviewed-by: Janosch Frank Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20231106163738.1116942-5-nrb@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/interrupt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c index e990c18..f7843a8 100644 --- a/lib/s390x/interrupt.c +++ b/lib/s390x/interrupt.c @@ -145,6 +145,7 @@ static void fixup_pgm_int(struct stack_frame_int *stack) if (lowcore.pgm_old_psw.addr >= (uint64_t)&sie_entry && lowcore.pgm_old_psw.addr <= (uint64_t)&sie_exit) { lowcore.pgm_old_psw.addr = (uint64_t)&sie_exit; + return; } switch (lowcore.pgm_int_code) { From patchwork Fri Nov 10 13:52:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452438 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E5DB38DD4 for ; Fri, 10 Nov 2023 13:54:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="LsmibvDY" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42C0438227 for ; Fri, 10 Nov 2023 05:54:45 -0800 (PST) Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AADkVe0032073; Fri, 10 Nov 2023 13:54: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=Mf31TBn2V32VsY0kO2HWr2kDiq809fa6aFCz2iP/rmY=; b=LsmibvDYPF6iYRZ6r8iw91Oi6m7v2ci6xWMfjZR2UrgI8HO3qgn4LMIGnsYW55C8xULU IxU+531T5ZSEhtJ33VveQ6a6gLAQYxPAk4a7v51Mh0bvkgXuYt1fYnpbri8tzRTRQng/ k7rovzb7v7My+XX6kffeS95GSPQ4ORyJ0ouyFqq2mrllud5iqnSe8s8qd/Ma/9Whq1HV 7/aESVMwwM/18qysc/N7X5z7NBzWCcOYyo/fzg0ItyHA0uHSjPWNS7J8bwBvyu/foF70 W4NFftZWfJ3muxMKNnlJm4qnsZCFlTpGiwHeXkMUU7uiPcx3IpDuVtR3I5H6ZJ1MZhwb /A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9mpbaetc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:42 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AADlsRv005652; Fri, 10 Nov 2023 13:54:42 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9mpbaesn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:42 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AADlK65003529; Fri, 10 Nov 2023 13:54:41 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3u7w22b6ra-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:41 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADscGv18875130 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:38 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E4ED02004B; Fri, 10 Nov 2023 13:54:37 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8CA0320043; Fri, 10 Nov 2023 13:54:37 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:37 +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: [kvm-unit-tests GIT PULL 23/26] s390x: lib: sie: don't reenter SIE on pgm int Date: Fri, 10 Nov 2023 14:52:32 +0100 Message-ID: <20231110135348.245156-24-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: egr29FAoK6H7A4XLrNC4FQ9Zg09tVxb5 X-Proofpoint-ORIG-GUID: 6yga1e5uvDClt9VbKvoUDMbeMHfZE3MJ X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=36 mlxscore=36 adultscore=0 mlxlogscore=25 clxscore=1015 lowpriorityscore=0 malwarescore=0 bulkscore=0 phishscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 spamscore=36 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 At the moment, when a PGM int occurs while in SIE, we will just reenter SIE after the interrupt handler was called. This is because sie() has a loop which checks icptcode and re-enters SIE if it is zero. However, this behaviour is quite undesirable for SIE tests, since it doesn't give the host the chance to assert on the PGM int. Instead, we will just re-enter SIE, on nullifing conditions even causing the exception again. In sie(), check whether a pgm int code is set in lowcore. If it has, exit the loop so the test can react to the interrupt. Add a new function read_pgm_int_code() to obtain the interrupt code. Note that this introduces a slight oddity with sie and pgm int in certain cases: If a PGM int occurs between a expect_pgm_int() and sie(), we will now never enter SIE until the pgm_int_code is cleared by e.g. clear_pgm_int(). Also add missing include of facility.h to mem.h. Reviewed-by: Thomas Huth Reviewed-by: Claudio Imbrenda Reviewed-by: Janosch Frank Link: https://lore.kernel.org/r/20231106163738.1116942-6-nrb@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/asm/interrupt.h | 14 ++++++++++++++ lib/s390x/asm/mem.h | 1 + lib/s390x/sie.c | 7 ++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/s390x/asm/interrupt.h b/lib/s390x/asm/interrupt.h index d01f8a8..39b43b6 100644 --- a/lib/s390x/asm/interrupt.h +++ b/lib/s390x/asm/interrupt.h @@ -97,4 +97,18 @@ static inline void low_prot_disable(void) ctl_clear_bit(0, CTL0_LOW_ADDR_PROT); } +/** + * read_pgm_int_code - Get the program interruption code of the last pgm int + * on the current CPU. + * + * This is similar to clear_pgm_int(), except that it doesn't clear the + * interruption information from lowcore. + * + * Return: 0 when none occurred. + */ +static inline uint16_t read_pgm_int_code(void) +{ + return lowcore.pgm_int_code; +} + #endif diff --git a/lib/s390x/asm/mem.h b/lib/s390x/asm/mem.h index 64ef59b..94d58c3 100644 --- a/lib/s390x/asm/mem.h +++ b/lib/s390x/asm/mem.h @@ -8,6 +8,7 @@ #ifndef _ASMS390X_MEM_H_ #define _ASMS390X_MEM_H_ #include +#include /* create pointer while avoiding compiler warnings */ #define OPAQUE_PTR(x) ((void *)(((uint64_t)&lowcore) + (x))) diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c index b8ee43e..28fbf14 100644 --- a/lib/s390x/sie.c +++ b/lib/s390x/sie.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,9 @@ void sie(struct vm *vm) { uint64_t old_cr13; + /* When a pgm int code is set, we'll never enter SIE below. */ + assert(!read_pgm_int_code()); + if (vm->sblk->sdf == 2) memcpy(vm->sblk->pv_grregs, vm->save_area.guest.grs, sizeof(vm->save_area.guest.grs)); @@ -81,7 +85,8 @@ void sie(struct vm *vm) /* also handle all interruptions in home space while in SIE */ irq_set_dat_mode(true, AS_HOME); - while (vm->sblk->icptcode == 0) { + /* leave SIE when we have an intercept or an interrupt so the test can react to it */ + while (vm->sblk->icptcode == 0 && !read_pgm_int_code()) { sie64a(vm->sblk, &vm->save_area); sie_handle_validity(vm); } From patchwork Fri Nov 10 13:52:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452439 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B3641BDC9 for ; Fri, 10 Nov 2023 13:54:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="cJxzH+cO" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73F493821D for ; Fri, 10 Nov 2023 05:54:46 -0800 (PST) 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 3AADaHNF001202; Fri, 10 Nov 2023 13:54: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=2fWoF5B1Aa6xzCPFemHlSoFBXqObLbGeuCWAhJzfqK4=; b=cJxzH+cOeC2iYL79jGvGJTbpwAJtwLoIQ60eLCdB03sVjzf/9ki2Gkmaif2SuWY+b5/Z 8y1muxfjRficb1bv4S+eV9WWkYsFTAIL7Yrect237NQNd1P+xZ7jF0UIJwWkGFjhgEty oU7BYBbB9LG2WwZzP/Sn+9pgqYQ+4lR19TUji8Icijpl0KRepC6ABJHQ8oQDHC5Gs4V1 xxb7a9bwyTy557Wksp1cBEHwBYX3zV+S1r8F0Ag1cKGDv0EmQ9XGQdP/LQqluD4YAPqk XXc7OYr43Bzy+JZlu/1NFqBjWDzq/7XzrbrXkQyfM2rGTdfuOjjWgTthvYze0U9+dvGw Cg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9mrn9s06-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:43 +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 3AADpibX020045; Fri, 10 Nov 2023 13:54:43 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9mrn9ry8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:42 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AADe20H028305; Fri, 10 Nov 2023 13:54:41 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w22u75g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:41 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADscbe17761022 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:38 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6408620040; Fri, 10 Nov 2023 13:54:38 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 02C752004E; Fri, 10 Nov 2023 13:54:38 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:37 +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: [kvm-unit-tests GIT PULL 24/26] s390x: add test source dir to include paths Date: Fri, 10 Nov 2023 14:52:33 +0100 Message-ID: <20231110135348.245156-25-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: iEXUl7Oa2YIzt0kss5YUnXAudWGv430n X-Proofpoint-GUID: 4bNLXj65pjT9gwLPj8jhtklUfgXCWOPg X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 Sometimes, it is useful to share some defines between a snippet and a test. By adding the source directory to include paths, header files can be placed in the snippet directory and included from the test (or vice versa). This is a prerequisite for future tests. Reviewed-by: Thomas Huth Reviewed-by: Janosch Frank Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20231106163738.1116942-7-nrb@linux.ibm.com Signed-off-by: Nico Boehr --- s390x/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s390x/Makefile b/s390x/Makefile index 6e96719..947a434 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -67,7 +67,7 @@ test_cases: $(tests) test_cases_binary: $(tests_binary) test_cases_pv: $(tests_pv_binary) -INCLUDE_PATHS = $(SRCDIR)/lib $(SRCDIR)/lib/s390x +INCLUDE_PATHS = $(SRCDIR)/lib $(SRCDIR)/lib/s390x $(SRCDIR)/s390x # Include generated header files (e.g. in case of out-of-source builds) INCLUDE_PATHS += lib CPPFLAGS = $(addprefix -I,$(INCLUDE_PATHS)) From patchwork Fri Nov 10 13:52:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Boehr X-Patchwork-Id: 13452440 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2670B1BDFB for ; Fri, 10 Nov 2023 13:54:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="aAPK0iHa" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A57EA38220 for ; Fri, 10 Nov 2023 05:54:47 -0800 (PST) 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 3AADoB6u003417; Fri, 10 Nov 2023 13:54:45 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=qCL0Te1PXnD3zGTg78WCdv69FXrpjLoxymnS3IPU/D8=; b=aAPK0iHa6tXPDrkfE9V3refYgsUrxKlFNd88KMlZvYD5A99JjeqKM8daLi5R3Xr8gWlQ 51PVpAISsvYokaxvrHZy/L0+pnhhyi5tHC+cWrfiN5XMVF62ajYyLf3sB8l2x7qtKHc6 QpoEBEWALMo3e/TDpGsWJgBNuWRDIsKk/c+b9+osADFSxa42/FAtOHzbLGBkiMmGy1C6 lwwU+77Nv7GA19Wd7Dt6L3PT48xAmPQusU1S0Q6LSDAAdCmGgPVaD/SE6Qh/31THXlso uZp2HOkORT5Dfhon964QYZ/ibuPh50Ot//GU26XKZmsJHkekVTWF1N8L4kFUnOZDR1tR Mw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nrd04yn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:45 +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 3AADoRit004134; Fri, 10 Nov 2023 13:54:45 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9nrd04ya-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:44 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AAAueFk014332; Fri, 10 Nov 2023 13:54:44 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w22b7xv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:44 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADseuC18940476 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:40 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7FDBA20040; Fri, 10 Nov 2023 13:54:39 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 776472004B; Fri, 10 Nov 2023 13:54:38 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:38 +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: [kvm-unit-tests GIT PULL 25/26] s390x: add a test for SIE without MSO/MSL Date: Fri, 10 Nov 2023 14:52:34 +0100 Message-ID: <20231110135348.245156-26-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: VehbY6K1mvRqvwHHL2_94YzV2drit9YR X-Proofpoint-ORIG-GUID: m20bxVaoQt85Zw6ic0qtmUA68tI6Yu39 X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 Since we now have the ability to run guests without MSO/MSL, add a test to make sure this doesn't break. Reviewed-by: Thomas Huth Reviewed-by: Janosch Frank Reviewed-by: Claudio Imbrenda Link: https://lore.kernel.org/r/20231106163738.1116942-8-nrb@linux.ibm.com [ nrb: __pa -> virt_to_pte_phys to fix incompatiblity with 2g align ] Signed-off-by: Nico Boehr --- s390x/Makefile | 2 + s390x/snippets/c/sie-dat.h | 2 + s390x/sie-dat.c | 114 +++++++++++++++++++++++++++++++++++++ s390x/snippets/c/sie-dat.c | 57 +++++++++++++++++++ s390x/unittests.cfg | 3 + 5 files changed, 178 insertions(+) create mode 100644 s390x/snippets/c/sie-dat.h create mode 100644 s390x/sie-dat.c create mode 100644 s390x/snippets/c/sie-dat.c diff --git a/s390x/Makefile b/s390x/Makefile index 947a434..f79fd00 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -41,6 +41,7 @@ tests += $(TEST_DIR)/migration-sck.elf tests += $(TEST_DIR)/exittime.elf tests += $(TEST_DIR)/ex.elf tests += $(TEST_DIR)/topology.elf +tests += $(TEST_DIR)/sie-dat.elf pv-tests += $(TEST_DIR)/pv-diags.elf pv-tests += $(TEST_DIR)/pv-icptcode.elf @@ -123,6 +124,7 @@ snippet_lib = $(snippet_asmlib) lib/auxinfo.o # perquisites (=guests) for the snippet hosts. # $(TEST_DIR)/.elf: snippets = $(SNIPPET_DIR)//.gbin $(TEST_DIR)/mvpg-sie.elf: snippets = $(SNIPPET_DIR)/c/mvpg-snippet.gbin +$(TEST_DIR)/sie-dat.elf: snippets = $(SNIPPET_DIR)/c/sie-dat.gbin $(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 diff --git a/s390x/snippets/c/sie-dat.h b/s390x/snippets/c/sie-dat.h new file mode 100644 index 0000000..ed3f99f --- /dev/null +++ b/s390x/snippets/c/sie-dat.h @@ -0,0 +1,2 @@ +#define GUEST_TEST_PAGE_COUNT 10 +#define GUEST_TOTAL_PAGE_COUNT 256 diff --git a/s390x/sie-dat.c b/s390x/sie-dat.c new file mode 100644 index 0000000..f025777 --- /dev/null +++ b/s390x/sie-dat.c @@ -0,0 +1,114 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Tests SIE with paging. + * + * Copyright 2023 IBM Corp. + * + * Authors: + * Nico Boehr + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "snippets/c/sie-dat.h" + +static struct vm vm; +static pgd_t *guest_root; + +static void test_sie_dat(void) +{ + uint64_t test_page_gpa, test_page_hpa; + uint8_t *test_page_hva, expected_val; + bool contents_match; + uint8_t r1; + + /* guest will tell us the guest physical address of the test buffer */ + sie(&vm); + assert(vm.sblk->icptcode == ICPT_INST && + (vm.sblk->ipa & 0xff00) == 0x8300 && vm.sblk->ipb == 0x9c0000); + + r1 = (vm.sblk->ipa & 0xf0) >> 4; + test_page_gpa = vm.save_area.guest.grs[r1]; + test_page_hpa = virt_to_pte_phys(guest_root, (void*)test_page_gpa); + test_page_hva = __va(test_page_hpa); + report_info("test buffer gpa=0x%lx hva=%p", test_page_gpa, test_page_hva); + + /* guest will now write to the test buffer and we verify the contents */ + sie(&vm); + assert(vm.sblk->icptcode == ICPT_INST && + vm.sblk->ipa == 0x8300 && vm.sblk->ipb == 0x440000); + + contents_match = true; + for (unsigned int i = 0; i < GUEST_TEST_PAGE_COUNT; i++) { + expected_val = 42 + i; + if (test_page_hva[i * PAGE_SIZE] != expected_val) { + report_fail("page %u mismatch actual_val=%x expected_val=%x", + i, test_page_hva[i], expected_val); + contents_match = false; + } + } + report(contents_match, "test buffer contents match"); + + /* the guest will now write to an unmapped address and we check that this causes a segment translation exception */ + report_prefix_push("guest write to unmapped"); + expect_pgm_int(); + sie(&vm); + check_pgm_int_code(PGM_INT_CODE_SEGMENT_TRANSLATION); + report((lowcore.trans_exc_id & PAGE_MASK) == (GUEST_TOTAL_PAGE_COUNT * PAGE_SIZE), "TEID address match"); + report_prefix_pop(); +} + +static void setup_guest(void) +{ + extern const char SNIPPET_NAME_START(c, sie_dat)[]; + extern const char SNIPPET_NAME_END(c, sie_dat)[]; + uint64_t guest_max_addr; + pgd_t *root; + + setup_vm(); + root = (pgd_t *)(stctg(1) & PAGE_MASK); + + snippet_setup_guest(&vm, false); + + /* allocate a region-1 table */ + guest_root = pgd_alloc_one(); + + /* map guest memory 1:1 */ + guest_max_addr = GUEST_TOTAL_PAGE_COUNT * PAGE_SIZE; + for (uint64_t i = 0; i < guest_max_addr; i += PAGE_SIZE) + install_page(guest_root, virt_to_pte_phys(root, vm.guest_mem + i), (void *)i); + + /* set up storage limit supression - leave mso and msl intact they are ignored anyways */ + vm.sblk->cpuflags |= CPUSTAT_SM; + + /* set up the guest asce */ + vm.save_area.guest.asce = __pa(guest_root) | ASCE_DT_REGION1 | REGION_TABLE_LENGTH; + + snippet_init(&vm, SNIPPET_NAME_START(c, sie_dat), + SNIPPET_LEN(c, sie_dat), SNIPPET_UNPACK_OFF); +} + +int main(void) +{ + report_prefix_push("sie-dat"); + if (!sclp_facilities.has_sief2) { + report_skip("SIEF2 facility unavailable"); + goto done; + } + + setup_guest(); + test_sie_dat(); + sie_guest_destroy(&vm); + +done: + report_prefix_pop(); + return report_summary(); + +} diff --git a/s390x/snippets/c/sie-dat.c b/s390x/snippets/c/sie-dat.c new file mode 100644 index 0000000..ecfcb60 --- /dev/null +++ b/s390x/snippets/c/sie-dat.c @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Snippet used by the sie-dat.c test to verify paging without MSO/MSL + * + * Copyright (c) 2023 IBM Corp + * + * Authors: + * Nico Boehr + */ +#include +#include +#include "sie-dat.h" + +static uint8_t test_pages[GUEST_TEST_PAGE_COUNT * PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); + +static inline void force_exit(void) +{ + asm volatile("diag 0,0,0x44\n" + : + : + : "memory" + ); +} + +static inline void force_exit_value(uint64_t val) +{ + asm volatile("diag %[val],0,0x9c\n" + : + : [val] "d"(val) + : "memory" + ); +} + +int main(void) +{ + uint8_t *invalid_ptr; + + memset(test_pages, 0, sizeof(test_pages)); + /* tell the host the page's physical address (we're running DAT off) */ + force_exit_value((uint64_t)test_pages); + + /* write some value to the page so the host can verify it */ + for (size_t i = 0; i < GUEST_TEST_PAGE_COUNT; i++) + test_pages[i * PAGE_SIZE] = 42 + i; + + /* indicate we've written all pages */ + force_exit(); + + /* the first unmapped address */ + invalid_ptr = (uint8_t *)(GUEST_TOTAL_PAGE_COUNT * PAGE_SIZE); + *invalid_ptr = 42; + + /* indicate we've written the non-allowed page (should never get here) */ + force_exit(); + + return 0; +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index b08b0fb..f5024b6 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -380,3 +380,6 @@ extra_params = """-cpu max,ctop=on -smp cpus=1,drawers=2,books=2,sockets=2,cores -device max-s390x-cpu,core-id=97,drawer-id=1,book-id=1,socket-id=1,entitlement=high,dedicated=true \ -device max-s390x-cpu,core-id=111,drawer-id=1,book-id=1,socket-id=1,entitlement=medium,dedicated=false \ """ + +[sie-dat] +file = sie-dat.elf From patchwork Fri Nov 10 13:52: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: 13452441 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2EC71CA81 for ; Fri, 10 Nov 2023 13:54:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="XGPoEcjN" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96A613821E for ; Fri, 10 Nov 2023 05:54:48 -0800 (PST) Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AADFZq4014119; Fri, 10 Nov 2023 13:54: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=oaWseYGv3XRzIUI4Xfw84IPZQRSJoG1yqWjSNVoIj80=; b=XGPoEcjNrcT+nKYvQtpomx54BbsjlHp0wyN03nRlU1ae+1KWVz9BDpZHFz+3nse7Jev6 +nB4jmUZcSYLXAFgVbk6ofOjH6rMR96pWcS8upNjDMCIbHmlU3lDRhqMJjQLaXC4EEEV 7kZrAdWilQe896Ya8rO8VSKDDT0bxpcar2eb6cFlIkZuW9DCVTv5k5qEJKb2MVGPTdfK +kXsxe/CPLSs8As6BXa7xnb2XfLCqmSJdWJFycAXSbTRd/ENbrUTekMIy+xlIduIJ2ip Z4Fo0KCKycgodWqTvw2Lb+RSV5LktVuDzSVaNpHko7xHVztz790vYdjPrnRPCMGlUidR kw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9n84s9rr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:46 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AADTRux006124; Fri, 10 Nov 2023 13:54:46 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u9n84s9ra-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:45 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AAB4RVQ014372; Fri, 10 Nov 2023 13:54:45 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3u7w22b7xx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Nov 2023 13:54:45 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AADsgQ312780110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Nov 2023 13:54:42 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2D54120040; Fri, 10 Nov 2023 13:54:42 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4AB0B20043; Fri, 10 Nov 2023 13:54:40 +0000 (GMT) Received: from t14-nrb.ibmuc.com (unknown [9.179.18.113]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 10 Nov 2023 13:54:39 +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: [kvm-unit-tests GIT PULL 26/26] lib: s390x: interrupt: remove TEID_ASCE defines Date: Fri, 10 Nov 2023 14:52:35 +0100 Message-ID: <20231110135348.245156-27-nrb@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231110135348.245156-1-nrb@linux.ibm.com> References: <20231110135348.245156-1-nrb@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: vMY11dhR71DMrCi0cEqrq9G966SA3aT- X-Proofpoint-ORIG-GUID: iLY0VavfMZlZS4RkQ4rhpQxvLdIeAxpv X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-10_10,2023-11-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=777 priorityscore=1501 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 clxscore=1015 mlxscore=0 impostorscore=0 spamscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311100114 These defines were - I can only guess - meant for the asce_id field. Since print_decode_teid() used AS_PRIM and friends instead, I see little benefit in keeping these around. Reviewed-by: Thomas Huth Reviewed-by: Claudio Imbrenda Reviewed-by: Janosch Frank Link: https://lore.kernel.org/r/20231106163738.1116942-9-nrb@linux.ibm.com Signed-off-by: Nico Boehr --- lib/s390x/asm/interrupt.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/s390x/asm/interrupt.h b/lib/s390x/asm/interrupt.h index 39b43b6..61d156d 100644 --- a/lib/s390x/asm/interrupt.h +++ b/lib/s390x/asm/interrupt.h @@ -13,11 +13,6 @@ #define EXT_IRQ_EXTERNAL_CALL 0x1202 #define EXT_IRQ_SERVICE_SIG 0x2401 -#define TEID_ASCE_PRIMARY 0 -#define TEID_ASCE_AR 1 -#define TEID_ASCE_SECONDARY 2 -#define TEID_ASCE_HOME 3 - union teid { unsigned long val; union {