From patchwork Fri Jul 17 14:58:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 11670569 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 780B614E3 for ; Fri, 17 Jul 2020 14:58:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69E34208C7 for ; Fri, 17 Jul 2020 14:58:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726996AbgGQO6a (ORCPT ); Fri, 17 Jul 2020 10:58:30 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:28212 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726832AbgGQO63 (ORCPT ); Fri, 17 Jul 2020 10:58:29 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06HEWMDU137528; Fri, 17 Jul 2020 10:58:28 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 32aut55um1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Jul 2020 10:58:28 -0400 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06HEwRf2032000; Fri, 17 Jul 2020 10:58:27 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com with ESMTP id 32aut55ukf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Jul 2020 10:58:27 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06HEpTOH027910; Fri, 17 Jul 2020 14:58:26 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06ams.nl.ibm.com with ESMTP id 3274pgxkxd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Jul 2020 14:58:26 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06HEwNGJ57081882 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jul 2020 14:58:23 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2D2EF42045; Fri, 17 Jul 2020 14:58:23 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 736B94203F; Fri, 17 Jul 2020 14:58:22 +0000 (GMT) Received: from linux01.pok.stglabs.ibm.com (unknown [9.114.17.81]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 17 Jul 2020 14:58:22 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: thuth@redhat.com, linux-s390@vger.kernel.org, david@redhat.com, borntraeger@de.ibm.com, cohuck@redhat.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests PATCH 2/3] s390x: skrf: Add exception new skey test and add test to unittests.cfg Date: Fri, 17 Jul 2020 10:58:12 -0400 Message-Id: <20200717145813.62573-3-frankja@linux.ibm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200717145813.62573-1-frankja@linux.ibm.com> References: <20200717145813.62573-1-frankja@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-17_06:2020-07-17,2020-07-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 adultscore=0 clxscore=1015 bulkscore=0 spamscore=0 suspectscore=1 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007170103 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org If a exception new psw mask contains a key a specification exception instead of a special operation exception is presented. Let's test that. Also let's add the test to unittests.cfg so it is run more often. Signed-off-by: Janosch Frank Reviewed-by: Claudio Imbrenda --- s390x/skrf.c | 81 +++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 4 +++ 2 files changed, 85 insertions(+) diff --git a/s390x/skrf.c b/s390x/skrf.c index 9cae589..9733412 100644 --- a/s390x/skrf.c +++ b/s390x/skrf.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include static uint8_t pagebuf[PAGE_SIZE * 2] __attribute__((aligned(PAGE_SIZE * 2))); @@ -106,6 +108,84 @@ static void test_tprot(void) report_prefix_pop(); } +#include +static int testflag = 0; + +static void wait_for_flag(void) +{ + while (!testflag) + mb(); +} + +static void set_flag(int val) +{ + mb(); + testflag = val; + mb(); +} + +static void ecall_cleanup(void) +{ + struct lowcore *lc = (void *)0x0; + + lc->ext_new_psw.mask = 0x0000000180000000UL; + lc->sw_int_crs[0] = 0x0000000000040000; + + /* + * PGM old contains the ext new PSW, we need to clean it up, + * so we don't get a special oepration exception on the lpswe + * of pgm old. + */ + lc->pgm_old_psw.mask = 0x0000000180000000UL; + lc->pgm_old_psw.addr = (unsigned long)wait_for_flag; + + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + set_flag(1); +} + +/* Set a key into the external new psw mask and open external call masks */ +static void ecall_setup(void) +{ + struct lowcore *lc = (void *)0x0; + uint64_t mask; + + register_pgm_int_func(ecall_cleanup); + expect_pgm_int(); + /* Put a skey into the ext new psw */ + lc->ext_new_psw.mask = 0x00F0000180000000UL; + /* Open up ext masks */ + ctl_set_bit(0, 13); + mask = extract_psw_mask(); + mask |= PSW_MASK_EXT; + load_psw_mask(mask); + /* Tell cpu 0 that we're ready */ + set_flag(1); +} + +static void test_exception_ext_new(void) +{ + struct psw psw = { + .mask = extract_psw_mask(), + .addr = (unsigned long)ecall_setup + }; + + report_prefix_push("exception external new"); + if (smp_query_num_cpus() < 2) { + report_skip("Need second cpu for exception external new test."); + report_prefix_pop(); + return; + } + + smp_cpu_setup(1, psw); + wait_for_flag(); + set_flag(0); + + sigp(1, SIGP_EXTERNAL_CALL, 0, NULL); + wait_for_flag(); + smp_cpu_stop(1); + report_prefix_pop(); +} + int main(void) { report_prefix_push("skrf"); @@ -121,6 +201,7 @@ int main(void) test_mvcos(); test_spka(); test_tprot(); + test_exception_ext_new(); done: report_prefix_pop(); diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 0f156af..b35269b 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -88,3 +88,7 @@ extra_params = -m 3G [css] file = css.elf extra_params = -device virtio-net-ccw + +[skrf] +file = skrf.elf +smp = 2