From patchwork Mon Oct 17 09:39:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13008449 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 3254FC433FE for ; Mon, 17 Oct 2022 09:40:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231232AbiJQJkG (ORCPT ); Mon, 17 Oct 2022 05:40:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231167AbiJQJkA (ORCPT ); Mon, 17 Oct 2022 05:40:00 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC4A71DA51 for ; Mon, 17 Oct 2022 02:39:59 -0700 (PDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29H8Sq7I013762 for ; Mon, 17 Oct 2022 09:39:59 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=K7O2HMm0Rb1Wpg3W0t0XJmbvn4p5BIENfVyxJu+RxZU=; b=kIc7ZPueQYxh3vMSUvaCkvKqK/FBHwQA5jmaq3LK/EASdUTv8MFvOz3bG4vPjvSdjPqs NsesdACPR/raD9POCsEXi/90MkTr80Nk9tdvbl2/YWEwuWrhEJCiRtGMpYiyKcFUHZ07 FBCoFu+0hLHX4LPbAVaniuWw46q80gaD4Mn85OndD8nK4pCripOGa74yq8bpWhc0VVJe Uze9ZCFOI4QggXTwFqO5Er0VW05lRn7k+3GefWdGFWH1MiwcyE4H1jfBaON3Cc7my00k ofR2e7oVEp3A0FH6hvP1zTy+WYqYLksjrqybyFK7apOC5NePEhgt1LdBEyDMww87EeFi 8Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k86sjkq6c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 17 Oct 2022 09:39:59 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29H7KEJO002149 for ; Mon, 17 Oct 2022 09:39:58 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 3k86sjkq5f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:39:58 +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 29H9ZAlr009852; Mon, 17 Oct 2022 09:39:56 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 3k7mg92qmm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:39:56 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29H9drbf918168 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 09:39:53 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 538A4A405B; Mon, 17 Oct 2022 09:39:53 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A49BAA4054; Mon, 17 Oct 2022 09:39:52 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 17 Oct 2022 09:39:52 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: imbrenda@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com, scgl@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v3 1/8] s390x: uv-host: Add access checks for donated memory Date: Mon, 17 Oct 2022 09:39:18 +0000 Message-Id: <20221017093925.2038-2-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221017093925.2038-1-frankja@linux.ibm.com> References: <20221017093925.2038-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Pjwhm_cgWoMH4UplL27_ZkU-KYcOxHjm X-Proofpoint-GUID: bmhX_P1NQa1EyfqTidSLZtHe9cyclS43 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-17_07,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 priorityscore=1501 phishscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 spamscore=0 clxscore=1015 suspectscore=0 mlxlogscore=971 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170055 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- 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 Mon Oct 17 09:39:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13008450 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 09440C4332F for ; Mon, 17 Oct 2022 09:40:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230520AbiJQJkI (ORCPT ); Mon, 17 Oct 2022 05:40:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230445AbiJQJkB (ORCPT ); Mon, 17 Oct 2022 05:40:01 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D1D8205D7 for ; Mon, 17 Oct 2022 02:40:00 -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 29H926ar021784 for ; Mon, 17 Oct 2022 09:39:59 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=nnqBu7jALeytCj7qUQK2+Pz7TuopgzfDC6RKJiVoliw=; b=LUD76QvQ6idJG3sNSxTVSX16B4jI2/TiKurt0Sk5fDumknmH5KxW4xa62/J5C98vEcNs iwkAJGMyRyeGYtEN3621YARDA4g4v0ZXBP3aJcubwvxH/e68r4gk8ULF9UJLnh+JtOdm 2fSiqWhFbB6fkg6JO/OEj0E7PG+R/KWnpKKfCUAYO3qXczcT0sma1wcBUwgLm3VJKTnc ZjCMrfpFLuTTkC6DWce2K3ceTkjMki3OCVoK/1aB9Wwju/g7ZlDDI60B1zUi8AZvJXh3 RE7hWORfjM9nr1vaZqZhhFkyL6AtzZPEQFAjH+Z9kYtaFOM9hEb0CMURK+lRrr0xV1xc QQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3k86g5u9sk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 17 Oct 2022 09:39:59 +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 29H9dxTD016051 for ; Mon, 17 Oct 2022 09:39:59 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 3k86g5u9s6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:39:58 +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 29H9ZLfX009693; Mon, 17 Oct 2022 09:39:57 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 3k7mg92r9n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:39:57 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29H9dssi918052 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 09:39:54 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 28A6AA405B; Mon, 17 Oct 2022 09:39:54 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79C4AA4054; Mon, 17 Oct 2022 09:39:53 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 17 Oct 2022 09:39:53 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: imbrenda@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com, scgl@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v3 2/8] s390x: uv-host: Add uninitialized UV tests Date: Mon, 17 Oct 2022 09:39:19 +0000 Message-Id: <20221017093925.2038-3-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221017093925.2038-1-frankja@linux.ibm.com> References: <20221017093925.2038-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ot54T_owlsE63cP5GHfr-GorlzyfQgKo X-Proofpoint-ORIG-GUID: kQVT2UekyMNNu1Za_GXpvJdL09N1S7dG 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-17_07,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 suspectscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 impostorscore=0 phishscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170055 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Let's also test for rc 0x3 Signed-off-by: Janosch Frank Reviewed-by: Nico Boehr Reviewed-by: Steffen Eiden --- 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 Mon Oct 17 09:39:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13008451 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 572ACC4332F for ; Mon, 17 Oct 2022 09:40:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231282AbiJQJkK (ORCPT ); Mon, 17 Oct 2022 05:40:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbiJQJkC (ORCPT ); Mon, 17 Oct 2022 05:40:02 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6785B237D4 for ; Mon, 17 Oct 2022 02:40:01 -0700 (PDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29H9VhN9027427 for ; Mon, 17 Oct 2022 09:40:01 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=ZIGFLIQ8cCCRCPuQmsTkJqlThiHyJjhkqcUMNV1aqa0=; b=KVA6ErtB90gO9CYTVQl6IDIVYHR1YXVV9bquqhSRPahf/HjasUal/EPqlLKZxggeCYyO opydd0LhZQvBSJKcKPOIIooH1krje9Vg/ZdLAPbgpnIstecsGBTQD2dnyk2TuLXsVRsZ qhYXazEBzYA6r/BasKrRr0SwqHkWjjBcL1/IyXR7+0ULAdxtunc4zOavO+KqTY0x3YTF 3+FZE7Jre41ihtWb2HMSYFwSmQSshY2ndyxy5Fy59aj+wbejaaLTPewnFThA7u0HfKOQ 9E+qK3Pa3COMB1fLlRCuxVGId6AAUrOT8L4AypumyyzKl8wFgGSvqJIY8leuYlFEEtS3 zQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k86sjkq73-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 17 Oct 2022 09:40:00 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29H7tgjm028712 for ; Mon, 17 Oct 2022 09:40:00 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 3k86sjkq67-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:40:00 +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 29H9adYQ032115; Mon, 17 Oct 2022 09:39:58 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03fra.de.ibm.com with ESMTP id 3k7mg9a2jd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:39:58 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29H9dtN357278770 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 09:39:55 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 071F2A405B; Mon, 17 Oct 2022 09:39:55 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4ED09A4054; Mon, 17 Oct 2022 09:39:54 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 17 Oct 2022 09:39:54 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: imbrenda@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com, scgl@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v3 3/8] s390x: uv-host: Test uv immediate parameter Date: Mon, 17 Oct 2022 09:39:20 +0000 Message-Id: <20221017093925.2038-4-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221017093925.2038-1-frankja@linux.ibm.com> References: <20221017093925.2038-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: NdZmhwLRWHP16kGoGIWBRFWZjVvfSUNz X-Proofpoint-GUID: Vg_8BjthLw1sLpPVZYN6a3jO2_n_Zy-U 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-17_07,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 priorityscore=1501 phishscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 spamscore=0 clxscore=1015 suspectscore=0 mlxlogscore=841 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170055 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- 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 Mon Oct 17 09:39:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13008453 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 251B7C433FE for ; Mon, 17 Oct 2022 09:40:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231305AbiJQJkO (ORCPT ); Mon, 17 Oct 2022 05:40:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231205AbiJQJkE (ORCPT ); Mon, 17 Oct 2022 05:40:04 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 999CF17E0E for ; Mon, 17 Oct 2022 02:40:03 -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 29H9JemO035747 for ; Mon, 17 Oct 2022 09:40:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=SOBBVNPiP0GZPZcEKK6UnOQdRuXe/B0g5k50Z6QzGrw=; b=SmW0WN3uAhdTE954fqkYIh+HCc6UN9vRgrKESwzr5e3RXLh/ZbrdB1C3nBvMLf+LRfWn skT8MvRWG89x/3yaSQhtkDkFaQOP8eq6cV9uqj0iq9FLUK1gTk3D3Ib41IWJ7bqd2jjs hajOVFO4ra43pviZVQyN2L4Zfa/SURmewXUt/51nIrxiLB0rQ2o16egUKPaRW9bIdGry 5Bz6KTuvnNnpF28xrATEKU1aWnQk2XNu0eBrmODlKMD3eF73VhYSmCovBj0zBspRbyDe 8OGp3zcAHGBIF+dyvJNjdllj6jQScKdq9UmCWFEP7u39kOttHm6fi5fYsA+mbHT5+j8p 1Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k86ugbemq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 17 Oct 2022 09:40:02 +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 29H9LN9F018885 for ; Mon, 17 Oct 2022 09:40:02 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 3k86ugbejg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:40:02 +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 29H9Z4jM009834; Mon, 17 Oct 2022 09:39:59 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 3k7mg92qmr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:39:58 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29H9dtXl57278772 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 09:39:55 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D0C4CA405B; Mon, 17 Oct 2022 09:39:55 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2D77DA4054; Mon, 17 Oct 2022 09:39:55 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 17 Oct 2022 09:39:55 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: imbrenda@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com, scgl@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v3 4/8] s390x: uv-host: Add access exception test Date: Mon, 17 Oct 2022 09:39:21 +0000 Message-Id: <20221017093925.2038-5-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221017093925.2038-1-frankja@linux.ibm.com> References: <20221017093925.2038-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: aR2wmZW8z4u0FFOHeVo7X2L0oa5ycXIm X-Proofpoint-ORIG-GUID: MIMRThIrkrzuvO4FuLiXuUg9UK8DRcxg 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-17_07,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=944 phishscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 spamscore=0 malwarescore=0 priorityscore=1501 adultscore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170055 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- 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 Mon Oct 17 09:39:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13008452 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 470ABC433FE for ; Mon, 17 Oct 2022 09:40:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231366AbiJQJkM (ORCPT ); Mon, 17 Oct 2022 05:40:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231235AbiJQJkG (ORCPT ); Mon, 17 Oct 2022 05:40:06 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B47BB25EBD for ; Mon, 17 Oct 2022 02:40:03 -0700 (PDT) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29H9VNfJ031502 for ; Mon, 17 Oct 2022 09:40:02 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=1m3ANcQKhpTluC+250DRIOjxVo9sB1ZcH8qoE9XXdQs=; b=UvwWs3DQQd+eNLPkPw0D7mJejQYTogJecHy0jsDl/vldx+q94+Up+Wtew3vxDpzxW6my L76CNQXPmu/phszu+W3IVvOfUdBy4fXpz8eYG552VHglJra4mwS0AGWjQHpa6y6X8Bc1 8AKgvJ6dz1tqQLSQJm9lkYjKL3+/sdCJP4wpi/uH3ovVyAbFZlArHCtNLjMLgkLNlMYG xe2KdUe6mx7hG5jeekB1xQuJ3yvnrSaDhJZVxXetSKk1wyBfBVBM/VXwKNBJqgPhFzZZ NnkoJRhrem3tK49vpTD/qDzz98U8EUhCqbeg4LlmtbWzlYRzXi7Y7iXcQoAK8njSTkow bA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k86hkb1ky-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 17 Oct 2022 09:40:02 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29H9dHNR002846 for ; Mon, 17 Oct 2022 09:40:01 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 3k86hkb1jx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:40:01 +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 29H9bCuh012593; Mon, 17 Oct 2022 09:39:59 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06ams.nl.ibm.com with ESMTP id 3k7m4jjrcj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:39:59 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29H9duFt6750736 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 09:39:56 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A59E4A405B; Mon, 17 Oct 2022 09:39:56 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 02A1BA4054; Mon, 17 Oct 2022 09:39:56 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 17 Oct 2022 09:39:55 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: imbrenda@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com, scgl@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v3 5/8] s390x: uv-host: Add a set secure config parameters test function Date: Mon, 17 Oct 2022 09:39:22 +0000 Message-Id: <20221017093925.2038-6-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221017093925.2038-1-frankja@linux.ibm.com> References: <20221017093925.2038-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 3EWNd7LohRiNGDHxAM93-v8GXnzU8R4r X-Proofpoint-ORIG-GUID: OhNCc5qoNFewTqvOgxO4WzPnGMgSstYH 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-17_07,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 spamscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170055 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Time for more tests. Signed-off-by: Janosch Frank Reviewed-by: Steffen Eiden --- 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 Mon Oct 17 09:39:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13008454 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 BD123C433FE for ; Mon, 17 Oct 2022 09:40:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231235AbiJQJkQ (ORCPT ); Mon, 17 Oct 2022 05:40:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231329AbiJQJkG (ORCPT ); Mon, 17 Oct 2022 05:40:06 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F28ED2612F for ; Mon, 17 Oct 2022 02:40:03 -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 29H9Sikd036486 for ; Mon, 17 Oct 2022 09:40:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=WNn40PAhbPsmQBWNZBVICZokJRHvZeoAljktxOW7PMw=; b=LIbJmY8Tf4z9kjYzzLMJNF3Faoozgued9kNfdGCBk0uOSY0D7m6pSoW018ZPOE/qH/gp WRTBrb8VYTOg3iLJBTOMbgw/2FI1uzSHFy0MnKVrYrHzbEmaZEhTXLk/Vm+rB2X0wy7e 6Chlal1enIpFYszCx+CabhyNiYa3Gp57+wjBYslZUSgGNmrkcxE9XvI1YcG2ZsDRnYDp SOm4K4+mkBT2QsjTwjQvfQI/lC64MGuxpxfEg2d26YXjwQ3JE+aJMSwBzHGNRBlnXbVh a1xLTxv/LQC5qrx+iVKu0YoVuViCDOdiUbOo77bG5p/2YA/CiQ0BxhGhWtVD3ekgVCXg rg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k86ugben4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 17 Oct 2022 09:40:03 +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 29H9LN9H018885 for ; Mon, 17 Oct 2022 09:40:03 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 3k86ugbekp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:40:03 +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 29H9Z51M009839; Mon, 17 Oct 2022 09:40:00 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 3k7mg92qmu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:40:00 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29H9eUl352953398 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 09:40:30 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 83DDCA405B; Mon, 17 Oct 2022 09:39:57 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CBBD3A4054; Mon, 17 Oct 2022 09:39:56 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 17 Oct 2022 09:39:56 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: imbrenda@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com, scgl@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v3 6/8] s390x: uv-host: Remove duplicated + Date: Mon, 17 Oct 2022 09:39:23 +0000 Message-Id: <20221017093925.2038-7-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221017093925.2038-1-frankja@linux.ibm.com> References: <20221017093925.2038-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 3-CbA8icW13Q7PWT1__LBC5LLzy3AIcW X-Proofpoint-ORIG-GUID: mbALF1iH5YhCEJjS01S6zIXTO2AtJ8qt 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-17_07,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 phishscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 spamscore=0 malwarescore=0 priorityscore=1501 adultscore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170055 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org One + is definitely enough here. Signed-off-by: Janosch Frank Reviewed-by: Claudio Imbrenda 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 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 Mon Oct 17 09:39:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13008455 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 AEE1DC433FE for ; Mon, 17 Oct 2022 09:40:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231357AbiJQJkT (ORCPT ); Mon, 17 Oct 2022 05:40:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230157AbiJQJkH (ORCPT ); Mon, 17 Oct 2022 05:40:07 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A209A264B4 for ; Mon, 17 Oct 2022 02:40:04 -0700 (PDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29H9Fta8027017 for ; Mon, 17 Oct 2022 09:40:04 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=jE9sWz1ovN5Pl22JvVJt77ITNe0sjU8w19kXxw8DRmk=; b=Yl2ALzF6glX7bD2Kh1LhWzAkB57uQYSBTLBym9y5hDhjNDg/VIoNSAZ54ParcT9WBgXW V1AdRCEEcpcUQPS5GL0hgLhiYWmK7FJSJplxqoahRc4WpOrEnyayjyTWK/lKZLbSRP5F zm/tQCupPsegegt4Tn80HYXKCTyLk4FOKlxj5dtpIuEbW8kWOB8l/EYn6c9m9NJdlb8C uhqIKa2QIyVRHFNBZjYGUtMU2sMCgfPeJuUwYYEdI3Z+xoStLRDujFJqGhjxIL1vWdKA wMT9WFr5SrhHmBX3PxScIQCO8FGRVbm0b5GC/QtJdcbeDgEf7swh3s261gYgOcmAXOx5 Dw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k86sjkq9e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 17 Oct 2022 09:40:04 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29H8gXBQ020050 for ; Mon, 17 Oct 2022 09:40:03 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k86sjkq83-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:40:03 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29H9ZDKH022726; Mon, 17 Oct 2022 09:40:01 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04fra.de.ibm.com with ESMTP id 3k7mg9232f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:40:01 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29H9Z2BH46465488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 09:35:02 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 63763A405C; Mon, 17 Oct 2022 09:39:58 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AAEACA4054; Mon, 17 Oct 2022 09:39:57 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 17 Oct 2022 09:39:57 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: imbrenda@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com, scgl@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v3 7/8] s390x: uv-host: Fence against being run as a PV guest Date: Mon, 17 Oct 2022 09:39:24 +0000 Message-Id: <20221017093925.2038-8-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221017093925.2038-1-frankja@linux.ibm.com> References: <20221017093925.2038-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Cqpq6JyyVRZA5RPAVvUZ0IStyCZN_tkm X-Proofpoint-GUID: o17FRfaQ_cW6MrwQObRGhSM7bfJrb7w6 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-17_07,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 priorityscore=1501 phishscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 spamscore=0 clxscore=1015 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170055 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- 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 Mon Oct 17 09:39:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 13008456 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 B4868C4332F for ; Mon, 17 Oct 2022 09:40:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231324AbiJQJkV (ORCPT ); Mon, 17 Oct 2022 05:40:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231167AbiJQJkH (ORCPT ); Mon, 17 Oct 2022 05:40:07 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0E5527B33 for ; Mon, 17 Oct 2022 02:40:05 -0700 (PDT) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29H9IcTh016700 for ; Mon, 17 Oct 2022 09:40:04 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=s7d7sGUhnwF+2T+jt/uLF7I3cSXcl6VLh/PLw43aufU=; b=Zfa1JJ0nPWVoFZ7/113bjhtu+r5lIwTo+7M7+p0i7PGe0a2lVMoVKqzw7tQLD7ASyHUI BejsDeNa2X3kCD3GXReuCb0+MK+4LiB/YMjvdDK7pHAZryXv95UF6WBX5sPaROZ0BEr7 GIooqbNkdPA9Du9baOtiao8ejY3rTv6Iho9u3G1EEkbMxm7n0OGCaLgV6fy8GUlRJWbi smyJwBerUErbb3zYH/1enQkxuk6TciOApvyXJs/0b38JX846AsOfx4cRp6pxlkia7BIb +N0XNaNEq/IrSSpg15H3JqNS9arelCCHVb+/M/3PNxpyKYJq8IpY+PG4xZcQkfHu7aPf 3A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k86hkb1nh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 17 Oct 2022 09:40:04 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29H85S89022773 for ; Mon, 17 Oct 2022 09:40:04 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 3k86hkb1mt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:40:03 +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 29H9b0ML012572; Mon, 17 Oct 2022 09:40:02 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 3k7m4jjrck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 09:40:02 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29H9dxXv5767816 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 09:39:59 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 380B6A405B; Mon, 17 Oct 2022 09:39:59 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89A34A4054; Mon, 17 Oct 2022 09:39:58 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 17 Oct 2022 09:39:58 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: imbrenda@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com, scgl@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v3 8/8] s390x: uv-host: Fix init storage origin and length check Date: Mon, 17 Oct 2022 09:39:25 +0000 Message-Id: <20221017093925.2038-9-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221017093925.2038-1-frankja@linux.ibm.com> References: <20221017093925.2038-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 2a42SMws321d26oZlc8FWsIRGWVovAAW X-Proofpoint-ORIG-GUID: PtkT7tPeDN7aLaQVufn72ytEYDGJ2zz1 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-17_07,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 mlxlogscore=979 impostorscore=0 bulkscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 spamscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170055 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- 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);