From patchwork Tue Mar 13 12:01:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10278383 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 0524B6038F for ; Tue, 13 Mar 2018 12:02:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA7CB284DA for ; Tue, 13 Mar 2018 12:02:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF9042861C; Tue, 13 Mar 2018 12:02:36 +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 B4FAF286FD for ; Tue, 13 Mar 2018 12:02:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932869AbeCMMCe (ORCPT ); Tue, 13 Mar 2018 08:02:34 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55930 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932841AbeCMMCc (ORCPT ); Tue, 13 Mar 2018 08:02:32 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2DC1pBn057354 for ; Tue, 13 Mar 2018 08:02:32 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gpdf9agec-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Tue, 13 Mar 2018 08:02:32 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Mar 2018 12:02:29 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 13 Mar 2018 12:02:26 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2DC2QnP57540790; Tue, 13 Mar 2018 12:02:26 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E35FD5204D; Tue, 13 Mar 2018 10:53:57 +0000 (GMT) Received: from s38lp20.boeblingen.de.ibm.com (unknown [9.145.6.90]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 449E15204B; Tue, 13 Mar 2018 10:53:57 +0000 (GMT) From: Janosch Frank To: kvm@vger.kernel.org Cc: thuth@redhat.com, david@redhat.com Subject: [kvm-unit-tests PATCH 4/8] s390x: Add diag10 tests Date: Tue, 13 Mar 2018 13:01:39 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520942503-6163-1-git-send-email-frankja@linux.vnet.ibm.com> References: <1520942503-6163-1-git-send-email-frankja@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18031312-0016-0000-0000-00000530F4E3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031312-0017-0000-0000-0000286E268F Message-Id: <1520942503-6163-5-git-send-email-frankja@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-13_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 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803130143 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Let's add some tests for the diag10 "Release pages" instruction. Signed-off-by: Janosch Frank Reviewed-by: Thomas Huth --- s390x/Makefile | 1 + s390x/diag10.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg | 3 ++ 3 files changed, 85 insertions(+) create mode 100644 s390x/diag10.c diff --git a/s390x/Makefile b/s390x/Makefile index b73031d..bc5dd91 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -4,6 +4,7 @@ tests += $(TEST_DIR)/emulator.elf tests += $(TEST_DIR)/sieve.elf tests += $(TEST_DIR)/sthyi.elf tests += $(TEST_DIR)/skey.elf +tests += $(TEST_DIR)/diag10.elf all: directories test_cases diff --git a/s390x/diag10.c b/s390x/diag10.c new file mode 100644 index 0000000..ed94ffd --- /dev/null +++ b/s390x/diag10.c @@ -0,0 +1,81 @@ +/* + * Release pages hypercall tests (DIAG 10) + * + * Copyright (c) 2017 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 * 2] __attribute__((aligned(PAGE_SIZE * 2))); +const unsigned long page0 = (unsigned long)pagebuf; +const unsigned long page1 = (unsigned long)(pagebuf + PAGE_SIZE); + +/* Tells the host to release pages from guest real addresses start to + * end. Parameters have to be page aligned, instruction is privileged. + */ +static inline void diag10(unsigned long start, unsigned long end) +{ + asm volatile ( + "diag %0,%1,0x10\n" + : : "a" (start), "a" (end)); +} + +/* Try freeing the prefix */ +static void test_prefix(void) +{ + expect_pgm_int(); + diag10(0, 0); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + + expect_pgm_int(); + diag10(0x1000, 0x1000); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + + expect_pgm_int(); + diag10(0, 0x1000); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); +} + +static void test_params(void) +{ + /* end < start */ + expect_pgm_int(); + diag10(page1, page0); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + + /* Unaligned start */ + expect_pgm_int(); + diag10((unsigned long) pagebuf + 42, page1); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); + + /* Unaligned end */ + expect_pgm_int(); + diag10(page0, (unsigned long) pagebuf + PAGE_SIZE + 42); + check_pgm_int_code(PGM_INT_CODE_SPECIFICATION); +} + +static void test_priv(void) +{ + expect_pgm_int(); + enter_pstate(); + diag10(page0, page0); + check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); +} + +int main(void) +{ + report_prefix_push("diag10"); + test_prefix(); + test_params(); + test_priv(); + return report_summary(); +} diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg index 8321e9b..5531590 100644 --- a/s390x/unittests.cfg +++ b/s390x/unittests.cfg @@ -41,3 +41,6 @@ accel = kvm [skey] file = skey.elf + +[diag10] +file = diag10.elf