From patchwork Fri Mar 12 10:41:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12134263 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 A557DC43381 for ; Fri, 12 Mar 2021 10:42:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F7D065031 for ; Fri, 12 Mar 2021 10:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233201AbhCLKmS (ORCPT ); Fri, 12 Mar 2021 05:42:18 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:63676 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232988AbhCLKmC (ORCPT ); Fri, 12 Mar 2021 05:42:02 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12CAWvm1173108 for ; Fri, 12 Mar 2021 05:42:02 -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=1Kg072U2s1o8UXNvR+hjpC6LwL5yeTNbwooihYMf9Bw=; b=Cgprlpvqvdcx7RTTzzpAxX7uLvbyc4Y1HiqvBtEWHcRvQDV63WCSI4/3NhQQAJ95MotL TyKHk3zNAY1ccrHQDcFlL53OW9jLn8Gqlzijue8qGnt8Aqz1RoiatnytGesHpdg3fT+X sDRje5YVtZ/svfGyL6zhACOShrMEWyGeBhQJIbHgoyw5ofVwY6mr3Ku2lTe/4hmtoJc1 ClQsKYI24iS1X92EHB9bmI1nmpnK+UbR5GlzAuE/VFNF9EbAAXDXD3fZrl80Lx6e2w7J rd5gTrqQLqTLMJDiignO1gNamlaLoAgFus7lzA4wizhovwy9JHA/+qDZpWEo0X1IPDY4 /w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3774mfe6f1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 12 Mar 2021 05:42:01 -0500 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 12CAXFwh173949 for ; Fri, 12 Mar 2021 05:42:01 -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 3774mfe6da-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Mar 2021 05:42:01 -0500 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 12CAcRYf019528; Fri, 12 Mar 2021 10:41:59 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 3768mpsfpk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Mar 2021 10:41:59 +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 12CAfuLR13697302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 10:41:56 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 17A87AE045; Fri, 12 Mar 2021 10:41:56 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B07E3AE051; Fri, 12 Mar 2021 10:41:55 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.32.251]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 12 Mar 2021 10:41:55 +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 v6 1/6] s390x: css: Store CSS Characteristics Date: Fri, 12 Mar 2021 11:41:49 +0100 Message-Id: <1615545714-13747-2-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615545714-13747-1-git-send-email-pmorel@linux.ibm.com> References: <1615545714-13747-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-12_03:2021-03-10,2021-03-12 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103120072 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 | 66 ++++++++++++++++++++++++++++++++ lib/s390x/css_lib.c | 93 ++++++++++++++++++++++++++++++++++++++++++++- s390x/css.c | 8 ++++ 3 files changed, 166 insertions(+), 1 deletion(-) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index 3e57445..3dc2f31 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -288,4 +288,70 @@ 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 reserved[9]; + 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_test_general_feature(bit) test_bit_inv(bit, chsc_scsc->general_char) +#define css_test_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..3c1acbf 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_test_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_test_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..12036b3 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 Fri Mar 12 10:41:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12134265 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 9EAD2C433E6 for ; Fri, 12 Mar 2021 10:42:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F97665038 for ; Fri, 12 Mar 2021 10:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233287AbhCLKmT (ORCPT ); Fri, 12 Mar 2021 05:42:19 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:64692 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232999AbhCLKmC (ORCPT ); Fri, 12 Mar 2021 05:42:02 -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 12CAWmGh121304 for ; Fri, 12 Mar 2021 05:42:02 -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=wL4T/mFkbnpYrcVA8WWmuvgbSBeTrjZC+aZCIy8vfzI=; b=qxlqo3Ss90ndm7O56NK1mpbHLltndjUYzG6zCvSUG7XsiGslmxB5snCvqNp3AwdZ7z+B mzQVnZATg7tEiPzkINr/BntM2bSt7yOfRAH9lKuRx7MITvaXVMlfOFhGUkcYtg3tyVhT f2oEgnYnO26648zpD4MN0SQEBkDPNY+XxXIrDL5HgTj161SAXPE5DN3w7Tbp3eT79X5x /bMbam1po4ypAWFRJEskuxYSqvUmIOvac7p5q3AJLZ7HKbAR3P42ZCdjws5yozFpjR+y wzLWFhK+BSPlLIO27DJmiPMyjuICKHAHhLP2KOXRLlkXcWwqWFIOAPLVuopvqV2eqAG7 Kw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3774mf61vr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 12 Mar 2021 05:42:02 -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 12CAX4tE121894 for ; Fri, 12 Mar 2021 05:42:01 -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 3774mf61uh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Mar 2021 05:42:01 -0500 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 12CAfkTf010302; Fri, 12 Mar 2021 10:41:59 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 376agr1dvr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Mar 2021 10:41:59 +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 12CAfuCq33489232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 10:41:56 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FAE2AE04D; Fri, 12 Mar 2021 10:41:56 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 28BBCAE051; Fri, 12 Mar 2021 10:41:56 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.32.251]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 12 Mar 2021 10:41:56 +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 v6 2/6] s390x: css: simplifications of the tests Date: Fri, 12 Mar 2021 11:41:50 +0100 Message-Id: <1615545714-13747-3-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615545714-13747-1-git-send-email-pmorel@linux.ibm.com> References: <1615545714-13747-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-12_03:2021-03-10,2021-03-12 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 clxscore=1015 mlxscore=0 malwarescore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103120072 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 Acked-by: Janosch Frank --- lib/s390x/css.h | 1 + lib/s390x/css_lib.c | 41 ++++++++++++++++++++++++++--------------- s390x/css.c | 15 +++++---------- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index 3dc2f31..b9e4c08 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 3c1acbf..a97d61e 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 */ @@ -250,10 +265,6 @@ void css_irq_io(void) lowcore_ptr->io_int_param, sid); goto pop; } - report_info("subsys_id_word: %08x io_int_param %08x io_int_word %08x", - lowcore_ptr->subsys_id_word, - lowcore_ptr->io_int_param, - lowcore_ptr->io_int_word); report_prefix_pop(); report_prefix_push("tsch"); diff --git a/s390x/css.c b/s390x/css.c index 12036b3..a477833 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -25,6 +25,7 @@ static unsigned long cu_type = DEFAULT_CU_TYPE; static int test_device_sid; static struct senseid *senseid; +struct ccw1 *ccw; static void test_enumerate(void) { @@ -58,7 +59,6 @@ static void test_enable(void) */ static void test_sense(void) { - struct ccw1 *ccw; int ret; int len; @@ -74,18 +74,12 @@ static void test_sense(void) return; } - 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; } ccw = ccw_alloc(CCW_CMD_SENSE_ID, senseid, sizeof(*senseid), CCW_F_SLI); @@ -137,12 +131,13 @@ error: free_io_mem(ccw, sizeof(*ccw)); error_ccw: free_io_mem(senseid, sizeof(*senseid)); -error_senseid: - unregister_io_int_func(css_irq_io); } static void css_init(void) { + assert(register_io_int_func(css_irq_io) == 0); + lowcore_ptr->io_int_param = 0; + report(get_chsc_scsc(), "Store Channel Characteristics"); } From patchwork Fri Mar 12 10:41:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12134273 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 DAE7BC4332E for ; Fri, 12 Mar 2021 10:42:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A329864F29 for ; Fri, 12 Mar 2021 10:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233332AbhCLKmT (ORCPT ); Fri, 12 Mar 2021 05:42:19 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:64702 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233255AbhCLKmC (ORCPT ); Fri, 12 Mar 2021 05:42:02 -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 12CAXoO2022765 for ; Fri, 12 Mar 2021 05:42:02 -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=wiE2PJJ/z/QIM//Q+lzTTZm1ajeW0XePcwXujyaz1Y4=; b=qFGLHN9Ykqo8h3Fu7xS3gAzibO8fi9KGNPrfdoC1i1g2FIdtChpvnzopieYNS5zMJxmp m6Vl+Jg8SRNtzuWiSb/gL3MwdDO9doRQJ3wyhPi6FGiucMR+HJhlMUr4ym0qrzwffI29 4O72SO1VoVaxZlB2j6SynUk+Subpk+LXGAaAE+8cdc8Ap5RddKHhp4MFd0PQp/2DWb35 8ljirPiWcn2w48Sh6q5YlEZQm5OPV4sEWVp4jE1Smrk9ksvfuk5WFkFF69yXFxQufqLW S1IqahWd4ooAXCdxi+aGzj7cTQiT6TDWW5tEErje13lUP/7xrjG0wMyZYPPcyqXU0zfY pw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3774mr5xaa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 12 Mar 2021 05:42:02 -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 12CAYXmb025422 for ; Fri, 12 Mar 2021 05:42:01 -0500 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 3774mr5x9m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Mar 2021 05:42:01 -0500 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 12CAcQtr019755; Fri, 12 Mar 2021 10:41:59 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 376mb0t7g2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Mar 2021 10:41:59 +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 12CAfujJ8323422 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 10:41:57 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DDC3CAE045; Fri, 12 Mar 2021 10:41:56 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8BA5FAE051; Fri, 12 Mar 2021 10:41:56 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.32.251]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 12 Mar 2021 10:41:56 +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 v6 3/6] s390x: css: extending the subchannel modifying functions Date: Fri, 12 Mar 2021 11:41:51 +0100 Message-Id: <1615545714-13747-4-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615545714-13747-1-git-send-email-pmorel@linux.ibm.com> References: <1615545714-13747-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-12_03:2021-03-10,2021-03-12 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 adultscore=0 clxscore=1015 impostorscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103120072 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 Acked-by: Janosch Frank --- 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 b9e4c08..7dddb42 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 { @@ -355,4 +359,7 @@ bool chsc(void *p, uint16_t code, uint16_t len); #define css_test_general_feature(bit) test_bit_inv(bit, chsc_scsc->general_char) #define css_test_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 a97d61e..8f09383 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 Fri Mar 12 10:41:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12134267 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 BD6A3C433E9 for ; Fri, 12 Mar 2021 10:42:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9307265036 for ; Fri, 12 Mar 2021 10:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233442AbhCLKmU (ORCPT ); Fri, 12 Mar 2021 05:42:20 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:22832 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233286AbhCLKmD (ORCPT ); Fri, 12 Mar 2021 05:42:03 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12CAXTwi171219 for ; Fri, 12 Mar 2021 05:42:02 -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=IjVrYqjyV1Ju9MXqPcBmI5GksYppG9Cn+B770KOPSag=; b=IokTLANq7P2dnQq6WtmxmXbw2cjL/Hie1jjc/ruzx0OeKmTqPXVC3yGta6UdVfoJByPe CBK01TGYQQmBilODmfXuGRuFpwo/wrKRb/w86YOGV7brLAG/gxiEExFX4kYL1Frki3r+ 0iX1VUpfw44qZYF1mRNLNzAi6FFYH0/LcydRl4Xtsx6jvRjO2nO5TX0xin+5IQAzMqiE iJoUecPHF/GdBAMo0mJq/mO1x3ojjmw0XF86BEK2dLqFopHyw0/Wou+LLdf1LlmtgzRf NPE13EYtjoDFIkT3VPThyObuT6m6OB+woP4uCH/e27GfaTlkD5qeKHa8T5PwwxVqz0XL ig== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 377yajanug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 12 Mar 2021 05:42:02 -0500 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 12CAYJqx173555 for ; Fri, 12 Mar 2021 05:42:01 -0500 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 377yajants-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Mar 2021 05:42:01 -0500 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 12CAb2M2018900; Fri, 12 Mar 2021 10:42:00 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03fra.de.ibm.com with ESMTP id 3768mpsfpm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Mar 2021 10:42:00 +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 12CAffV137028228 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 10:41:41 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 54EAAAE053; Fri, 12 Mar 2021 10:41:57 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF355AE04D; Fri, 12 Mar 2021 10:41:56 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.32.251]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 12 Mar 2021 10:41:56 +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 v6 4/6] s390x: css: implementing Set CHannel Monitor Date: Fri, 12 Mar 2021 11:41:52 +0100 Message-Id: <1615545714-13747-5-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615545714-13747-1-git-send-email-pmorel@linux.ibm.com> References: <1615545714-13747-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-12_03:2021-03-10,2021-03-12 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 phishscore=0 clxscore=1015 impostorscore=0 bulkscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103120072 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 7dddb42..7158423 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -309,6 +309,7 @@ struct chsc_scsc { uint8_t reserved[9]; struct chsc_header res; uint32_t res_fmt; +#define CSSC_EXTENDED_MEASUREMENT_BLOCK 48 uint64_t general_char[255]; uint64_t chsc_char[254]; }; @@ -359,6 +360,17 @@ bool chsc(void *p, uint16_t code, uint16_t len); #define css_test_general_feature(bit) test_bit_inv(bit, chsc_scsc->general_char) #define css_test_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 a477833..af68266 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -141,6 +141,40 @@ static void css_init(void) report(get_chsc_scsc(), "Store Channel Characteristics"); } +static void test_schm(void) +{ + if (css_test_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); @@ -150,6 +184,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 Fri Mar 12 10:41:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12134271 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 DCA7FC43331 for ; Fri, 12 Mar 2021 10:42:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4D4865043 for ; Fri, 12 Mar 2021 10:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233468AbhCLKmU (ORCPT ); Fri, 12 Mar 2021 05:42:20 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:20224 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233497AbhCLKmE (ORCPT ); Fri, 12 Mar 2021 05:42:04 -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 12CAXwN8161289 for ; Fri, 12 Mar 2021 05:42:04 -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=P50ZHWrN4azW1++K3SjCB1h07TxgYC6u/usi7dsMzlE=; b=o5CH6b7I2Pg8PPMJ6RgJUR5XOaOAhCOonfQEwwAhZl+kf8KlyY5MZ4wOx+HhrKVoNQm/ bZq3cWc7sJ1tHLTjp6yQFng/bR2hMR2KDD4RW6GabNJ9jPXeHywC2d41lAfxFaM8Gswz vLVPXuwcgq/gIIcAtQ0QPfOBHn62eF0Hy62B5SLclWUsvUx4CR89o4ssAtmAdldlJNlp vMCvdRw8PFkxki+QPnxMqJyY+b9XW6e+DUK6i92upVu66a1I5n/cVPFj13YNtZJ1uSmH NhcjMsVT25AifAjixN1rhahhBen8RPROh0V+zu7HENQtxnoTRcvja4Zf0NAhrwRXuyKK Zg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3774kyjf77-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 12 Mar 2021 05:42:04 -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 12CAY7b9161691 for ; Fri, 12 Mar 2021 05:42:03 -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 3774kyjf5r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Mar 2021 05:42:03 -0500 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 12CAfp6a010330; Fri, 12 Mar 2021 10:42:00 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma01fra.de.ibm.com with ESMTP id 376agr1dvt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Mar 2021 10:42:00 +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 12CAfgfj37028230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 10:41:42 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B9BB0AE051; Fri, 12 Mar 2021 10:41:57 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 670FAAE04D; Fri, 12 Mar 2021 10:41:57 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.32.251]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 12 Mar 2021 10:41:57 +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 v6 5/6] s390x: css: testing measurement block format 0 Date: Fri, 12 Mar 2021 11:41:53 +0100 Message-Id: <1615545714-13747-6-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615545714-13747-1-git-send-email-pmorel@linux.ibm.com> References: <1615545714-13747-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-12_03:2021-03-10,2021-03-12 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 clxscore=1015 impostorscore=0 priorityscore=1501 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103120072 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 Reviewed-by: Cornelia Huck Acked-by: Janosch Frank --- lib/s390x/css.h | 12 +++++++ s390x/css.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index 7158423..335bc70 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -374,4 +374,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 af68266..658c5f8 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -133,6 +133,13 @@ error_ccw: free_io_mem(senseid, sizeof(*senseid)); } +static void sense_id(void) +{ + assert(!start_ccw1_chain(test_device_sid, ccw)); + + assert(wait_and_check_io_completion(test_device_sid) >= 0); +} + static void css_init(void) { assert(register_io_int_func(css_irq_io) == 0); @@ -175,6 +182,81 @@ 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; + + senseid = alloc_io_mem(sizeof(*senseid), 0); + assert(senseid); + + ccw = ccw_alloc(CCW_CMD_SENSE_ID, senseid, sizeof(*senseid), CCW_F_SLI); + assert(ccw); + + if (!css_enable_mb(test_device_sid, mbo, mbi, PMCW_MBUE, fmt1)) { + report_abort("Enabling measurement block failed"); + return false; + } + + for (i = 0; i < SCHM_UPDATE_CNT; i++) + sense_id(); + + free_io_mem(ccw, sizeof(*ccw)); + free_io_mem(senseid, sizeof(*senseid)); + + 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); + + if (!test_device_sid) { + report_skip("No device"); + return; + } + + /* 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"); + if (start_measuring(0, 1, false)) + report(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); @@ -185,6 +267,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 Fri Mar 12 10:41:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12134269 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 CBCCFC4332B for ; Fri, 12 Mar 2021 10:42:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B19AA6503F for ; Fri, 12 Mar 2021 10:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233475AbhCLKmV (ORCPT ); Fri, 12 Mar 2021 05:42:21 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:6966 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233493AbhCLKmE (ORCPT ); Fri, 12 Mar 2021 05:42:04 -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 12CAXiMi119868 for ; Fri, 12 Mar 2021 05:42:03 -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=DishcRxBAFwRuNThKfh9pH9U39zaiJMec1GDct8bPYE=; b=GqEU8Ds6Qa7NLw42YewinH/q/w6QmxNexseDOq59qe7TRYxEv3uivnUjcFFdEJkeLVf8 n7l3sxzOo3NDODJtDaLKfB0cIv5FJruVpGc704hhcicUTkE14DsmeomhX2EiNizCP3Ib Li8rJY/LfEqKKHNt103NX88KRGmztlUiWxOwUI7uW01gEhq305Qn5kUtMRFkiUU+HFBu cY6aJiiCgpKX/CNpZfZUt7QyFqx8ht55LhL9ZifsGr3wRrKpXGxPX95soExXtzqKTFEK +gD8wyTTHUUVCTQpgGRyaDF7YQtIfD7hNrRZG3wFHQzq1TI3cjSBev9ADfN7NUvysSPl XQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3774m8t1tt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 12 Mar 2021 05:42:03 -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 12CAXqPn120262 for ; Fri, 12 Mar 2021 05:42:02 -0500 Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 3774m8t1t8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Mar 2021 05:42:02 -0500 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 12CAdFlZ027958; Fri, 12 Mar 2021 10:42:01 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma06fra.de.ibm.com with ESMTP id 3768n61fp0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Mar 2021 10:42:01 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 12CAfgOo24642002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 10:41:42 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A473AE053; Fri, 12 Mar 2021 10:41:58 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB54EAE04D; Fri, 12 Mar 2021 10:41:57 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.32.251]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 12 Mar 2021 10:41:57 +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 v6 6/6] s390x: css: testing measurement block format 1 Date: Fri, 12 Mar 2021 11:41:54 +0100 Message-Id: <1615545714-13747-7-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615545714-13747-1-git-send-email-pmorel@linux.ibm.com> References: <1615545714-13747-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-12_03:2021-03-10,2021-03-12 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 clxscore=1015 malwarescore=0 suspectscore=0 adultscore=0 phishscore=0 impostorscore=0 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103120072 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 Reviewed-by: Cornelia Huck --- 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 335bc70..7e3d261 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; @@ -386,4 +387,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 8f09383..efc7057 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 658c5f8..c340c53 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -257,6 +257,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_test_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"); + if (start_measuring((u64)mb1, 0, true)) + report(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); @@ -268,6 +342,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 } };