From patchwork Fri Apr 19 06:32:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10909171 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 7E578922 for ; Fri, 19 Apr 2019 18:21:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73B8028DB9 for ; Fri, 19 Apr 2019 18:21:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 684FE28DBA; Fri, 19 Apr 2019 18:21:30 +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 0F06228DB5 for ; Fri, 19 Apr 2019 18:21:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727513AbfDSSVU (ORCPT ); Fri, 19 Apr 2019 14:21:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55974 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726941AbfDSSVT (ORCPT ); Fri, 19 Apr 2019 14:21:19 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D3A9CAA87; Fri, 19 Apr 2019 06:32:16 +0000 (UTC) Received: from thuth.com (ovpn-116-62.ams2.redhat.com [10.36.116.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 706705D9C5; Fri, 19 Apr 2019 06:32:15 +0000 (UTC) From: Thomas Huth To: =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Paolo Bonzini , kvm@vger.kernel.org Cc: David Hildenbrand , Janosch Frank Subject: [kvm-unit-tests PULL 2/4] s390x/skey: Skip the "iske" test when running under z/VM 6 Date: Fri, 19 Apr 2019 08:32:05 +0200 Message-Id: <20190419063207.11474-3-thuth@redhat.com> In-Reply-To: <20190419063207.11474-1-thuth@redhat.com> References: <20190419063207.11474-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 19 Apr 2019 06:32:16 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is a known bug of z/VM 6 which causes the "iske" test to fail. Since it is still sometimes useful to run the kvm-unit-tests in such a nested environment, let's rather skip the "iske" test there instead of always reporting a failure. Acked-by: Christian Borntraeger Signed-off-by: Thomas Huth --- s390x/skey.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/s390x/skey.c b/s390x/skey.c index f4894f1..b1e11af 100644 --- a/s390x/skey.c +++ b/s390x/skey.c @@ -70,9 +70,51 @@ static void test_set(void) skey.str.acc == ret.str.acc && skey.str.fp == ret.str.fp); } +static inline int stsi(void *addr, int fc, int sel1, int sel2) +{ + register int r0 asm("0") = (fc << 28) | sel1; + register int r1 asm("1") = sel2; + int rc = 0; + + asm volatile( + " stsi 0(%3)\n" + " jz 0f\n" + " lhi %1,-1\n" + "0:\n" + : "+d" (r0), "+d" (rc) + : "d" (r1), "a" (addr) + : "cc", "memory"); + + return rc; +} + +/* Returns true if we are running under z/VM 6.x */ +static bool check_for_zvm6(void) +{ + int dcbt; /* Descriptor block count */ + int nr; + static const unsigned char zvm6[] = { + /* This is "z/VM 6" in EBCDIC */ + 0xa9, 0x61, 0xe5, 0xd4, 0x40, 0x40, 0x40, 0x40, 0xf6 + }; + + if (stsi(pagebuf, 3, 2, 2)) + return false; + + dcbt = pagebuf[31] & 0xf; + + for (nr = 0; nr < dcbt; nr++) { + if (!memcmp(&pagebuf[32 + nr * 64 + 24], zvm6, sizeof(zvm6))) + return true; + } + + return false; +} + static void test_priv(void) { union skey skey; + bool is_zvm6 = check_for_zvm6(); memset(pagebuf, 0, PAGE_SIZE * 2); report_prefix_push("privileged"); @@ -87,10 +129,15 @@ static void test_priv(void) report("skey did not change on exception", skey.str.acc != 3); report_prefix_push("iske"); - expect_pgm_int(); - enter_pstate(); - get_storage_key(page0); - check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); + if (is_zvm6) { + /* There is a known bug with z/VM 6, so skip the test there */ + report_skip("not working on z/VM 6"); + } else { + expect_pgm_int(); + enter_pstate(); + get_storage_key(page0); + check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); + } report_prefix_pop(); report_prefix_pop();