From patchwork Wed Mar 28 07:39:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 10312463 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CC4BC60467 for ; Wed, 28 Mar 2018 07:40:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCE3628A0F for ; Wed, 28 Mar 2018 07:40:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B087D2940F; Wed, 28 Mar 2018 07:40:03 +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=-6.9 required=2.0 tests=BAYES_00,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 5608128A0F for ; Wed, 28 Mar 2018 07:40:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753490AbeC1Hj7 (ORCPT ); Wed, 28 Mar 2018 03:39:59 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58552 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753479AbeC1Hjz (ORCPT ); Wed, 28 Mar 2018 03:39:55 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CFCFB406E968; Wed, 28 Mar 2018 07:39:54 +0000 (UTC) Received: from thh440s.str.redhat.com (dhcp-192-189.str.redhat.com [10.33.192.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0B3010B2B38; Wed, 28 Mar 2018 07:39:53 +0000 (UTC) From: Thomas Huth To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: kvm@vger.kernel.org, David Hildenbrand , Janosch Frank Subject: [kvm-unit-tests PULL 6/8] s390x: Add cmm tests Date: Wed, 28 Mar 2018 09:39:42 +0200 Message-Id: <1522222784-7709-7-git-send-email-thuth@redhat.com> In-Reply-To: <1522222784-7709-1-git-send-email-thuth@redhat.com> References: <1522222784-7709-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 28 Mar 2018 07:39:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 28 Mar 2018 07:39:54 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Janosch Frank Collaborative Memory Management is the extended vm memory usage hinting for the hypervisor and handling the ESSA instruction is quite complicated. Let's add at least a bare-bones test, maybe someone will extend it later. Signed-off-by: Janosch Frank Reviewed-by: David Hildenbrand Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- s390x/Makefile | 1 + s390x/cmm.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 +++ 3 files changed, 73 insertions(+) create mode 100644 s390x/cmm.c diff --git a/s390x/Makefile b/s390x/Makefile index 074c32e..d80ca96 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -6,6 +6,7 @@ tests += $(TEST_DIR)/sthyi.elf tests += $(TEST_DIR)/skey.elf tests += $(TEST_DIR)/diag10.elf tests += $(TEST_DIR)/pfmf.elf +tests += $(TEST_DIR)/cmm.elf all: directories test_cases diff --git a/s390x/cmm.c b/s390x/cmm.c new file mode 100644 index 0000000..9e6a193 --- /dev/null +++ b/s390x/cmm.c @@ -0,0 +1,69 @@ +/* + * CMM tests (ESSA) + * + * Copyright (c) 2018 IBM Corp + * + * Authors: + * Janosch Frank + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU Library General Public License version 2. + */ + +#include +#include +#include +#include + +static uint8_t pagebuf[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); + +static unsigned long essa(uint8_t state, unsigned long paddr) +{ + uint64_t extr_state; + + asm volatile(".insn rrf,0xb9ab0000,%[extr_state],%[addr],%[new_state],0" + : [extr_state] "=d" (extr_state) + : [addr] "a" (paddr), [new_state] "i" (state)); + return (unsigned long)extr_state; +} + +static void test_params(void) +{ + expect_pgm_int(); + essa(8, (unsigned long)pagebuf); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); +} + +static void test_priv(void) +{ + expect_pgm_int(); + enter_pstate(); + essa(0, (unsigned long)pagebuf); + check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); +} + +/* Unfortunately the availability is not indicated by stfl bits, but + * we have to try to execute it and test for an operation exception. + */ +static bool test_availability(void) +{ + expect_pgm_int(); + essa(0, (unsigned long)pagebuf); + return clear_pgm_int() == 0; +} + +int main(void) +{ + bool has_essa = test_availability(); + + report_prefix_push("cmm"); + report_xfail("ESSA available", !has_essa, has_essa); + if (!has_essa) + goto done; + + test_priv(); + test_params(); +done: + report_prefix_pop(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index a420457..63135d5 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -46,3 +46,6 @@ file = diag10.elf [pfmf] file = pfmf.elf + +[cmm] +file = cmm.elf