From patchwork Wed Feb 10 13:20:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12080855 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 8E51BC433DB for ; Wed, 10 Feb 2021 13:21:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BBF664DE7 for ; Wed, 10 Feb 2021 13:21:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231731AbhBJNVt (ORCPT ); Wed, 10 Feb 2021 08:21:49 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:3778 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbhBJNVN (ORCPT ); Wed, 10 Feb 2021 08:21:13 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 11ADDNG8000645; Wed, 10 Feb 2021 08:20:22 -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=BSHojOlGpXTabfBTs1kE+IwoFwKTBze3eC6tbAQXfIM=; b=NYaAhu0AVQ3WiEV3jOtRXVo7jFatn69BvwWoBj4qy3p4cT2mEg5bhoLuxlJmP+hXH79e dg0EqKtcuKB/faSwVC+wSD9rgk54a3zNp0MW2/Ytg7uQA1Jpq1msuaIt1h3SLkATw+w3 rH5q6k6Q3hHDhMatswGbTXd5F3gKz8N2aRdVk3EHTP6NplXnmP3Sm/oMOvqYDpLQ+uX8 WldLuR3j57FJr+NaHw1oA3RwUFIGwTfsDO67m215Q/2SuHgFnfYfxyE24LV6ZQjk/1xM +goIV0cXJd0CDfZGXZ7moi/FGw1DbKJaa6+xfk+igQhendvMBz6TDsd/lzb1BQM+buk9 7A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 36mg66r6mh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 08:20:21 -0500 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 11ADFnhj013041; Wed, 10 Feb 2021 08:20:21 -0500 Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com with ESMTP id 36mg66r6ke-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 08:20:21 -0500 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 11ADHNui023078; Wed, 10 Feb 2021 13:20:19 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma02fra.de.ibm.com with ESMTP id 36hjr8ag63-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 13:20:18 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 11ADKGJj38601172 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 13:20:16 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1ABD74C044; Wed, 10 Feb 2021 13:20:16 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A622D4C040; Wed, 10 Feb 2021 13:20:15 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.174.85]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 10 Feb 2021 13:20:15 +0000 (GMT) From: Pierre Morel To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests PATCH v2 1/5] s390x: css: Store CSS Characteristics Date: Wed, 10 Feb 2021 14:20:10 +0100 Message-Id: <1612963214-30397-2-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1612963214-30397-1-git-send-email-pmorel@linux.ibm.com> References: <1612963214-30397-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.737 definitions=2021-02-10_05:2021-02-10,2021-02-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 adultscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100121 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 --- lib/s390x/css.h | 69 +++++++++++++++++++++++++++ lib/s390x/css_lib.c | 112 +++++++++++++++++++++++++++++++++++++++++++- s390x/css.c | 12 +++++ 3 files changed, 192 insertions(+), 1 deletion(-) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index 3e57445..1e317d1 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -288,4 +288,73 @@ 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 { + u16 len; + u16 code; +}; + +/* Store Channel Subsystem Characteristics */ +struct chsc_scsc { + struct chsc_header req; + u16 req_fmt; + u8 cssid; + u8 res_03; + u32 res_04[2]; + struct chsc_header res; + u32 res_fmt; + u64 general_char[255]; + u64 chsc_char[254]; +}; +extern struct chsc_scsc *chsc_scsc; +#define CHSC_SCSC 0x0010 +#define CHSC_SCSC_LEN 0x0010 + +int 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; +} + +int 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..88aa7a1 100644 --- a/lib/s390x/css_lib.c +++ b/lib/s390x/css_lib.c @@ -15,11 +15,121 @@ #include #include #include - +#include #include #include static struct schib schib; +struct chsc_scsc *chsc_scsc; + +static const char *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 2 - 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 int check_response(void *p) +{ + struct chsc_header *h = p; + + if (h->code == CHSC_RSP_OK) { + report(1, "CHSC command completed."); + return 0; + } + if (h->code > CHSC_RSP_MAX) + h->code = 0; + report(0, "Response code %04x: %s", h->code, chsc_rsp_description[h->code]); + return -1; +} + +int chsc(void *p, uint16_t code, uint16_t len) +{ + struct chsc_header *h = p; + int cc; + + report_prefix_push("Channel Subsystem Call"); + h->code = code; + h->len = len; + cc = _chsc(p); + switch (cc) { + case 3: + report(0, "Subchannel invalid or not enabled."); + break; + case 2: + report(0, "CHSC subchannel busy."); + break; + case 1: + report(0, "Subchannel invalid or not enabled."); + break; + case 0: + cc = check_response(p + len); + break; + } + + report_prefix_pop(); + return cc; +} + +int get_chsc_scsc(void) +{ + int i, n; + int ret = 0; + char buffer[510]; + char *p; + + report_prefix_push("Channel Subsystem Call"); + + if (chsc_scsc) { + report_info("chsc_scsc already initialized"); + goto end; + } + + chsc_scsc = alloc_page(); + report_info("scsc_scsc at: %016lx", (u64)chsc_scsc); + if (!chsc_scsc) { + ret = -1; + report(0, "could not allocate chsc_scsc page!"); + goto end; + } + + report_info("scsc format %x\n", chsc_scsc->req_fmt); + ret = chsc(chsc_scsc, CHSC_SCSC, CHSC_SCSC_LEN); + if (ret) { + report(0, "chsc: CC %d", ret); + goto end; + } + + for (i = 0, p = buffer; i < CSS_GENERAL_FEAT_BITLEN; i++) { + if (css_general_feature(i)) { + n = snprintf(p, sizeof(buffer) - ret, "%d,", i); + p += n; + } + } + report_info("General features: %s", buffer); + + for (i = 0, p = buffer, ret = 0; i < CSS_CHSC_FEAT_BITLEN; i++) { + if (css_chsc_feature(i)) { + n = snprintf(p, sizeof(buffer) - ret, "%d,", i); + p += n; + } + } + report_info("CHSC features: %s", buffer); + +end: + report_prefix_pop(); + return ret; +} /* * css_enumerate: diff --git a/s390x/css.c b/s390x/css.c index 1a61a5c..18dbf01 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -140,10 +141,21 @@ error_senseid: unregister_io_int_func(css_irq_io); } +static void css_init(void) +{ + int ret; + + ret = get_chsc_scsc(); + if (!ret) + report(1, " "); +} + 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 Wed Feb 10 13:20:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12080857 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 AF9CEC433E0 for ; Wed, 10 Feb 2021 13:21:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DCFD64E77 for ; Wed, 10 Feb 2021 13:21:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230376AbhBJNVw (ORCPT ); Wed, 10 Feb 2021 08:21:52 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:30504 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231865AbhBJNVN (ORCPT ); Wed, 10 Feb 2021 08:21:13 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 11AD2Xwb152926; Wed, 10 Feb 2021 08:20:22 -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=9wHg7THNyebN4vwwx8EoOuILYbk2bcaEDUYnfyp2CWA=; b=ZJZnxfqjyJAdR2EBKXG9HjRofJ4K3NB5OiptKdWiVYd9Qf8KYil8eNGRbcnzeSl6/hiO 2rplAcALrKCWd0W2bI+AziL4XuOpF5XaBw42PmchyvByWz/zI1uW7olr3pSQ+bEKiwGu hwS2AFLEQfL05/fK5pRMDjg0HevUMhE6BcZqWW99Zj9my8lD8rt7dnNERmhdnWDTEyry vi90Jqewtfbo2TRGhY/1FcGJh+oD4GJgMqbw/zLMeEs4bJJQAISwfaA2LgzpVT3l7p1N lZs0Q3Y5RJLEXiTq/crhjrHjlUw90ML3O/4XbT0HrcpEfDby8RlmSOpUXlNoYVlwOlXv Iw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 36mfes9p95-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 08:20:22 -0500 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 11AD2Zaf153167; Wed, 10 Feb 2021 08:20:22 -0500 Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 36mfes9p84-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 08:20:22 -0500 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 11ADHok9014330; Wed, 10 Feb 2021 13:20:19 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04fra.de.ibm.com with ESMTP id 36hjr8agea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 13:20:19 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 11ADKGJS36962574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 13:20:16 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 942A54C044; Wed, 10 Feb 2021 13:20:16 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C3DC4C040; Wed, 10 Feb 2021 13:20:16 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.174.85]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 10 Feb 2021 13:20:16 +0000 (GMT) From: Pierre Morel To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests PATCH v2 2/5] s390x: css: simplifications of the tests Date: Wed, 10 Feb 2021 14:20:11 +0100 Message-Id: <1612963214-30397-3-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1612963214-30397-1-git-send-email-pmorel@linux.ibm.com> References: <1612963214-30397-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.737 definitions=2021-02-10_05:2021-02-10,2021-02-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 impostorscore=0 bulkscore=0 malwarescore=0 phishscore=0 adultscore=0 spamscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100121 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 | 51 ++++++++++++++++++++++++++------------------- 3 files changed, 56 insertions(+), 33 deletions(-) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index 1e317d1..fa8775f 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 88aa7a1..5426a6b 100644 --- a/lib/s390x/css_lib.c +++ b/lib/s390x/css_lib.c @@ -180,6 +180,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 @@ -229,18 +254,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 18dbf01..d4b3cc8 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -56,36 +56,27 @@ static void test_enable(void) * - We need the test device as the first recognized * device by the enumeration. */ -static void test_sense(void) +static bool do_test_sense(void) { struct ccw1 *ccw; + bool success = false; int ret; int len; if (!test_device_sid) { report_skip("No device"); - return; + return success; } - ret = css_enable(test_device_sid, IO_SCH_ISC); - if (ret) { - report(0, "Could not enable the subchannel: %08x", - test_device_sid); - return; - } - - ret = register_io_int_func(css_irq_io); - if (ret) { - report(0, "Could not register IRQ handler"); - return; + if (!css_enabled(test_device_sid)) { + report(0, "enabling subchannel %08x", test_device_sid); + return success; } - lowcore_ptr->io_int_param = 0; - senseid = alloc_io_mem(sizeof(*senseid), 0); if (!senseid) { report(0, "Allocation of senseid"); - goto error_senseid; + return success; } ccw = ccw_alloc(CCW_CMD_SENSE_ID, senseid, sizeof(*senseid), CCW_F_SLI); @@ -129,16 +120,21 @@ static void test_sense(void) report_info("reserved 0x%02x cu_type 0x%04x cu_model 0x%02x dev_type 0x%04x dev_model 0x%02x", senseid->reserved, senseid->cu_type, senseid->cu_model, senseid->dev_type, senseid->dev_model); + report_info("cu_type expected 0x%04x got 0x%04x", (uint16_t)cu_type, + senseid->cu_type); - report(senseid->cu_type == cu_type, "cu_type expected 0x%04x got 0x%04x", - (uint16_t)cu_type, senseid->cu_type); + success = senseid->cu_type == cu_type; error: free_io_mem(ccw, sizeof(*ccw)); error_ccw: free_io_mem(senseid, sizeof(*senseid)); -error_senseid: - unregister_io_int_func(css_irq_io); + return success; +} + +static void test_sense(void) +{ + report(do_test_sense(), "Got CU type expected"); } static void css_init(void) @@ -146,8 +142,19 @@ static void css_init(void) int ret; ret = get_chsc_scsc(); - if (!ret) - report(1, " "); + if (ret) { + report(0, "Could not get CHSC Characteristics"); + 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; + + report(1, "CSS initialized"); } static struct { From patchwork Wed Feb 10 13:20: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: 12080861 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 CD46BC433DB for ; Wed, 10 Feb 2021 13:22:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8101664E77 for ; Wed, 10 Feb 2021 13:22:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231803AbhBJNWH (ORCPT ); Wed, 10 Feb 2021 08:22:07 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34000 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231208AbhBJNVO (ORCPT ); Wed, 10 Feb 2021 08:21:14 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 11AD3n5I036087; Wed, 10 Feb 2021 08:20:23 -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=446qmvsGr9gOVHGtq7ve8cUesW5T+1JkaHCgElu/rb8=; b=oBTqtTupoHStmMd7fIysi3fxz4Nc3doKz5sJeLI9qOMSto2NQyt9YzKfyHL844Nb0VNx hWCHCZ6+CNPer2b9edmvB2gKLc/IFDINcq6f+jykAZXQck2JEPw4mQTzZyQ8vyOoGp9G NVNqJljh8dvCPh5BB8lAdM14shxIFlDShpEqtBsdInb+y6pTl+UxuCa4461im9SNyn8M 0GAZxsgB4oDgz1413DyqeOvrTL8VKQtipnYIry1lEB5hmCixN4KCksxk41KmpeZMB88k 1QTu8Vl6gR6xmhwPma5Ge3ynvH0wfPNmnD7++P1/uP2KanEefZRm7snv6ZBIhVHVhN48 mw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 36mfejsqmx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 08:20:22 -0500 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 11AD42Ce037268; Wed, 10 Feb 2021 08:20:22 -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 36mfejsqkv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 08:20:22 -0500 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 11ADH9He012098; Wed, 10 Feb 2021 13:20:20 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma06ams.nl.ibm.com with ESMTP id 36j94wm1uv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 13:20:20 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 11ADK7Jw24510854 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 13:20:07 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1A3384C050; Wed, 10 Feb 2021 13:20:17 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A7DB84C040; Wed, 10 Feb 2021 13:20:16 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.174.85]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 10 Feb 2021 13:20:16 +0000 (GMT) From: Pierre Morel To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests PATCH v2 3/5] s390x: css: implementing Set CHannel Monitor Date: Wed, 10 Feb 2021 14:20:12 +0100 Message-Id: <1612963214-30397-4-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1612963214-30397-1-git-send-email-pmorel@linux.ibm.com> References: <1612963214-30397-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.737 definitions=2021-02-10_05:2021-02-10,2021-02-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100126 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. An initial test reports the presence of the extended measurement block feature. Several tests on SCHM verify the error reporting of the hypervisor. Signed-off-by: Pierre Morel --- lib/s390x/css.h | 19 +++++++++++- lib/s390x/css_lib.c | 74 +++++++++++++++++++++++++++++++++++++++++++++ s390x/css.c | 36 ++++++++++++++++++++++ 3 files changed, 128 insertions(+), 1 deletion(-) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index fa8775f..0e3254a 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -82,6 +82,7 @@ struct pmcw { uint32_t intparm; #define PMCW_DNV 0x0001 #define PMCW_ENABLE 0x0080 +#define PMCW_MBUE 0x0010 #define PMCW_ISC_MASK 0x3800 #define PMCW_ISC_SHIFT 11 uint16_t flags; @@ -94,6 +95,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 +103,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 { @@ -306,6 +309,7 @@ struct chsc_scsc { u32 res_04[2]; struct chsc_header res; u32 res_fmt; +#define CSSC_EXTENDED_MEASUREMENT_BLOCK 48 u64 general_char[255]; u64 chsc_char[254]; }; @@ -358,4 +362,17 @@ int chsc(void *p, uint16_t code, uint16_t len); #define css_general_feature(bit) test_bit_inv(bit, chsc_scsc->general_char) #define css_chsc_feature(bit) test_bit_inv(bit, chsc_scsc->chsc_char) +#define SCHM_DCTM 1 /* activate Device Connection TiMe */ +#define SCHM_MBU 2 /* activate Measurement Block Update */ + +static inline void schm(void *mbo, unsigned int flags) +{ + register void *__gpr2 asm("2") = mbo; + register long __gpr1 asm("1") = flags; + + asm("schm" : : "d" (__gpr2), "d" (__gpr1)); +} + +bool css_enable_mb(int sid, uint64_t mb, uint16_t mbi, uint16_t flg, bool fmt1); + #endif diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c index 5426a6b..355881d 100644 --- a/lib/s390x/css_lib.c +++ b/lib/s390x/css_lib.c @@ -267,6 +267,80 @@ retry: return -1; } +static bool schib_update(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 */ + pmcw->flags |= flags; + + if (format1) + pmcw->flags2 |= PMCW_MBF1; + else + pmcw->flags2 &= ~PMCW_MBF1; + + pmcw->mbi = mbi; + schib.mbo = mb; + + /* 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 to verify the measurement block origin + */ + 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 Mesurement 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 + * Return value: + * On success: 0 + * On error the CC of the faulty instruction + * or -1 if the retry count is exceeded. + */ +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(schid, mb, mbi, flags, format1)) + mdelay(10); /* the hardware was not ready, give it some time */ + + return schib.mbo == mb && pmcw->mbi == mbi; +} + static struct irb irb; void css_irq_io(void) diff --git a/s390x/css.c b/s390x/css.c index d4b3cc8..a382235 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -157,6 +157,41 @@ static void css_init(void) report(1, "CSS initialized"); } +static void test_schm(void) +{ + if (css_general_feature(CSSC_EXTENDED_MEASUREMENT_BLOCK)) + report_info("Extended measurement block available"); + + /* bits 59-63 of MB address must be 0 if MBU is defined */ + report_prefix_push("Unaligned operand"); + expect_pgm_int(); + schm((void *)0x01, SCHM_MBU); + check_pgm_int_code(PGM_INT_CODE_OPERAND); + report_prefix_pop(); + + /* bits 36-61 flags must be 0 */ + report_prefix_push("Bad flags"); + expect_pgm_int(); + schm(NULL, 0x04); + check_pgm_int_code(PGM_INT_CODE_OPERAND); + report_prefix_pop(); + + /* bits 36-61 flags must be 0 */ + 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); @@ -166,6 +201,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 Wed Feb 10 13:20: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: 12080853 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 46344C433DB for ; Wed, 10 Feb 2021 13:21:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0488C64DE7 for ; Wed, 10 Feb 2021 13:21:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231699AbhBJNVq (ORCPT ); Wed, 10 Feb 2021 08:21:46 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:31644 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231868AbhBJNVN (ORCPT ); Wed, 10 Feb 2021 08:21:13 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 11AD64Xa091553; Wed, 10 Feb 2021 08:20:23 -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=HbEBOZqdv9etvu0vZuKmz+75jYENVs/tQaaUC9wfzPI=; b=f2RBu4WR8XptbuwiTjUJypKWnh7P1zrqfFNW8xYn+0IkV3Q60w2cV6WsRomjlQ9JkRk/ TQd746zh7SySuFAOsXbZgMOpYpkFtpsymUjoC3XoFeZQWzrbRAA0nUc8GVyW7AyFs9nu G84cGLxZD3bewlO2YLpzmUJ/nF8zcQ+2cwkfvUvZjrPItCQD+ngn+Tw7cPR3lcPa0kL0 G6E+jP/X+mu90rok1LOEh+6G4zXKYyhn+MJZjczACZLmzyQasKjYtqucN0a5aLyXORA3 1MyK0HPeFGo4Fb8AQ6nWbpaFR+5ckNtKwleQ/H50qdhmxEgoJB+d+hovvoL9VsWkShhh 8Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 36mfuv8thw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 08:20:22 -0500 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 11ADKMue173326; Wed, 10 Feb 2021 08:20:22 -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 36mfuv8tgw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 08:20:22 -0500 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 11ADGcHM025825; Wed, 10 Feb 2021 13:20:20 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03ams.nl.ibm.com with ESMTP id 36m1m2ry2x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 13:20:20 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 11ADK7lj21758282 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 13:20:07 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A087B4C044; Wed, 10 Feb 2021 13:20:17 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3713F4C040; Wed, 10 Feb 2021 13:20:17 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.174.85]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 10 Feb 2021 13:20:17 +0000 (GMT) From: Pierre Morel To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests PATCH v2 4/5] s390x: css: testing measurement block format 0 Date: Wed, 10 Feb 2021 14:20:13 +0100 Message-Id: <1612963214-30397-5-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1612963214-30397-1-git-send-email-pmorel@linux.ibm.com> References: <1612963214-30397-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.737 definitions=2021-02-10_05:2021-02-10,2021-02-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 phishscore=0 suspectscore=0 mlxscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100121 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We tests the update of the mesurement block format 0, the mesurement 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 | 14 +++++++++++++ s390x/css.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index 0e3254a..5478f45 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -374,5 +374,19 @@ 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); +#define SCHM_DCTM 1 /* activate Device Connection TiMe */ +#define SCHM_MBU 2 /* activate Measurement Block Update */ + +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 a382235..f3fdc0c 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -189,7 +189,61 @@ static void test_schm(void) schm(NULL, SCHM_MBU); report(1,"SCHM call without address"); report_prefix_pop(); +} + +#define SCHM_UPDATE_CNT 10 +static bool start_measure(uint64_t mbo, uint16_t mbi, bool fmt1) +{ + int i; + + if (!css_enable_mb(test_device_sid, mbo, mbi, PMCW_MBUE, fmt1)) { + report(0, "Enabling measurement_block_format"); + return false; + } + + for (i = 0; i < SCHM_UPDATE_CNT; i++) { + if (!do_test_sense()) { + report(0, "Error during sense"); + return false; + } + } + + return true; +} + +static void test_schm_fmt0(void) +{ + struct measurement_block_format0 *mb0; + + report_prefix_push("Format 0"); + + mb0 = alloc_io_mem(sizeof(struct measurement_block_format0), 0); + if (!mb0) { + report_abort("measurement_block_format0 allocation failed"); + goto end; + } + + schm(NULL, 0); /* Clear previous MB address */ + schm(mb0, SCHM_MBU); + /* Expect error for non aligned MB */ + report_prefix_push("Unaligned MB index"); + report_xfail(start_measure(0, 0x01, false), mb0->ssch_rsch_count != 0, + "SSCH measured %d", mb0->ssch_rsch_count); + report_prefix_pop(); + + memset(mb0, 0, sizeof(*mb0)); + + /* Expect success */ + report_prefix_push("Valid MB address and index"); + report(start_measure(0, 0, false) && + mb0->ssch_rsch_count == SCHM_UPDATE_CNT, + "SSCH measured %d", mb0->ssch_rsch_count); + report_prefix_pop(); + + free_io_mem(mb0, sizeof(struct measurement_block_format0)); +end: + report_prefix_pop(); } static struct { @@ -202,6 +256,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 Wed Feb 10 13:20: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: 12080859 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 A12F6C433E0 for ; Wed, 10 Feb 2021 13:22:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5185664DE7 for ; Wed, 10 Feb 2021 13:22:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231744AbhBJNV7 (ORCPT ); Wed, 10 Feb 2021 08:21:59 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51256 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231873AbhBJNVN (ORCPT ); Wed, 10 Feb 2021 08:21:13 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 11ADDLjW196273; Wed, 10 Feb 2021 08:20: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=7CrLF66ZHGGi/L45r0MaJGuTVuMHsrdqG5zOCFD/PiI=; b=eG2XtSL/G5o1BwIlOUIF9glOUPXHpDbzNw+GHqjS6mNPg79nIB10Rxoi57Z1g49e3eoN sKvqPkcaIb48rx7vJlMgVMkPRgL5hciWn+XfsxsM6uz1pRbRJnzfmHbg7wkHLRArUh6G e81HZuxck2bTFDjzDolf6pPfBm7d9+jsvAu3YVoFJGELy2LO9g3LU69sCDfA2T51MfeU mAuq++VaD45lSuUcpFa3xBV4bmguHjlMHvSrAWLTyR7n/DrAKkKNGxVg/s/TsbaA5Ze2 rvKHf9EHAjKgYjr0UYaEFuQUwjFNwC2E3DBjaTpllRsjY7X3/gfnOevnmMddKgzbBTLF hQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 36mg66r6ny-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 08:20:25 -0500 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 11ADEx5N009338; Wed, 10 Feb 2021 08:20:23 -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 36mg66r6n1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 08:20:23 -0500 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 11ADHFqe026292; Wed, 10 Feb 2021 13:20:21 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03ams.nl.ibm.com with ESMTP id 36m1m2ry2y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Feb 2021 13:20:21 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 11ADK8fO29950390 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Feb 2021 13:20:08 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B51D4C04A; Wed, 10 Feb 2021 13:20:18 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B332F4C040; Wed, 10 Feb 2021 13:20:17 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.174.85]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 10 Feb 2021 13:20:17 +0000 (GMT) From: Pierre Morel To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, imbrenda@linux.ibm.com Subject: [kvm-unit-tests PATCH v2 5/5] s390x: css: testing measurement block format 1 Date: Wed, 10 Feb 2021 14:20:14 +0100 Message-Id: <1612963214-30397-6-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1612963214-30397-1-git-send-email-pmorel@linux.ibm.com> References: <1612963214-30397-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.737 definitions=2021-02-10_05:2021-02-10,2021-02-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 suspectscore=0 phishscore=0 priorityscore=1501 adultscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 lowpriorityscore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100121 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Measurement block format 1 is made available by the extended mesurement block facility and is indicated in the SCHIB by the bit in the PMCW. The MBO is specified in the SCHIB of each channel and the MBO defined by the SCHM instruction is ignored. The test of the MB format 1 is just skipped if the feature is not available. Signed-off-by: Pierre Morel --- lib/s390x/css.h | 14 ++++++++++++++ s390x/css.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index 5478f45..ee525f1 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -389,4 +389,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/s390x/css.c b/s390x/css.c index f3fdc0c..ec5e365 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -246,6 +246,41 @@ end: report_prefix_pop(); } +static void test_schm_fmt1(void) +{ + struct measurement_block_format1 *mb1; + + report_prefix_push("Format 1"); + + mb1 = alloc_io_mem(sizeof(struct measurement_block_format1), 0); + if (!mb1) { + report_abort("measurement_block_format1 allocation failed"); + goto end; + } + + schm(NULL, 0); /* Clear previous MB address */ + schm(0, SCHM_MBU); + + /* Expect error for non aligned MB */ + report_prefix_push("Unaligned MB origin"); + report_xfail(start_measure((u64)mb1 + 1, 0, true), mb1->ssch_rsch_count != 0, + "SSCH measured %d", mb1->ssch_rsch_count); + report_prefix_pop(); + + memset(mb1, 0, sizeof(*mb1)); + + /* Expect success */ + report_prefix_push("Valid MB address and index"); + report(start_measure((u64)mb1, 0, true) && + mb1->ssch_rsch_count == SCHM_UPDATE_CNT, + "SSCH measured %d", mb1->ssch_rsch_count); + report_prefix_pop(); + + free_io_mem(mb1, sizeof(struct measurement_block_format1)); +end: + report_prefix_pop(); +} + static struct { const char *name; void (*func)(void); @@ -257,6 +292,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 } };