From patchwork Thu Oct 20 09:00:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13012819 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 40523C433FE for ; Thu, 20 Oct 2022 09:01:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230041AbiJTJBP (ORCPT ); Thu, 20 Oct 2022 05:01:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbiJTJBI (ORCPT ); Thu, 20 Oct 2022 05:01:08 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9692118C41C for ; Thu, 20 Oct 2022 02:01:06 -0700 (PDT) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29K90Juf019809 for ; Thu, 20 Oct 2022 09:01:05 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=7t6G/p1D7bR71EJsY8UABxSM7JbF2MlSFFs5n06w8MY=; b=YcEgKIOVtHdMdEdT5jBLhxWXtrnutsgM26/NRK49MBhWXrCv9uB9GF6NDG4Fe4FXot8b QU24N6gwjQL2CVTTKUXjX5Yz3tnajaeijGLvKUxoP8wxgEXfsE3VK/dYCiHJqaCjuiEn kehmvjTucY1lrM2rikmKUBNdXSqMfR4oyNF+p+w9kP8zWbu2YtoK4XrdoAYv14huQdNL siLWYui+Wuf57S3KY932cKbVyKZlbev+DIZEbt0bQp/TPG2ApTFHhJTdzcMLgdRTSzet MD8m092Z01z5XMbboOLilB6xWPjpjzqtAVDkX0IZ8Os6sPy4S5WynfIWifowfSZ6lbd4 uw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3katy3wncp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 20 Oct 2022 09:01:05 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29K8dBmx037607 for ; Thu, 20 Oct 2022 09:01:05 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3katy3wnbk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 09:01:05 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29K8oifB017389; Thu, 20 Oct 2022 09:01:03 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma01fra.de.ibm.com with ESMTP id 3k99fn3ya9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 09:01:03 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29K910p739912066 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Oct 2022 09:01:00 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE2A24203F; Thu, 20 Oct 2022 09:00:59 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4970042041; Thu, 20 Oct 2022 09:00:59 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 20 Oct 2022 09:00:59 +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 v2 1/7] s390x: snippets: asm: Add a macro to write an exception PSW Date: Thu, 20 Oct 2022 09:00:03 +0000 Message-Id: <20221020090009.2189-2-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020090009.2189-1-frankja@linux.ibm.com> References: <20221020090009.2189-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 1E6zS8iamgfrseSbfLzHVe87oFW1ypne X-Proofpoint-GUID: uyUT1EXK3B9_3QJrIf4OjBQQ-eEBhdXi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-20_02,2022-10-19_04,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=973 adultscore=0 impostorscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 spamscore=0 mlxscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210200049 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 Reviewed-by: Claudio Imbrenda --- 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 Thu Oct 20 09:00:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13012818 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 8AC1DC4332F for ; Thu, 20 Oct 2022 09:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230033AbiJTJBM (ORCPT ); Thu, 20 Oct 2022 05:01:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbiJTJBI (ORCPT ); Thu, 20 Oct 2022 05:01:08 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1818018C434 for ; Thu, 20 Oct 2022 02:01:07 -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 29K88Ktx029975 for ; Thu, 20 Oct 2022 09:01:06 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=724alMVyjVoXE/wbtbUO15rfLMT4SRSUrQ6fqcjDUXM=; b=L+Ftg0b/PsH/piwyij7AIYc1NoDu6IJmf/oj148zqsygYf8v8dQxXH+6+fwygbqAyUhw uQ5/ReEu4LijT4J1XZ/A8KVggajKwhkBvr0if329ZOgzXin/fEJUK8j/OFQ6LnQi7aG2 8UDKBBl81yiHXQSl8J1BCIS4wYh0H7McM+Bo9P25KUC2JKt9sEyiEKpoGTbcP/Jp9mh3 yy/jPFHWu47flAb3aMLjBtb1NnCarmY0QMtK2mVacxEM+682ncLFQFHdJ7iW4Qdkyq7f hL9hUri5yFTdu6EZyUk/L/r1f7IbysN2TPgANXMn7uupaRJRDimg6tF/62ozN6QnAjk8 1g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kb1rpb9qr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 20 Oct 2022 09:01:06 +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 29K89WGT001782 for ; Thu, 20 Oct 2022 09:01:05 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kb1rpb9q0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 09:01:05 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29K8nfLA004148; Thu, 20 Oct 2022 09:01:04 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma05fra.de.ibm.com with ESMTP id 3k7mg8xexw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 09:01:03 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29K9107s52756780 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Oct 2022 09:01:00 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD56542045; Thu, 20 Oct 2022 09:01:00 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1FF254203F; Thu, 20 Oct 2022 09:01:00 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 20 Oct 2022 09:01:00 +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 v2 2/7] s390x: MAKEFILE: Use $< instead of pathsubst Date: Thu, 20 Oct 2022 09:00:04 +0000 Message-Id: <20221020090009.2189-3-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020090009.2189-1-frankja@linux.ibm.com> References: <20221020090009.2189-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: il1TzWVxm39UM1LlB5GajHdNf8tF2J2D X-Proofpoint-ORIG-GUID: LHZV14I9W13Ti6hwFOoS95UwjryPKlUM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-20_02,2022-10-19_04,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 spamscore=0 priorityscore=1501 mlxlogscore=689 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210200049 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 Reviewed-by: Claudio Imbrenda --- s390x/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s390x/Makefile b/s390x/Makefile index 649486f2..3b175015 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -136,7 +136,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 Thu Oct 20 09:00:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13012823 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 B389BC4332F for ; Thu, 20 Oct 2022 09:01:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230043AbiJTJBU (ORCPT ); Thu, 20 Oct 2022 05:01:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230035AbiJTJBO (ORCPT ); Thu, 20 Oct 2022 05:01:14 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4118F1905D9 for ; Thu, 20 Oct 2022 02:01:12 -0700 (PDT) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29K8axjB031759 for ; Thu, 20 Oct 2022 09:01:12 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=8+bPRMF0/V5l4Ks5nlMf6/hz5nxu2DKV0YAvPoP/+6k=; b=cK59RW6lusMmD872ppON9MH387B9hLJeqAJuvMFqYfn4tAXbxsG9vbkx42UE6TMZ9mO4 VMkhmKB9Nr7pkzozRMmhlsUZUzS35OdfjnT9S5nig/STVK6zAe1ctUx5+Q+rd4c4r2BC qEQfr04BhF7Al+siU7txbUbsW+SJ7K8M1P8ENtoH7qFV9hgtRkQojghllgBrOcvKItJO SBo5rELgtDTFHTN8OMjKxKfcsijNZxCXZjABpmn08sTdE8HpzkAeqqyue4umm12NtNKN GQ0lS2q8dIMxTczGBEUk+65p0+ybFrdgubI/r4DSGiLnbBJ9X57D+PyxLo2658BD9GOK 7w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kb1d5kjwe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 20 Oct 2022 09:01:12 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29K8iuLs024705 for ; Thu, 20 Oct 2022 09:01:11 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 3kb1d5kjt2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 09:01:11 +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 29K8pWNV018645; Thu, 20 Oct 2022 09:01:05 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04fra.de.ibm.com with ESMTP id 3k7mg96ena-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 09:01:04 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29K8tx9t46531002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Oct 2022 08:55:59 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC53E42042; Thu, 20 Oct 2022 09:01:01 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F341B4203F; Thu, 20 Oct 2022 09:01:00 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 20 Oct 2022 09:01:00 +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 v2 3/7] s390x: Add a linker script to assembly snippets Date: Thu, 20 Oct 2022 09:00:05 +0000 Message-Id: <20221020090009.2189-4-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020090009.2189-1-frankja@linux.ibm.com> References: <20221020090009.2189-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: WrfrGdYdICAFNBtc_5dhn-xSYioyNSY2 X-Proofpoint-ORIG-GUID: MqpGxiVuSCQRTsmgCuJ59ZaMuWWHqb0A X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-20_02,2022-10-19_04,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210200053 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 - We can remove a lot of the offset variables from lib/s390x/snippet.h 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 | 14 +++++--------- s390x/Makefile | 18 ++++++++++++++---- s390x/mvpg-sie.c | 2 +- s390x/pv-diags.c | 6 +++--- s390x/snippets/asm/flat.lds | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 17 deletions(-) create mode 100644 s390x/snippets/asm/flat.lds diff --git a/lib/s390x/snippet.h b/lib/s390x/snippet.h index b17b2a4c..fcd04081 100644 --- a/lib/s390x/snippet.h +++ b/lib/s390x/snippet.h @@ -32,8 +32,6 @@ #define SNIPPET_PV_TWEAK0 0x42UL #define SNIPPET_PV_TWEAK1 0UL -#define SNIPPET_OFF_C 0 -#define SNIPPET_OFF_ASM 0x4000 /* @@ -57,15 +55,14 @@ static const struct psw snippet_psw = { * @vm: VM that this function will populated, has to be initialized already * @gbin: Snippet gbin data pointer * @gbin_len: Length of the gbin data - * @off: Offset from guest absolute 0x0 where snippet is copied to */ static inline void snippet_init(struct vm *vm, const char *gbin, - uint64_t gbin_len, uint64_t off) + uint64_t gbin_len) { uint64_t mso = vm->sblk->mso; /* Copy test image to guest memory */ - memcpy((void *)mso + off, gbin, gbin_len); + memcpy((void *)mso, gbin, gbin_len); /* Setup guest PSW */ vm->sblk->gpsw = snippet_psw; @@ -87,23 +84,22 @@ static inline void snippet_init(struct vm *vm, const char *gbin, * @hdr: Snippet SE header data pointer * @gbin_len: Length of the gbin data * @hdr_len: Length of the hdr data - * @off: Offset from guest absolute 0x0 where snippet is copied to */ static inline void snippet_pv_init(struct vm *vm, const char *gbin, const char *hdr, uint64_t gbin_len, - uint64_t hdr_len, uint64_t off) + uint64_t hdr_len) { uint64_t tweak[2] = {SNIPPET_PV_TWEAK0, SNIPPET_PV_TWEAK1}; uint64_t mso = vm->sblk->mso; int i; - snippet_init(vm, gbin, gbin_len, off); + snippet_init(vm, gbin, gbin_len); uv_create_guest(vm); uv_set_se_hdr(vm->uv.vm_handle, (void *)hdr, hdr_len); /* Unpack works on guest addresses so we only need off */ - uv_unpack(vm, off, gbin_len, tweak[0]); + uv_unpack(vm, 0, gbin_len, tweak[0]); uv_verify_load(vm); /* diff --git a/s390x/Makefile b/s390x/Makefile index 3b175015..0eaa72f4 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -124,6 +124,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 $@ $< @@ -131,17 +138,20 @@ $(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 $(SNIPPET_DIR)/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) - $(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/snippets/c/flat.lds $< $(snippet_lib) $(FLATLIBS) + $(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/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' $@ $(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..17e209ad 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)); /* 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..d472c994 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); 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); 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); /* 0x44 */ report_prefix_push("0x44"); diff --git a/s390x/snippets/asm/flat.lds b/s390x/snippets/asm/flat.lds new file mode 100644 index 00000000..388d7d5d --- /dev/null +++ b/s390x/snippets/asm/flat.lds @@ -0,0 +1,35 @@ +SECTIONS +{ + .lowcore : { + /* Restart new PSW for booting via PSW restart. */ + . = 0x1a0; + QUAD(0x0000000180000000) + QUAD(0x0000000000004000) + /* + * Invalid PGM new PSW so we hopefully get a code 8 + * intercept on a PGM for PV snippets. + */ + . = 0x1d0; + QUAD(0x0008000000000000) + QUAD(0x0000000000000001) + } + . = 0x4000; + .text : { + *(.text) + *(.text.*) + } + . = ALIGN(64K); + etext = .; + . = ALIGN(16); + .data : { + *(.data) + *(.data.rel*) + } + . = ALIGN(16); + .rodata : { *(.rodata) *(.rodata.*) } + . = ALIGN(16); + __bss_start = .; + .bss : { *(.bss) } + __bss_end = .; + . = ALIGN(64K); +} From patchwork Thu Oct 20 09:00:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13012840 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 68FD0C4332F for ; Thu, 20 Oct 2022 09:06:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229456AbiJTJGa (ORCPT ); Thu, 20 Oct 2022 05:06:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231124AbiJTJG0 (ORCPT ); Thu, 20 Oct 2022 05:06:26 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0F4719E917 for ; Thu, 20 Oct 2022 02:06:13 -0700 (PDT) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29K8Tf65019989 for ; Thu, 20 Oct 2022 09:06:12 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=PoiFRHhjHxGo3hzEWog+BpHQt4LJwlXpby4nWEEk1Eg=; b=J2ZLBiXF9B0vt8ECpk//dFLJufIdQbjAp3PIyoZWgNu7uKgNyfPbzyNh9ibXmqI+z+ZL z2odA4pHYJXL3MB+UzS30qW44j3nGb7EK/AOl+O6X3T3TQx6eRfEfo4Wfos9oeH/SlNj 80wDMYpOus0FcRjdM51XmgxnE1h4k13/ppPjl0PcKqv16gKLbJBLEfD4hPPHGe+fdw3N JdYWy6xZNK08Oh69hcmVJnShFgOUJuQDMxH8mjmV0Pd1D7TY3N5oTMUVkhfSFFePSanA crK32zEXiR4lP4NypsEtmuOOFVZ+dfbKD3OTC6QeiaJVZGl7TuvuuLwoKpQl1YVZwHTF rw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3katy3wst7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 20 Oct 2022 09:06:11 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29K8bD7X028036 for ; Thu, 20 Oct 2022 09:06:11 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3katy3wspr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 09:06:11 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29K8nxQd004185; Thu, 20 Oct 2022 09:01:05 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma05fra.de.ibm.com with ESMTP id 3k7mg8xey1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 09:01:05 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29K912xo66912642 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Oct 2022 09:01:02 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 82A3E42041; Thu, 20 Oct 2022 09:01:02 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D29054203F; Thu, 20 Oct 2022 09:01:01 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 20 Oct 2022 09:01:01 +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 v2 4/7] lib: s390x: sie: Improve validity handling and make it vm specific Date: Thu, 20 Oct 2022 09:00:06 +0000 Message-Id: <20221020090009.2189-5-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020090009.2189-1-frankja@linux.ibm.com> References: <20221020090009.2189-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: WHwPQPipU9dsmGLz3WCwwnhPflcW4XNu X-Proofpoint-GUID: TJGGyAly2zrIq8lPhAejsYxZtx-ghbyv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-20_02,2022-10-19_04,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=515 adultscore=0 impostorscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 spamscore=0 mlxscore=0 malwarescore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210200053 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 Reviewed-by: Claudio Imbrenda --- lib/s390x/sie.c | 27 ++++++++++++++------------- lib/s390x/sie.h | 6 ++++-- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c index 00aff713..3fee3def 100644 --- a/lib/s390x/sie.c +++ b/lib/s390x/sie.c @@ -15,19 +15,22 @@ #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) { + assert(vm->sblk->icptcode == ICPT_VALIDITY); + 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 +38,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 Thu Oct 20 09:00:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13012822 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 694A2C433FE for ; Thu, 20 Oct 2022 09:01:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230086AbiJTJBT (ORCPT ); Thu, 20 Oct 2022 05:01:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230010AbiJTJBM (ORCPT ); Thu, 20 Oct 2022 05:01:12 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E64E1170DC9 for ; Thu, 20 Oct 2022 02:01:09 -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 29K8o4Tx011246 for ; Thu, 20 Oct 2022 09:01: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 : mime-version : content-transfer-encoding; s=pp1; bh=MgVLPgU63u9X6Q/usV/GR8GAIFPTqvBeU8rGLF6Nvfk=; b=EC6CcfmpHHTNA2pROFvdcp8xRRLlk+SSSLlrHkUDE9Xg9x9xuDre0H2fOoLy7WBgwTxv MGM+b1wlYxRnaPsjiSFZimIywvORrHyiSCV59kdmeWEh+FoV832NcazWqeTOuHOLw84+ 0JvrsKs/f3zQYvnyDA8noABo+tgt2Cv5BNAotuhV4cPs1S8GaxM5NzsyiTjcWXEIvBwZ w1R+XWarAZgGXHU/v3ftJPsCR+6UbTyakq61l79ZLcOJMwYSGIfx6F5nHHjDgt9cF3kt gcuNI+XFOshvmJoi4GnWnzEKnsyWFDjQ5jBgvEaDuo+tGS+eh6XU2rWmt3/be0OnyOWk WQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kb35w89y9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 20 Oct 2022 09:01:08 +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 29K8opoh014349 for ; Thu, 20 Oct 2022 09:01:08 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 3kb35w89xc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 09:01:08 +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 29K8pWnf016814; Thu, 20 Oct 2022 09:01:06 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04ams.nl.ibm.com with ESMTP id 3k7mg98hjh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 09:01:06 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29K91aOw52953442 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Oct 2022 09:01:36 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5804B42049; Thu, 20 Oct 2022 09:01:03 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8FC942041; Thu, 20 Oct 2022 09:01:02 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 20 Oct 2022 09:01:02 +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 v2 5/7] lib: s390x: Use a new asce for each PV guest Date: Thu, 20 Oct 2022 09:00:07 +0000 Message-Id: <20221020090009.2189-6-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020090009.2189-1-frankja@linux.ibm.com> References: <20221020090009.2189-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: UbTLRNoK5h9Z4jjiDWQdcU_7YFsnQQrf X-Proofpoint-GUID: uCQZ_Fe_FCJYK1BewFeHGW0DMQ8SttJl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-20_02,2022-10-19_04,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 bulkscore=0 phishscore=0 adultscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210200049 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 --- lib/s390x/asm-offsets.c | 2 ++ lib/s390x/sie.c | 2 ++ lib/s390x/sie.h | 2 ++ lib/s390x/uv.c | 24 +++++++++++++++++++++++- lib/s390x/uv.h | 5 ++--- s390x/cpu.S | 6 ++++++ 6 files changed, 37 insertions(+), 4 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 3fee3def..6efad965 100644 --- a/lib/s390x/sie.c +++ b/lib/s390x/sie.c @@ -85,6 +85,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..0b6eb843 100644 --- a/lib/s390x/uv.c +++ b/lib/s390x/uv.c @@ -90,6 +90,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 +144,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 +186,8 @@ 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)); } 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 Thu Oct 20 09:00:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13012821 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 505F4C43217 for ; Thu, 20 Oct 2022 09:01:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229940AbiJTJBS (ORCPT ); Thu, 20 Oct 2022 05:01:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229995AbiJTJBM (ORCPT ); Thu, 20 Oct 2022 05:01:12 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2B8F17999F for ; Thu, 20 Oct 2022 02:01:10 -0700 (PDT) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29K8ckh4024523 for ; Thu, 20 Oct 2022 09:01:10 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=uUzX15mnK6AvromgOewf8Lqoj0s9WKzVaSAXFcvhph0=; b=sODe3himFX0ncskr1urIJxaq+Y2ZY3FkVWHXFINHMgxNmmAHc3CtbLJzBejlL2BD6hSf w7XkcZMMGAonp5JyG0d/e4NMkRNnJcgcZ/j2f3IMC51V7eKwW1iD0zKs4aMDpjkz9wLW vc/cfZkHiotbV7T0E0Uc7OLUIBC8HrKbxt103AhJNTt0ka4+fvkYaMBWYYV/K8yHyNvm OwwZf30b2k24JwMYFYfW4H9NdyyT7Kkdyn/jA6V7aQEhsnTJwahm91eVXvORY5vNcztc aCc+XhXLBLauxX8AclgQa6w0DWZTK9QmczyoQx64HWzb9mlLK9rWL9eOfXg0fs4Pb/tR DA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kb29q20kj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 20 Oct 2022 09:01:09 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29K8fJCW001946 for ; Thu, 20 Oct 2022 09:01:09 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kb29q20j8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 09:01:09 +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 29K8oWx7030777; Thu, 20 Oct 2022 09:01:07 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03fra.de.ibm.com with ESMTP id 3k7mg9eemv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 09:01:07 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29K914WQ3736182 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Oct 2022 09:01:04 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3675F4203F; Thu, 20 Oct 2022 09:01:04 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7DCA942049; Thu, 20 Oct 2022 09:01:03 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 20 Oct 2022 09:01:03 +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 v2 6/7] lib: s390x: Enable reusability of VMs that were in PV mode Date: Thu, 20 Oct 2022 09:00:08 +0000 Message-Id: <20221020090009.2189-7-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020090009.2189-1-frankja@linux.ibm.com> References: <20221020090009.2189-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: zplu6VWwaCy_RVMAGivglUifweGUDMUU X-Proofpoint-GUID: tt4mwpp302hAPIcMBUsf80xsEqlSB-8b X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-20_02,2022-10-19_04,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 malwarescore=0 phishscore=0 impostorscore=0 clxscore=1015 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210200049 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Convert the sblk to non-PV when the PV guest is destroyed. Early return in uv_init() instead of running into the assert. This is necessary since snippet_pv_init() will always call uv_init(). Signed-off-by: Janosch Frank Reviewed-by: Claudio Imbrenda --- lib/s390x/uv.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/s390x/uv.c b/lib/s390x/uv.c index 0b6eb843..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); @@ -188,6 +189,14 @@ void uv_destroy_guest(struct vm *vm) 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) From patchwork Thu Oct 20 09:00:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13012820 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 CCEEFC4332F for ; Thu, 20 Oct 2022 09:01:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230046AbiJTJBR (ORCPT ); Thu, 20 Oct 2022 05:01:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229973AbiJTJBN (ORCPT ); Thu, 20 Oct 2022 05:01:13 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4BD8186D7E for ; Thu, 20 Oct 2022 02:01:11 -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 29K88PbM030506 for ; Thu, 20 Oct 2022 09:01: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 : mime-version : content-transfer-encoding; s=pp1; bh=XcLqTkx/3HhjHwUli8dPYx3iooAzP3ptN7mqnxSkkCI=; b=Y0fSxtu3WBDCCJHJunnWX8TxsOJklcY56h54wb1Pm91EKogkVQVzPP3ytMQfZN5dFq1q AlTKVcte6hTvXQOCJxal/08avChNf3yozP51Mcgvm2A2gaKgE5wI4XMLVQduqiYMfFFi r3iSiyPZQcQA+tiJTbzJWqQKqwQqlPr3VCL8DApvbaoQ1pCzmiONyE4jn0uq5jQQ6a1X 4CxsdHwXjfgCCchW3sTNs4gc9bnAvbcy//SvUD9kAzukx6EMdqBexM3/Y3kiGpS760BO 4kgURv6jc73WpSjm7EKjTlJBiIUxIQix4h0aiP5mbe/aFDlJCH5oP0dIPueUikawWAyt zQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kb1rpb9te-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 20 Oct 2022 09:01:10 +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 29K88aW8031496 for ; Thu, 20 Oct 2022 09:01:10 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kb1rpb9sa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 09:01:10 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29K8pEvl005033; Thu, 20 Oct 2022 09:01:08 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03ams.nl.ibm.com with ESMTP id 3k7mg98mh7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Oct 2022 09:01:08 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29K915WJ66584890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Oct 2022 09:01:05 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0BFCA42042; Thu, 20 Oct 2022 09:01:05 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5C9D64203F; Thu, 20 Oct 2022 09:01:04 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 20 Oct 2022 09:01:04 +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 v2 7/7] lib: s390x: sie: Properly populate SCA Date: Thu, 20 Oct 2022 09:00:09 +0000 Message-Id: <20221020090009.2189-8-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020090009.2189-1-frankja@linux.ibm.com> References: <20221020090009.2189-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: r9cRYLFdnUIcjPgbRGAPDXJnNPBA2wN2 X-Proofpoint-ORIG-GUID: H5n--QBLRkgVRgfI8g-FSQmHp_Nc7y54 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-20_02,2022-10-19_04,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 spamscore=0 priorityscore=1501 mlxlogscore=678 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210200049 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 Reviewed-by: Claudio Imbrenda --- 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 6efad965..a71985b6 100644 --- a/lib/s390x/sie.c +++ b/lib/s390x/sie.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -72,6 +73,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 */