From patchwork Mon Mar 1 11:47:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12109529 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1D8AC433DB for ; Mon, 1 Mar 2021 11:48:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99DF064E22 for ; Mon, 1 Mar 2021 11:48:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234263AbhCALsd (ORCPT ); Mon, 1 Mar 2021 06:48:33 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:24442 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234188AbhCALr5 (ORCPT ); Mon, 1 Mar 2021 06:47:57 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 121BXuZK061562 for ; Mon, 1 Mar 2021 06:47:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=v/wonPWmwERnt8dYDvIELVtp/cOUxOzPo8zX5zdUDo8=; b=oF3WWQu72K41uZS0abnOeMu7UPMbo2Mjve4LKdm/5McQQQd25Q/O1qwRIQ7PrHnHSyiO eoSe5Lm13g7fBjNz+BUuEMc8x5G2rCyBG2P4HppxBKa/QfMpkjvFNqiWDpq1rxSpQY7d x2ptBTt16+2esoVQFZWhf82wXETVBn0fh0ostmfvH2smBIupEJ4ywrntRSk2to1TvUD9 wq14pCAp07U9UoiTPVFbZyf+25svvXGgMRRSf87IEb+n0q6ivchdiqD4jWrJTbIDt3TU +/VA+7rKLevQESymDQRqAxUmJKCTV95syrRo+u5EPIch3/j6/otLxER3DwsaRZxnsL5e SQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 370xxa1c2g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 01 Mar 2021 06:47:13 -0500 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 121BY5DQ061811 for ; Mon, 1 Mar 2021 06:47:12 -0500 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 370xxa1c1a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Mar 2021 06:47:12 -0500 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 121Bhr3C025923; Mon, 1 Mar 2021 11:47:10 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03fra.de.ibm.com with ESMTP id 36ydq80xue-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Mar 2021 11:47:10 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 121Bl7dm36045096 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 1 Mar 2021 11:47:07 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 598CBAE045; Mon, 1 Mar 2021 11:47:07 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F1AD3AE051; Mon, 1 Mar 2021 11:47:06 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.52.26]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 1 Mar 2021 11:47:06 +0000 (GMT) From: Pierre Morel To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests PATCH v4 1/6] s390x: css: Store CSS Characteristics Date: Mon, 1 Mar 2021 12:47:00 +0100 Message-Id: <1614599225-17734-2-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1614599225-17734-1-git-send-email-pmorel@linux.ibm.com> References: <1614599225-17734-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-03-01_06:2021-02-26,2021-03-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103010098 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org CSS characteristics exposes the features of the Channel SubSystem. Let's use Store Channel Subsystem Characteristics to retrieve the features of the CSS. Signed-off-by: Pierre Morel Reviewed-by: Cornelia Huck Acked-by: Janosch Frank --- lib/s390x/css.h | 67 ++++++++++++++++++++++++++++++++ lib/s390x/css_lib.c | 93 ++++++++++++++++++++++++++++++++++++++++++++- s390x/css.c | 8 ++++ 3 files changed, 167 insertions(+), 1 deletion(-) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index 3e57445..4210472 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -288,4 +288,71 @@ int css_residual_count(unsigned int schid); void enable_io_isc(uint8_t isc); int wait_and_check_io_completion(int schid); +/* + * CHSC definitions + */ +struct chsc_header { + uint16_t len; + uint16_t code; +}; + +/* Store Channel Subsystem Characteristics */ +struct chsc_scsc { + struct chsc_header req; + uint16_t req_fmt; + uint8_t cssid; + uint8_t res_03; + uint32_t res_04[2]; + struct chsc_header res; + uint32_t res_fmt; + uint64_t general_char[255]; + uint64_t chsc_char[254]; +}; + +extern struct chsc_scsc *chsc_scsc; +#define CHSC_SCSC 0x0010 +#define CHSC_SCSC_LEN 0x0010 + +bool get_chsc_scsc(void); + +#define CSS_GENERAL_FEAT_BITLEN (255 * 64) +#define CSS_CHSC_FEAT_BITLEN (254 * 64) + +#define CHSC_SCSC 0x0010 +#define CHSC_SCSC_LEN 0x0010 + +#define CHSC_ERROR 0x0000 +#define CHSC_RSP_OK 0x0001 +#define CHSC_RSP_INVAL 0x0002 +#define CHSC_RSP_REQERR 0x0003 +#define CHSC_RSP_ENOCMD 0x0004 +#define CHSC_RSP_NODATA 0x0005 +#define CHSC_RSP_SUP31B 0x0006 +#define CHSC_RSP_EFRMT 0x0007 +#define CHSC_RSP_ECSSID 0x0008 +#define CHSC_RSP_ERFRMT 0x0009 +#define CHSC_RSP_ESSID 0x000A +#define CHSC_RSP_EBUSY 0x000B +#define CHSC_RSP_MAX 0x000B + +static inline int _chsc(void *p) +{ + int cc; + + asm volatile(" .insn rre,0xb25f0000,%2,0\n" + " ipm %0\n" + " srl %0,28\n" + : "=d" (cc), "=m" (p) + : "d" (p), "m" (p) + : "cc"); + + return cc; +} + +bool chsc(void *p, uint16_t code, uint16_t len); + +#include +#define css_general_feature(bit) test_bit_inv(bit, chsc_scsc->general_char) +#define css_chsc_feature(bit) test_bit_inv(bit, chsc_scsc->chsc_char) + #endif diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c index 3c24480..f46e871 100644 --- a/lib/s390x/css_lib.c +++ b/lib/s390x/css_lib.c @@ -15,11 +15,102 @@ #include #include #include - +#include #include #include static struct schib schib; +struct chsc_scsc *chsc_scsc; + +static const char * const chsc_rsp_description[] = { + "CHSC unknown error", + "Command executed", + "Invalid command", + "Request-block error", + "Command not installed", + "Data not available", + "Absolute address of channel-subsystem communication block exceeds 2G - 1.", + "Invalid command format", + "Invalid channel-subsystem identification (CSSID)", + "The command-request block specified an invalid format for the command response block.", + "Invalid subchannel-set identification (SSID)", + "A busy condition precludes execution.", +}; + +static bool check_response(void *p) +{ + struct chsc_header *h = p; + + if (h->code == CHSC_RSP_OK) + return true; + + if (h->code > CHSC_RSP_MAX) + h->code = 0; + + report_abort("Response code %04x: %s", h->code, + chsc_rsp_description[h->code]); + return false; +} + +bool chsc(void *p, uint16_t code, uint16_t len) +{ + struct chsc_header *h = p; + + h->code = code; + h->len = len; + + switch (_chsc(p)) { + case 3: + report_abort("Subchannel invalid or not enabled."); + break; + case 2: + report_abort("CHSC subchannel busy."); + break; + case 1: + report_abort("Subchannel invalid or not enabled."); + break; + case 0: + return check_response(p + len); + } + return false; +} + +bool get_chsc_scsc(void) +{ + int i, n; + char buffer[510]; + char *p; + + if (chsc_scsc) /* chsc_scsc already initialized */ + return true; + + chsc_scsc = alloc_page(); + if (!chsc_scsc) { + report_abort("could not allocate chsc_scsc page!"); + return false; + } + + if (!chsc(chsc_scsc, CHSC_SCSC, CHSC_SCSC_LEN)) + return false; + + for (i = 0, p = buffer; i < CSS_GENERAL_FEAT_BITLEN; i++) { + if (css_general_feature(i)) { + n = snprintf(p, sizeof(buffer), "%d,", i); + p += n; + } + } + report_info("General features: %s", buffer); + + for (i = 0, p = buffer; i < CSS_CHSC_FEAT_BITLEN; i++) { + if (css_chsc_feature(i)) { + n = snprintf(p, sizeof(buffer), "%d,", i); + p += n; + } + } + report_info("CHSC features: %s", buffer); + + return true; +} /* * css_enumerate: diff --git a/s390x/css.c b/s390x/css.c index 1a61a5c..09703c1 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -140,10 +141,17 @@ error_senseid: unregister_io_int_func(css_irq_io); } +static void css_init(void) +{ + report(!!get_chsc_scsc(), "Store Channel Characteristics"); +} + static struct { const char *name; void (*func)(void); } tests[] = { + /* The css_init test is needed to initialize the CSS Characteristics */ + { "initialize CSS (chsc)", css_init }, { "enumerate (stsch)", test_enumerate }, { "enable (msch)", test_enable }, { "sense (ssch/tsch)", test_sense }, From patchwork Mon Mar 1 11:47:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12109521 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E519C433DB for ; Mon, 1 Mar 2021 11:48:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E599964DBD for ; Mon, 1 Mar 2021 11:48:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234224AbhCALsJ (ORCPT ); Mon, 1 Mar 2021 06:48:09 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:61532 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234185AbhCALr5 (ORCPT ); Mon, 1 Mar 2021 06:47:57 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 121BXgB6099386 for ; Mon, 1 Mar 2021 06:47:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=UuaM3bqmOVYkKvf5PYh8XQQOHIstM7b9SFYJpuY1/rk=; b=oIVFQEslUn2z4siUAFrjxBOBGCu72Eh8WNbYBbWivV/UF2Ql+sNP8SqTBDYjEP42qDrh Pd7Bzq8t5+T1eaXpaxTvMYXptwuPXhIsu8XldY9aTylS2XT8/3d/25kTxP7v9TVY0uHo EyvQJeQLT3L8ioWzOg51ujWfGia5tM69jt9bVaodi1w+924/mXC/F7O9UzFnCDQzF1oc DUPqeCTKUewGZy1YdbKnMBzmEKNVhROjFJlgUMuCt4O1HzHAIuhKL5hAPG2yGNtE9mU+ JACydFfvLxi5LZ8SoTi72o9PTqBZtmCqapqXep4NHPToXkzrFVVJndMFtqbczdMCqVbu 8w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 370yau8myu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 01 Mar 2021 06:47:12 -0500 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 121BY5u8100753 for ; Mon, 1 Mar 2021 06:47:12 -0500 Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com with ESMTP id 370yau8my5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Mar 2021 06:47:12 -0500 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 121Bhxuu016183; Mon, 1 Mar 2021 11:47:10 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma01fra.de.ibm.com with ESMTP id 370atn0eyg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Mar 2021 11:47:10 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 121Bl7ku18219488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 1 Mar 2021 11:47:07 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C1179AE04D; Mon, 1 Mar 2021 11:47:07 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6B895AE051; Mon, 1 Mar 2021 11:47:07 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.52.26]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 1 Mar 2021 11:47:07 +0000 (GMT) From: Pierre Morel To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests PATCH v4 2/6] s390x: css: simplifications of the tests Date: Mon, 1 Mar 2021 12:47:01 +0100 Message-Id: <1614599225-17734-3-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1614599225-17734-1-git-send-email-pmorel@linux.ibm.com> References: <1614599225-17734-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-03-01_06:2021-02-26,2021-03-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 clxscore=1015 mlxlogscore=999 spamscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103010098 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org In order to ease the writing of tests based on: - interrupt - enabling a subchannel - using multiple I/O on a channel without disabling it We do the following simplifications: - the I/O interrupt handler is registered on CSS initialization - We do not enable again a subchannel in senseid if it is already enabled - we add a css_enabled() function to test if a subchannel is enabled Signed-off-by: Pierre Morel Reviewed-by: Cornelia Huck --- lib/s390x/css.h | 1 + lib/s390x/css_lib.c | 37 ++++++++++++++++++++++++++----------- s390x/css.c | 44 ++++++++++++++++++++++++-------------------- 3 files changed, 51 insertions(+), 31 deletions(-) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index 4210472..fbfa034 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -278,6 +278,7 @@ int css_enumerate(void); #define IO_SCH_ISC 3 int css_enable(int schid, int isc); +bool css_enabled(int schid); /* Library functions */ int start_ccw1_chain(unsigned int sid, struct ccw1 *ccw); diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c index f46e871..41134dc 100644 --- a/lib/s390x/css_lib.c +++ b/lib/s390x/css_lib.c @@ -161,6 +161,31 @@ out: return schid; } +/* + * css_enabled: report if the subchannel is enabled + * @schid: Subchannel Identifier + * Return value: + * true if the subchannel is enabled + * false otherwise + */ +bool css_enabled(int schid) +{ + struct pmcw *pmcw = &schib.pmcw; + int cc; + + cc = stsch(schid, &schib); + if (cc) { + report_info("stsch: updating sch %08x failed with cc=%d", + schid, cc); + return false; + } + + if (!(pmcw->flags & PMCW_ENABLE)) { + report_info("stsch: sch %08x not enabled", schid); + return false; + } + return true; +} /* * css_enable: enable the subchannel with the specified ISC * @schid: Subchannel Identifier @@ -210,18 +235,8 @@ retry: /* * Read the SCHIB again to verify the enablement */ - cc = stsch(schid, &schib); - if (cc) { - report_info("stsch: updating sch %08x failed with cc=%d", - schid, cc); - return cc; - } - - if ((pmcw->flags & flags) == flags) { - report_info("stsch: sch %08x successfully modified after %d retries", - schid, retry_count); + if (css_enabled(schid)) return 0; - } if (retry_count++ < MAX_ENABLE_RETRIES) { mdelay(10); /* the hardware was not ready, give it some time */ diff --git a/s390x/css.c b/s390x/css.c index 09703c1..c9e4903 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -56,36 +56,27 @@ static void test_enable(void) * - We need the test device as the first recognized * device by the enumeration. */ -static void test_sense(void) +static bool do_test_sense(void) { struct ccw1 *ccw; + bool success = false; int ret; int len; if (!test_device_sid) { report_skip("No device"); - return; + return success; } - ret = css_enable(test_device_sid, IO_SCH_ISC); - if (ret) { - report(0, "Could not enable the subchannel: %08x", - test_device_sid); - return; + if (!css_enabled(test_device_sid)) { + report(0, "enabling subchannel %08x", test_device_sid); + return success; } - ret = register_io_int_func(css_irq_io); - if (ret) { - report(0, "Could not register IRQ handler"); - return; - } - - lowcore_ptr->io_int_param = 0; - senseid = alloc_io_mem(sizeof(*senseid), 0); if (!senseid) { report(0, "Allocation of senseid"); - goto error_senseid; + return success; } ccw = ccw_alloc(CCW_CMD_SENSE_ID, senseid, sizeof(*senseid), CCW_F_SLI); @@ -129,21 +120,34 @@ static void test_sense(void) report_info("reserved 0x%02x cu_type 0x%04x cu_model 0x%02x dev_type 0x%04x dev_model 0x%02x", senseid->reserved, senseid->cu_type, senseid->cu_model, senseid->dev_type, senseid->dev_model); + report_info("cu_type expected 0x%04x got 0x%04x", (uint16_t)cu_type, + senseid->cu_type); - report(senseid->cu_type == cu_type, "cu_type expected 0x%04x got 0x%04x", - (uint16_t)cu_type, senseid->cu_type); + success = senseid->cu_type == cu_type; error: free_io_mem(ccw, sizeof(*ccw)); error_ccw: free_io_mem(senseid, sizeof(*senseid)); -error_senseid: - unregister_io_int_func(css_irq_io); + return success; +} + +static void test_sense(void) +{ + report(do_test_sense(), "Got CU type expected"); } static void css_init(void) { report(!!get_chsc_scsc(), "Store Channel Characteristics"); + + if (register_io_int_func(css_irq_io)) { + report(0, "Could not register IRQ handler"); + return; + } + lowcore_ptr->io_int_param = 0; + + report(1, "CSS initialized"); } static struct { From patchwork Mon Mar 1 11:47:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12109531 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0702C433DB for ; Mon, 1 Mar 2021 11:48:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69ECA64E2E for ; Mon, 1 Mar 2021 11:48:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234269AbhCALsg (ORCPT ); Mon, 1 Mar 2021 06:48:36 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:20752 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234193AbhCALr6 (ORCPT ); Mon, 1 Mar 2021 06:47:58 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 121Bb9JD027315 for ; Mon, 1 Mar 2021 06:47:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=qaYjIdp+FNXHdRzGaWlqyVjdD/RwGrqYo8RNQ4dX64g=; b=qOKX4Ogj28OLC7r5rSAPAXkv4CBIzXBHJXrGbH9+ZBWhVmYsXnf7qRj0FVVIhu1jIo5q TuPtvw45Tfks4ljTtJORq55APlLz8CTZCtaVonHK36EfvF7FP8V9Pv1QaVJtg/3d1dKg iOZ8K7rqAd0xNxuVRT3mgrqZwejkD5mts/hQx1Vb1Dl7klVnk1XsKo5y2KF0v1wYaIdG c7TGjcvRtdB4KbLIsCPuoHaj5jeiTg1KNqmSmehnmJ7GDiOwtzsesxN7oonK18/+jFSv s/LIaYtlyynO7YKNjfmceEEv4Q4yPTSPczgaz+lnApBOG7XkliV7XkRNDomdsBKYX1cs 8g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 370v7xy822-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 01 Mar 2021 06:47:13 -0500 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 121BbHmE028208 for ; Mon, 1 Mar 2021 06:47:13 -0500 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 370v7xy81j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Mar 2021 06:47:12 -0500 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 121BhQMh018480; Mon, 1 Mar 2021 11:47:11 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03ams.nl.ibm.com with ESMTP id 36ydq89tqm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Mar 2021 11:47:11 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 121BksfX34275782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 1 Mar 2021 11:46:54 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 32758AE053; Mon, 1 Mar 2021 11:47:08 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D2162AE051; Mon, 1 Mar 2021 11:47:07 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.52.26]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 1 Mar 2021 11:47:07 +0000 (GMT) From: Pierre Morel To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests PATCH v4 3/6] s390x: css: extending the subchannel modifying functions Date: Mon, 1 Mar 2021 12:47:02 +0100 Message-Id: <1614599225-17734-4-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1614599225-17734-1-git-send-email-pmorel@linux.ibm.com> References: <1614599225-17734-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-03-01_05:2021-02-26,2021-03-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 bulkscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103010098 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org To enable or disable measurement we will need specific modifications on the subchannel. Signed-off-by: Pierre Morel Reviewed-by: Cornelia Huck --- lib/s390x/css.h | 9 +++- lib/s390x/css_lib.c | 100 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 1 deletion(-) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index fbfa034..1cb3de2 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -82,6 +82,8 @@ struct pmcw { uint32_t intparm; #define PMCW_DNV 0x0001 #define PMCW_ENABLE 0x0080 +#define PMCW_MBUE 0x0010 +#define PMCW_DCTME 0x0008 #define PMCW_ISC_MASK 0x3800 #define PMCW_ISC_SHIFT 11 uint16_t flags; @@ -94,6 +96,7 @@ struct pmcw { uint8_t pom; uint8_t pam; uint8_t chpid[8]; +#define PMCW_MBF1 0x0004 uint32_t flags2; }; #define PMCW_CHANNEL_TYPE(pmcw) (pmcw->flags2 >> 21) @@ -101,7 +104,8 @@ struct pmcw { struct schib { struct pmcw pmcw; struct scsw scsw; - uint8_t md[12]; + uint64_t mbo; + uint8_t md[4]; } __attribute__ ((aligned(4))); struct irb { @@ -356,4 +360,7 @@ bool chsc(void *p, uint16_t code, uint16_t len); #define css_general_feature(bit) test_bit_inv(bit, chsc_scsc->general_char) #define css_chsc_feature(bit) test_bit_inv(bit, chsc_scsc->chsc_char) +bool css_enable_mb(int sid, uint64_t mb, uint16_t mbi, uint16_t flg, bool fmt1); +bool css_disable_mb(int schid); + #endif diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c index 41134dc..77b39c7 100644 --- a/lib/s390x/css_lib.c +++ b/lib/s390x/css_lib.c @@ -248,6 +248,106 @@ retry: return -1; } +/* + * schib_update_mb: update the subchannel Measurement Block + * @schid: Subchannel Identifier + * @mb : 64bit address of the measurement block + * @mbi : the measurement block offset + * @flags : PMCW_MBUE to enable measurement block update + * PMCW_DCTME to enable device connect time + * 0 to disable measurement + * @format1: set if format 1 is to be used + */ +static bool schib_update_mb(int schid, uint64_t mb, uint16_t mbi, + uint16_t flags, bool format1) +{ + struct pmcw *pmcw = &schib.pmcw; + int cc; + + /* Read the SCHIB for this subchannel */ + cc = stsch(schid, &schib); + if (cc) { + report_info("stsch: sch %08x failed with cc=%d", schid, cc); + return false; + } + + /* Update the SCHIB to enable the measurement block */ + if (flags) { + pmcw->flags |= flags; + + if (format1) + pmcw->flags2 |= PMCW_MBF1; + else + pmcw->flags2 &= ~PMCW_MBF1; + + pmcw->mbi = mbi; + schib.mbo = mb & ~0x3f; + } else { + pmcw->flags &= ~(PMCW_MBUE | PMCW_DCTME); + } + + /* Tell the CSS we want to modify the subchannel */ + cc = msch(schid, &schib); + if (cc) { + /* + * If the subchannel is status pending or + * if a function is in progress, + * we consider both cases as errors. + */ + report_info("msch: sch %08x failed with cc=%d", schid, cc); + return false; + } + + /* + * Read the SCHIB again + */ + cc = stsch(schid, &schib); + if (cc) { + report_info("stsch: updating sch %08x failed with cc=%d", + schid, cc); + return false; + } + + return true; +} + +/* + * css_enable_mb: enable the subchannel Measurement Block + * @schid: Subchannel Identifier + * @mb : 64bit address of the measurement block + * @format1: set if format 1 is to be used + * @mbi : the measurement block offset + * @flags : PMCW_MBUE to enable measurement block update + * PMCW_DCTME to enable device connect time + */ +bool css_enable_mb(int schid, uint64_t mb, uint16_t mbi, uint16_t flags, + bool format1) +{ + int retry_count = MAX_ENABLE_RETRIES; + struct pmcw *pmcw = &schib.pmcw; + + while (retry_count-- && + !schib_update_mb(schid, mb, mbi, flags, format1)) + mdelay(10); /* the hardware was not ready, give it some time */ + + return schib.mbo == mb && pmcw->mbi == mbi; +} + +/* + * css_disable_mb: disable the subchannel Measurement Block + * @schid: Subchannel Identifier + */ +bool css_disable_mb(int schid) +{ + int retry_count = MAX_ENABLE_RETRIES; + + while (retry_count-- && + !schib_update_mb(schid, 0, 0, 0, 0)) + mdelay(10); /* the hardware was not ready, give it some time */ + + return retry_count > 0; +} + static struct irb irb; void css_irq_io(void) From patchwork Mon Mar 1 11:47:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12109527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1145CC433DB for ; Mon, 1 Mar 2021 11:48:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D80A164E09 for ; Mon, 1 Mar 2021 11:48:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234261AbhCALs1 (ORCPT ); Mon, 1 Mar 2021 06:48:27 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:12694 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234205AbhCALr5 (ORCPT ); Mon, 1 Mar 2021 06:47:57 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 121BX0sW026355 for ; Mon, 1 Mar 2021 06:47:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=7SwerKTgwsFrIxi/y5WBqeX5YphlWY4HIa3ExWODyLQ=; b=MITEXZlqh6kEv/Ia8Wpq7Oxpjc57gzHtD6jN47/gXpfD6iPwM9bgZ42hl9R4yw1zjLIE Y2+V+wZWA/K0/ktLijEu7/EhCy8QEioF9xmI72c0b9eGaey/Wpmwb9bu60jMj1PlFroQ KDFn5WNpx0QoOthPAnC3v4qsXyrpAHwIaSnbSJ4q3f9Z10b9VszAfXIFsc5Bmt5Qet7s FQSrrno6GGQ2ryE3fW2U3SDRtArGEnKHAhngzNfVH6f8KO0Uh6TvBslonRT6CuroMiJ7 prxSA8iPPDX3PUAKNCz4tNvVLPH2Ot7T7xClhke7yByB9A/HeIru9UZ44ttFl86oBMOM Qg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 370y778xmh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 01 Mar 2021 06:47:14 -0500 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 121BY8LS032185 for ; Mon, 1 Mar 2021 06:47:13 -0500 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 370y778xkp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Mar 2021 06:47:13 -0500 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 121Bh4ka015732; Mon, 1 Mar 2021 11:47:11 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04ams.nl.ibm.com with ESMTP id 36ydq8hu22-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Mar 2021 11:47:11 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 121BksIW34603468 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 1 Mar 2021 11:46:55 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9E7DFAE04D; Mon, 1 Mar 2021 11:47:08 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 43717AE045; Mon, 1 Mar 2021 11:47:08 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.52.26]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 1 Mar 2021 11:47:08 +0000 (GMT) From: Pierre Morel To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests PATCH v4 4/6] s390x: css: implementing Set CHannel Monitor Date: Mon, 1 Mar 2021 12:47:03 +0100 Message-Id: <1614599225-17734-5-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1614599225-17734-1-git-send-email-pmorel@linux.ibm.com> References: <1614599225-17734-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-03-01_05:2021-02-26,2021-03-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 spamscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 mlxscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103010098 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We implement the call of the Set CHannel Monitor instruction, starting the monitoring of the all Channel Sub System, and initializing channel subsystem monitoring. Initial tests report the presence of the extended measurement block feature, and verify the error reporting of the hypervisor for SCHM. Signed-off-by: Pierre Morel Reviewed-by: Cornelia Huck Acked-by: Janosch Frank --- lib/s390x/css.h | 12 ++++++++++++ s390x/css.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index 1cb3de2..b8ac363 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -310,6 +310,7 @@ struct chsc_scsc { uint32_t res_04[2]; struct chsc_header res; uint32_t res_fmt; +#define CSSC_EXTENDED_MEASUREMENT_BLOCK 48 uint64_t general_char[255]; uint64_t chsc_char[254]; }; @@ -360,6 +361,17 @@ bool chsc(void *p, uint16_t code, uint16_t len); #define css_general_feature(bit) test_bit_inv(bit, chsc_scsc->general_char) #define css_chsc_feature(bit) test_bit_inv(bit, chsc_scsc->chsc_char) +#define SCHM_DCTM 1 /* activate Device Connection TiMe */ +#define SCHM_MBU 2 /* activate Measurement Block Update */ + +static inline void schm(void *mbo, unsigned int flags) +{ + register void *__gpr2 asm("2") = mbo; + register long __gpr1 asm("1") = flags; + + asm("schm" : : "d" (__gpr2), "d" (__gpr1)); +} + bool css_enable_mb(int sid, uint64_t mb, uint16_t mbi, uint16_t flg, bool fmt1); bool css_disable_mb(int schid); diff --git a/s390x/css.c b/s390x/css.c index c9e4903..e8f96f3 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -150,6 +150,40 @@ static void css_init(void) report(1, "CSS initialized"); } +static void test_schm(void) +{ + if (css_general_feature(CSSC_EXTENDED_MEASUREMENT_BLOCK)) + report_info("Extended measurement block available"); + + /* bits 59-63 of MB address must be 0 if MBU is defined */ + report_prefix_push("Unaligned operand"); + expect_pgm_int(); + schm((void *)0x01, SCHM_MBU); + check_pgm_int_code(PGM_INT_CODE_OPERAND); + report_prefix_pop(); + + /* bits 36-61 of register 1 (flags) must be 0 */ + report_prefix_push("Bad flags"); + expect_pgm_int(); + schm(NULL, 0xfffffffc); + check_pgm_int_code(PGM_INT_CODE_OPERAND); + report_prefix_pop(); + + /* SCHM is a privilege operation */ + report_prefix_push("Privilege"); + enter_pstate(); + expect_pgm_int(); + schm(NULL, SCHM_MBU); + check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION); + report_prefix_pop(); + + /* Normal operation */ + report_prefix_push("Normal operation"); + schm(NULL, SCHM_MBU); + report(1, "SCHM call without address"); + report_prefix_pop(); +} + static struct { const char *name; void (*func)(void); @@ -159,6 +193,7 @@ static struct { { "enumerate (stsch)", test_enumerate }, { "enable (msch)", test_enable }, { "sense (ssch/tsch)", test_sense }, + { "measurement block (schm)", test_schm }, { NULL, NULL } }; From patchwork Mon Mar 1 11:47:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12109533 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE6A6C433E0 for ; Mon, 1 Mar 2021 11:48:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8333B64E09 for ; Mon, 1 Mar 2021 11:48:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234277AbhCALsl (ORCPT ); Mon, 1 Mar 2021 06:48:41 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:3684 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234208AbhCALr6 (ORCPT ); Mon, 1 Mar 2021 06:47:58 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 121Bb8gj027252 for ; Mon, 1 Mar 2021 06:47:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=vN8FGrMViRuF0A48KejdsIHqw0H3h1UbujVuInQMUkU=; b=gFAp3zJNsUJX9zAge7Ug+42dHXQ1DpGfXBnnCJpYi0n1cHGVzow7+Dgj6tEgcsDUGtF4 0q6Vk7n91cuwY9vtKlyNaakNha149p2jfXLLyLlKhIh/RbJ4iciHQlWgGLB9Yj42uv54 sonnBqQ1u+BYIucP+k5oqJ9dVbmBBes9Ec4NzY8FKCL6Ux80qoSoDEAb3HFSh3Dh73sJ ER7DjqT36woHD/siZuQhntHx/83kpSc7Or0hj2FGNzoMG/RCpr8OlHcvNjcJdC6c1RUa wUjlbuGs+Ja28OlTaE/7wCeeCZeMUJHNPlyRqoLsTa5uQOPfv33MEYIq/g1Wk5HSN4xK 3A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 370v7xy828-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 01 Mar 2021 06:47:14 -0500 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 121BbD6f027664 for ; Mon, 1 Mar 2021 06:47:13 -0500 Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 370v7xy81t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Mar 2021 06:47:13 -0500 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 121BgtJu010381; Mon, 1 Mar 2021 11:47:12 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma05fra.de.ibm.com with ESMTP id 36ydq88xv4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Mar 2021 11:47:11 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 121Bl9G540960438 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 1 Mar 2021 11:47:09 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0E59BAE056; Mon, 1 Mar 2021 11:47:09 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B0787AE045; Mon, 1 Mar 2021 11:47:08 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.52.26]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 1 Mar 2021 11:47:08 +0000 (GMT) From: Pierre Morel To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests PATCH v4 5/6] s390x: css: testing measurement block format 0 Date: Mon, 1 Mar 2021 12:47:04 +0100 Message-Id: <1614599225-17734-6-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1614599225-17734-1-git-send-email-pmorel@linux.ibm.com> References: <1614599225-17734-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-03-01_05:2021-02-26,2021-03-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 bulkscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103010098 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We test the update of the measurement block format 0, the measurement block origin is calculated from the mbo argument used by the SCHM instruction and the offset calculated using the measurement block index of the SCHIB. Signed-off-by: Pierre Morel --- lib/s390x/css.h | 12 +++++++++ s390x/css.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index b8ac363..40f9efa 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -375,4 +375,16 @@ static inline void schm(void *mbo, unsigned int flags) bool css_enable_mb(int sid, uint64_t mb, uint16_t mbi, uint16_t flg, bool fmt1); bool css_disable_mb(int schid); +struct measurement_block_format0 { + uint16_t ssch_rsch_count; + uint16_t sample_count; + uint32_t device_connect_time; + uint32_t function_pending_time; + uint32_t device_disconnect_time; + uint32_t cu_queuing_time; + uint32_t device_active_only_time; + uint32_t device_busy_time; + uint32_t initial_cmd_resp_time; +}; + #endif diff --git a/s390x/css.c b/s390x/css.c index e8f96f3..3915ed3 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -184,6 +184,71 @@ static void test_schm(void) report_prefix_pop(); } +#define SCHM_UPDATE_CNT 10 +static bool start_measuring(uint64_t mbo, uint16_t mbi, bool fmt1) +{ + int i; + + if (!css_enable_mb(test_device_sid, mbo, mbi, PMCW_MBUE, fmt1)) { + report(0, "Enabling measurement_block_format"); + return false; + } + + for (i = 0; i < SCHM_UPDATE_CNT; i++) { + if (!do_test_sense()) { + report(0, "Error during sense"); + return false; + } + } + + return true; +} + +/* + * test_schm_fmt0: + * With measurement block format 0 a memory space is shared + * by all subchannels, each subchannel can provide an index + * for the measurement block facility to store the measurements. + */ +static void test_schm_fmt0(void) +{ + struct measurement_block_format0 *mb0; + int shared_mb_size = 2 * sizeof(struct measurement_block_format0); + + /* Allocate zeroed Measurement block */ + mb0 = alloc_io_mem(shared_mb_size, 0); + if (!mb0) { + report_abort("measurement_block_format0 allocation failed"); + return; + } + + schm(NULL, 0); /* Stop any previous measurement */ + schm(mb0, SCHM_MBU); + + /* Expect success */ + report_prefix_push("Valid MB address and index 0"); + report(start_measuring(0, 0, false) && + mb0->ssch_rsch_count == SCHM_UPDATE_CNT, + "SSCH measured %d", mb0->ssch_rsch_count); + report_prefix_pop(); + + /* Clear the measurement block for the next test */ + memset(mb0, 0, shared_mb_size); + + /* Expect success */ + report_prefix_push("Valid MB address and index 1"); + report(start_measuring(0, 1, false) && + mb0[1].ssch_rsch_count == SCHM_UPDATE_CNT, + "SSCH measured %d", mb0[1].ssch_rsch_count); + report_prefix_pop(); + + /* Stop the measurement */ + css_disable_mb(test_device_sid); + schm(NULL, 0); + + free_io_mem(mb0, shared_mb_size); +} + static struct { const char *name; void (*func)(void); @@ -194,6 +259,7 @@ static struct { { "enable (msch)", test_enable }, { "sense (ssch/tsch)", test_sense }, { "measurement block (schm)", test_schm }, + { "measurement block format0", test_schm_fmt0 }, { NULL, NULL } }; From patchwork Mon Mar 1 11:47:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12109523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EB81C43381 for ; Mon, 1 Mar 2021 11:48:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1DB264E09 for ; Mon, 1 Mar 2021 11:48:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232139AbhCALsU (ORCPT ); Mon, 1 Mar 2021 06:48:20 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34474 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234211AbhCALr5 (ORCPT ); Mon, 1 Mar 2021 06:47:57 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 121BXGjq060575 for ; Mon, 1 Mar 2021 06:47:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=7BVcL6nmNb9Ih0bIDSFpJBhc6rY8axTKd7rF67FM6X0=; b=iNLvhtdjyKfP14NhDnXq/fPk8eXmwx51M52ln/e7TIje4BkHkTC00xBxRdZt5sY7kEzx 1CivO8XDHm/b9XN/S84e2xZ7yYTPBDpmB3MVAMI202JOlYu+N4awMlc5eMbIbQ1f9kv4 jjJHCFQGAEEnzSSt9mXtORMfeVnNd7CZ8vSp9j8lXA3hDNooI5PKxG8HbExwN6HydURJ OJNAEf5kqPhpeyLiDVXoqTbhPMp5nQUZV2uXtmeL15uhFvDFtTPsMkBObytwReFYff/m bfOnvBtCBJFuqxSdEB7eIQWeJy4PxBo4BghKqLk2oMMQDkb5XLovVDAKvrYk/C1ZR1qS kg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 370vday0r9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 01 Mar 2021 06:47:15 -0500 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 121BXTp4061480 for ; Mon, 1 Mar 2021 06:47:14 -0500 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 370vday0qq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Mar 2021 06:47:14 -0500 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 121Bgq9s014162; Mon, 1 Mar 2021 11:47:12 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06ams.nl.ibm.com with ESMTP id 370c59rua7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 01 Mar 2021 11:47:12 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 121Bl9Rj34079092 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 1 Mar 2021 11:47:09 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 78C8AAE055; Mon, 1 Mar 2021 11:47:09 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 20765AE045; Mon, 1 Mar 2021 11:47:09 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.52.26]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 1 Mar 2021 11:47:09 +0000 (GMT) From: Pierre Morel To: kvm@vger.kernel.org Cc: frankja@linux.ibm.com, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests PATCH v4 6/6] s390x: css: testing measurement block format 1 Date: Mon, 1 Mar 2021 12:47:05 +0100 Message-Id: <1614599225-17734-7-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1614599225-17734-1-git-send-email-pmorel@linux.ibm.com> References: <1614599225-17734-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-03-01_05:2021-02-26,2021-03-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 mlxscore=0 clxscore=1015 phishscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103010098 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Measurement block format 1 is made available by the extended measurement block facility and is indicated in the SCHIB by the bit in the PMCW. The MBO is specified in the SCHIB of each channel and the MBO defined by the SCHM instruction is ignored. The test of the MB format 1 is just skipped if the feature is not available. Signed-off-by: Pierre Morel --- lib/s390x/css.h | 15 +++++++++ lib/s390x/css_lib.c | 2 +- s390x/css.c | 75 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index 40f9efa..c8c8e04 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -107,6 +107,7 @@ struct schib { uint64_t mbo; uint8_t md[4]; } __attribute__ ((aligned(4))); +extern struct schib schib; struct irb { struct scsw scsw; @@ -387,4 +388,18 @@ struct measurement_block_format0 { uint32_t initial_cmd_resp_time; }; +struct measurement_block_format1 { + uint32_t ssch_rsch_count; + uint32_t sample_count; + uint32_t device_connect_time; + uint32_t function_pending_time; + uint32_t device_disconnect_time; + uint32_t cu_queuing_time; + uint32_t device_active_only_time; + uint32_t device_busy_time; + uint32_t initial_cmd_resp_time; + uint32_t irq_delay_time; + uint32_t irq_prio_delay_time; +}; + #endif diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c index 77b39c7..a43da5c 100644 --- a/lib/s390x/css_lib.c +++ b/lib/s390x/css_lib.c @@ -19,7 +19,7 @@ #include #include -static struct schib schib; +struct schib schib; struct chsc_scsc *chsc_scsc; static const char * const chsc_rsp_description[] = { diff --git a/s390x/css.c b/s390x/css.c index 3915ed3..5723808 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -249,6 +249,80 @@ static void test_schm_fmt0(void) free_io_mem(mb0, shared_mb_size); } +static void msch_with_wrong_fmt1_mbo(unsigned int schid, uint64_t mb) +{ + struct pmcw *pmcw = &schib.pmcw; + int cc; + + /* Read the SCHIB for this subchannel */ + cc = stsch(schid, &schib); + if (cc) { + report(0, "stsch: sch %08x failed with cc=%d", schid, cc); + return; + } + + /* Update the SCHIB to enable the measurement block */ + pmcw->flags |= PMCW_MBUE; + pmcw->flags2 |= PMCW_MBF1; + schib.mbo = mb; + + /* Tell the CSS we want to modify the subchannel */ + expect_pgm_int(); + cc = msch(schid, &schib); + check_pgm_int_code(PGM_INT_CODE_OPERAND); +} + +/* + * test_schm_fmt1: + * With measurement block format 1 the measurement block is + * dedicated to a subchannel. + */ +static void test_schm_fmt1(void) +{ + struct measurement_block_format1 *mb1; + + if (!test_device_sid) { + report_skip("No device"); + return; + } + + if (!css_general_feature(CSSC_EXTENDED_MEASUREMENT_BLOCK)) { + report_skip("Extended measurement block not available"); + return; + } + + /* Allocate zeroed Measurement block */ + mb1 = alloc_io_mem(sizeof(struct measurement_block_format1), 0); + if (!mb1) { + report_abort("measurement_block_format1 allocation failed"); + return; + } + + schm(NULL, 0); /* Stop any previous measurement */ + schm(0, SCHM_MBU); + + /* Expect error for non aligned MB */ + report_prefix_push("Unaligned MB origin"); + msch_with_wrong_fmt1_mbo(test_device_sid, (uint64_t)mb1 + 1); + report_prefix_pop(); + + /* Clear the measurement block for the next test */ + memset(mb1, 0, sizeof(*mb1)); + + /* Expect success */ + report_prefix_push("Valid MB origin"); + report(start_measuring((u64)mb1, 0, true) && + mb1->ssch_rsch_count == SCHM_UPDATE_CNT, + "SSCH measured %d", mb1->ssch_rsch_count); + report_prefix_pop(); + + /* Stop the measurement */ + css_disable_mb(test_device_sid); + schm(NULL, 0); + + free_io_mem(mb1, sizeof(struct measurement_block_format1)); +} + static struct { const char *name; void (*func)(void); @@ -260,6 +334,7 @@ static struct { { "sense (ssch/tsch)", test_sense }, { "measurement block (schm)", test_schm }, { "measurement block format0", test_schm_fmt0 }, + { "measurement block format1", test_schm_fmt1 }, { NULL, NULL } };