From patchwork Fri Jul 29 08:26:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12932135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 114AEC00144 for ; Fri, 29 Jul 2022 08:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234371AbiG2I2W (ORCPT ); Fri, 29 Jul 2022 04:28:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235639AbiG2I2F (ORCPT ); Fri, 29 Jul 2022 04:28:05 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8393E83204 for ; Fri, 29 Jul 2022 01:27:18 -0700 (PDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26T8Igs2027603 for ; Fri, 29 Jul 2022 08:27:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=vHXnHDpTloNk2ogAmOxJn1flc7fmoy7Bht6CezBdbso=; b=n5cO3Dn7KE03Dg04X7caqCyxMsiHqNqhziafhWG+0A5Abbxj0n7xjYGjfJQhqEWw9S/y OMSXIXub673wB6lk9BAwQqEYFXGlPzz6nKw4zLw/dcr0R6rPwJJT5viJvNHdUl22L96d 8uKO/BMfq6Yz6uCSOi3B2De20Tg/dNCmcxN9WEwoAZMWOIpdf8+k6WgQTKpJH+Ewx1vR CEmusGYTwgb7Sgkuw6sTfuLAWJVmG3uDURVqHsGOMWpruapMeptfs7WWfFpXMF51ZCKq +8k/btJoKe/nj3GgpVblS5IsiVswzwhjaGLXIDGM+2DuIlVsBqH5FC3ZdGYZwKVLH5Io rQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hmbx7g61g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 29 Jul 2022 08:27:18 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26T8LYlI003052 for ; Fri, 29 Jul 2022 08:27:17 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hmbx7g60j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 08:27:17 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26T8MbTt007098; Fri, 29 Jul 2022 08:27:15 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma04fra.de.ibm.com with ESMTP id 3hg945nhmb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 08:27:14 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26T8RBvY30474552 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jul 2022 08:27:11 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BA68C5204F; Fri, 29 Jul 2022 08:27:11 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 175D25204E; Fri, 29 Jul 2022 08:27:11 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: imbrenda@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com, scgl@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH 1/6] s390x: snippets: asm: Add a macro to write an exception PSW Date: Fri, 29 Jul 2022 08:26:28 +0000 Message-Id: <20220729082633.277240-2-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220729082633.277240-1-frankja@linux.ibm.com> References: <20220729082633.277240-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: yQ0vHSpRc1QzAyaF84mlJDm_b25g4Ndu X-Proofpoint-ORIG-GUID: kOvLHiTMqkxUJUe5H35f92ulRZdhMt9r X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-28_06,2022-07-28_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 spamscore=0 malwarescore=0 clxscore=1015 mlxscore=0 priorityscore=1501 adultscore=0 impostorscore=0 mlxlogscore=963 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207290032 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Setting exception new PSWs is commonly needed so let's add a macro for that. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr --- s390x/snippets/asm/macros.S | 28 ++++++++++++++++++++++++ s390x/snippets/asm/snippet-pv-diag-288.S | 4 ++-- s390x/snippets/asm/snippet-pv-diag-500.S | 6 ++--- 3 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 s390x/snippets/asm/macros.S diff --git a/s390x/snippets/asm/macros.S b/s390x/snippets/asm/macros.S new file mode 100644 index 00000000..667fb6dc --- /dev/null +++ b/s390x/snippets/asm/macros.S @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Commonly used assembly macros + * + * Copyright (c) 2022 IBM Corp + * + * Authors: + * Janosch Frank + */ +#include + +/* + * Writes a PSW to addr_psw, useful for exception PSWs in lowcore + * + * reg is the scratch register used for temporary storage, it's NOT restored + * The psw address part is defined via psw_new_addr + * The psw mask part is always 64 bit + */ +.macro SET_PSW_NEW_ADDR reg, psw_new_addr, addr_psw +larl \reg, psw_mask_64 +stg \reg, \addr_psw +larl \reg, \psw_new_addr +stg \reg, \addr_psw + 8 +.endm + +.section .rodata +psw_mask_64: + .quad 0x0000000180000000 diff --git a/s390x/snippets/asm/snippet-pv-diag-288.S b/s390x/snippets/asm/snippet-pv-diag-288.S index aaee3cd1..63f2113b 100644 --- a/s390x/snippets/asm/snippet-pv-diag-288.S +++ b/s390x/snippets/asm/snippet-pv-diag-288.S @@ -8,6 +8,7 @@ * Janosch Frank */ #include +#include "macros.S" .section .text /* Clean and pre-load registers that are used for diag 288 */ @@ -19,8 +20,7 @@ lghi %r1, 2 lghi %r2, 3 /* Let's jump to the pgm exit label on a PGM */ -larl %r4, exit_pgm -stg %r4, GEN_LC_PGM_NEW_PSW + 8 +SET_PSW_NEW_ADDR 4, exit_pgm, GEN_LC_PGM_NEW_PSW /* Execute the diag288 */ diag %r0, %r2, 0x288 diff --git a/s390x/snippets/asm/snippet-pv-diag-500.S b/s390x/snippets/asm/snippet-pv-diag-500.S index 8dd66bd9..f4d75388 100644 --- a/s390x/snippets/asm/snippet-pv-diag-500.S +++ b/s390x/snippets/asm/snippet-pv-diag-500.S @@ -8,6 +8,7 @@ * Janosch Frank */ #include +#include "macros.S" .section .text /* Clean and pre-load registers that are used for diag 500 */ @@ -21,10 +22,7 @@ lghi %r3, 3 lghi %r4, 4 /* Let's jump to the next label on a PGM */ -xgr %r5, %r5 -stg %r5, GEN_LC_PGM_NEW_PSW -larl %r5, next -stg %r5, GEN_LC_PGM_NEW_PSW + 8 +SET_PSW_NEW_ADDR 5, next, GEN_LC_PGM_NEW_PSW /* Execute the diag500 */ diag 0, 0, 0x500 From patchwork Fri Jul 29 08:26:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12932134 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2445FC04A68 for ; Fri, 29 Jul 2022 08:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234869AbiG2I2U (ORCPT ); Fri, 29 Jul 2022 04:28:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235640AbiG2I2F (ORCPT ); Fri, 29 Jul 2022 04:28:05 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BEC083206 for ; Fri, 29 Jul 2022 01:27:19 -0700 (PDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26T8IjdN027654 for ; Fri, 29 Jul 2022 08:27:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=AHeR5+dpWE7fp+ZIdF4DGTiQnrFeIceriJqfUkXFPsU=; b=Rh8ob93+WSwev40d0Fm4oiEdYNAOtjXZqwg5lvV2kL16W9eUb2WNZ3cCD14ZlbOdETm5 UO7xSq9VCAJrgep25koOCVgQf9tjrQorzP6LPqVn5ldK6AtymMGfTHh9OEWz5M4i8fwe HRbb2eqyrqtGLhTzbJhT2gDekFxp5cvk5pAZ61HKdcIRRsXNxrk/3o4rQv+hgMeJnMS2 eM1ewSASZrThfq4ygHMEb0Wa8S3IbpT2yZLNGlQDIeAFAxTq36MS3hlfrhn2BRVCyKr/ axbPg4CRyuV+gax4VisZP/1gz2ubPrMMvGhYi17jpKF0rnXhSVjc4UWDZgSp98k9AhST pg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hmbx7g61p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 29 Jul 2022 08:27:18 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26T8JEtv028556 for ; Fri, 29 Jul 2022 08:27:18 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hmbx7g60r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 08:27:18 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26T8NqVd027104; Fri, 29 Jul 2022 08:27:15 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06fra.de.ibm.com with ESMTP id 3hg98fjk7h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 08:27:15 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26T8RC4I26739070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jul 2022 08:27:12 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8ED555204F; Fri, 29 Jul 2022 08:27:12 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id D5F515204E; Fri, 29 Jul 2022 08:27:11 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: imbrenda@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com, scgl@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH 2/6] s390x: MAKEFILE: Use $< instead of pathsubst Date: Fri, 29 Jul 2022 08:26:29 +0000 Message-Id: <20220729082633.277240-3-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220729082633.277240-1-frankja@linux.ibm.com> References: <20220729082633.277240-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: kwD6VvZJHZz4N3y4m1wDJJpJQhhLkq4L X-Proofpoint-ORIG-GUID: 3VqdrE2AfVsOt8lRNiWY3FuLLGncLiVH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-28_06,2022-07-28_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 spamscore=0 malwarescore=0 clxscore=1015 mlxscore=0 priorityscore=1501 adultscore=0 impostorscore=0 mlxlogscore=689 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207290032 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org No need to mangle strings if we already have the value at hand. Signed-off-by: Janosch Frank Reviewed-by: Steffen Eiden Reviewed-by: Nico Boehr --- s390x/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s390x/Makefile b/s390x/Makefile index efd5e0c1..ee34a1d7 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -134,7 +134,7 @@ $(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.o truncate -s '%4096' $@ $(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) - $(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/snippets/c/flat.lds $(patsubst %.gbin,%.o,$@) $(snippet_lib) $(FLATLIBS) + $(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/snippets/c/flat.lds $< $(snippet_lib) $(FLATLIBS) $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $@ $@ truncate -s '%4096' $@ From patchwork Fri Jul 29 08:26:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12932136 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1D03C04A68 for ; Fri, 29 Jul 2022 08:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234899AbiG2I2X (ORCPT ); Fri, 29 Jul 2022 04:28:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235641AbiG2I2F (ORCPT ); Fri, 29 Jul 2022 04:28:05 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF88983207 for ; Fri, 29 Jul 2022 01:27:19 -0700 (PDT) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26T7wGr3008229 for ; Fri, 29 Jul 2022 08:27: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 : mime-version : content-transfer-encoding; s=pp1; bh=bgHgBKEafCyes+QJEZ9bCyDYIyr/PrwJMl8m8E4GSTo=; b=oDiPk4KQOzBS874AXmAGra/Iisio/TLbp9nKPf6hj5x5x1msnDe93XDN/USsFqkpgvHR mwMIHdmU7T7OsDlUzzgpR7LLsHY4uI2gbKC6l1c7wHqC2ffOgxlb5xSw/3HDtQw0FoH1 hta8nJHBKQjIufi2WSMh/FlkrZCLpVH0ts8dfbVxEgMGMncfuOV7lmjGl9lSdGppDlrI SskbX76yNBqPkJd/IsE2a+RPheDtb/T/SRSObp3FsqXQXVqhrCUSUg1pZRnD8OP/ZgTf KW5g0D/7s5Omd4Sj2C2PUn0hbmoqBzFNIh+EPaXTdHf6WNtHFyHZb9I6b0kgzAlzkUKk aA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hmbmmrvr5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 29 Jul 2022 08:27:18 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26T7wKLI008305 for ; Fri, 29 Jul 2022 08:27:18 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hmbmmrvqh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 08:27:18 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26T8K6bO021088; Fri, 29 Jul 2022 08:27:16 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03fra.de.ibm.com with ESMTP id 3hg95ydj0t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 08:27:16 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26T8RDO529688210 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jul 2022 08:27:13 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 599D05204F; Fri, 29 Jul 2022 08:27:13 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id AAC2A5204E; Fri, 29 Jul 2022 08:27:12 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: imbrenda@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com, scgl@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH 3/6] s390x: Add a linker script to assembly snippets Date: Fri, 29 Jul 2022 08:26:30 +0000 Message-Id: <20220729082633.277240-4-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220729082633.277240-1-frankja@linux.ibm.com> References: <20220729082633.277240-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: -mDego_LWHrx7Yz_inxyxxMSStP7roaH X-Proofpoint-GUID: oUq5i9m5caOyWZAkqx-_iVkG-KP1PcMw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-28_06,2022-07-28_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 suspectscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207290032 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org A linker script has a few benefits: - We can easily define a lowcore and load the snippet from 0x0 instead of 0x4000 which makes asm snippets behave like c snippets - We can easily define an invalid PGM new PSW to ensure an exit on a guest PGM As we gain another step and file extension by linking, a comment explains which file extensions are generated and why. Signed-off-by: Janosch Frank --- lib/s390x/snippet.h | 3 +-- s390x/Makefile | 16 +++++++++++++--- s390x/mvpg-sie.c | 2 +- s390x/pv-diags.c | 6 +++--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/s390x/snippet.h b/lib/s390x/snippet.h index b17b2a4c..57045994 100644 --- a/lib/s390x/snippet.h +++ b/lib/s390x/snippet.h @@ -32,8 +32,7 @@ #define SNIPPET_PV_TWEAK0 0x42UL #define SNIPPET_PV_TWEAK1 0UL -#define SNIPPET_OFF_C 0 -#define SNIPPET_OFF_ASM 0x4000 +#define SNIPPET_UNPACK_OFF 0 /* diff --git a/s390x/Makefile b/s390x/Makefile index ee34a1d7..9a0b48e2 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -122,6 +122,13 @@ else snippet-hdr-obj = endif +# Each snippet will generate the following files (in order): \ + *.o is a snippet that has been compiled \ + *.ol is a snippet that has been linked \ + *.gbin is a snippet that has been converted to binary \ + *.gobj is the final format after converting the binary into a elf file again, \ + it will be linked into the tests + # the asm/c snippets %.o have additional generated files as dependencies $(SNIPPET_DIR)/asm/%.o: $(SNIPPET_DIR)/asm/%.S $(asm-offsets) $(CC) $(CFLAGS) -c -nostdlib -o $@ $< @@ -129,8 +136,11 @@ $(SNIPPET_DIR)/asm/%.o: $(SNIPPET_DIR)/asm/%.S $(asm-offsets) $(SNIPPET_DIR)/c/%.o: $(SNIPPET_DIR)/c/%.c $(asm-offsets) $(CC) $(CFLAGS) -c -nostdlib -o $@ $< -$(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.o - $(OBJCOPY) -O binary -j ".rodata" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $(patsubst %.gbin,%.o,$@) $@ +$(SNIPPET_DIR)/asm/%.ol: $(SNIPPET_DIR)/asm/%.o + $(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/snippets/asm/flat.lds $< + +$(SNIPPET_DIR)/asm/%.gbin: $(SNIPPET_DIR)/asm/%.ol + $(OBJCOPY) -O binary -j ".rodata" -j ".lowcore" -j ".text" -j ".data" -j ".bss" --set-section-flags .bss=alloc,load,contents $< $@ truncate -s '%4096' $@ $(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) @@ -139,7 +149,7 @@ $(SNIPPET_DIR)/c/%.gbin: $(SNIPPET_DIR)/c/%.o $(snippet_lib) $(FLATLIBS) truncate -s '%4096' $@ $(SNIPPET_DIR)/asm/%.hdr: $(SNIPPET_DIR)/asm/%.gbin $(HOST_KEY_DOCUMENT) - $(GEN_SE_HEADER) -k $(HOST_KEY_DOCUMENT) -c $<,0x4000,0x00000000000000420000000000000000 --psw-addr 0x4000 -o $@ + $(GEN_SE_HEADER) -k $(HOST_KEY_DOCUMENT) -c $<,0x0,0x00000000000000420000000000000000 --psw-addr 0x4000 -o $@ $(SNIPPET_DIR)/c/%.hdr: $(SNIPPET_DIR)/c/%.gbin $(HOST_KEY_DOCUMENT) $(GEN_SE_HEADER) -k $(HOST_KEY_DOCUMENT) -c $<,0x0,0x00000000000000420000000000000000 --psw-addr 0x4000 -o $@ diff --git a/s390x/mvpg-sie.c b/s390x/mvpg-sie.c index 46a2edb6..99f4859b 100644 --- a/s390x/mvpg-sie.c +++ b/s390x/mvpg-sie.c @@ -87,7 +87,7 @@ static void setup_guest(void) snippet_setup_guest(&vm, false); snippet_init(&vm, SNIPPET_NAME_START(c, mvpg_snippet), - SNIPPET_LEN(c, mvpg_snippet), SNIPPET_OFF_C); + SNIPPET_LEN(c, mvpg_snippet), SNIPPET_UNPACK_OFF); /* Enable MVPG interpretation as we want to test KVM and not ourselves */ vm.sblk->eca = ECA_MVPGI; diff --git a/s390x/pv-diags.c b/s390x/pv-diags.c index 9ced68c7..5165937a 100644 --- a/s390x/pv-diags.c +++ b/s390x/pv-diags.c @@ -28,7 +28,7 @@ static void test_diag_500(void) snippet_pv_init(&vm, SNIPPET_NAME_START(asm, snippet_pv_diag_500), SNIPPET_HDR_START(asm, snippet_pv_diag_500), - size_gbin, size_hdr, SNIPPET_OFF_ASM); + size_gbin, size_hdr, SNIPPET_UNPACK_OFF); sie(&vm); report(vm.sblk->icptcode == ICPT_PV_INSTR && vm.sblk->ipa == 0x8302 && @@ -83,7 +83,7 @@ static void test_diag_288(void) snippet_pv_init(&vm, SNIPPET_NAME_START(asm, snippet_pv_diag_288), SNIPPET_HDR_START(asm, snippet_pv_diag_288), - size_gbin, size_hdr, SNIPPET_OFF_ASM); + size_gbin, size_hdr, SNIPPET_UNPACK_OFF); sie(&vm); report(vm.sblk->icptcode == ICPT_PV_INSTR && vm.sblk->ipa == 0x8302 && @@ -124,7 +124,7 @@ static void test_diag_yield(void) snippet_pv_init(&vm, SNIPPET_NAME_START(asm, snippet_pv_diag_yield), SNIPPET_HDR_START(asm, snippet_pv_diag_yield), - size_gbin, size_hdr, SNIPPET_OFF_ASM); + size_gbin, size_hdr, SNIPPET_UNPACK_OFF); /* 0x44 */ report_prefix_push("0x44"); From patchwork Fri Jul 29 08:26:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12932137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB662C00144 for ; Fri, 29 Jul 2022 08:28:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234931AbiG2I2Y (ORCPT ); Fri, 29 Jul 2022 04:28:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235645AbiG2I2G (ORCPT ); Fri, 29 Jul 2022 04:28:06 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F01B83208 for ; Fri, 29 Jul 2022 01:27:20 -0700 (PDT) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26T8HqWK011242 for ; Fri, 29 Jul 2022 08:27: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 : mime-version : content-transfer-encoding; s=pp1; bh=daynlHv7VtDmf5b4t+9WYbcemt/15Ad5fG6YSWIoXVs=; b=DD3gDm0ucB4rQAp/GDvUIiwiQUIHMi172QBx4uLkVZVK+TOT4GCLMRrisJiecUpnmJGn oZI9+g/VW6M06BU8i4crxKqMnKiIy8NDcGSEV7jMTCPJ3MLU5zf4+O29zpW9pw7eG1cV jztHsmzIImUf65nCj033dCJN8A81rgltZ1rwCn25h3w7KTtFJPmyfk2Nfi7h7NGyVRdy a5eNbwNdFjzv9pAJAO54onN8cZvxZwghztA3swtn8Gl33XKW4ivVkGHaorG7dd4FFWgx aPt4yIOMYqfC+XAeV/TT/DCa8cAUSPEZoJZkeTBdq/NJ/wvHe1KS8g3ZMB1XNXYyM7a0 +A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hmbwu86ug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 29 Jul 2022 08:27:19 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26T8JmI1016247 for ; Fri, 29 Jul 2022 08:27:19 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hmbwu86ty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 08:27:19 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26T8LRcN005009; Fri, 29 Jul 2022 08:27:17 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 3hg96wqbwn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 08:27:17 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26T8REVf15794454 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jul 2022 08:27:14 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 23B675204F; Fri, 29 Jul 2022 08:27:14 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 7535B5204E; Fri, 29 Jul 2022 08:27:13 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: imbrenda@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com, scgl@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH 4/6] lib: s390x: sie: Improve validity handling and make it vm specific Date: Fri, 29 Jul 2022 08:26:31 +0000 Message-Id: <20220729082633.277240-5-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220729082633.277240-1-frankja@linux.ibm.com> References: <20220729082633.277240-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: HGrBPgh11lZWsMp4AMKa38WJsvBfgJVv X-Proofpoint-GUID: kthanfUJ-g47ylCoGopdQai8M64Akl0L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-28_06,2022-07-28_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=561 mlxscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 malwarescore=0 spamscore=0 priorityscore=1501 adultscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207290032 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The current library doesn't support running multiple vms at once as it stores the validity once and not per vm. Let's move the validity handling into the vm and introduce a new function to retrieve the vir. Signed-off-by: Janosch Frank Reviewed-by: Steffen Eiden Reviewed-by: Nico Boehr --- lib/s390x/sie.c | 26 +++++++++++++------------- lib/s390x/sie.h | 6 ++++-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c index 00aff713..c3a53ad6 100644 --- a/lib/s390x/sie.c +++ b/lib/s390x/sie.c @@ -15,19 +15,21 @@ #include #include -static bool validity_expected; -static uint16_t vir; /* Validity interception reason */ - -void sie_expect_validity(void) +void sie_expect_validity(struct vm *vm) { - validity_expected = true; - vir = 0; + vm->validity_expected = true; } -void sie_check_validity(uint16_t vir_exp) +uint16_t sie_get_validity(struct vm *vm) { + return vm->sblk->ipb >> 16; +} + +void sie_check_validity(struct vm *vm, uint16_t vir_exp) +{ + uint16_t vir = sie_get_validity(vm); + report(vir_exp == vir, "VALIDITY: %x", vir); - vir = 0; } void sie_handle_validity(struct vm *vm) @@ -35,11 +37,9 @@ void sie_handle_validity(struct vm *vm) if (vm->sblk->icptcode != ICPT_VALIDITY) return; - vir = vm->sblk->ipb >> 16; - - if (!validity_expected) - report_abort("VALIDITY: %x", vir); - validity_expected = false; + if (!vm->validity_expected) + report_abort("VALIDITY: %x", sie_get_validity(vm)); + vm->validity_expected = false; } void sie(struct vm *vm) diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h index de91ea5a..320c4218 100644 --- a/lib/s390x/sie.h +++ b/lib/s390x/sie.h @@ -233,14 +233,16 @@ struct vm { struct vm_uv uv; /* PV UV information */ /* Ptr to first guest page */ uint8_t *guest_mem; + bool validity_expected; }; extern void sie_entry(void); extern void sie_exit(void); extern void sie64a(struct kvm_s390_sie_block *sblk, struct vm_save_area *save_area); void sie(struct vm *vm); -void sie_expect_validity(void); -void sie_check_validity(uint16_t vir_exp); +void sie_expect_validity(struct vm *vm); +uint16_t sie_get_validity(struct vm *vm); +void sie_check_validity(struct vm *vm, uint16_t vir_exp); void sie_handle_validity(struct vm *vm); void sie_guest_sca_create(struct vm *vm); void sie_guest_create(struct vm *vm, uint64_t guest_mem, uint64_t guest_mem_len); From patchwork Fri Jul 29 08:26:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12932139 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A97AC19F2B for ; Fri, 29 Jul 2022 08:28:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234984AbiG2I20 (ORCPT ); Fri, 29 Jul 2022 04:28:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235646AbiG2I2G (ORCPT ); Fri, 29 Jul 2022 04:28:06 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6295683209 for ; Fri, 29 Jul 2022 01:27:21 -0700 (PDT) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26T8H0sb030704 for ; Fri, 29 Jul 2022 08:27: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 : mime-version : content-transfer-encoding; s=pp1; bh=qQijznDGfkSwnh8BvUM2SBUHsNAt/IG3vM1t6VmAELI=; b=VfceDylOEFq6ILLsLkYic0Ssm9XZpED/ccMAHA39HDhEN8ARD6IyG6GzOI4+C+GW85nk NRlbwQaMQRJKqigXrYQ4eroPNngTZi9fhBWCpjctqEnIeT3lfO8YqhGZT2+cTzoSoQBJ Tf4UI4RxOCAJlDKcG4btMjeHf4kYQNuZiXad/nuJNmaIDFQ5C/A3c1osOZWFOGeXZhpg 6YffSS8ven5dIFo2VD51SBt2HGjUIzjJsoDbNxLB9Hb6qvb5hcxGs6DBW3zboS4HSYoh DJ6z/u86z1GjRX6aKle9KVhK1gWsAsJYCnmJ2EZWxoIc8b50yoLSoqdULupYA9V2y966 9g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hmbw9g849-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 29 Jul 2022 08:27:20 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26T8Isft011945 for ; Fri, 29 Jul 2022 08:27:20 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hmbw9g83f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 08:27:20 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26T8LYwE009756; Fri, 29 Jul 2022 08:27:18 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma06ams.nl.ibm.com with ESMTP id 3hg97tfaxm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 08:27:18 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26T8RTmF26804734 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jul 2022 08:27:29 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E3BA952050; Fri, 29 Jul 2022 08:27:14 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 40E315204E; Fri, 29 Jul 2022 08:27:14 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: imbrenda@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com, scgl@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH 5/6] lib: s390x: Use a new asce for each PV guest Date: Fri, 29 Jul 2022 08:26:32 +0000 Message-Id: <20220729082633.277240-6-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220729082633.277240-1-frankja@linux.ibm.com> References: <20220729082633.277240-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fcRieiiXdWCJVUzNTIjUjwzD5Y4gvVwA X-Proofpoint-ORIG-GUID: vKAQm02RdoX_56ij7B73fghue9T7bmqQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-28_06,2022-07-28_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 clxscore=1015 spamscore=0 bulkscore=0 impostorscore=0 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207290032 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Every PV guest needs its own ASCE so let's copy the topmost table designated by CR1 to create a new ASCE for the PV guest. Before and after SIE we now need to switch ASCEs to and from the PV guest / test ASCE. The SIE assembly function does that automatically. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr --- lib/s390x/asm-offsets.c | 2 ++ lib/s390x/sie.c | 2 ++ lib/s390x/sie.h | 2 ++ lib/s390x/uv.c | 35 +++++++++++++++++++++++++++++++++-- lib/s390x/uv.h | 5 ++--- s390x/cpu.S | 6 ++++++ 6 files changed, 47 insertions(+), 5 deletions(-) diff --git a/lib/s390x/asm-offsets.c b/lib/s390x/asm-offsets.c index fbea3278..f612f327 100644 --- a/lib/s390x/asm-offsets.c +++ b/lib/s390x/asm-offsets.c @@ -75,9 +75,11 @@ int main(void) OFFSET(SIE_SAVEAREA_HOST_GRS, vm_save_area, host.grs[0]); OFFSET(SIE_SAVEAREA_HOST_FPRS, vm_save_area, host.fprs[0]); OFFSET(SIE_SAVEAREA_HOST_FPC, vm_save_area, host.fpc); + OFFSET(SIE_SAVEAREA_HOST_ASCE, vm_save_area, host.asce); OFFSET(SIE_SAVEAREA_GUEST_GRS, vm_save_area, guest.grs[0]); OFFSET(SIE_SAVEAREA_GUEST_FPRS, vm_save_area, guest.fprs[0]); OFFSET(SIE_SAVEAREA_GUEST_FPC, vm_save_area, guest.fpc); + OFFSET(SIE_SAVEAREA_GUEST_ASCE, vm_save_area, guest.asce); OFFSET(STACK_FRAME_INT_BACKCHAIN, stack_frame_int, back_chain); OFFSET(STACK_FRAME_INT_FPC, stack_frame_int, fpc); OFFSET(STACK_FRAME_INT_FPRS, stack_frame_int, fprs); diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c index c3a53ad6..5ba669f1 100644 --- a/lib/s390x/sie.c +++ b/lib/s390x/sie.c @@ -84,6 +84,8 @@ void sie_guest_create(struct vm *vm, uint64_t guest_mem, uint64_t guest_mem_len) /* Guest memory chunks are always 1MB */ assert(!(guest_mem_len & ~HPAGE_MASK)); + /* For non-PV guests we re-use the host's ASCE for ease of use */ + vm->save_area.guest.asce = stctg(1); /* Currently MSO/MSL is the easiest option */ vm->sblk->mso = (uint64_t)guest_mem; vm->sblk->msl = (uint64_t)guest_mem + ((guest_mem_len - 1) & HPAGE_MASK); diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h index 320c4218..3e3605c9 100644 --- a/lib/s390x/sie.h +++ b/lib/s390x/sie.h @@ -205,12 +205,14 @@ union { struct vm_uv { uint64_t vm_handle; uint64_t vcpu_handle; + uint64_t asce; void *conf_base_stor; void *conf_var_stor; void *cpu_stor; }; struct vm_save_regs { + uint64_t asce; uint64_t grs[16]; uint64_t fprs[16]; uint32_t fpc; diff --git a/lib/s390x/uv.c b/lib/s390x/uv.c index 3b4cafa9..99775929 100644 --- a/lib/s390x/uv.c +++ b/lib/s390x/uv.c @@ -76,7 +76,8 @@ void uv_init(void) int cc; /* Let's not do this twice */ - assert(!initialized); + if (initialized) + return; /* Query is done on initialization but let's check anyway */ assert(uvcb_qui.header.rc == 1 || uvcb_qui.header.rc == 0x100); @@ -90,6 +91,25 @@ void uv_init(void) initialized = true; } +/* + * Create a new ASCE for the UV config because they can't be shared + * for security reasons. We just simply copy the top most table into a + * fresh set of allocated pages and use those pages as the asce. + */ +static uint64_t create_asce(void) +{ + void *pgd_new, *pgd_old; + uint64_t asce = stctg(1); + + pgd_new = memalign_pages_flags(PAGE_SIZE, PAGE_SIZE * 4, 0); + pgd_old = (void *)(asce & PAGE_MASK); + + memcpy(pgd_new, pgd_old, PAGE_SIZE * 4); + + asce = __pa(pgd_new) | ASCE_DT_REGION1 | REGION_TABLE_LENGTH | ASCE_P; + return asce; +} + void uv_create_guest(struct vm *vm) { struct uv_cb_cgc uvcb_cgc = { @@ -125,7 +145,8 @@ void uv_create_guest(struct vm *vm) vm->uv.cpu_stor = memalign_pages_flags(PAGE_SIZE, uvcb_qui.cpu_stor_len, 0); uvcb_csc.stor_origin = (uint64_t)vm->uv.cpu_stor; - uvcb_cgc.guest_asce = (uint64_t)stctg(1); + uvcb_cgc.guest_asce = create_asce(); + vm->save_area.guest.asce = uvcb_cgc.guest_asce; uvcb_cgc.guest_sca = (uint64_t)vm->sca; cc = uv_call(0, (uint64_t)&uvcb_cgc); @@ -166,6 +187,16 @@ void uv_destroy_guest(struct vm *vm) assert(cc == 0); free_pages(vm->uv.conf_base_stor); free_pages(vm->uv.conf_var_stor); + + free_pages((void *)(vm->uv.asce & PAGE_MASK)); + memset(&vm->uv, 0, sizeof(vm->uv)); + + /* Convert the sblk back to non-PV */ + vm->save_area.guest.asce = stctg(1); + vm->sblk->sdf = 0; + vm->sblk->sidad = 0; + vm->sblk->pv_handle_cpu = 0; + vm->sblk->pv_handle_config = 0; } int uv_unpack(struct vm *vm, uint64_t addr, uint64_t len, uint64_t tweak) diff --git a/lib/s390x/uv.h b/lib/s390x/uv.h index 44264861..5fe29bda 100644 --- a/lib/s390x/uv.h +++ b/lib/s390x/uv.h @@ -28,9 +28,8 @@ static inline void uv_setup_asces(void) /* We need to have a valid primary ASCE to run guests. */ setup_vm(); - /* Set P bit in ASCE as it is required for PV guests */ - asce = stctg(1) | ASCE_P; - lctlg(1, asce); + /* Grab the ASCE which setup_vm() just set up */ + asce = stctg(1); /* Copy ASCE into home space CR */ lctlg(13, asce); diff --git a/s390x/cpu.S b/s390x/cpu.S index 82b5e25d..45bd551a 100644 --- a/s390x/cpu.S +++ b/s390x/cpu.S @@ -76,6 +76,9 @@ sie64a: .endr stfpc SIE_SAVEAREA_HOST_FPC(%r3) + stctg %c1, %c1, SIE_SAVEAREA_HOST_ASCE(%r3) + lctlg %c1, %c1, SIE_SAVEAREA_GUEST_ASCE(%r3) + # Store scb and save_area pointer into stack frame stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area @@ -102,6 +105,9 @@ sie_exit: # Load guest register save area lg %r14,__SF_SIE_SAVEAREA(%r15) + # Restore the host asce + lctlg %c1, %c1, SIE_SAVEAREA_HOST_ASCE(%r14) + # Store guest's gprs, fprs and fpc stmg %r0,%r13,SIE_SAVEAREA_GUEST_GRS(%r14) # save guest gprs 0-13 .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 From patchwork Fri Jul 29 08:26:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12932138 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B84C6C19F2C for ; Fri, 29 Jul 2022 08:28:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235026AbiG2I21 (ORCPT ); Fri, 29 Jul 2022 04:28:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235494AbiG2I2G (ORCPT ); Fri, 29 Jul 2022 04:28:06 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AD7A8320B for ; Fri, 29 Jul 2022 01:27:22 -0700 (PDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26T8Iirw027644 for ; Fri, 29 Jul 2022 08:27:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=f11gVDeTsmG6afoL+ivYXjEZ8NaliiWL629KbqF9MAw=; b=cFBNfF8vfNLZtqjduDvI9hTikMhvezsTmhJWeY/XCMLlOdfBgmDpIkttZ3UfAvXvUGod xn1whm71r5vaHeuH3gLlMZgHxCxU8ltzB0HcOHJy2bPqoVTjIiQJSzhY4Yl1VTYiCcc4 mb4iOFAWRBI7+adKr6ti51oqs+05ztji90o3YIbbs1wzvFISugsmt8ZCG43IBfj8+3F4 ISh1lPzumaZzcwHkKCS4mgEbffi6jAnVnc+eeplkeXrrmf5VrWdPuCS4MnNNl1bDmQr3 TPUnT+NZelKH6luYU8wQZpCEXL7GWrYr5dekIxMZvzWsz5vtDAdrjM1HO0AG1T0N4zcf kg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hmbx7g63u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 29 Jul 2022 08:27:21 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26T8Jd6E029422 for ; Fri, 29 Jul 2022 08:27:21 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hmbx7g62e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 08:27:21 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26T8K5H9021085; Fri, 29 Jul 2022 08:27:19 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03fra.de.ibm.com with ESMTP id 3hg95ydj0u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 29 Jul 2022 08:27:19 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26T8RULR30736730 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jul 2022 08:27:30 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE3E452051; Fri, 29 Jul 2022 08:27:15 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 0B91A5204E; Fri, 29 Jul 2022 08:27:14 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: imbrenda@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com, scgl@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH 6/6] lib: s390x: sie: Properly populate SCA Date: Fri, 29 Jul 2022 08:26:33 +0000 Message-Id: <20220729082633.277240-7-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220729082633.277240-1-frankja@linux.ibm.com> References: <20220729082633.277240-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: PDuA_l0NWv2X6qDyNelSJ-tBn4-Z1KRD X-Proofpoint-ORIG-GUID: t0ZGbiF6cxi-eaYZKJ_rA4EvFv4-cS3A X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-28_06,2022-07-28_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 spamscore=0 malwarescore=0 clxscore=1015 mlxscore=0 priorityscore=1501 adultscore=0 impostorscore=0 mlxlogscore=674 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207290032 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org CPU0 is the only cpu that's being used but we should still mark it as online and set the SDA in the SCA. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr --- lib/s390x/sie.c | 8 ++++++++ lib/s390x/sie.h | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c index 5ba669f1..acfdff99 100644 --- a/lib/s390x/sie.c +++ b/lib/s390x/sie.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -71,6 +72,13 @@ void sie_guest_sca_create(struct vm *vm) vm->sblk->scaoh = ((uint64_t)vm->sca >> 32); vm->sblk->scaol = (uint64_t)vm->sca & ~0x3fU; vm->sblk->ecb2 |= ECB2_ESCA; + + /* Enable SIGP sense running interpretation */ + vm->sblk->ecb |= ECB_SRSI; + + /* We assume that cpu 0 is always part of the vm */ + vm->sca->mcn[0] = BIT(63); + vm->sca->cpu[0].sda = (uint64_t)vm->sblk; } /* Initializes the struct vm members like the SIE control block. */ diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h index 3e3605c9..a27a8401 100644 --- a/lib/s390x/sie.h +++ b/lib/s390x/sie.h @@ -202,6 +202,39 @@ union { uint64_t pv_grregs[16]; /* 0x0380 */ } __attribute__((packed)); +union esca_sigp_ctrl { + uint16_t value; + struct { + uint8_t c : 1; + uint8_t reserved: 7; + uint8_t scn; + }; +}; + +struct esca_entry { + union esca_sigp_ctrl sigp_ctrl; + uint16_t reserved1[3]; + uint64_t sda; + uint64_t reserved2[6]; +}; + +union ipte_control { + unsigned long val; + struct { + unsigned long k : 1; + unsigned long kh : 31; + unsigned long kg : 32; + }; +}; + +struct esca_block { + union ipte_control ipte_control; + uint64_t reserved1[7]; + uint64_t mcn[4]; + uint64_t reserved2[20]; + struct esca_entry cpu[256]; +}; + struct vm_uv { uint64_t vm_handle; uint64_t vcpu_handle; @@ -230,7 +263,7 @@ struct vm_save_area { struct vm { struct kvm_s390_sie_block *sblk; struct vm_save_area save_area; - void *sca; /* System Control Area */ + struct esca_block *sca; /* System Control Area */ uint8_t *crycb; /* Crypto Control Block */ struct vm_uv uv; /* PV UV information */ /* Ptr to first guest page */