From patchwork Tue Mar 9 12:51:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12124963 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 60D2DC433E9 for ; Tue, 9 Mar 2021 12:52:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3190F65274 for ; Tue, 9 Mar 2021 12:52:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231243AbhCIMvk (ORCPT ); Tue, 9 Mar 2021 07:51:40 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50182 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231273AbhCIMvZ (ORCPT ); Tue, 9 Mar 2021 07:51:25 -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 129CWbPK005213 for ; Tue, 9 Mar 2021 07:51:25 -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=8XMcQeqnTkeZ3eySvJgaJlf5wjun0kUqA5lzqI4C8Gk=; b=WXQ1+fJmPP/A4LUjHXBfeC9KMGWbeqNtd+s6vScWu7Agm2K7BIIcO84bYYZFAFgtmXvE 3amwZQ7mjlRiDypDW93svEzgKviN1VnLqozy8CDsU2ALzOQD8E7Ihe5kxl1FvJEir9i3 qn6CCQqgjpr/9q4rCSYPkFyypqi8PzuuLtuZXNhoGsw8/oyxdLZU3NA3p8v2OcpmTx3M IiSkv1hkFoVZIHorAtkFqtmOQhP6vv2ciSm64p/eoWTgywA8gVnBtkuioiohDTtZ7z7G vjhy2xnq/b8ZoPETaDby7vKDBevJOtwsXnFKVGAfAjPTEXg2GXdF2YbNGnwNbBUF+U16 XQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3762wtkcwj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 09 Mar 2021 07:51:25 -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 129CWnfY005993 for ; Tue, 9 Mar 2021 07:51:24 -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 3762wtkcv2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Mar 2021 07:51:24 -0500 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 129CSLpi006719; Tue, 9 Mar 2021 12:51:22 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06ams.nl.ibm.com with ESMTP id 3768urr0yb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Mar 2021 12:51:22 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 129CpJmJ17301828 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 Mar 2021 12:51:19 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 262DD52050; Tue, 9 Mar 2021 12:51:19 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.156.215]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id D6A8052057; Tue, 9 Mar 2021 12:51:18 +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 v5 1/6] s390x: css: Store CSS Characteristics Date: Tue, 9 Mar 2021 13:51:12 +0100 Message-Id: <1615294277-7332-2-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615294277-7332-1-git-send-email-pmorel@linux.ibm.com> References: <1615294277-7332-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-09_11:2021-03-08,2021-03-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 adultscore=0 bulkscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103090062 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..fe68b7d 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_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..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 Tue Mar 9 12:51:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12124969 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 A182BC4332D for ; Tue, 9 Mar 2021 12:52:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6367F65279 for ; Tue, 9 Mar 2021 12:52:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231273AbhCIMvl (ORCPT ); Tue, 9 Mar 2021 07:51:41 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:15916 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231265AbhCIMvZ (ORCPT ); Tue, 9 Mar 2021 07:51:25 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 129CWuRt077292 for ; Tue, 9 Mar 2021 07:51:25 -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=xCPSGl1tNO2kMMwukic+d4g8c7Iq3WaOy1lroRlL6OA=; b=Zueh5p9dtqda/rVdyU1TkzUcnKHFR+bRYcnGnXxYhOiy/dIL3N1pXoqocRl0zEIblQP7 3R3y9Rgi9s5iR3fzeVrNIQb1siXNKoGaTsd10YkWrhUIOhXdXqOxlHZbopQ/Ehyh3baZ SuFARmmtsxgu+urZWZf1tMKBYfI9NdP2URri0UZfa9f9xd9Ap2iAJnnS/FkEEe7OQhqN qkzGX3rCAtTfHQKiHCuak9B5ILlWE8FLhtAIeB6n3B1eyq2Eu7KDVhACvFD5DQJ9xFqC tw9e5ejQV+ir4IKqflQTBEf6xryqPhfNVnj+JBbLldyYtkP8YCK5b4khdKcuohqdCyYI uA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 375whqt3un-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 09 Mar 2021 07:51:25 -0500 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 129CXm2u083290 for ; Tue, 9 Mar 2021 07:51:24 -0500 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 375whqt3t7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Mar 2021 07:51:24 -0500 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 129CSjtN027496; Tue, 9 Mar 2021 12:51:22 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 3768t4g12m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Mar 2021 12:51:22 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 129CpJOn46203258 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 Mar 2021 12:51:19 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 913B852069; Tue, 9 Mar 2021 12:51:19 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.156.215]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 33B3752063; Tue, 9 Mar 2021 12:51:19 +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 v5 2/6] s390x: css: simplifications of the tests Date: Tue, 9 Mar 2021 13:51:13 +0100 Message-Id: <1615294277-7332-3-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615294277-7332-1-git-send-email-pmorel@linux.ibm.com> References: <1615294277-7332-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-09_11:2021-03-08,2021-03-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103090062 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 | 3 +++ 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index fe68b7d..71d91f0 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 12036b3..069c2be 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -143,6 +143,9 @@ error_senseid: 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 Tue Mar 9 12:51:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12124961 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 9FFE3C43381 for ; Tue, 9 Mar 2021 12:52:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FB8865274 for ; Tue, 9 Mar 2021 12:52:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231345AbhCIMvm (ORCPT ); Tue, 9 Mar 2021 07:51:42 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:5530 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231295AbhCIMv0 (ORCPT ); Tue, 9 Mar 2021 07:51:26 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 129ClQ9U054700 for ; Tue, 9 Mar 2021 07:51:26 -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=9dpCZ2DOfqcgwAsXZCugzhBVS4lIfqVZ4K9b+V4g4l4=; b=Ph9AHJrjrEyEsmW9qXtQTg8Povvh9vj+KGbPj709d2lFallNrqog5FaV1nSYDvhxdKmT ulgI8AatXMQC8vGjQEKtVc4BefZ7II5ifY+yHAepl3EY2KpS3pF/6FGXKGubeFb8yBQJ H9fbzv0QxMkN4JRQk0ocPX54NsFj3/a2MqNjADT1AJqwBVillkD+4U7471aTX4CfxuoP MU4xmUc+od92vu4apPuUtwm/V5GiyDbLgacPJZukaaAj0SJ3O2ZHLBdeApjKVvx4riL7 qznlBtp4QUTp2OBxhFn82SlvtXVopDLndWs8vyLlQULbIXjhv1C9YG0jXYnHasmCRx8U 5w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3769b6g1th-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 09 Mar 2021 07:51:25 -0500 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 129CmGMK062075 for ; Tue, 9 Mar 2021 07:51:25 -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 3769b6g1sq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Mar 2021 07:51:24 -0500 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 129CTZAJ008604; Tue, 9 Mar 2021 12:51:22 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma06ams.nl.ibm.com with ESMTP id 3768urr0yc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Mar 2021 12:51:22 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 129CpKui35914162 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 Mar 2021 12:51:20 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D2B0552065; Tue, 9 Mar 2021 12:51:19 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.156.215]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 8E66D5205F; Tue, 9 Mar 2021 12:51:19 +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 v5 3/6] s390x: css: extending the subchannel modifying functions Date: Tue, 9 Mar 2021 13:51:14 +0100 Message-Id: <1615294277-7332-4-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615294277-7332-1-git-send-email-pmorel@linux.ibm.com> References: <1615294277-7332-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-09_11:2021-03-08,2021-03-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 suspectscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 mlxscore=0 adultscore=0 clxscore=1015 phishscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103090062 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 71d91f0..3c50fa8 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_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 Tue Mar 9 12:51:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12124965 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 C6540C4332B for ; Tue, 9 Mar 2021 12:52:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99C8D65275 for ; Tue, 9 Mar 2021 12:52:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231339AbhCIMvl (ORCPT ); Tue, 9 Mar 2021 07:51:41 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53982 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbhCIMv0 (ORCPT ); Tue, 9 Mar 2021 07:51:26 -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 129CXYA9052878 for ; Tue, 9 Mar 2021 07:51:26 -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=4xXjZh5Y+TbFcBX53gdf+y4NWeqa08C3loloU/0ug1E=; b=dElmG0BuqGtuOGjYkICzNgUnE59P6Q6uWIe6J8tOf0819R5gqEQsr8ZDPybvkjxdQQAn itMVs44pVEEoMW75ENdwMRb2LfVeJU5nly1VRj5LKzYHOF7eDvBKAb2sosPY30fsL3va kSZ6Qttdppp2Hq+6Hz8x1wxCsDIZngtYYz03777CiXfhi+8w1QNB2xz3TKBFN1DnZP7y u/Z/eAbVrGU71VsN2a2eyngjw6lIaOBTLcMQGi51QLBH+Rvtuv/KVNaEagCXeAcyvj5E j9SsOMWHXKLoNOZSSnRtQf9Wad7ua0AfUdN3wwAVWiN7ANPCuyRApOcicmcTPamGmn0R qA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3762wr3fgm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 09 Mar 2021 07:51:25 -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 129CY1r9053956 for ; Tue, 9 Mar 2021 07:51:25 -0500 Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 3762wr3ffk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Mar 2021 07:51:25 -0500 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 129CTMbH014293; Tue, 9 Mar 2021 12:51:23 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma05fra.de.ibm.com with ESMTP id 3768va00h1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Mar 2021 12:51:23 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 129CpKu429950406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 Mar 2021 12:51:20 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3203B52052; Tue, 9 Mar 2021 12:51:20 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.156.215]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id E11A55204E; Tue, 9 Mar 2021 12:51:19 +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 v5 4/6] s390x: css: implementing Set CHannel Monitor Date: Tue, 9 Mar 2021 13:51:15 +0100 Message-Id: <1615294277-7332-5-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615294277-7332-1-git-send-email-pmorel@linux.ibm.com> References: <1615294277-7332-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-09_11:2021-03-08,2021-03-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 bulkscore=0 adultscore=0 spamscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103090062 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 | 16 ++++++++++++++-- lib/s390x/css_lib.c | 4 ++-- s390x/css.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index 3c50fa8..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]; }; @@ -356,8 +357,19 @@ static inline int _chsc(void *p) 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) +#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/lib/s390x/css_lib.c b/lib/s390x/css_lib.c index 77b39c7..95d9a78 100644 --- a/lib/s390x/css_lib.c +++ b/lib/s390x/css_lib.c @@ -94,7 +94,7 @@ bool get_chsc_scsc(void) return false; for (i = 0, p = buffer; i < CSS_GENERAL_FEAT_BITLEN; i++) { - if (css_general_feature(i)) { + if (css_test_general_feature(i)) { n = snprintf(p, sizeof(buffer), "%d,", i); p += n; } @@ -102,7 +102,7 @@ bool get_chsc_scsc(void) report_info("General features: %s", buffer); for (i = 0, p = buffer; i < CSS_CHSC_FEAT_BITLEN; i++) { - if (css_chsc_feature(i)) { + if (css_test_chsc_feature(i)) { n = snprintf(p, sizeof(buffer), "%d,", i); p += n; } diff --git a/s390x/css.c b/s390x/css.c index 069c2be..a763814 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -149,6 +149,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); @@ -158,6 +192,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 Tue Mar 9 12:51:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12124971 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 E555BC43332 for ; Tue, 9 Mar 2021 12:52:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C79DA65279 for ; Tue, 9 Mar 2021 12:52:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231357AbhCIMvo (ORCPT ); Tue, 9 Mar 2021 07:51:44 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42128 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbhCIMv2 (ORCPT ); Tue, 9 Mar 2021 07:51:28 -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 129CXWJu189390 for ; Tue, 9 Mar 2021 07:51:27 -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=NowY+b02fjSQpxuIn/cKH3cmWZ93gHrdFglfZfK6/ck=; b=mh66GjyUvAJVd00P/riGznOxpaoD17LmeAXnPf68qqATi/+I+SHNm5/s3SSHnSsz/65s Bf0LeUvWtkpQpmQW7G62vqU9+o8Noluy48vznxQvrJLJ/FYkpBB7AMTK4CTWNNBn9O1/ BQn9/rz7l2EbQl7gwUEfVbOOV2iQHD8MEwkdJwtfLuyT64EBuCtkr53tunVVyIz+Q7sy ZMTkBnemsSmnZWiFbZqlLlEvVucO1wis10KXTB6rO6b1SnvMJBNUxdFsCzi0+8PCW4jl t3+QVkHJLPK8NTSxJ5P5xI+rrn+Mf2EFwe5U+NGLVY3ZTpKRp0ViFzkh7yoHDlc/BiBK mQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 375wcm8q0w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 09 Mar 2021 07:51:27 -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 129CXeLo189719 for ; Tue, 9 Mar 2021 07:51:27 -0500 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 375wcm8pyh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Mar 2021 07:51:26 -0500 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 129CSdtO027447; Tue, 9 Mar 2021 12:51:23 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03ams.nl.ibm.com with ESMTP id 3768t4g12n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Mar 2021 12:51:23 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 129CpKOC23069124 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 Mar 2021 12:51:20 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 831BB52057; Tue, 9 Mar 2021 12:51:20 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.156.215]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 365F852054; Tue, 9 Mar 2021 12:51:20 +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 v5 5/6] s390x: css: testing measurement block format 0 Date: Tue, 9 Mar 2021 13:51:16 +0100 Message-Id: <1615294277-7332-6-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615294277-7332-1-git-send-email-pmorel@linux.ibm.com> References: <1615294277-7332-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-09_11:2021-03-08,2021-03-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103090062 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 ++++++ lib/s390x/css_lib.c | 4 -- s390x/css.c | 95 ++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 98 insertions(+), 13 deletions(-) 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/lib/s390x/css_lib.c b/lib/s390x/css_lib.c index 95d9a78..8f09383 100644 --- a/lib/s390x/css_lib.c +++ b/lib/s390x/css_lib.c @@ -365,10 +365,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 a763814..b63826e 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -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,8 +131,24 @@ 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 sense_id(void) +{ + struct ccw1 *ccw; + + senseid = alloc_io_mem(sizeof(*senseid), 0); + assert(senseid); + + ccw = ccw_alloc(CCW_CMD_SENSE_ID, senseid, sizeof(*senseid), CCW_F_SLI); + assert(ccw); + + assert(!start_ccw1_chain(test_device_sid, ccw)); + + assert(wait_and_check_io_completion(test_device_sid) >= 0); + + free_io_mem(ccw, sizeof(*ccw)); + free_io_mem(senseid, sizeof(*senseid)); } static void css_init(void) @@ -183,6 +193,72 @@ 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_abort("Enabling measurement block failed"); + return false; + } + + for (i = 0; i < SCHM_UPDATE_CNT; i++) + sense_id(); + + 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); @@ -193,6 +269,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 Tue Mar 9 12:51:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12124967 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 D3249C43331 for ; Tue, 9 Mar 2021 12:52:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B0A95652B5 for ; Tue, 9 Mar 2021 12:52:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231354AbhCIMvm (ORCPT ); Tue, 9 Mar 2021 07:51:42 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:26916 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231152AbhCIMv1 (ORCPT ); Tue, 9 Mar 2021 07:51:27 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 129CYLHY053639 for ; Tue, 9 Mar 2021 07:51:26 -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=J+hDfOZ5r6Ke/FWBmtDKwunEwXSZRn7kBz6Gx02ospg=; b=QvsWwColblA35fobEf78UPmIQBBSGN0NPttIdUHzdj6e0bIMzWhILfFXt+dN8zcVIPqy GlXg4YuA1PgcKFoA6sOycMQwMfiZd+osjL8gdhdpD3odEk4tkWdpO8xWpMgYoWchU4zU Fh01foiL2yoKkskmDi3zjBaioKx/6SbFtTvrVvdxS0MqVDMZ9t2Bt/Or3aodTWMAVc7r fVQ+7NNR6R5ypxohFYP2NkORAAtjBHLOqR5KOQERBV4fei+4Ft4U7H8IJHQ0xXaQVcbv KNatLIXr+zjkW3lzLgG4roEWRzc76oHEghkCNB1XWxbu8rsN2RzFBiaeWWqqmOrJsuj3 eA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 37607sphju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 09 Mar 2021 07:51:26 -0500 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 129CpQmt147724 for ; Tue, 9 Mar 2021 07:51:26 -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 37607sphgc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Mar 2021 07:51:26 -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 129CRq8c011456; Tue, 9 Mar 2021 12:51:23 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 3768n1g1u5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 Mar 2021 12:51:23 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 129CpKAS24773018 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 Mar 2021 12:51:21 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB51652051; Tue, 9 Mar 2021 12:51:20 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.156.215]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 8715E5205F; Tue, 9 Mar 2021 12:51:20 +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 v5 6/6] s390x: css: testing measurement block format 1 Date: Tue, 9 Mar 2021 13:51:17 +0100 Message-Id: <1615294277-7332-7-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1615294277-7332-1-git-send-email-pmorel@linux.ibm.com> References: <1615294277-7332-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-09_11:2021-03-08,2021-03-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 suspectscore=0 spamscore=0 impostorscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 mlxlogscore=999 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103090062 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 b63826e..a5c647e 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -259,6 +259,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); @@ -270,6 +344,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 } };