From patchwork Tue Oct 25 11:43:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019090 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 11DC2C04A95 for ; Tue, 25 Oct 2022 11:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232052AbiJYLoB (ORCPT ); Tue, 25 Oct 2022 07:44:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231811AbiJYLnz (ORCPT ); Tue, 25 Oct 2022 07:43:55 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEA451735AA for ; Tue, 25 Oct 2022 04:43:52 -0700 (PDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29PB8VKT011743 for ; Tue, 25 Oct 2022 11:43:52 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=CJZF97+gkskPQAwfBvUvguO3jii+7kPjgU9+Jx5RgUw=; b=jafm+DORJsES+EDCBrRosjobXejqIq1AG5VbYOqR5JT9pxXOjEQY3OJPLI/3qPhNDNPX +Ct1FyMj2MtogBZ3nooDtnv4G9pTO9lH2exwbIfTXnG3FVpz8BLdQ7dr43msba1RpeDD nElE2aRR+HB9mus6VTBGXZ1rXXx2kGfTf677GudHsUeWqexJSw6Vbl8b1wPTX0r9Rc5E q2e7sKvTDMzjLIU5sLlQl9QuRQMPbs7pYBmMsUBudH6wgAa2HY8BKqBy43LTrugWwt4N qsMiXBRi3V5zWR7OMJ9Szk+f2v+tn1sGJMPS1u0EOmQkmzbclKQeN/ReBqG7uJmGHaf1 pA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kee02tdm6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:51 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29PB8mkU012955 for ; Tue, 25 Oct 2022 11:43:51 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kee02tdkq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:51 +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 29PBd6Wv011295; Tue, 25 Oct 2022 11:43:49 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma01fra.de.ibm.com with ESMTP id 3kc8593yv2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:49 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBhkB94195048 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:43:46 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC9F2AE045; Tue, 25 Oct 2022 11:43:45 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A9D33AE053; Tue, 25 Oct 2022 11:43:45 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:45 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Janis Schoetterl-Glausch , Nico Boehr Subject: [kvm-unit-tests GIT PULL 01/22] s390x: Add specification exception test Date: Tue, 25 Oct 2022 13:43:24 +0200 Message-Id: <20221025114345.28003-2-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: RBwwpG7CmPIrjGREK0yumShe8AIvkL9y X-Proofpoint-ORIG-GUID: jftk3mH8RTpIKjyiDjWsgwGaXI4Y0_sT 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 phishscore=0 adultscore=0 malwarescore=0 mlxscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janis Schoetterl-Glausch Generate specification exceptions and check that they occur. Signed-off-by: Janis Schoetterl-Glausch Reviewed-by: Nico Boehr Reviewed-by: Janosch Frank Message-Id: <20220928201710.3185449-2-scgl@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- s390x/Makefile | 1 + lib/s390x/asm/arch_def.h | 5 + s390x/spec_ex.c | 203 +++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 + 4 files changed, 212 insertions(+) create mode 100644 s390x/spec_ex.c diff --git a/s390x/Makefile b/s390x/Makefile index 649486f2..6acb7b16 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -27,6 +27,7 @@ tests += $(TEST_DIR)/uv-host.elf tests += $(TEST_DIR)/edat.elf tests += $(TEST_DIR)/mvpg-sie.elf tests += $(TEST_DIR)/spec_ex-sie.elf +tests += $(TEST_DIR)/spec_ex.elf tests += $(TEST_DIR)/firq.elf tests += $(TEST_DIR)/epsw.elf tests += $(TEST_DIR)/adtl-status.elf diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h index b92291e8..aca3af8e 100644 --- a/lib/s390x/asm/arch_def.h +++ b/lib/s390x/asm/arch_def.h @@ -41,6 +41,11 @@ struct psw { uint64_t addr; }; +struct short_psw { + uint32_t mask; + uint32_t addr; +}; + struct cpu { struct lowcore *lowcore; uint64_t *stack; diff --git a/s390x/spec_ex.c b/s390x/spec_ex.c new file mode 100644 index 00000000..2d4adb8c --- /dev/null +++ b/s390x/spec_ex.c @@ -0,0 +1,203 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright IBM Corp. 2021, 2022 + * + * Specification exception test. + * Tests that specification exceptions occur when expected. + * + * Can be extended by adding triggers to spec_ex_triggers, see comments below. + */ +#include +#include +#include +#include + +/* toggled to signal occurrence of invalid psw fixup */ +static bool invalid_psw_expected; +static struct psw expected_psw; +static struct psw invalid_psw; +static struct psw fixup_psw; + +/* + * The standard program exception handler cannot deal with invalid old PSWs, + * especially not invalid instruction addresses, as in that case one cannot + * find the instruction following the faulting one from the old PSW. + * The PSW to return to is set by load_psw. + */ +static void fixup_invalid_psw(struct stack_frame_int *stack) +{ + assert_msg(invalid_psw_expected, + "Unexpected invalid PSW during program interrupt fixup: %#lx %#lx", + lowcore.pgm_old_psw.mask, lowcore.pgm_old_psw.addr); + /* signal occurrence of invalid psw fixup */ + invalid_psw_expected = false; + invalid_psw = lowcore.pgm_old_psw; + lowcore.pgm_old_psw = fixup_psw; +} + +/* + * Load possibly invalid psw, but setup fixup_psw before, + * so that fixup_invalid_psw() can bring us back onto the right track. + * Also acts as compiler barrier, -> none required in expect/check_invalid_psw + */ +static void load_psw(struct psw psw) +{ + uint64_t scratch; + + /* + * The fixup psw is the current psw with the instruction address replaced + * by the address of the nop following the instruction loading the new psw. + */ + fixup_psw.mask = extract_psw_mask(); + asm volatile ( "larl %[scratch],0f\n" + " stg %[scratch],%[fixup_addr]\n" + " lpswe %[psw]\n" + "0: nop\n" + : [scratch] "=&d" (scratch), + [fixup_addr] "=&T" (fixup_psw.addr) + : [psw] "Q" (psw) + : "cc", "memory" + ); +} + +static void load_short_psw(struct short_psw psw) +{ + uint64_t scratch; + + fixup_psw.mask = extract_psw_mask(); + asm volatile ( "larl %[scratch],0f\n" + " stg %[scratch],%[fixup_addr]\n" + " lpsw %[psw]\n" + "0: nop\n" + : [scratch] "=&d" (scratch), + [fixup_addr] "=&T" (fixup_psw.addr) + : [psw] "Q" (psw) + : "cc", "memory" + ); +} + +static void expect_invalid_psw(struct psw psw) +{ + expected_psw = psw; + invalid_psw_expected = true; +} + +static int check_invalid_psw(void) +{ + /* Since the fixup sets this to false we check for false here. */ + if (!invalid_psw_expected) { + if (expected_psw.mask == invalid_psw.mask && + expected_psw.addr == invalid_psw.addr) + return 0; + report_fail("Wrong invalid PSW"); + } else { + report_fail("Expected exception due to invalid PSW"); + } + return 1; +} + +/* For normal PSWs bit 12 has to be 0 to be a valid PSW*/ +static int psw_bit_12_is_1(void) +{ + struct psw invalid = { + .mask = BIT(63 - 12), + .addr = 0x00000000deadbeee + }; + + expect_invalid_psw(invalid); + load_psw(invalid); + return check_invalid_psw(); +} + +/* A short PSW needs to have bit 12 set to be valid. */ +static int short_psw_bit_12_is_0(void) +{ + struct psw invalid = { + .mask = BIT(63 - 12), + .addr = 0x00000000deadbeee + }; + struct short_psw short_invalid = { + .mask = 0x0, + .addr = 0xdeadbeee + }; + + expect_invalid_psw(invalid); + load_short_psw(short_invalid); + /* + * lpsw may optionally check bit 12 before loading the new psw + * -> cannot check the expected invalid psw like with lpswe + */ + return 0; +} + +static int bad_alignment(void) +{ + uint32_t words[5] __attribute__((aligned(16))); + uint32_t (*bad_aligned)[4] = (uint32_t (*)[4])&words[1]; + + /* LOAD PAIR FROM QUADWORD (LPQ) requires quadword alignment */ + asm volatile ("lpq %%r6,%[bad]" + : : [bad] "T" (*bad_aligned) + : "%r6", "%r7" + ); + return 0; +} + +static int not_even(void) +{ + uint64_t quad[2] __attribute__((aligned(16))) = {0}; + + asm volatile (".insn rxy,0xe3000000008f,%%r7,%[quad]" /* lpq %%r7,%[quad] */ + : : [quad] "T" (quad) + : "%r7", "%r8" + ); + return 0; +} + +/* + * Harness for specification exception testing. + * func only triggers exception, reporting is taken care of automatically. + */ +struct spec_ex_trigger { + const char *name; + int (*func)(void); + void (*fixup)(struct stack_frame_int *stack); +}; + +/* List of all tests to execute */ +static const struct spec_ex_trigger spec_ex_triggers[] = { + { "psw_bit_12_is_1", &psw_bit_12_is_1, &fixup_invalid_psw }, + { "short_psw_bit_12_is_0", &short_psw_bit_12_is_0, &fixup_invalid_psw }, + { "bad_alignment", &bad_alignment, NULL }, + { "not_even", ¬_even, NULL }, + { NULL, NULL, NULL }, +}; + +static void test_spec_ex(const struct spec_ex_trigger *trigger) +{ + int rc; + + expect_pgm_int(); + register_pgm_cleanup_func(trigger->fixup); + rc = trigger->func(); + register_pgm_cleanup_func(NULL); + /* test failed, nothing to be done, reporting responsibility of trigger */ + if (rc) + return; + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); +} + +int main(int argc, char **argv) +{ + unsigned int i; + + report_prefix_push("specification exception"); + for (i = 0; spec_ex_triggers[i].name; i++) { + report_prefix_push(spec_ex_triggers[i].name); + test_spec_ex(&spec_ex_triggers[i]); + report_prefix_pop(); + } + report_prefix_pop(); + + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index f9f102ab..412fd130 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -114,6 +114,9 @@ file = mvpg-sie.elf [spec_ex-sie] file = spec_ex-sie.elf +[spec_ex] +file = spec_ex.elf + [firq-linear-cpu-ids-kvm] file = firq.elf timeout = 20 From patchwork Tue Oct 25 11:43:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019088 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 A9205C38A2D for ; Tue, 25 Oct 2022 11:43:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231962AbiJYLn5 (ORCPT ); Tue, 25 Oct 2022 07:43:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231766AbiJYLnz (ORCPT ); Tue, 25 Oct 2022 07:43:55 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3D8217536E for ; Tue, 25 Oct 2022 04:43:52 -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 29PB8AoG028295 for ; Tue, 25 Oct 2022 11:43:52 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=lyWRm8FGtHluZi/wSCBoqJpwhGcDDBgsr5xGcfxN7WQ=; b=DaRvNlJFeOp3jb1jQXlFBB1i+4zHJaEN0njZeVLC84lyK1mfyCxSjr1gjmKojHzrFzlM 6B8hJRvjd1chtV/9nbzItlSQKdHkAQcUmRTTKmSqKgNITvE4yHlSh0SfkV6ZM1bpKwhp 3tXncf8FJm+xgJOZz9gCHlQEJzOe5t5AIM4MDw8KOPBz9Bh9+hZ4BrQgdVtaQKlxzjkk CfiUCrFTajC71f8HyB9d2R5jB6LY6tI4rQTDleOtfSvqveysz+WLg4Gsy8CT2kc07Z0b zyNTITE+7l3e8GSXeA7YQTX3oiiGKviXgR6QJZqkRZUMWP6TDE9meom26I/p7Q93UGY0 +g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kee35t8dd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:52 +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 29PB9c4L035588 for ; Tue, 25 Oct 2022 11:43:51 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 3kee35t8cr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:51 +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 29PBcBAx013911; Tue, 25 Oct 2022 11:43:49 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 3kc8594ddj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:49 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBhkGj4195050 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:43:46 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4142FAE045; Tue, 25 Oct 2022 11:43:46 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0547BAE04D; Tue, 25 Oct 2022 11:43:46 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:45 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Janis Schoetterl-Glausch , Nico Boehr Subject: [kvm-unit-tests GIT PULL 02/22] s390x: Test specification exceptions during transaction Date: Tue, 25 Oct 2022 13:43:25 +0200 Message-Id: <20221025114345.28003-3-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: pWGLmdNPM3G9GiaXcW2C8GRf4qnoIRsD X-Proofpoint-GUID: l-sWSBDvcO10NgBrk23wH2kDUwvYNr-V 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 suspectscore=0 adultscore=0 mlxscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 phishscore=0 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janis Schoetterl-Glausch Program interruptions during transactional execution cause other interruption codes. Check that we see the expected code for (some) specification exceptions. Signed-off-by: Janis Schoetterl-Glausch Reviewed-by: Nico Boehr Acked-by: Janosch Frank Message-Id: <20220928201710.3185449-3-scgl@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- lib/s390x/asm/arch_def.h | 1 + s390x/spec_ex.c | 199 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 195 insertions(+), 5 deletions(-) diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h index aca3af8e..41c9bd8c 100644 --- a/lib/s390x/asm/arch_def.h +++ b/lib/s390x/asm/arch_def.h @@ -73,6 +73,7 @@ struct cpu { #define PSW_MASK_BA 0x0000000080000000UL #define PSW_MASK_64 (PSW_MASK_BA | PSW_MASK_EA) +#define CTL0_TRANSACT_EX_CTL (63 - 8) #define CTL0_LOW_ADDR_PROT (63 - 35) #define CTL0_EDAT (63 - 40) #define CTL0_FETCH_PROTECTION_OVERRIDE (63 - 38) diff --git a/s390x/spec_ex.c b/s390x/spec_ex.c index 2d4adb8c..42ecaed3 100644 --- a/s390x/spec_ex.c +++ b/s390x/spec_ex.c @@ -4,13 +4,19 @@ * * Specification exception test. * Tests that specification exceptions occur when expected. + * This includes specification exceptions occurring during transactional execution + * as these result in another interruption code (the transactional-execution-aborted + * bit is set). * * Can be extended by adding triggers to spec_ex_triggers, see comments below. */ #include +#include #include #include +#include #include +#include /* toggled to signal occurrence of invalid psw fixup */ static bool invalid_psw_expected; @@ -157,20 +163,22 @@ static int not_even(void) /* * Harness for specification exception testing. * func only triggers exception, reporting is taken care of automatically. + * If a trigger is transactable it will also be executed during a transaction. */ struct spec_ex_trigger { const char *name; int (*func)(void); + bool transactable; void (*fixup)(struct stack_frame_int *stack); }; /* List of all tests to execute */ static const struct spec_ex_trigger spec_ex_triggers[] = { - { "psw_bit_12_is_1", &psw_bit_12_is_1, &fixup_invalid_psw }, - { "short_psw_bit_12_is_0", &short_psw_bit_12_is_0, &fixup_invalid_psw }, - { "bad_alignment", &bad_alignment, NULL }, - { "not_even", ¬_even, NULL }, - { NULL, NULL, NULL }, + { "psw_bit_12_is_1", &psw_bit_12_is_1, false, &fixup_invalid_psw }, + { "short_psw_bit_12_is_0", &short_psw_bit_12_is_0, false, &fixup_invalid_psw }, + { "bad_alignment", &bad_alignment, true, NULL }, + { "not_even", ¬_even, true, NULL }, + { NULL, NULL, false, NULL }, }; static void test_spec_ex(const struct spec_ex_trigger *trigger) @@ -187,10 +195,181 @@ static void test_spec_ex(const struct spec_ex_trigger *trigger) check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); } +#define TRANSACTION_COMPLETED 4 +#define TRANSACTION_MAX_RETRIES 5 + +/* + * NULL must not be passed to __builtin_tbegin via variable, only constant, + * forbid diagnose from being NULL at all to keep things simple + */ +static int __attribute__((nonnull)) +with_transaction(int (*trigger)(void), struct __htm_tdb *diagnose) +{ + int cc; + + cc = __builtin_tbegin(diagnose); + /* + * Everything between tbegin and tend is part of the transaction, + * which either completes in its entirety or does not have any effect. + * If the transaction fails, execution is reset to this point with another + * condition code indicating why the transaction failed. + */ + if (cc == _HTM_TBEGIN_STARTED) { + /* + * return code is meaningless: transaction needs to complete + * in order to return and completion indicates a test failure + */ + trigger(); + __builtin_tend(); + return TRANSACTION_COMPLETED; + } else { + return cc; + } +} + +static int retry_transaction(const struct spec_ex_trigger *trigger, unsigned int max_retries, + struct __htm_tdb *tdb, uint16_t expected_pgm) +{ + int trans_result, i; + uint16_t pgm; + + for (i = 0; i < max_retries; i++) { + expect_pgm_int(); + trans_result = with_transaction(trigger->func, tdb); + if (trans_result == _HTM_TBEGIN_TRANSIENT) { + mb(); + pgm = lowcore.pgm_int_code; + if (pgm == expected_pgm) + return 0; + else if (pgm == 0) + /* + * Transaction failed for unknown reason but not because + * of an unexpected program exception. Give it another + * go so that hopefully it reaches the triggering instruction. + */ + continue; + } + return trans_result; + } + return TRANSACTION_MAX_RETRIES; +} + +struct args { + uint64_t max_retries; + bool diagnose; +}; + +static void test_spec_ex_trans(struct args *args, const struct spec_ex_trigger *trigger) +{ + const uint16_t expected_pgm = PGM_INT_CODE_SPECIFICATION | + PGM_INT_CODE_TX_ABORTED_EVENT; + union { + struct __htm_tdb tdb; + uint64_t dwords[sizeof(struct __htm_tdb) / sizeof(uint64_t)]; + } diag; + unsigned int i; + int trans_result; + + if (!test_facility(73)) { + report_skip("transactional-execution facility not installed"); + return; + } + ctl_set_bit(0, CTL0_TRANSACT_EX_CTL); /* enable transactional-exec */ + + register_pgm_cleanup_func(trigger->fixup); + trans_result = retry_transaction(trigger, args->max_retries, &diag.tdb, expected_pgm); + register_pgm_cleanup_func(NULL); + switch (trans_result) { + case 0: + report_pass("Program interrupt: expected(%d) == received(%d)", + expected_pgm, expected_pgm); + break; + case _HTM_TBEGIN_INDETERMINATE: + case _HTM_TBEGIN_PERSISTENT: + report_info("transaction failed with cc %d", trans_result); + report_info("transaction abort code: %llu", diag.tdb.abort_code); + if (args->diagnose) + for (i = 0; i < 32; i++) + report_info("diag+%03d: %016lx", i * 8, diag.dwords[i]); + break; + case _HTM_TBEGIN_TRANSIENT: + report_fail("Program interrupt: expected(%d) == received(%d)", + expected_pgm, clear_pgm_int()); + break; + case TRANSACTION_COMPLETED: + report_fail("Transaction completed without exception"); + break; + case TRANSACTION_MAX_RETRIES: + report_skip("Transaction retried %lu times with transient failures, giving up", + args->max_retries); + break; + default: + report_fail("Invalid transaction result"); + break; + } + + ctl_clear_bit(0, CTL0_TRANSACT_EX_CTL); +} + +static bool parse_unsigned(const char *arg, unsigned int *out) +{ + char *end; + long num; + + if (arg[0] == '\0') + return false; + num = strtol(arg, &end, 10); + if (end[0] != '\0' || num < 0) + return false; + *out = num; + return true; +} + +static struct args parse_args(int argc, char **argv) +{ + struct args args = { + .max_retries = 20, + .diagnose = false + }; + unsigned int i, arg; + bool has_arg; + const char *flag; + + for (i = 1; i < argc; i++) { + if (i + 1 < argc) + has_arg = parse_unsigned(argv[i + 1], &arg); + else + has_arg = false; + + flag = "--max-retries"; + if (!strcmp(flag, argv[i])) { + if (!has_arg) + report_abort("%s needs a positive parameter", flag); + args.max_retries = arg; + ++i; + continue; + } + if (!strcmp("--diagnose", argv[i])) { + args.diagnose = true; + continue; + } + if (!strcmp("--no-diagnose", argv[i])) { + args.diagnose = false; + continue; + } + report_abort("Unsupported parameter '%s'", + argv[i]); + } + + return args; +} + int main(int argc, char **argv) { unsigned int i; + struct args args = parse_args(argc, argv); + report_prefix_push("specification exception"); for (i = 0; spec_ex_triggers[i].name; i++) { report_prefix_push(spec_ex_triggers[i].name); @@ -199,5 +378,15 @@ int main(int argc, char **argv) } report_prefix_pop(); + report_prefix_push("specification exception during transaction"); + for (i = 0; spec_ex_triggers[i].name; i++) { + if (spec_ex_triggers[i].transactable) { + report_prefix_push(spec_ex_triggers[i].name); + test_spec_ex_trans(&args, &spec_ex_triggers[i]); + report_prefix_pop(); + } + } + report_prefix_pop(); + return report_summary(); } From patchwork Tue Oct 25 11:43:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019089 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 C7854C38A2D for ; Tue, 25 Oct 2022 11:44:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232097AbiJYLn7 (ORCPT ); Tue, 25 Oct 2022 07:43:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231663AbiJYLnz (ORCPT ); Tue, 25 Oct 2022 07:43:55 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1889173FD3 for ; Tue, 25 Oct 2022 04:43:52 -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 29PB8Swa028272 for ; Tue, 25 Oct 2022 11:43:52 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=2M5Sulwh3/JdTkj8TvueB9mkIUtcuxJOI8wBiXyqpac=; b=FDTa95MP/fvkZ59/G4KJobEm8yjrwp2JNPLib0PQ+BvxJz4PckUUcP6aiHRcey0uN3c2 PF/H74NUcDcUUI8x2wYDPt2xryJ+5V/+jzVUQxx5d51wKYSgZ7mVtnUTs+fqcxe0E3ky V1r602ttLeC8QunlaLWcG163lwqmiYBf4fC2eALLtU6cD2JGeirQt6jAIK0+e/Zoumam ZAZI2LWI/W+LW1AX9sacQ9x3ppCU2h7KYPJDkfsj6xeoA72bL3DTHeHAfKfZaxJDOtap yI31eaJkj8ItjcFL+IuWZMCosfTUOIbfYNOLGE+RwzRsFNxW3uDGSBPJ8O/KEMoAkGzz 4A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kebjt8a8w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:52 +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 29PBB3Fi006521 for ; Tue, 25 Oct 2022 11:43:51 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kebjt8a86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:51 +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 29PBd2xK024232; Tue, 25 Oct 2022 11:43:49 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03ams.nl.ibm.com with ESMTP id 3kdugat576-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:49 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBhkKL34931190 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:43:46 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7EC6FAE045; Tue, 25 Oct 2022 11:43:46 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4CC84AE051; Tue, 25 Oct 2022 11:43:46 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:46 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 03/22] lib/s390x: move TOD clock related functions to library Date: Tue, 25 Oct 2022 13:43:26 +0200 Message-Id: <20221025114345.28003-4-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: FP8w6hsPm9flP7bNl0iOCLBk31k1pZRc X-Proofpoint-ORIG-GUID: H_6eaR_fWJyeEpYYY1DJBA2XeswrGvcD 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 clxscore=1015 mlxscore=0 adultscore=0 lowpriorityscore=0 mlxlogscore=975 priorityscore=1501 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr The TOD-clock related functions can be useful for other tests beside the sck test, hence move them to the library. While at it, add a wrapper for stckf, express get_clock_us() with stck() and remove an unneeded memory clobber. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Message-Id: <20221011170024.972135-2-nrb@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- lib/s390x/asm/time.h | 50 +++++++++++++++++++++++++++++++++++++++++++- s390x/sck.c | 32 ---------------------------- 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/lib/s390x/asm/time.h b/lib/s390x/asm/time.h index d8d91d68..ad689b09 100644 --- a/lib/s390x/asm/time.h +++ b/lib/s390x/asm/time.h @@ -18,11 +18,59 @@ #define CPU_TIMER_SHIFT_US S390_CLOCK_SHIFT_US +static inline int sck(uint64_t *time) +{ + int cc; + + asm volatile( + " sck %[time]\n" + " ipm %[cc]\n" + " srl %[cc],28\n" + : [cc] "=d"(cc) + : [time] "Q"(*time) + : "cc" + ); + + return cc; +} + +static inline int stck(uint64_t *time) +{ + int cc; + + asm volatile( + " stck %[time]\n" + " ipm %[cc]\n" + " srl %[cc],28\n" + : [cc] "=d" (cc), [time] "=Q" (*time) + : + : "cc" + ); + + return cc; +} + +static inline int stckf(uint64_t *time) +{ + int cc; + + asm volatile( + " stckf %[time]\n" + " ipm %[cc]\n" + " srl %[cc],28\n" + : [cc] "=d" (cc), [time] "=Q" (*time) + : + : "cc" + ); + + return cc; +} + static inline uint64_t get_clock_us(void) { uint64_t clk; - asm volatile(" stck %0 " : : "Q"(clk) : "memory"); + stck(&clk); return clk >> STCK_SHIFT_US; } diff --git a/s390x/sck.c b/s390x/sck.c index 88d52b74..dff49618 100644 --- a/s390x/sck.c +++ b/s390x/sck.c @@ -12,38 +12,6 @@ #include #include -static inline int sck(uint64_t *time) -{ - int cc; - - asm volatile( - " sck %[time]\n" - " ipm %[cc]\n" - " srl %[cc],28\n" - : [cc] "=d"(cc) - : [time] "Q"(*time) - : "cc" - ); - - return cc; -} - -static inline int stck(uint64_t *time) -{ - int cc; - - asm volatile( - " stck %[time]\n" - " ipm %[cc]\n" - " srl %[cc],28\n" - : [cc] "=d" (cc), [time] "=Q" (*time) - : - : "cc", "memory" - ); - - return cc; -} - static void test_priv(void) { uint64_t time_to_set_privileged = 0xfacef00dcafe0000, From patchwork Tue Oct 25 11:43:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019093 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 316B3ECDFA1 for ; Tue, 25 Oct 2022 11:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232168AbiJYLoD (ORCPT ); Tue, 25 Oct 2022 07:44:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231808AbiJYLnz (ORCPT ); Tue, 25 Oct 2022 07:43:55 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18555175370 for ; Tue, 25 Oct 2022 04:43:53 -0700 (PDT) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29PB7wOO006377 for ; Tue, 25 Oct 2022 11:43:52 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=YKEaLQCC3x3KI4aay9MuBvNM4mkNNo204dMMqEQ+UiY=; b=T+DuwU3HF2Tz8TvQNtRwux2IBba4vczvNt+xuqIxCou+GMhWFddTAk2aMNcf34BHExpB V7rKn9hKLkUdTUxqB/HaAFdhlcM2AcLukv4WTXHYtLSkiSWjvYq1vTSaekv2Eo7YxFrB Sb+FeNno4BpOFQI5WiQwoWnYbXlcpte6sUSH7XCR5v2Sppoc+8WrOTzOa3Y6iRgIAhpc ViEzY/L8D+eYuvo7UTAe3fzOhTZzhp3qM33GE+x7ZqfKll9TtrOBq6wk0F5ReWSg19rn 86tU/gyFNgKwiVqllJHiff67uS0ymHUF9nu30Lv3/z9Uf7pybqKBbVHvg+IqvHy78p9y Zw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ked6qvf9y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:52 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29PBb86x003328 for ; Tue, 25 Oct 2022 11:43:52 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 3ked6qvf96-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:52 +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 29PBcLF7027544; Tue, 25 Oct 2022 11:43:50 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 3kc859dhpm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:49 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBhkSJ34931192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:43:46 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BC10BAE045; Tue, 25 Oct 2022 11:43:46 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8AB6FAE04D; Tue, 25 Oct 2022 11:43:46 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:46 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 04/22] s390x: add migration TOD clock test Date: Tue, 25 Oct 2022 13:43:27 +0200 Message-Id: <20221025114345.28003-5-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: f7Wl09v_AF8O_pyOk8BW1vHK0cxUPGFs X-Proofpoint-ORIG-GUID: 1XED_DgzlgelU_fszeeX7PR2g5a5nC7x 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 clxscore=1015 bulkscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr On migration, we expect the guest clock value to be preserved. Add a test to verify this: - advance the guest TOD by much more than we need to migrate - migrate the guest - get the guest TOD After migration, assert the guest TOD value is at least the value we set before migration. This is the minimal check for architectural compliance; implementations may decide to do something more sophisticated. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Message-Id: <20221011170024.972135-3-nrb@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- s390x/Makefile | 1 + s390x/migration-sck.c | 54 +++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 4 ++++ 3 files changed, 59 insertions(+) create mode 100644 s390x/migration-sck.c diff --git a/s390x/Makefile b/s390x/Makefile index 6acb7b16..7b08ed80 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -37,6 +37,7 @@ tests += $(TEST_DIR)/migration-cmm.elf tests += $(TEST_DIR)/migration-skey.elf tests += $(TEST_DIR)/panic-loop-extint.elf tests += $(TEST_DIR)/panic-loop-pgm.elf +tests += $(TEST_DIR)/migration-sck.elf pv-tests += $(TEST_DIR)/pv-diags.elf diff --git a/s390x/migration-sck.c b/s390x/migration-sck.c new file mode 100644 index 00000000..2d9a195a --- /dev/null +++ b/s390x/migration-sck.c @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * SET CLOCK migration tests + * + * Copyright IBM Corp. 2022 + * + * Authors: + * Nico Boehr + */ + +#include +#include + +static void test_sck_migration(void) +{ + uint64_t now_before_set = 0, now_after_set = 0, now_after_migration, time_to_set, time_to_advance; + int cc; + + stckf(&now_before_set); + + /* Advance the clock by a lot more than we might ever need to migrate (600s) */ + time_to_advance = (600ULL * 1000000) << STCK_SHIFT_US; + time_to_set = now_before_set + time_to_advance; + + cc = sck(&time_to_set); + report(!cc, "setting clock succeeded"); + + /* Check the clock is running after being set */ + cc = stckf(&now_after_set); + report(!cc, "clock running after set"); + report(now_after_set >= time_to_set, "TOD clock value is larger than what has been set"); + + puts("Please migrate me, then press return\n"); + (void)getchar(); + + cc = stckf(&now_after_migration); + report(!cc, "clock still set"); + + /* + * The architectural requirement for the TOD clock is that it doesn't move backwards after + * migration. Implementations can just migrate the guest TOD value or do something more + * sophisticated (e.g. slowly adjust to the host TOD). + */ + report(now_after_migration >= time_to_set, "TOD clock value did not jump backwards"); +} + +int main(void) +{ + report_prefix_push("migration-sck"); + + test_sck_migration(); + report_prefix_pop(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 412fd130..1bc79a23 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -200,3 +200,7 @@ file = panic-loop-pgm.elf groups = panic accel = kvm timeout = 5 + +[migration-sck] +file = migration-sck.elf +groups = migration From patchwork Tue Oct 25 11:43:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019097 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 A7CF1C38A2D for ; Tue, 25 Oct 2022 11:44:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232173AbiJYLoP (ORCPT ); Tue, 25 Oct 2022 07:44:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231967AbiJYLn5 (ORCPT ); Tue, 25 Oct 2022 07:43:57 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA18A172B79 for ; Tue, 25 Oct 2022 04:43:53 -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 29PB7ukB030441 for ; Tue, 25 Oct 2022 11:43:53 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=cUsFPN5T4B+h1UFbbGnXz/i1ZyjUpKQNwAQeXmaPnts=; b=NMeEr3Swf5P2ULHNgMj/uNRZmTXRdy15MI2TD94T6hEqHlvIQFWSgNMUt/1R9/qiJD4W X6zjK+4PAyr7lGSh8r+YmBQxxRXcWRR8SDHQyfhnGvHDteOVJs77HOMLkPyXc6tlcz1f m9UxD4oXveIAdmrl0KdU3PwgVculp5tMd8IRPvW9F44b6hqcAofcWLGjzGtJWUxEGdjf Lryfz5rSNUoFQO2vfDvm3HV436bct4Qm6LUQVDkeotsQRpGb8JMmiMqCrARgog7ekBLh zVIqqQynJNMM41psoyblPgiyV6JASdVMVftS6bOS+bKUwi+jU4nYtmPLrILfet928pW6 cg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kedu32u1w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:53 +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 29PB82mu031067 for ; Tue, 25 Oct 2022 11:43:52 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 3kedu32u0v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:52 +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 29PBd6Ww011295; Tue, 25 Oct 2022 11:43:50 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma01fra.de.ibm.com with ESMTP id 3kc8593yv3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:50 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBiLgB32899470 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:44:21 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0931AAE045; Tue, 25 Oct 2022 11:43:47 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C79A2AE051; Tue, 25 Oct 2022 11:43:46 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:46 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 05/22] s390x: add exittime tests Date: Tue, 25 Oct 2022 13:43:28 +0200 Message-Id: <20221025114345.28003-6-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Nuv-TZ2t6zm7HLZRU8MOg4jQd6o6njhQ X-Proofpoint-ORIG-GUID: cpAHPiv2GpTj1r2iEelkDyH7p3NkG4b3 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 priorityscore=1501 adultscore=0 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 mlxscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr Add a test to measure the execution time of several instructions. This can be helpful in finding performance regressions in hypervisor code. All tests are currently reported as PASS, since the baseline for their execution time depends on the respective environment and since needs to be determined on a case-by-case basis. Signed-off-by: Nico Boehr Reviewed-by: Claudio Imbrenda Message-Id: <20221017101828.703068-2-nrb@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- s390x/Makefile | 1 + s390x/exittime.c | 296 ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 4 + 3 files changed, 301 insertions(+) create mode 100644 s390x/exittime.c diff --git a/s390x/Makefile b/s390x/Makefile index 7b08ed80..cc902472 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -38,6 +38,7 @@ tests += $(TEST_DIR)/migration-skey.elf tests += $(TEST_DIR)/panic-loop-extint.elf tests += $(TEST_DIR)/panic-loop-pgm.elf tests += $(TEST_DIR)/migration-sck.elf +tests += $(TEST_DIR)/exittime.elf pv-tests += $(TEST_DIR)/pv-diags.elf diff --git a/s390x/exittime.c b/s390x/exittime.c new file mode 100644 index 00000000..8ccffbfc --- /dev/null +++ b/s390x/exittime.c @@ -0,0 +1,296 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Measure run time of various instructions. Can be used to find runtime + * regressions of instructions which cause exits. + * + * Copyright IBM Corp. 2022 + * + * Authors: + * Nico Boehr + */ +#include +#include +#include +#include +#include +#include +#include +#include + +const uint64_t iters_to_normalize_to = 10000; +char pagebuf[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); + +static void test_sigp_sense_running(long destcpu) +{ + smp_sigp(destcpu, SIGP_SENSE_RUNNING, 0, NULL); +} + +static void test_nop(long ignore) +{ + /* nops don't trap into the hypervisor, so let's test them for reference */ + asm volatile( + "nop" + : + : + : "memory" + ); +} + +static void test_diag9c(long destcpu) +{ + asm volatile( + "diag %[destcpu],0,0x9c" + : + : [destcpu] "d" (destcpu) + ); +} + +static long setup_get_this_cpuaddr(long ignore) +{ + return stap(); +} + +static void test_diag44(long ignore) +{ + asm volatile( + "diag 0,0,0x44" + ); +} + +static void test_stnsm(long ignore) +{ + int out; + + asm volatile( + "stnsm %[out],0xff" + : [out] "=Q" (out) + ); +} + +static void test_stosm(long ignore) +{ + int out; + + asm volatile( + "stosm %[out],0" + : [out] "=Q" (out) + ); +} + +static long setup_ssm(long ignore) +{ + long system_mask = 0; + + asm volatile( + "stosm %[system_mask],0" + : [system_mask] "=Q" (system_mask) + ); + + return system_mask; +} + +static void test_ssm(long old_system_mask) +{ + asm volatile( + "ssm %[old_system_mask]" + : + : [old_system_mask] "Q" (old_system_mask) + ); +} + +static long setup_lctl4(long ignore) +{ + long ctl4_orig = 0; + + asm volatile( + "stctg 4,4,%[ctl4_orig]" + : [ctl4_orig] "=S" (ctl4_orig) + ); + + return ctl4_orig; +} + +static void test_lctl4(long ctl4_orig) +{ + asm volatile( + "lctlg 4,4,%[ctl4_orig]" + : + : [ctl4_orig] "S" (ctl4_orig) + ); +} + +static void test_stpx(long ignore) +{ + unsigned int prefix; + + asm volatile( + "stpx %[prefix]" + : [prefix] "=Q" (prefix) + ); +} + +static void test_stfl(long ignore) +{ + asm volatile( + "stfl 0" + : + : + : "memory" + ); +} + +static void test_epsw(long ignore) +{ + long r1, r2; + + asm volatile( + "epsw %[r1], %[r2]" + : [r1] "=d" (r1), [r2] "=d" (r2) + ); +} + +static void test_illegal(long ignore) +{ + expect_pgm_int(); + asm volatile( + ".word 0" + ); + clear_pgm_int(); +} + +static long setup_servc(long arg) +{ + memset(pagebuf, 0, PAGE_SIZE); + return arg; +} + +static void test_servc(long ignore) +{ + SCCB *sccb = (SCCB *) pagebuf; + + sccb->h.length = 8; + servc(0, (unsigned long) sccb); +} + +static void test_stsi(long fc) +{ + stsi(pagebuf, fc, 2, 2); +} + +struct test { + const char *name; + bool supports_tcg; + /* + * When non-null, will be called once before running the test loop. + * Its return value will be given as argument to testfunc. + */ + long (*setupfunc)(long arg); + void (*testfunc)(long arg); + long arg; + long iters; +} const exittime_tests[] = { + {"nop", true, NULL, test_nop, 0, 200000 }, + {"sigp sense running(0)", true, NULL, test_sigp_sense_running, 0, 20000 }, + {"sigp sense running(1)", true, NULL, test_sigp_sense_running, 1, 20000 }, + {"diag9c(self)", false, setup_get_this_cpuaddr, test_diag9c, 0, 2000 }, + {"diag9c(0)", false, NULL, test_diag9c, 0, 2000 }, + {"diag9c(1)", false, NULL, test_diag9c, 1, 2000 }, + {"diag44", true, NULL, test_diag44, 0, 2000 }, + {"stnsm", true, NULL, test_stnsm, 0, 200000 }, + {"stosm", true, NULL, test_stosm, 0, 200000 }, + {"ssm", true, setup_ssm, test_ssm, 0, 200000 }, + {"lctl4", true, setup_lctl4, test_lctl4, 0, 20000 }, + {"stpx", true, NULL, test_stpx, 0, 2000 }, + {"stfl", true, NULL, test_stfl, 0, 2000 }, + {"epsw", true, NULL, test_epsw, 0, 20000 }, + {"illegal", true, NULL, test_illegal, 0, 2000 }, + {"servc", true, setup_servc, test_servc, 0, 2000 }, + {"stsi122", true, NULL, test_stsi, 1, 200 }, + {"stsi222", true, NULL, test_stsi, 2, 200 }, + {"stsi322", true, NULL, test_stsi, 3, 200 }, +}; + +struct test_result { + uint64_t total; + uint64_t best; + uint64_t average; + uint64_t worst; +}; + +static uint64_t tod_to_us(uint64_t tod) +{ + return tod >> STCK_SHIFT_US; +} + +static uint64_t tod_to_ns(uint64_t tod) +{ + return tod_to_us(tod * 1000); +} + +static uint64_t normalize_iters(uint64_t value_to_normalize, uint64_t iters) +{ + return value_to_normalize * iters_to_normalize_to / iters; +} + +static void report_iteration_result(struct test const* test, struct test_result const* test_result) +{ + uint64_t total = tod_to_ns(normalize_iters(test_result->total, test->iters)), + best = tod_to_ns(normalize_iters(test_result->best, test->iters)), + average = tod_to_ns(normalize_iters(test_result->average, test->iters)), + worst = tod_to_ns(normalize_iters(test_result->worst, test->iters)); + + report_pass( + "total/best/avg/worst %lu.%03lu/%lu.%03lu/%lu.%03lu/%lu.%03lu us", + total / 1000, total % 1000, + best / 1000, best % 1000, + average / 1000, average % 1000, + worst / 1000, worst % 1000 + ); +} + +int main(void) +{ + int i, j, k, testfunc_arg; + const int outer_iters = 100; + struct test const *current_test; + struct test_result result; + uint64_t start, end, elapsed; + + report_prefix_push("exittime"); + report_info("reporting total/best/avg/worst normalized to %lu iterations", iters_to_normalize_to); + + for (i = 0; i < ARRAY_SIZE(exittime_tests); i++) { + current_test = &exittime_tests[i]; + result.total = 0; + result.worst = 0; + result.best = -1; + report_prefix_pushf("%s", current_test->name); + + if (host_is_tcg() && !current_test->supports_tcg) { + report_skip("not supported under TCG"); + report_prefix_pop(); + continue; + } + + testfunc_arg = current_test->arg; + if (current_test->setupfunc) + testfunc_arg = current_test->setupfunc(testfunc_arg); + + for (j = 0; j < outer_iters; j++) { + stckf(&start); + for (k = 0; k < current_test->iters; k++) + current_test->testfunc(testfunc_arg); + stckf(&end); + elapsed = end - start; + result.best = MIN(result.best, elapsed); + result.worst = MAX(result.worst, elapsed); + result.total += elapsed; + } + result.average = result.total / outer_iters; + report_iteration_result(current_test, &result); + report_prefix_pop(); + } + + report_prefix_pop(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 1bc79a23..3caf81ed 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -204,3 +204,7 @@ timeout = 5 [migration-sck] file = migration-sck.elf groups = migration + +[exittime] +file = exittime.elf +smp = 2 From patchwork Tue Oct 25 11:43:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019094 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 766D4FA3742 for ; Tue, 25 Oct 2022 11:44:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231833AbiJYLoJ (ORCPT ); Tue, 25 Oct 2022 07:44:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231815AbiJYLn4 (ORCPT ); Tue, 25 Oct 2022 07:43:56 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08B101735BE for ; Tue, 25 Oct 2022 04:43:54 -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 29PB7tLk030431 for ; Tue, 25 Oct 2022 11:43:53 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=tEdBO+YMSSjm7Z0cmTQ+xrwnoFqSWoYKWK8bo2Wt/F0=; b=T2NvMWZFKJJ+3LZwJcQ1UNN3SKdkiRNuIKgDxHt45cMe5ZpQOHAXNGAEkTkAYcfDmzlu QvIPZUpOUAgBcvMwGwaHm7uSLqOUUYOmwGdqL8K0Vfn/j0MC/BgX3y6fVdaT5qps3ony cYvZKqpeE7r5ZYqwhGksSKxdNbOYISIneBfzRbtSz3gI6PDSwHu5MY/qNMNV5q0zf4Ww imFtP44SX1sKZmV96LrcOLXhJuPg8cUxzf/SSfGhAbvyMPwqAsVJzgCDQSSIgauuGyRT 3tbQdxlLEmWcc4J6CC5Dy9oOvC6n6a0wbuVUEQDJNpwU2IM4N1iJmULLU5brHu8nJbI1 eg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kedu32u26-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:53 +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 29PBeXWJ027113 for ; Tue, 25 Oct 2022 11:43:53 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 3kedu32u13-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:53 +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 29PBcP7B014644; Tue, 25 Oct 2022 11:43:50 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma05fra.de.ibm.com with ESMTP id 3kc8594ddk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:50 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBiLWJ32899474 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:44:21 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 45E34AE045; Tue, 25 Oct 2022 11:43:47 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 14ADCAE04D; Tue, 25 Oct 2022 11:43:47 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:47 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 06/22] s390x: do not enable PV dump support by default Date: Tue, 25 Oct 2022 13:43:29 +0200 Message-Id: <20221025114345.28003-7-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: kyIEb1CIc-3IQ5MorPtlBgqsQOYH0WmH X-Proofpoint-ORIG-GUID: 8wf2X1fNJjGi10rcUN2myj6u0LW7fxHf 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 priorityscore=1501 adultscore=0 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 mlxscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Nico Boehr Currently, dump support is always enabled by setting the respective plaintext control flag (PCF). Unfortunately, older machines without support for PV dump will not start the guest when this PCF is set. This will result in an error message like this: qemu-system-s390x: KVM PV command 2 (KVM_PV_SET_SEC_PARMS) failed: header rc 106 rrc 0 IOCTL rc: -22 Hence, by default, disable dump support to preserve compatibility with older machines. Users can enable dumping support by passing --enable-dump to the configure script. Fixes: 3043685825d9 ("s390x: create persistent comm-key") Signed-off-by: Nico Boehr Reviewed-by: Janosch Frank Message-Id: <20221019145320.1228710-2-nrb@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- configure | 11 +++++++++++ s390x/Makefile | 26 +++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/configure b/configure index 5b7daac3..b81f2094 100755 --- a/configure +++ b/configure @@ -28,6 +28,7 @@ errata_force=0 erratatxt="$srcdir/errata.txt" host_key_document= gen_se_header= +enable_dump=no page_size= earlycon= efi= @@ -67,6 +68,9 @@ usage() { --gen-se-header=GEN_SE_HEADER Provide an executable to generate a PV header requires --host-key-document. (s390x-snippets only) + --[enable|disable]-dump + Allow PV guests to be dumped. Requires at least z16. + (s390x only) --page-size=PAGE_SIZE Specify the page size (translation granule) (4k, 16k or 64k, default is 64k, arm64 only) @@ -146,6 +150,12 @@ while [[ "$1" = -* ]]; do --gen-se-header) gen_se_header="$arg" ;; + --enable-dump) + enable_dump=yes + ;; + --disable-dump) + enable_dump=no + ;; --page-size) page_size="$arg" ;; @@ -387,6 +397,7 @@ U32_LONG_FMT=$u32_long WA_DIVIDE=$wa_divide GENPROTIMG=${GENPROTIMG-genprotimg} HOST_KEY_DOCUMENT=$host_key_document +CONFIG_DUMP=$enable_dump CONFIG_EFI=$efi CONFIG_WERROR=$werror GEN_SE_HEADER=$gen_se_header diff --git a/s390x/Makefile b/s390x/Makefile index cc902472..5e0b4f39 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -176,18 +176,26 @@ $(comm-key): %.bin: %.elf $(OBJCOPY) -O binary $< $@ -# The genprotimg arguments for the cck changed over time so we need to -# figure out which argument to use in order to set the cck -GENPROTIMG_HAS_COMM_KEY = $(shell $(GENPROTIMG) --help | grep -q -- --comm-key && echo yes) -ifeq ($(GENPROTIMG_HAS_COMM_KEY),yes) - GENPROTIMG_COMM_KEY = --comm-key $(comm-key) -else - GENPROTIMG_COMM_KEY = --x-comm-key $(comm-key) +# Will only be filled when dump has been enabled +GENPROTIMG_COMM_KEY = +# allow PCKMO +genprotimg_pcf = 0x000000e0 + +ifeq ($(CONFIG_DUMP),yes) + # The genprotimg arguments for the cck changed over time so we need to + # figure out which argument to use in order to set the cck + GENPROTIMG_HAS_COMM_KEY = $(shell $(GENPROTIMG) --help | grep -q -- --comm-key && echo yes) + ifeq ($(GENPROTIMG_HAS_COMM_KEY),yes) + GENPROTIMG_COMM_KEY = --comm-key $(comm-key) + else + GENPROTIMG_COMM_KEY = --x-comm-key $(comm-key) + endif + + # allow dumping + PCKMO + genprotimg_pcf = 0x200000e0 endif # use x-pcf to be compatible with old genprotimg versions -# allow dumping + PCKMO -genprotimg_pcf = 0x200000e0 genprotimg_args = --host-key-document $(HOST_KEY_DOCUMENT) --no-verify $(GENPROTIMG_COMM_KEY) --x-pcf $(genprotimg_pcf) %selftest.pv.bin: %selftest.bin $(HOST_KEY_DOCUMENT) $(patsubst %.pv.bin,%.parmfile,$@) $(comm-key) From patchwork Tue Oct 25 11:43:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019091 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 81FBDFA3740 for ; Tue, 25 Oct 2022 11:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232242AbiJYLoG (ORCPT ); Tue, 25 Oct 2022 07:44:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231842AbiJYLn4 (ORCPT ); Tue, 25 Oct 2022 07:43:56 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D03D9175359 for ; Tue, 25 Oct 2022 04:43:53 -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 29PB8Ttt028286 for ; Tue, 25 Oct 2022 11:43:53 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=g1NvoQXOc5s/bQKikMOoFfTWAeIvTTKU4MS56HgdLv8=; b=CQqeI7RahfOpi2mClT8TYMLk/ACu9oXu+dC/ghptEfLmvrkGYfy/6pUV5h/SWk9cfKfv Q+fwlTn0I3cJpWQfl//rRaHUw+BwBMa5X1WXzaoyAAdNrUrKKhgBGCcdiYJujxTp16j3 i1fa58LbfqWELg+smdEgHAGcXRwvy6bBiQnqjJOA4136CHPuuqb/HBdLY25UcxUdsw+1 adNIRTDpYvicizQMB49IoP460eh/gT2Sm7WB3+JPAELJuNdVaYJJMNAfKLg9xcMJDivQ 4yaxNdmx78WTG49HPEV9RD0XrSU6BdGQ0tu2EIxPFJ1qOF3D1sOA/H18kVq94JSBBgNW tA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kebjt8a9b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:52 +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 29PB8bBC029832 for ; Tue, 25 Oct 2022 11:43:52 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kebjt8a8k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:52 +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 29PBcwtR024198; Tue, 25 Oct 2022 11:43:50 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03ams.nl.ibm.com with ESMTP id 3kdugat579-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:50 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBiMUH32899478 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:44:22 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 822F4AE045; Tue, 25 Oct 2022 11:43:47 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 51350AE051; Tue, 25 Oct 2022 11:43:47 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:47 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 07/22] s390x: uv-host: Add access checks for donated memory Date: Tue, 25 Oct 2022 13:43:30 +0200 Message-Id: <20221025114345.28003-8-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: kqg-l9yeofi4m84Y2PpaQpL3eqvn5Yj3 X-Proofpoint-ORIG-GUID: s7op7Tqy-4ocdP3Od8cXhWoo_0VHCsiC 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 clxscore=1015 mlxscore=0 adultscore=0 lowpriorityscore=0 mlxlogscore=909 priorityscore=1501 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank Let's check if the UV really protected all the memory we donated. Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Reviewed-by: Claudio Imbrenda Reviewed-by; Steffen Eiden Message-Id: <20221017093925.2038-2-frankja@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- s390x/uv-host.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index a1a6d120..622c7f7e 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -43,6 +43,32 @@ static void cpu_loop(void) for (;;) {} } +/* + * Checks if a memory area is protected as secure memory. + * Will return true if all pages are protected, false otherwise. + */ +static bool access_check_3d(uint8_t *access_ptr, uint64_t len) +{ + assert(!(len & ~PAGE_MASK)); + assert(!((uint64_t)access_ptr & ~PAGE_MASK)); + + while (len) { + expect_pgm_int(); + READ_ONCE(*access_ptr); + if (clear_pgm_int() != PGM_INT_CODE_SECURE_STOR_ACCESS) + return false; + expect_pgm_int(); + WRITE_ONCE(*access_ptr, 42); + if (clear_pgm_int() != PGM_INT_CODE_SECURE_STOR_ACCESS) + return false; + + access_ptr += PAGE_SIZE; + len -= PAGE_SIZE; + } + + return true; +} + static struct cmd_list cmds[] = { { "init", UVC_CMD_INIT_UV, sizeof(struct uv_cb_init), BIT_UVC_CMD_INIT_UV }, { "create conf", UVC_CMD_CREATE_SEC_CONF, sizeof(struct uv_cb_cgc), BIT_UVC_CMD_CREATE_SEC_CONF }, @@ -194,6 +220,10 @@ static void test_cpu_create(void) report(rc == 0 && uvcb_csc.header.rc == UVC_RC_EXECUTED && uvcb_csc.cpu_handle, "success"); + rc = access_check_3d((uint8_t *)uvcb_csc.stor_origin, + uvcb_qui.cpu_stor_len); + report(rc, "Storage protection"); + tmp = uvcb_csc.stor_origin; uvcb_csc.stor_origin = (unsigned long)memalign(PAGE_SIZE, uvcb_qui.cpu_stor_len); rc = uv_call(0, (uint64_t)&uvcb_csc); @@ -292,6 +322,13 @@ static void test_config_create(void) rc = uv_call(0, (uint64_t)&uvcb_cgc); report(rc == 0 && uvcb_cgc.header.rc == UVC_RC_EXECUTED, "successful"); + rc = access_check_3d((uint8_t *)uvcb_cgc.conf_base_stor_origin, + uvcb_qui.conf_base_phys_stor_len); + report(rc, "Base storage protection"); + + rc = access_check_3d((uint8_t *)uvcb_cgc.conf_var_stor_origin, vsize); + report(rc, "Variable storage protection"); + uvcb_cgc.header.rc = 0; uvcb_cgc.header.rrc = 0; tmp = uvcb_cgc.guest_handle; From patchwork Tue Oct 25 11:43:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019092 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 41B3BFA3741 for ; Tue, 25 Oct 2022 11:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232209AbiJYLoE (ORCPT ); Tue, 25 Oct 2022 07:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231833AbiJYLn4 (ORCPT ); Tue, 25 Oct 2022 07:43:56 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F9A617535B for ; Tue, 25 Oct 2022 04:43:54 -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 29PB8A3M028254 for ; Tue, 25 Oct 2022 11:43:54 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=L9gcrzacnQsomFvbWWhbCoCMwle349TI0zKauC6QD08=; b=bzmFoZ+30d3pMtnUMrNr4kAV1bbp8TtDMhuRsY9D0GW9tVcOL1F36UaQTDKFEC0Y9cAG gRt7CN1Q14asK4CfKJJJwrRjJnS0NneWFTZ1dBlvOqAHPoakeb44HNfjoXdf9wHeX/q5 xU/XZ2MaQGzYQ04kvCTSw7hQx8GXJ0bL4IByImIfatLLVlFSzPkHVLhv4sNVY6vHDmPD 0a9HT4qKF61ND33gvQNpRxojC0YwP4VoC0/NAxJResg0G2Bd25k2Hh7eKkxbegrbiK5q SSGs3lHhFrXMM443olYeGXfsht8ARJcfPfWdtogX+7pzEbGrI5kW1Jih2v5k8zzV1zws MQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kee35t8e0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:53 +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 29PBB4FM000749 for ; Tue, 25 Oct 2022 11:43:53 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 3kee35t8d5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:53 +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 29PBcJpA026830; Tue, 25 Oct 2022 11:43:50 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 3kc859dhpn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:50 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBiMcS50987420 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:44:22 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C4D63AE045; Tue, 25 Oct 2022 11:43:47 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8E0E9AE04D; Tue, 25 Oct 2022 11:43:47 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:47 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Nico Boehr , Steffen Eiden Subject: [kvm-unit-tests GIT PULL 08/22] s390x: uv-host: Add uninitialized UV tests Date: Tue, 25 Oct 2022 13:43:31 +0200 Message-Id: <20221025114345.28003-9-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: xCPcF9m3h4aB8ydOFkiaLdKwniYpu78A X-Proofpoint-GUID: SqewdUo9h5w9GVaUt8ei1MaswQvebquj 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 suspectscore=0 adultscore=0 mlxscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 phishscore=0 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank Let's also test for rc 0x3 Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Reviewed-by: Steffen Eiden Message-Id: <20221017093925.2038-3-frankja@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- s390x/uv-host.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index 622c7f7e..24dcd6dc 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -109,6 +109,25 @@ static void test_priv(void) report_prefix_pop(); } +static void test_uv_uninitialized(void) +{ + struct uv_cb_header uvcb = {}; + int i; + + report_prefix_push("uninitialized"); + + for (i = 0; cmds[i].name; i++) { + if (cmds[i].cmd == UVC_CMD_INIT_UV) + continue; + expect_pgm_int(); + uvcb.cmd = cmds[i].cmd; + uvcb.len = cmds[i].len; + uv_call_once(0, (uint64_t)&uvcb); + report(uvcb.rc == UVC_RC_INV_STATE, "%s", cmds[i].name); + } + report_prefix_pop(); +} + static void test_config_destroy(void) { int rc; @@ -476,13 +495,68 @@ static void test_invalid(void) report_prefix_pop(); } +static void setup_test_clear(void) +{ + unsigned long vsize; + int rc; + + uvcb_cgc.header.cmd = UVC_CMD_CREATE_SEC_CONF; + uvcb_cgc.header.len = sizeof(uvcb_cgc); + + uvcb_cgc.guest_stor_origin = 0; + uvcb_cgc.guest_stor_len = 42 * (1UL << 20); + vsize = uvcb_qui.conf_base_virt_stor_len + + ((uvcb_cgc.guest_stor_len / (1UL << 20)) * uvcb_qui.conf_virt_var_stor_len); + + uvcb_cgc.conf_base_stor_origin = (uint64_t)memalign(PAGE_SIZE * 4, uvcb_qui.conf_base_phys_stor_len); + uvcb_cgc.conf_var_stor_origin = (uint64_t)memalign(PAGE_SIZE, vsize); + uvcb_cgc.guest_asce = (uint64_t)memalign(PAGE_SIZE, 4 * PAGE_SIZE) | ASCE_DT_SEGMENT | REGION_TABLE_LENGTH | ASCE_P; + uvcb_cgc.guest_sca = (uint64_t)memalign(PAGE_SIZE * 4, PAGE_SIZE * 4); + + rc = uv_call(0, (uint64_t)&uvcb_cgc); + assert(rc == 0); + + uvcb_csc.header.len = sizeof(uvcb_csc); + uvcb_csc.header.cmd = UVC_CMD_CREATE_SEC_CPU; + uvcb_csc.guest_handle = uvcb_cgc.guest_handle; + uvcb_csc.stor_origin = (unsigned long)memalign(PAGE_SIZE, uvcb_qui.cpu_stor_len); + uvcb_csc.state_origin = (unsigned long)memalign(PAGE_SIZE, PAGE_SIZE); + + rc = uv_call(0, (uint64_t)&uvcb_csc); + assert(rc == 0); +} + static void test_clear(void) { - uint64_t *tmp = (void *)uvcb_init.stor_origin; + uint64_t *tmp; + + report_prefix_push("load normal reset"); + + /* + * Setup a config and a cpu so we can check if a diag308 reset + * clears the donated memory and makes the pages unsecure. + */ + setup_test_clear(); diag308_load_reset(1); sclp_console_setup(); - report(!*tmp, "memory cleared after reset 1"); + + tmp = (void *)uvcb_init.stor_origin; + report(!*tmp, "uv init donated memory cleared"); + + tmp = (void *)uvcb_cgc.conf_base_stor_origin; + report(!*tmp, "config base donated memory cleared"); + + tmp = (void *)uvcb_cgc.conf_base_stor_origin; + report(!*tmp, "config variable donated memory cleared"); + + tmp = (void *)uvcb_csc.stor_origin; + report(!*tmp, "cpu donated memory cleared after reset 1"); + + /* Check if uninitialized after reset */ + test_uv_uninitialized(); + + report_prefix_pop(); } static void setup_vmem(void) @@ -513,6 +587,7 @@ int main(void) test_priv(); test_invalid(); + test_uv_uninitialized(); test_query(); test_init(); From patchwork Tue Oct 25 11:43:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019095 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 3C97CC38A2D for ; Tue, 25 Oct 2022 11:44:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231808AbiJYLoK (ORCPT ); Tue, 25 Oct 2022 07:44:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231925AbiJYLn5 (ORCPT ); Tue, 25 Oct 2022 07:43:57 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1860917537A for ; Tue, 25 Oct 2022 04:43:55 -0700 (PDT) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29PB7uKS006252 for ; Tue, 25 Oct 2022 11:43:54 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=Rr5w/3x1oQlLRljNtIP878GohRWWtenlK2aogyaq5dM=; b=LBDIIpuy4bbc3e3pkF+bgGQi9o/kjicVMi5naGPViCLxHrEZYOyMMRfV4eA9+UGxF+Cz ckcdwwH3Blu93oBbGoYqlsy4Rnm8rxYi65MwWck9vPyFSw0KorukjTWK7JTqYnQ0F/C+ t/h3Pg+J0OL3NM/sdf4615P3K0w7c5UISoEqI8ihXDas/niAoKsbJhiFOIhDLm/vZJNx EEJjLusFLpUYqFv52q2pTIv8Kl9ydmkWi6nDx+l/9/gOcCuhwFEvxU16tgIHtJDTjnro MCYhNHFRfWRIuD1tYW8WCiHr0zDeNqA6FcxEDXeBw2r5obLt6OEe1FHMGOmDK0uDjn1x gw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ked6qvfap-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:54 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29PBJHWN027642 for ; Tue, 25 Oct 2022 11:43:54 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 3ked6qvf9w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:54 +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 29PBdmbR013584; Tue, 25 Oct 2022 11:43:51 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03fra.de.ibm.com with ESMTP id 3kdv5fgr4a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:51 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBcZDv40370652 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:38:35 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0E410AE045; Tue, 25 Oct 2022 11:43:48 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D0ACAAE051; Tue, 25 Oct 2022 11:43:47 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:47 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Steffen Eiden Subject: [kvm-unit-tests GIT PULL 09/22] s390x: uv-host: Test uv immediate parameter Date: Tue, 25 Oct 2022 13:43:32 +0200 Message-Id: <20221025114345.28003-10-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: dZMcyW974H22hQAAxEX7ju3a5yTzeDiD X-Proofpoint-ORIG-GUID: zSrOqjsqfIUemayAvhmoYT14WK-_RHr1 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 clxscore=1015 bulkscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=854 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank Let's check if we get a specification PGM exception if we set a non-zero i3 when doing a UV call. Signed-off-by: Janosch Frank Reviewed-by: Steffen Eiden Message-Id: <20221017093925.2038-4-frankja@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- s390x/uv-host.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index 24dcd6dc..e401fa5d 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -90,6 +90,28 @@ static struct cmd_list cmds[] = { { NULL, 0, 0 }, }; +static void test_i3(void) +{ + struct uv_cb_header uvcb = { + .cmd = UVC_CMD_INIT_UV, + .len = sizeof(struct uv_cb_init), + }; + unsigned long r1 = 0; + int cc; + + report_prefix_push("i3"); + expect_pgm_int(); + asm volatile( + "0: .insn rrf,0xB9A40000,%[r1],%[r2],4,2\n" + " ipm %[cc]\n" + " srl %[cc],28\n" + : [cc] "=d" (cc) + : [r1] "a" (r1), [r2] "a" (&uvcb) + : "memory", "cc"); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + report_prefix_pop(); +} + static void test_priv(void) { struct uv_cb_header uvcb = {}; @@ -585,6 +607,7 @@ int main(void) goto done; } + test_i3(); test_priv(); test_invalid(); test_uv_uninitialized(); From patchwork Tue Oct 25 11:43:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019096 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 14FE1ECDFA1 for ; Tue, 25 Oct 2022 11:44:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230245AbiJYLoM (ORCPT ); Tue, 25 Oct 2022 07:44:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231938AbiJYLn5 (ORCPT ); Tue, 25 Oct 2022 07:43:57 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08739175379 for ; Tue, 25 Oct 2022 04:43:55 -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 29PB7tQP030425 for ; Tue, 25 Oct 2022 11:43:54 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=I00cO2SD4zQxeQ0lN5Qm+MFrfW7sMi+fD3Q42xpkD/M=; b=cwCd+mXF1oqmQrZKidX2RkFuVQW5volRN8cdvDo7IbnseNLKFCJO7HPdwYNotnx2yOTE UeKw/7Cd56O2o7rW60A1dsX2P8cjR5sfehh4MJfOgpMuIEPChegqRtgjDyR99aMDy5ez ilLXxjgSqMokhsPT4gNCs0i8UKEs5Yo2DN7p1w0RxFGWaE3thIH/aXG8mxJ853uoac8q O71JtZ3+YKjxj8yvuP+LVJGiIeUUo8E+3xBRL344ccs+M/If28gbtxJ1EAnz+nH79bgO l53XlYVLaFXTQWRoGL3zrOrW0YxYw+zTabBA7wJAA8O7+0VFbwNkaiSLtIyHxryu82KN FQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kedu32u2k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:54 +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 29PBNXIH006970 for ; Tue, 25 Oct 2022 11:43:54 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 3kedu32u1k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:53 +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 29PBdGlr011453; Tue, 25 Oct 2022 11:43:51 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma01fra.de.ibm.com with ESMTP id 3kc8593yv4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:51 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBcZ8e41484576 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:38:35 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 52170AE045; Tue, 25 Oct 2022 11:43:48 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18D65AE053; Tue, 25 Oct 2022 11:43:48 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:48 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Steffen Eiden , Nico Boehr Subject: [kvm-unit-tests GIT PULL 10/22] s390x: uv-host: Add access exception test Date: Tue, 25 Oct 2022 13:43:33 +0200 Message-Id: <20221025114345.28003-11-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 3HTACBoYvSuNRCj3j9-ViZlMDKm4abVg X-Proofpoint-ORIG-GUID: FY70dGD7g_KRGO9TLNRpsQ0kXej9FCa3 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 priorityscore=1501 adultscore=0 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 mlxscore=0 phishscore=0 mlxlogscore=931 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank Let's check that we get access exceptions if the UVCB is on an invalid page or starts at a valid page and crosses into an invalid one. Signed-off-by: Janosch Frank Reviewed-by: Steffen Eiden Reviewed-by: Nico Boehr Message-Id: <20221017093925.2038-5-frankja@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- s390x/uv-host.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index e401fa5d..305b490f 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -15,12 +15,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include @@ -150,6 +152,54 @@ static void test_uv_uninitialized(void) report_prefix_pop(); } +static void test_access(void) +{ + struct uv_cb_header *uvcb; + void *pages = alloc_pages(1); + uint16_t pgm; + int i; + + /* Put UVCB on second page which we will protect later */ + uvcb = pages + PAGE_SIZE; + + report_prefix_push("access"); + + report_prefix_push("non-crossing"); + protect_page(uvcb, PAGE_ENTRY_I); + for (i = 0; cmds[i].name; i++) { + expect_pgm_int(); + mb(); + uv_call_once(0, (uint64_t)uvcb); + pgm = clear_pgm_int(); + report(pgm == PGM_INT_CODE_PAGE_TRANSLATION, "%s", cmds[i].name); + } + report_prefix_pop(); + + report_prefix_push("crossing"); + /* + * Put the header into the readable page 1, everything after + * the header will be on the second, invalid page. + */ + uvcb -= 1; + for (i = 0; cmds[i].name; i++) { + uvcb->cmd = cmds[i].cmd; + uvcb->len = cmds[i].len; + + expect_pgm_int(); + mb(); + uv_call_once(0, (uint64_t)uvcb); + pgm = clear_pgm_int(); + report(pgm == PGM_INT_CODE_PAGE_TRANSLATION, "%s", cmds[i].name); + } + report_prefix_pop(); + + uvcb += 1; + unprotect_page(uvcb, PAGE_ENTRY_I); + + free_pages(pages); + report_prefix_pop(); +} + static void test_config_destroy(void) { int rc; @@ -615,6 +665,8 @@ int main(void) test_init(); setup_vmem(); + test_access(); + test_config_create(); test_cpu_create(); test_cpu_destroy(); From patchwork Tue Oct 25 11:43:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019098 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 750A0C04A95 for ; Tue, 25 Oct 2022 11:44:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231739AbiJYLoR (ORCPT ); Tue, 25 Oct 2022 07:44:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231987AbiJYLn5 (ORCPT ); Tue, 25 Oct 2022 07:43:57 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 014BA17535C for ; Tue, 25 Oct 2022 04:43:54 -0700 (PDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29PB8UIc011576 for ; Tue, 25 Oct 2022 11:43:54 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=clu6OQ6JaBz3eP1HGsNYBZoV6x1K04GF0jA3ljFhupE=; b=Sl2W1nt2KH0WxHbYdK2u8Pwh1nLwL73cIIg/z/WrD615aZ/ZiAx7B/DCP1q2POzlOo4D X+RbdjOWa12F8NEvV3U0Ujn3yI8Jb+YJrlaPwpTAwLsgs0TPLpPD72pj6K8t8HLxUVEY rpho6s8mQTdPB6noGZaQknikIggZCi4Ii+KTU63xtOf20Au/pzIiBXwKcz4xj6qLRBc7 5LjWorrgUr5OhcC2zZ/RzC4FCdinG9LA8eyYOvTNBnliHvm9wEfGM+fMh69uYdCM4MTz nixcahDtq4IP+N6MclAN9uXK0KZ1Y8p3rnt8HQY9hlZiJ0de/2i7RF+Ls5D9WHKgY6Ob DA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kee02tdn4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:53 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29PB94NN013911 for ; Tue, 25 Oct 2022 11:43:53 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kee02tdmj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:53 +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 29PBc7cI013897; Tue, 25 Oct 2022 11:43:51 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma05fra.de.ibm.com with ESMTP id 3kc8594ddm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:51 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBcZS348365836 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:38:35 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8F5FCAE045; Tue, 25 Oct 2022 11:43:48 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5DC56AE055; Tue, 25 Oct 2022 11:43:48 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:48 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Steffen Eiden Subject: [kvm-unit-tests GIT PULL 11/22] s390x: uv-host: Add a set secure config parameters test function Date: Tue, 25 Oct 2022 13:43:34 +0200 Message-Id: <20221025114345.28003-12-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: CqLNPoBvnRPeNLeCPiKeZcsCA40QAArG X-Proofpoint-ORIG-GUID: iJwP1RVNEEqiHkWCXudhvEL2akRBnU5Y 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 phishscore=0 adultscore=0 malwarescore=0 mlxscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank Time for more tests. Signed-off-by: Janosch Frank Reviewed-by: Steffen Eiden Message-Id: <20221017093925.2038-6-frankja@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- s390x/uv-host.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index 305b490f..05502d9a 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -256,6 +256,53 @@ static void test_cpu_destroy(void) report_prefix_pop(); } +static void test_set_se_header(void) +{ + struct uv_cb_ssc uvcb = { + .header.cmd = UVC_CMD_SET_SEC_CONF_PARAMS, + .header.len = sizeof(uvcb), + .guest_handle = uvcb_cgc.guest_handle, + .sec_header_origin = 0, + .sec_header_len = 0x1000, + }; + void *pages = alloc_pages(1); + void *inv; + int rc; + + report_prefix_push("sscp"); + + uvcb.header.len -= 8; + rc = uv_call(0, (uint64_t)&uvcb); + report(rc == 1 && uvcb.header.rc == UVC_RC_INV_LEN, + "hdr invalid length"); + uvcb.header.len += 8; + + uvcb.guest_handle += 1; + rc = uv_call(0, (uint64_t)&uvcb); + report(rc == 1 && uvcb.header.rc == UVC_RC_INV_GHANDLE, "invalid handle"); + uvcb.guest_handle -= 1; + + inv = pages + PAGE_SIZE; + uvcb.sec_header_origin = (uint64_t)inv; + protect_page(inv, PAGE_ENTRY_I); + rc = uv_call(0, (uint64_t)&uvcb); + report(rc == 1 && uvcb.header.rc == 0x103, + "se hdr access exception"); + + /* + * Shift the ptr so the first few DWORDs are accessible but + * the following are on an invalid page. + */ + uvcb.sec_header_origin -= 0x20; + rc = uv_call(0, (uint64_t)&uvcb); + report(rc == 1 && uvcb.header.rc == 0x103, + "se hdr access exception crossing"); + unprotect_page(inv, PAGE_ENTRY_I); + + free_pages(pages); + report_prefix_pop(); +} + static void test_cpu_create(void) { int rc; @@ -669,6 +716,7 @@ int main(void) test_config_create(); test_cpu_create(); + test_set_se_header(); test_cpu_destroy(); test_config_destroy(); test_clear(); From patchwork Tue Oct 25 11:43:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019099 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 14ADBC38A2D for ; Tue, 25 Oct 2022 11:44:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232103AbiJYLoT (ORCPT ); Tue, 25 Oct 2022 07:44:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231972AbiJYLn5 (ORCPT ); Tue, 25 Oct 2022 07:43:57 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 037B3175378 for ; Tue, 25 Oct 2022 04:43:54 -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 29PB8gcs031257 for ; Tue, 25 Oct 2022 11:43:54 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=utgcngMBOfxpFnPw7+copp+Yloi8iSab8fJfwcLJLDQ=; b=Vz8G4Flte30YhXhlQ/ziy8MAOCh8G0jUSU0j09ukffMudGJIrRnLYOQKuSr8hOLhDiwJ qYMHbkILUR+fXDFlx+un24wqtInrHC1oDW4BuKDq7LFeX6Bkk0/Ca8gd/4nHDZJxJCXw 0aTe7U0itg9x9cY/KMRKejrVnpz6oy1JyLxRU1KdY5wEjxasxr9CDjf2ZkLYJza+w831 1qxnveQdmsLpKvxOQ4oxs+g3741akmzV8TogUiAh97RTq+h6v5JGYVTjj0bM8/zndL55 S7I1Ac29C9nw4/DiZ1DHUKN5d/jZcjlGP285aFHLIckgR6qIOxSurAzSn5JjKImoqkP8 2A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kecrqw80k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:54 +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 29PB9amg002379 for ; Tue, 25 Oct 2022 11:43:53 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 3kecrqw803-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:53 +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 29PBcZlQ012640; Tue, 25 Oct 2022 11:43:52 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03fra.de.ibm.com with ESMTP id 3kdv5fgr4b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:51 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBcaCW48365838 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:38:36 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D573EAE045; Tue, 25 Oct 2022 11:43:48 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B4B6AE04D; Tue, 25 Oct 2022 11:43:48 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:48 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Steffen Eiden Subject: [kvm-unit-tests GIT PULL 12/22] s390x: uv-host: Remove duplicated + Date: Tue, 25 Oct 2022 13:43:35 +0200 Message-Id: <20221025114345.28003-13-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 9lUuboQXFy_z12CXQlmTsBtpQ5dUyNcR X-Proofpoint-ORIG-GUID: sgev4ScmF2gez5EDpRWB346R_FQbVy67 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 phishscore=0 impostorscore=0 spamscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank One + is definitely enough here. Signed-off-by: Janosch Frank Reviewed-by: Claudio Imbrenda Reviewed-by: Steffen Eiden Message-Id: <20221017093925.2038-7-frankja@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- s390x/uv-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index 05502d9a..76d3e373 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -451,7 +451,7 @@ static void test_config_create(void) uvcb_cgc.guest_sca = tmp; tmp = uvcb_cgc.guest_sca; - uvcb_cgc.guest_sca = get_max_ram_size() + + PAGE_SIZE * 4; + uvcb_cgc.guest_sca = get_max_ram_size() + PAGE_SIZE * 4; rc = uv_call(0, (uint64_t)&uvcb_cgc); report(uvcb_cgc.header.rc == 0x10d && rc == 1, "sca inaccessible"); From patchwork Tue Oct 25 11:43:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019103 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 61571C38A2D for ; Tue, 25 Oct 2022 11:44:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231452AbiJYLo0 (ORCPT ); Tue, 25 Oct 2022 07:44:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232038AbiJYLn5 (ORCPT ); Tue, 25 Oct 2022 07:43:57 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9607617537C for ; Tue, 25 Oct 2022 04:43:55 -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 29PB8TMS028294 for ; Tue, 25 Oct 2022 11:43:54 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=7kjQ9DF9WFWNcAjx5lOKSIj65pE+NAI8k6isQJFkH20=; b=h8iI5z44jEdsujgq7OvLG21zaM5g2KB17NaykUQTCqxBX4Wn0O59ICzpxH1SP7HiGRKq 8TLWdavHdPSECd7OntRlFBDOrpY8/CGBHQ+kFMDQL6W/s1g9yW4qXpP2jY16Fs2txK2q KMCDEZOdSgm4we3/14otdeAwNbEY3ZRiXoNRFr8fH3NFVQZql3CVvIN/gXDz7UVLFEgy tuDDmahwncDbMulv7CLTlfzXquJR5Mj4/6XiX0UInuGTGQZHTqGJJ5EYaRAPvva28yCX jl4lL08bGkpTyFCjw3EWwKoIIYfd2dFxHSWJksh2cC+r5e9bWyfb548Cv9FCef4XBnIh 8A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kebjt8aa9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:54 +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 29PB9psM002534 for ; Tue, 25 Oct 2022 11:43:54 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kebjt8a9h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:54 +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 29PBdEGB024284; Tue, 25 Oct 2022 11:43:52 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 3kdugat57a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:52 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBhnFc1573446 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:43:49 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 279D2AE045; Tue, 25 Oct 2022 11:43:49 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E13FCAE051; Tue, 25 Oct 2022 11:43:48 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:48 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Steffen Eiden Subject: [kvm-unit-tests GIT PULL 13/22] s390x: uv-host: Fence against being run as a PV guest Date: Tue, 25 Oct 2022 13:43:36 +0200 Message-Id: <20221025114345.28003-14-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fsrzswH_wXGYYucMCMfGsLZzlRm88qNV X-Proofpoint-ORIG-GUID: _HbA-BjIOEU7jFWMwBg11iHJveeCQo45 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 clxscore=1015 mlxscore=0 adultscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank This test checks the UV host API so we should skip it if we're a PV guest. Signed-off-by: Janosch Frank Reviewed-by: Steffen Eiden Message-Id: <20221017093925.2038-8-frankja@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- s390x/uv-host.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index 76d3e373..a33389b9 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -703,6 +703,10 @@ int main(void) report_skip("Ultravisor call facility is not available"); goto done; } + if (!uv_os_is_host()) { + report_skip("This test needs to be run in a UV host environment"); + goto done; + } test_i3(); test_priv(); From patchwork Tue Oct 25 11:43:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019102 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 12554C04A95 for ; Tue, 25 Oct 2022 11:44:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231749AbiJYLoY (ORCPT ); Tue, 25 Oct 2022 07:44:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232062AbiJYLn6 (ORCPT ); Tue, 25 Oct 2022 07:43:58 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EAD017536E for ; Tue, 25 Oct 2022 04:43:56 -0700 (PDT) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29PB7vDV006340 for ; Tue, 25 Oct 2022 11:43:55 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=Oh+orQqoWd9tY0JbhI7tgzChpyC/W1hknh15aIO3IME=; b=oYrCKfjRMHjVNaUC6FjKyKk7Gyfjuru9m0fw+OPeGY7U9YaxUorLTI9I5AWXXvJ8UyZt +hvzAgaWzjefnBl8WDcJBDINnRpApTaQspUBhbyfvQX5mJFpmSo0DeaNUS52oCPNqmhW rIJgVb6Yerq8G9FrIbaW+nIXmbvZkGbp01W8rt1B8b7gqL/0Sla5kbgPi5g4tWkZOxOc 79Pcb4m4Kmr1nkCx5qlT3rc41JK7MPiRfyv5jPUk1AkjYmqT3KmcAnlCLu2JHDUP0bCC 6S9IIhl9IH40XvSRxjk/Xo417JAlNbwdcUPqVVMu6Gc84CnX/nuWcmXBN3DakGythaFa 9g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ked6qvfbg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:55 +0000 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29PB8F64007833 for ; Tue, 25 Oct 2022 11:43:55 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 3ked6qvfa9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:55 +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 29PBc6nq013894; Tue, 25 Oct 2022 11:43:52 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma05fra.de.ibm.com with ESMTP id 3kc8594ddn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:52 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBhnw21573448 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:43:49 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 64A6DAE045; Tue, 25 Oct 2022 11:43:49 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 33719AE04D; Tue, 25 Oct 2022 11:43:49 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:49 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Steffen Eiden Subject: [kvm-unit-tests GIT PULL 14/22] s390x: uv-host: Fix init storage origin and length check Date: Tue, 25 Oct 2022 13:43:37 +0200 Message-Id: <20221025114345.28003-15-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 1V-MkOt139rprsQk8v712DF2D9EWkSFM X-Proofpoint-ORIG-GUID: HBWS-VFXiWG1KQqSQOSd5wOPLPNhWjqW 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 clxscore=1015 bulkscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=992 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank The origin and length are masked with the HPAGE_MASK and PAGE_MASK respectively so adding a few bytes doesn't matter at all. Signed-off-by: Janosch Frank Reviewed-by: Steffen Eiden Message-Id: <20221017093925.2038-9-frankja@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- s390x/uv-host.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index a33389b9..191e8b3f 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -524,17 +524,22 @@ static void test_init(void) "storage invalid length"); uvcb_init.stor_len += 8; - uvcb_init.stor_origin = get_max_ram_size() + 8; + /* Storage origin is 1MB aligned, the length is 4KB aligned */ + uvcb_init.stor_origin = get_max_ram_size(); rc = uv_call(0, (uint64_t)&uvcb_init); - report(rc == 1 && uvcb_init.header.rc == 0x104, + report(rc == 1 && (uvcb_init.header.rc == 0x104 || uvcb_init.header.rc == 0x105), "storage origin invalid"); uvcb_init.stor_origin = mem; - uvcb_init.stor_origin = get_max_ram_size() - 8; - rc = uv_call(0, (uint64_t)&uvcb_init); - report(rc == 1 && uvcb_init.header.rc == 0x105, - "storage + length invalid"); - uvcb_init.stor_origin = mem; + if (uvcb_init.stor_len >= HPAGE_SIZE) { + uvcb_init.stor_origin = get_max_ram_size() - HPAGE_SIZE; + rc = uv_call(0, (uint64_t)&uvcb_init); + report(rc == 1 && uvcb_init.header.rc == 0x105, + "storage + length invalid"); + uvcb_init.stor_origin = mem; + } else { + report_skip("storage + length invalid, stor_len < HPAGE_SIZE"); + } uvcb_init.stor_origin = 1UL << 30; rc = uv_call(0, (uint64_t)&uvcb_init); From patchwork Tue Oct 25 11:43:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019101 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 A3D4DC04A95 for ; Tue, 25 Oct 2022 11:44:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232195AbiJYLoW (ORCPT ); Tue, 25 Oct 2022 07:44:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232006AbiJYLn5 (ORCPT ); Tue, 25 Oct 2022 07:43:57 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2741C175366 for ; Tue, 25 Oct 2022 04:43:56 -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 29PB8A3O028254 for ; Tue, 25 Oct 2022 11:43:55 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=fW03cszluypob1Kl7I4yUcvR8fEHIFec+VMud8zwcHU=; b=aLFsGsU57BPoTmQoAU0yCkZymu0u8R96egjxRhOdntpy9s7Dh5V6NzXvn+lm/aG4Wlwk hxd8Fqv020Y5pe+WF+nQiDgvlwXiPFvQNZ9sTAIc8AhPvZgh6aZ+K/ERIhNEAGJD7YRG 28du8LCt8CR/89aEZ7nUMEYYgoQmc+PCucbtUuweUpiatzDWzym0+UVaB5hMOChyM7QP BRrhqOmjSt6vv1j83JvJscuKJWkJolV7JpkqVcdyYBlZAp/vae5u4cqIkecJZqORBxxg 2z7cRONl3HSFYpHbf6WgYn6kX/oa38NH7e40gowBIwUnsBqeVp+JHoORucXyClj28mID DQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kee35t8ey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:55 +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 29PBPDk2017640 for ; Tue, 25 Oct 2022 11:43:55 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 3kee35t8e2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:55 +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 29PBd9Nc024274; Tue, 25 Oct 2022 11:43:52 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 3kdugat57b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:52 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBhnnK21496144 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:43:49 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A369DAE04D; Tue, 25 Oct 2022 11:43:49 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 70193AE051; Tue, 25 Oct 2022 11:43:49 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:49 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 15/22] lib: s390x: terminate if PGM interrupt in interrupt handler Date: Tue, 25 Oct 2022 13:43:38 +0200 Message-Id: <20221025114345.28003-16-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 2YXAzw22ZJ-gkCK2Gp55HtY9BPvVFZLS X-Proofpoint-GUID: vTsIaSK5zPprdJ8U00jo-Bpjto9s_rmy 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=367 suspectscore=0 adultscore=0 mlxscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 phishscore=0 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org If a program interrupt is received while in an interrupt handler, terminate immediately, stopping all CPUs and leaving the last CPU in disabled wait with a specific PSW code. This will aid debugging by not cluttering the output, avoiding further interrupts (that would be needed to write to the output), and providing an indication of the cause of the termination. Signed-off-by: Claudio Imbrenda Message-Id: <20221020123143.213778-2-imbrenda@linux.ibm.com> Reviewed-by: Nico Boehr --- lib/s390x/asm/arch_def.h | 11 +++++++++++ lib/s390x/interrupt.c | 20 ++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h index 41c9bd8c..783a7eaa 100644 --- a/lib/s390x/asm/arch_def.h +++ b/lib/s390x/asm/arch_def.h @@ -56,6 +56,7 @@ struct cpu { bool active; bool pgm_int_expected; bool ext_int_expected; + bool in_interrupt_handler; }; #define AS_PRIM 0 @@ -336,6 +337,16 @@ static inline void load_psw_mask(uint64_t mask) : "+r" (tmp) : "a" (&psw) : "memory", "cc" ); } +static inline void disabled_wait(uint64_t message) +{ + struct psw psw = { + .mask = PSW_MASK_WAIT, /* Disabled wait */ + .addr = message, + }; + + asm volatile(" lpswe 0(%0)\n" : : "a" (&psw) : "memory", "cc"); +} + /** * psw_mask_clear_bits - clears bits from the current PSW mask * @clear: bitmask of bits that will be cleared diff --git a/lib/s390x/interrupt.c b/lib/s390x/interrupt.c index 7cc2c5fb..dadb7415 100644 --- a/lib/s390x/interrupt.c +++ b/lib/s390x/interrupt.c @@ -14,6 +14,7 @@ #include #include #include +#include "smp.h" /** * expect_pgm_int - Expect a program interrupt on the current CPU. @@ -226,6 +227,11 @@ static void print_pgm_info(struct stack_frame_int *stack) void handle_pgm_int(struct stack_frame_int *stack) { + if (THIS_CPU->in_interrupt_handler) { + /* Something went very wrong, stop everything now without printing anything */ + smp_teardown(); + disabled_wait(0xfa12edbad21); + } if (!THIS_CPU->pgm_int_expected) { /* Force sclp_busy to false, otherwise we will loop forever */ sclp_handle_ext(); @@ -233,15 +239,18 @@ void handle_pgm_int(struct stack_frame_int *stack) } THIS_CPU->pgm_int_expected = false; + THIS_CPU->in_interrupt_handler = true; if (THIS_CPU->pgm_cleanup_func) THIS_CPU->pgm_cleanup_func(stack); else fixup_pgm_int(stack); + THIS_CPU->in_interrupt_handler = false; } void handle_ext_int(struct stack_frame_int *stack) { + THIS_CPU->in_interrupt_handler = true; if (!THIS_CPU->ext_int_expected && lowcore.ext_int_code != EXT_IRQ_SERVICE_SIG) { report_abort("Unexpected external call interrupt (code %#x): on cpu %d at %#lx", lowcore.ext_int_code, stap(), lowcore.ext_old_psw.addr); @@ -260,6 +269,7 @@ void handle_ext_int(struct stack_frame_int *stack) if (THIS_CPU->ext_cleanup_func) THIS_CPU->ext_cleanup_func(stack); + THIS_CPU->in_interrupt_handler = false; } void handle_mcck_int(void) @@ -272,11 +282,13 @@ static void (*io_int_func)(void); void handle_io_int(void) { + THIS_CPU->in_interrupt_handler = true; if (io_int_func) - return io_int_func(); - - report_abort("Unexpected io interrupt: on cpu %d at %#lx", - stap(), lowcore.io_old_psw.addr); + io_int_func(); + else + report_abort("Unexpected io interrupt: on cpu %d at %#lx", + stap(), lowcore.io_old_psw.addr); + THIS_CPU->in_interrupt_handler = false; } int register_io_int_func(void (*f)(void)) From patchwork Tue Oct 25 11:43:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019100 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 C6EA1C38A2D for ; Tue, 25 Oct 2022 11:44:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230075AbiJYLoU (ORCPT ); Tue, 25 Oct 2022 07:44:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232058AbiJYLn6 (ORCPT ); Tue, 25 Oct 2022 07:43:58 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6041F17579E for ; Tue, 25 Oct 2022 04:43:56 -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 29PB891H028179 for ; Tue, 25 Oct 2022 11:43:56 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=YKdBzTKjyGoc08uZsMMYw6HkTyEebJff88vpFXTYmBM=; b=OCymQbhEJU3VnE9twdP49Y2zeHFd68JrIvOSiTzl9ed/V8QCcm0DXs3QanEOmKrJMX1x YkhnyJqe6XjT4PYjiJLGWdQ7Nt62G0AHe6r3QCC4tO67Uqc8p/coC+mmxdKoW7QDo+FZ A6WaqGt5kSJxs/O2Uj3sSZfoKU7qJmgZudlqgN9AWWpJY2kviiupZgd/126qeMqc5yG+ 1qN0IJNtc4bXthC7a7kGGHTNeDgyJIF2/g60GFLGbTwBklv8aaTJmBm+ghuA5jhqcWO4 YPylSV+QNukCpJZNZE3eOSseSlfXfMhVHPG5ZcheQafwvh6g7aER7oNgfzBBBzgL0p2e fQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kee35t8f6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:55 +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 29PB8AZB028265 for ; Tue, 25 Oct 2022 11:43:55 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 3kee35t8e5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:55 +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 29PBd8YP024257; Tue, 25 Oct 2022 11:43:53 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03ams.nl.ibm.com with ESMTP id 3kdugat57c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:53 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBhoQ14981394 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:43:50 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC63FAE04D; Tue, 25 Oct 2022 11:43:49 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AFB2CAE053; Tue, 25 Oct 2022 11:43:49 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:49 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Steffen Eiden Subject: [kvm-unit-tests GIT PULL 16/22] s390x: uv-host: fix allocation of UV memory Date: Tue, 25 Oct 2022 13:43:39 +0200 Message-Id: <20221025114345.28003-17-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: _lxJ20aQGQkpPjQQjmmKv1I4ocQr4NBY X-Proofpoint-GUID: xw8rduj7b6rx9gLRd4_KK_cdHqb6aZqD 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=985 suspectscore=0 adultscore=0 mlxscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 phishscore=0 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Allocate the donated storage with 1M alignment from the normal pool, to force it to be above 2G without wasting a whole 2G block of memory. Signed-off-by: Claudio Imbrenda Message-Id: <20221020123143.213778-3-imbrenda@linux.ibm.com> Reviewed-by: Janosch Frank Reviewed-by: Steffen Eiden --- s390x/uv-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s390x/uv-host.c b/s390x/uv-host.c index 191e8b3f..9f09f80e 100644 --- a/s390x/uv-host.c +++ b/s390x/uv-host.c @@ -504,7 +504,7 @@ static void test_init(void) struct psw psw; /* Donated storage needs to be over 2GB */ - mem = (uint64_t)memalign(1UL << 31, uvcb_qui.uv_base_stor_len); + mem = (uint64_t)memalign_pages_flags(SZ_1M, uvcb_qui.uv_base_stor_len, AREA_NORMAL); uvcb_init.header.len = sizeof(uvcb_init); uvcb_init.header.cmd = UVC_CMD_INIT_UV; From patchwork Tue Oct 25 11:43:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019104 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 62D2EC04A95 for ; Tue, 25 Oct 2022 11:44:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231376AbiJYLo1 (ORCPT ); Tue, 25 Oct 2022 07:44:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231766AbiJYLn6 (ORCPT ); Tue, 25 Oct 2022 07:43:58 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A9FB172B6E for ; Tue, 25 Oct 2022 04:43:56 -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 29PB8T0D028356 for ; Tue, 25 Oct 2022 11:43:55 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=LBNGIx0NhGmblKcVx4Tvn9bAbddOPCXabpCjyURzZa4=; b=Ihmo645eoFoQ8D8S9pTMEBw14nbGAkpSubFvJG8PxIeVL3c+nJrxGThQn7D7Y6Ce+bKc SnaoiAaZ+DZFRG2e1ro9XHIWU2TzzRMn72KAvv7w5aBhMI3uWCr9+kgeB57WAMPMgsFk yhcGY3cGcINW/mvcqiyfAq619xvUjhWSz6R6HJKlgXU3UyDm+ayVXyiLedXX3vFV07mC PedGEUSk0+JiXajRxf6qUetoqbw4KtEDC4d15S4xji83vKfyt9xHpxg0Ay3+3j9FPoQ5 TaEGz5HJGDWoFzpQg/NprbTWF49jKiKaSbWmXGc3QjLAJ0n25BabK+IIQ/a0057vrAAP cg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kebjt8aaq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:55 +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 29PBFMcL026943 for ; Tue, 25 Oct 2022 11:43:55 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kebjt8aa1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:55 +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 29PBc2fm026793; Tue, 25 Oct 2022 11:43:53 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma04ams.nl.ibm.com with ESMTP id 3kc859dhpr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:53 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBhoO24981398 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:43:50 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3589EAE045; Tue, 25 Oct 2022 11:43:50 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 038A3AE051; Tue, 25 Oct 2022 11:43:50 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:49 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 17/22] s390x: snippets: asm: Add a macro to write an exception PSW Date: Tue, 25 Oct 2022 13:43:40 +0200 Message-Id: <20221025114345.28003-18-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: UvGy8eSs2XqvYcjgr8f1wAt94uczpVwp X-Proofpoint-ORIG-GUID: CRhwr9B-kgS9IlV8ILYM9FCTq_ZOHkTV 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 clxscore=1015 mlxscore=0 adultscore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank 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 Message-Id: <20221021063902.10878-2-frankja@linux.ibm.com> Signed-off-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 Tue Oct 25 11:43:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019109 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 10D94C04A95 for ; Tue, 25 Oct 2022 11:44:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232146AbiJYLog (ORCPT ); Tue, 25 Oct 2022 07:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232164AbiJYLoC (ORCPT ); Tue, 25 Oct 2022 07:44:02 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A494175372 for ; Tue, 25 Oct 2022 04:44:01 -0700 (PDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29PB8Wnd011996 for ; Tue, 25 Oct 2022 11:44:00 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=KBK7hxF6AsbVOiGUxhW8EfLU7ptE1OhO3ccu/YAmvLw=; b=QrcqRcKU2LHydT3ah6CxWDrL/aYpEwMrdzwTVZPtdN0Pj3e3octw/+5HdPnRu+4/RGSz Z0fqCMFqwtJbqke7oMSFbwRXyT+CwCs51FwBENvjuPZudXfAFsgANPPBpmDREu9l/MHz +y1lk72fzvnzWWvPVJaie/30Or00W6IlQE9C46MYAxvsFJe6Z0nPvT12MjPVDZIf9D/z yd/5dZNy+MGjnjtoUM5yaexSHgxRlQNF0M8FSf0kkpPzi1XYUbkuXoZ3UbXmV50Efby2 CmAvfRay6euEF4K4MLkN+DjCynHYVDBEwQxP6QWzz+YhWzDx1xt/tCJkvl8WuIj+IK7J +g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kee02tdqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:44:00 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29PB9S0u015218 for ; Tue, 25 Oct 2022 11:44:00 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kee02tdnb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:59 +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 29PBdQcc014327; Tue, 25 Oct 2022 11:43:53 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06ams.nl.ibm.com with ESMTP id 3kc7sj5h74-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:53 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBhoF16685198 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:43:50 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 81DF6AE045; Tue, 25 Oct 2022 11:43:50 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 42463AE04D; Tue, 25 Oct 2022 11:43:50 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:50 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Steffen Eiden , Nico Boehr Subject: [kvm-unit-tests GIT PULL 18/22] s390x: MAKEFILE: Use $< instead of pathsubst Date: Tue, 25 Oct 2022 13:43:41 +0200 Message-Id: <20221025114345.28003-19-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: RM0m4VEmmDeWNVMTW-B6Z6OR-abxUWUB X-Proofpoint-ORIG-GUID: njzunYGZCg_bbbLN3eOfADPJJN8nAS2v 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=673 impostorscore=0 phishscore=0 adultscore=0 malwarescore=0 mlxscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank 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 Message-Id: <20221021063902.10878-3-frankja@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- s390x/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s390x/Makefile b/s390x/Makefile index 5e0b4f39..bf1504f9 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -139,7 +139,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 Tue Oct 25 11:43:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019106 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 325AAC04A95 for ; Tue, 25 Oct 2022 11:44:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231646AbiJYLoa (ORCPT ); Tue, 25 Oct 2022 07:44:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232113AbiJYLn7 (ORCPT ); Tue, 25 Oct 2022 07:43:59 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C095175359 for ; Tue, 25 Oct 2022 04:43:57 -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 29PB8gcu031257 for ; Tue, 25 Oct 2022 11:43:56 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=pYHlWgD2iqu2Vb5guvPgnpBXDmDe7NoACbeU3KjJCGU=; b=iT+ltxbpEPQQfitRwUn7d9KCo3VyIifHGFmEbNYRuakO4wsFLviXcQrTUWKwg72wryqj MKWI0BA9jnhbqt0aRLhRsk/MnXtoORltktkmszgxQYywG4WBIrmIVeeclV2WEWfkH9Jc JcHKfk5wvtDWRAvn+6qiXqPYvx8AEZOxM7WTfWl4WCu2LGB2yDLGYAFUR5CAMsqmXFD8 m/m6PPH04vem2RRaRPouUolohvdsM6+qG5KXfksaV9DwZYyYwK1dINFJ4RR4ojIFfgQS BnYdWpoarrQcFE2WCuRFAxRz/kYAUA2n1FCqcunjIThzKltzDRR6nM94OkrTmAVbKSf3 pw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kecrqw81p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:56 +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 29PBRIqg015873 for ; Tue, 25 Oct 2022 11:43:56 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 3kecrqw80v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:55 +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 29PBdIXA013085; Tue, 25 Oct 2022 11:43:54 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 3kdv5fgr4c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:53 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBhoZt6685200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:43:50 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C49ACAE045; Tue, 25 Oct 2022 11:43:50 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8DBE2AE051; Tue, 25 Oct 2022 11:43:50 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:50 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Steffen Eiden , Nico Boehr Subject: [kvm-unit-tests GIT PULL 19/22] lib: s390x: sie: Improve validity handling and make it vm specific Date: Tue, 25 Oct 2022 13:43:42 +0200 Message-Id: <20221025114345.28003-20-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Pk1_88IVANA-wULbjgDox8imPzyydwrB X-Proofpoint-ORIG-GUID: ExEGBT1ew40XZsupynXe-sLYdQXCvwP3 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 phishscore=0 impostorscore=0 spamscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 mlxlogscore=560 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank 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 Message-Id: <20221021063902.10878-4-frankja@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- lib/s390x/sie.h | 6 ++++-- lib/s390x/sie.c | 25 +++++++++++++------------ 2 files changed, 17 insertions(+), 14 deletions(-) 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); 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(struct vm *vm) +{ + vm->validity_expected = true; +} -void sie_expect_validity(void) +uint16_t sie_get_validity(struct vm *vm) { - validity_expected = true; - vir = 0; + assert(vm->sblk->icptcode == ICPT_VALIDITY); + return vm->sblk->ipb >> 16; } -void sie_check_validity(uint16_t vir_exp) +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) From patchwork Tue Oct 25 11:43:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019105 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 F1126C38A2D for ; Tue, 25 Oct 2022 11:44:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231315AbiJYLo2 (ORCPT ); Tue, 25 Oct 2022 07:44:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231909AbiJYLn6 (ORCPT ); Tue, 25 Oct 2022 07:43:58 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A05A8175370 for ; Tue, 25 Oct 2022 04:43:56 -0700 (PDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29PB8Vp8011653 for ; Tue, 25 Oct 2022 11:43:56 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=DJ0rE5Sz18nIdU7QV1+Xe8vKpcL58TIlTo3KdsBO+S4=; b=HfO4f45/85GjdsIF1mn1NJUZDq2GG1SObTazv8NVvWB+v5VynEk90WBdFpYEisccIt3f t0ZuPX0J9I9rGAau1TxTmrFYA92pg9uis35ZF1m/lk3SYbwbMndVb9vhLshnJZ4Q/iNC Hz7aEMnCx9zk5NMEXRCFTFS/g9RAvGalJzClXQuVd1b4K5IU/y8P410GIYeAmC8rM00X fury9DLj+2vFpH/9YgUzfX0s1rGbcRP4ultVokZA2CaHOeABEplmTITbVaMmohs9BXDs WkbPrP1b4ee0fhZ/TLRULsfRkX321MjtHW2fxRhP5dG3o1XaxvOixwDXepQsXHvWr8j7 BA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kee02tdp2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:55 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29PB9V1w015982 for ; Tue, 25 Oct 2022 11:43:55 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kee02tdn9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:55 +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 29PBd65n011292; Tue, 25 Oct 2022 11:43:53 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma01fra.de.ibm.com with ESMTP id 3kc8593yv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:53 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBhp2I2228912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:43:51 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0766DAE045; Tue, 25 Oct 2022 11:43:51 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D0665AE04D; Tue, 25 Oct 2022 11:43:50 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:50 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com Subject: [kvm-unit-tests GIT PULL 20/22] lib: s390x: Use a new asce for each PV guest Date: Tue, 25 Oct 2022 13:43:43 +0200 Message-Id: <20221025114345.28003-21-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: jND2ffGLAUkqAFsf4_fzngmMSILeSem0 X-Proofpoint-ORIG-GUID: omoQwgb1u0BJ120rHqTfso0gTDvU9prN 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 phishscore=0 adultscore=0 malwarescore=0 mlxscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank 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: Claudio Imbrenda Message-Id: <20221021063902.10878-5-frankja@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- lib/s390x/sie.h | 2 ++ lib/s390x/uv.h | 5 ++--- lib/s390x/asm-offsets.c | 2 ++ lib/s390x/sie.c | 2 ++ lib/s390x/uv.c | 24 +++++++++++++++++++++++- s390x/cpu.S | 6 ++++++ 6 files changed, 37 insertions(+), 4 deletions(-) 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.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/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/uv.c b/lib/s390x/uv.c index 3b4cafa9..b2a43424 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(PAGE_SIZE, PAGE_SIZE * 4); + pgd_old = (void *)(asce & PAGE_MASK); + + memcpy(pgd_new, pgd_old, PAGE_SIZE * 4); + + asce = __pa(pgd_new) | ASCE_P | (asce & (ASCE_DT | ASCE_TL)); + 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/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 Tue Oct 25 11:43:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019107 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 AA22FC04A95 for ; Tue, 25 Oct 2022 11:44:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbiJYLob (ORCPT ); Tue, 25 Oct 2022 07:44:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232091AbiJYLn7 (ORCPT ); Tue, 25 Oct 2022 07:43:59 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AFD11735BE for ; Tue, 25 Oct 2022 04:43:57 -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 29PB8aXH036411 for ; Tue, 25 Oct 2022 11:43:56 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=w9ua085AiVut2l8g9IXu0gftjsh5dHR9PaZsLOOP4dE=; b=WVxq2NJerI48C6/zOuIluEomJifkQm7b/6hXHGv9yPtP+JnHu1+BImOBJGwVjVSjFAvw OBBsD9hXVqNEyfGbJNYUD8872V4tKEOi3nmbyEa3cj3w/jPMroI1XZY/Mfl01IhyG3eS JKqUeyuTdk4kqNT9CSU6KboGeluNhhvcrdvaBxTm7Ye6fwSMmWlljVyxizMfdRrIvmDZ p3Ck29OimQ9okkf2lmNML44bhSh3kluZ4iRNU1xyjOSFy8vq9awWCKTHwjkibnqpe2yv tfXo0Oywky1sJlRd+GNKhMLJrt3U63ECRxeb8FdRsXPL5T6FccU2WBwL849+8uj3FHh4 Zg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kedduur3k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:56 +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 29PB8xWe037441 for ; Tue, 25 Oct 2022 11:43:56 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 3kedduur32-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:56 +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 29PBcLF8027544; Tue, 25 Oct 2022 11:43:54 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 3kc859dhpu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:54 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBhpNn2228914 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:43:51 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 44ADCAE045; Tue, 25 Oct 2022 11:43:51 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 12F24AE051; Tue, 25 Oct 2022 11:43:51 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:51 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Steffen Eiden Subject: [kvm-unit-tests GIT PULL 21/22] lib: s390x: Enable reusability of VMs that were in PV mode Date: Tue, 25 Oct 2022 13:43:44 +0200 Message-Id: <20221025114345.28003-22-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: -CfPwPvkX-MeBX90CYdc0KO5za6Jq5Gs X-Proofpoint-ORIG-GUID: 6J2vyT-blop7CIdfa_dKBjmVFBO0EHyA 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 phishscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 adultscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank 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 Message-Id: <20221021063902.10878-6-frankja@linux.ibm.com> Reviewed-by: Steffen Eiden Signed-off-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 b2a43424..383271a5 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 Tue Oct 25 11:43:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 13019108 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 5F8A3ECDFA1 for ; Tue, 25 Oct 2022 11:44:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231987AbiJYLoe (ORCPT ); Tue, 25 Oct 2022 07:44:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232138AbiJYLoB (ORCPT ); Tue, 25 Oct 2022 07:44:01 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06A1317535B for ; Tue, 25 Oct 2022 04:43:57 -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 29PB8hA7031332 for ; Tue, 25 Oct 2022 11:43:57 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=G6+jZGVsQjStF9+2xgC1/SIsSgyowEKjlkJgxMvl890=; b=Di4MxptpMDzkScyefW99NGd3FdWHRLlTH5BgYE0OBhVJ5DzkXbc5hcRr+FH6WIYkqAQx KLTrCq01J+zhlRIpu25j2QMFde+GyKpufWrZXrEiyl90k/hoG5H2S5/uqdZPnlOgitJR 5xr+nc3WQoftQedIVLlWOgi6tXuu0cLPEV3jOFtbIfgJnwIe4JHpYflxdGoa8QNNkKmg EJgceQUfhmiuczQVzk61Is3dtJePfNxCpgoXuKvpvJ+7pcQj9W14PDwpMjRIBmQYDoZW 4EdJyJbRFidJTq6KdW/VWJGmRZVagBKQM6ORgpykBIGgOuGI7W/7oc2JKEVMPBwCCH0X ag== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kecrqw821-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 25 Oct 2022 11:43:56 +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 29PBQ1Fb011775 for ; Tue, 25 Oct 2022 11:43:56 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 3kecrqw818-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:56 +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 29PBdQcd014327; Tue, 25 Oct 2022 11:43:54 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06ams.nl.ibm.com with ESMTP id 3kc7sj5h76-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 25 Oct 2022 11:43:54 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29PBhp9M2228916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 25 Oct 2022 11:43:51 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 84261AE045; Tue, 25 Oct 2022 11:43:51 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 507CCAE04D; Tue, 25 Oct 2022 11:43:51 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.252]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 25 Oct 2022 11:43:51 +0000 (GMT) From: Claudio Imbrenda To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, thuth@redhat.com, frankja@linux.ibm.com, Nico Boehr Subject: [kvm-unit-tests GIT PULL 22/22] lib: s390x: sie: Properly populate SCA Date: Tue, 25 Oct 2022 13:43:45 +0200 Message-Id: <20221025114345.28003-23-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025114345.28003-1-imbrenda@linux.ibm.com> References: <20221025114345.28003-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 5JP1tomiRpv1M58cpVaHwWQNL_n3zMTO X-Proofpoint-ORIG-GUID: jIzBO9VqUvOwCyfrSFOP98Q0CiP_9c8Z 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-25_05,2022-10-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 phishscore=0 impostorscore=0 spamscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 mlxlogscore=695 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210250067 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Janosch Frank 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 Message-Id: <20221021063902.10878-7-frankja@linux.ibm.com> Signed-off-by: Claudio Imbrenda --- lib/s390x/sie.h | 35 ++++++++++++++++++++++++++++++++++- lib/s390x/sie.c | 8 ++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) 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 */ 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. */