From patchwork Wed May 5 08:42:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 12239353 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=unavailable 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 91C73C43461 for ; Wed, 5 May 2021 08:43:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 539B66121F for ; Wed, 5 May 2021 08:43:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232133AbhEEIoc (ORCPT ); Wed, 5 May 2021 04:44:32 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56098 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232016AbhEEIoa (ORCPT ); Wed, 5 May 2021 04:44:30 -0400 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 1458WgLh037446; Wed, 5 May 2021 04:43:33 -0400 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 : content-transfer-encoding : mime-version; s=pp1; bh=TwBEtCKBMBu56emLAoF0kLyHK7HSxyT6l/De0e4AC5M=; b=e4cNz3ONL4R3+U9mu2sNog/bMk8elnSa0Cd2Kuj0naqO4xbpsmoD91D1TWSzta+SuUWw 9N1FWpeuWgdeB3v5eMNvZ12IlJax6PxzcoWBeV5vOZO2EKaZ7Kfth5pF6VM43XNtB+Lo INYp9BgSEm1VFMc4Pnlf1/hmMND9/rnbVK+BjELv5nQLzgJbuNob4OhlMCzAEZnAO0Pz bl2kmm+vE1UXDaq4jc/b7INmuAO6V0sUGcJE8I82SP44PCK3M63CWzt2NsETu8iVA6YM 7j/zL1vYetf9nZx4t1ZwRS8s0V9+OBFF3vFfj3bOeNKVQzeqIXPFmFL9rZ7V1zD65SgI iw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 38bqdn94ra-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 May 2021 04:43:33 -0400 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 1458Wqjd037914; Wed, 5 May 2021 04:43:33 -0400 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 38bqdn94qv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 May 2021 04:43:33 -0400 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 1458gq4A021490; Wed, 5 May 2021 08:43:31 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 38bedxr6ax-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 May 2021 08:43:31 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1458h3aF29753748 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 May 2021 08:43:03 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C4B8EA405F; Wed, 5 May 2021 08:43:28 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3932FA405C; Wed, 5 May 2021 08:43:28 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.145.65.32]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 5 May 2021 08:43:28 +0000 (GMT) From: Janosch Frank To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, borntraeger@de.ibm.com, cohuck@redhat.com, linux-s390@vger.kernel.org, imbrenda@linux.ibm.com, thuth@redhat.com Subject: [kvm-unit-tests GIT PULL 2/9] s390x: css: Store CSS Characteristics Date: Wed, 5 May 2021 10:42:54 +0200 Message-Id: <20210505084301.17395-3-frankja@linux.ibm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210505084301.17395-1-frankja@linux.ibm.com> References: <20210505084301.17395-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: -e9siCLwZBsXqmSWJHhbWI1l8u_ZTsd1 X-Proofpoint-ORIG-GUID: XVQBZGoRsFezYtVtUH46xi98yjg-v3fV X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-05-05_03:2021-05-05,2021-05-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 spamscore=0 clxscore=1011 mlxscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2105050063 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Pierre Morel 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 Link: https://lore.kernel.org/kvm/1615545714-13747-2-git-send-email-pmorel@linux.ibm.com/ Signed-off-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 3e574455..3dc2f313 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -288,4 +288,70 @@ int css_residual_count(unsigned int schid); void enable_io_isc(uint8_t isc); int wait_and_check_io_completion(int schid); +/* + * CHSC definitions + */ +struct chsc_header { + uint16_t len; + uint16_t code; +}; + +/* Store Channel Subsystem Characteristics */ +struct chsc_scsc { + struct chsc_header req; + uint16_t req_fmt; + uint8_t cssid; + uint8_t reserved[9]; + struct chsc_header res; + uint32_t res_fmt; + uint64_t general_char[255]; + uint64_t chsc_char[254]; +}; + +extern struct chsc_scsc *chsc_scsc; +#define CHSC_SCSC 0x0010 +#define CHSC_SCSC_LEN 0x0010 + +bool get_chsc_scsc(void); + +#define CSS_GENERAL_FEAT_BITLEN (255 * 64) +#define CSS_CHSC_FEAT_BITLEN (254 * 64) + +#define CHSC_SCSC 0x0010 +#define CHSC_SCSC_LEN 0x0010 + +#define CHSC_ERROR 0x0000 +#define CHSC_RSP_OK 0x0001 +#define CHSC_RSP_INVAL 0x0002 +#define CHSC_RSP_REQERR 0x0003 +#define CHSC_RSP_ENOCMD 0x0004 +#define CHSC_RSP_NODATA 0x0005 +#define CHSC_RSP_SUP31B 0x0006 +#define CHSC_RSP_EFRMT 0x0007 +#define CHSC_RSP_ECSSID 0x0008 +#define CHSC_RSP_ERFRMT 0x0009 +#define CHSC_RSP_ESSID 0x000A +#define CHSC_RSP_EBUSY 0x000B +#define CHSC_RSP_MAX 0x000B + +static inline int _chsc(void *p) +{ + int cc; + + asm volatile(" .insn rre,0xb25f0000,%2,0\n" + " ipm %0\n" + " srl %0,28\n" + : "=d" (cc), "=m" (p) + : "d" (p), "m" (p) + : "cc"); + + return cc; +} + +bool chsc(void *p, uint16_t code, uint16_t len); + +#include +#define css_test_general_feature(bit) test_bit_inv(bit, chsc_scsc->general_char) +#define css_test_chsc_feature(bit) test_bit_inv(bit, chsc_scsc->chsc_char) + #endif diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c index 3c244801..3c1acbfb 100644 --- a/lib/s390x/css_lib.c +++ b/lib/s390x/css_lib.c @@ -15,11 +15,102 @@ #include #include #include - +#include #include #include static struct schib schib; +struct chsc_scsc *chsc_scsc; + +static const char * const chsc_rsp_description[] = { + "CHSC unknown error", + "Command executed", + "Invalid command", + "Request-block error", + "Command not installed", + "Data not available", + "Absolute address of channel-subsystem communication block exceeds 2G - 1.", + "Invalid command format", + "Invalid channel-subsystem identification (CSSID)", + "The command-request block specified an invalid format for the command response block.", + "Invalid subchannel-set identification (SSID)", + "A busy condition precludes execution.", +}; + +static bool check_response(void *p) +{ + struct chsc_header *h = p; + + if (h->code == CHSC_RSP_OK) + return true; + + if (h->code > CHSC_RSP_MAX) + h->code = 0; + + report_abort("Response code %04x: %s", h->code, + chsc_rsp_description[h->code]); + return false; +} + +bool chsc(void *p, uint16_t code, uint16_t len) +{ + struct chsc_header *h = p; + + h->code = code; + h->len = len; + + switch (_chsc(p)) { + case 3: + report_abort("Subchannel invalid or not enabled."); + break; + case 2: + report_abort("CHSC subchannel busy."); + break; + case 1: + report_abort("Subchannel invalid or not enabled."); + break; + case 0: + return check_response(p + len); + } + return false; +} + +bool get_chsc_scsc(void) +{ + int i, n; + char buffer[510]; + char *p; + + if (chsc_scsc) /* chsc_scsc already initialized */ + return true; + + chsc_scsc = alloc_page(); + if (!chsc_scsc) { + report_abort("could not allocate chsc_scsc page!"); + return false; + } + + if (!chsc(chsc_scsc, CHSC_SCSC, CHSC_SCSC_LEN)) + return false; + + for (i = 0, p = buffer; i < CSS_GENERAL_FEAT_BITLEN; i++) { + if (css_test_general_feature(i)) { + n = snprintf(p, sizeof(buffer), "%d,", i); + p += n; + } + } + report_info("General features: %s", buffer); + + for (i = 0, p = buffer; i < CSS_CHSC_FEAT_BITLEN; i++) { + if (css_test_chsc_feature(i)) { + n = snprintf(p, sizeof(buffer), "%d,", i); + p += n; + } + } + report_info("CHSC features: %s", buffer); + + return true; +} /* * css_enumerate: diff --git a/s390x/css.c b/s390x/css.c index 1a61a5c2..12036b3b 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 },