From patchwork Wed Feb 6 08:46:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10798887 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2A6E2922 for ; Wed, 6 Feb 2019 08:47:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1752C2AD23 for ; Wed, 6 Feb 2019 08:47:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0874D2ACBC; Wed, 6 Feb 2019 08:47:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CBC62ACBC for ; Wed, 6 Feb 2019 08:47:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728357AbfBFIrZ (ORCPT ); Wed, 6 Feb 2019 03:47:25 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35258 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727598AbfBFIrY (ORCPT ); Wed, 6 Feb 2019 03:47:24 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x168dmZ8018573 for ; Wed, 6 Feb 2019 03:47:23 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2qftgxp68p-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 06 Feb 2019 03:47:22 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 6 Feb 2019 08:47:20 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 6 Feb 2019 08:47:17 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x168lGDK9175478 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 6 Feb 2019 08:47:17 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C9B2642049; Wed, 6 Feb 2019 08:47:16 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C12642047; Wed, 6 Feb 2019 08:47:16 +0000 (GMT) Received: from s38lp20.lnxne.boe (unknown [9.152.224.63]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 6 Feb 2019 08:47:16 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v2] s390x: Only look at relevant skey bits Date: Wed, 6 Feb 2019 09:46:56 +0100 X-Mailer: git-send-email 2.14.3 In-Reply-To: <14a40cfb-e15a-08ec-f172-b54ee26fb02b@redhat.com> References: <14a40cfb-e15a-08ec-f172-b54ee26fb02b@redhat.com> X-TM-AS-GCONF: 00 x-cbid: 19020608-0016-0000-0000-0000025309D5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19020608-0017-0000-0000-000032AD1145 Message-Id: <20190206084656.110920-1-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-02-06_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902060069 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Reference and change indication should not be consulted when checking for ACC and FP values of storage keys. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand Reviewed-by: Thomas Huth --- lib/s390x/asm/mem.h | 5 +++++ s390x/pfmf.c | 6 +++++- s390x/skey.c | 15 +++++++++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/s390x/asm/mem.h b/lib/s390x/asm/mem.h index 909e6d4..75bd778 100644 --- a/lib/s390x/asm/mem.h +++ b/lib/s390x/asm/mem.h @@ -10,6 +10,11 @@ #ifndef _ASM_S390_MEM_H #define _ASM_S390_MEM_H +#define SKEY_ACC 0xf0 +#define SKEY_FP 0x08 +#define SKEY_RF 0x04 +#define SKEY_CH 0x02 + union skey { struct { uint8_t acc : 4; diff --git a/s390x/pfmf.c b/s390x/pfmf.c index 5e61267..4cc6bd1 100644 --- a/s390x/pfmf.c +++ b/s390x/pfmf.c @@ -70,6 +70,7 @@ static void test_4k_key(void) r1.reg.key = 0x30; pfmf(r1.val, (unsigned long) pagebuf); skey.val = get_storage_key((unsigned long) pagebuf); + skey.val &= SKEY_ACC | SKEY_FP; report("set 4k", skey.val == 0x30); } @@ -77,6 +78,7 @@ static void test_1m_key(void) { int i; union r1 r1; + union skey skey; r1.val = 0; r1.reg.sk = 1; @@ -84,7 +86,9 @@ static void test_1m_key(void) r1.reg.key = 0x30; pfmf(r1.val, (unsigned long) pagebuf); for (i = 0; i < 256; i++) { - if (get_storage_key((unsigned long) pagebuf + i * PAGE_SIZE) != 0x30) { + skey.val = get_storage_key((unsigned long) pagebuf + i * PAGE_SIZE); + skey.val &= SKEY_ACC | SKEY_FP; + if (skey.val != 0x30) { report("set 1M", false); return; } diff --git a/s390x/skey.c b/s390x/skey.c index 1949533..f4894f1 100644 --- a/s390x/skey.c +++ b/s390x/skey.c @@ -35,9 +35,10 @@ static void test_set_mb(void) while (addr < end) addr = set_storage_key_mb(addr, skey.val); - ret1.val = get_storage_key(end - PAGE_SIZE); - ret2.val = get_storage_key(end - PAGE_SIZE * 2); - report("multi block", ret1.val == ret2.val && ret1.val == skey.val); + ret1.val = get_storage_key(end - PAGE_SIZE) & (SKEY_ACC | SKEY_FP); + ret2.val = get_storage_key(end - PAGE_SIZE * 2) & (SKEY_ACC | SKEY_FP); + report("multi block", + ret1.val == ret2.val && ret1.val == skey.val); } static void test_chg(void) @@ -60,7 +61,13 @@ static void test_set(void) ret.val = get_storage_key(page0); set_storage_key(page0, skey.val, 0); ret.val = get_storage_key(page0); - report("set key test", skey.val == ret.val); + /* + * For all set tests we only test the ACC and FP bits. RF and + * CH are set by the machine for memory references and changes + * and hence might change between a set and a get. + */ + report("set key test", + skey.str.acc == ret.str.acc && skey.str.fp == ret.str.fp); } static void test_priv(void)