From patchwork Mon Aug 31 12:05:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 11746263 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB37D1744 for ; Mon, 31 Aug 2020 12:06:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D6E520936 for ; Mon, 31 Aug 2020 12:06:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="WY2vAkkE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726968AbgHaMF5 (ORCPT ); Mon, 31 Aug 2020 08:05:57 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51810 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726521AbgHaMFm (ORCPT ); Mon, 31 Aug 2020 08:05:42 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 07VC3YjX059955; Mon, 31 Aug 2020 08:05:41 -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; s=pp1; bh=tZWG+2p/xlDOByL5lYGeOEc7ZMoYpuu8PiqCDJ6CaFM=; b=WY2vAkkEp0RufIOdJeiACnbWKI9rMiRAuERDK0sxrQD7QMyLOT+kfbd1zwq/EoECWvmm gpq+uyxMj1hP4WUF63Ye3L8YLy951aiyPC55zng2lkcRAuGe8ffSSxXUAaJwgKUjF6P8 QGvFG7l7HZrdruc5Vt+MqGpjvvvMV0jdM7rqyS1F3CuWiSxydfGTYTRzVUwfZHQUwRg/ 7umU5ThEFIUB5b9oN8NUUxc7+KRd+8biRaILDRGZme5c0x/9CM+FWb8tYH70schJXbia 6KwK1coEq769ZGS0W8XA7eTLigqmz6VWBG5etQ9HN2v/swmvZyga4bcrp5yvwFVrCFFu gw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 33908mgytp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Aug 2020 08:05:41 -0400 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 07VC4GNq062234; Mon, 31 Aug 2020 08:05:41 -0400 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 33908mgysj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Aug 2020 08:05:41 -0400 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 07VBwIZJ009957; Mon, 31 Aug 2020 12:05:38 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma05fra.de.ibm.com with ESMTP id 337en819wa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Aug 2020 12:05:38 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 07VC5atS25821478 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 31 Aug 2020 12:05:36 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1A3D7A4054; Mon, 31 Aug 2020 12:05:36 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C0B86A406B; Mon, 31 Aug 2020 12:05:35 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.160.216]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 31 Aug 2020 12:05:35 +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 Subject: [PATCH v1 3/3] s390x: css: pv: css test adaptation for PV Date: Mon, 31 Aug 2020 14:05:33 +0200 Message-Id: <1598875533-19947-4-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1598875533-19947-1-git-send-email-pmorel@linux.ibm.com> References: <1598875533-19947-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.235,18.0.687 definitions=2020-08-31_04:2020-08-31,2020-08-31 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=3 phishscore=0 impostorscore=0 adultscore=0 mlxlogscore=688 bulkscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008310070 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We want the tests to automatically work with or without protected virtualisation. To do this we need to share the I/O memory with the host. Let's replace all static allocations with dynamic allocations to clearly separate shared and private memory. Signed-off-by: Pierre Morel --- lib/s390x/css.h | 3 +-- lib/s390x/css_lib.c | 28 ++++++++-------------------- s390x/css.c | 35 ++++++++++++++++++++++++----------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/lib/s390x/css.h b/lib/s390x/css.h index 221b67c..e3dee9f 100644 --- a/lib/s390x/css.h +++ b/lib/s390x/css.h @@ -283,8 +283,7 @@ int css_enable(int schid, int isc); /* Library functions */ int start_ccw1_chain(unsigned int sid, struct ccw1 *ccw); -int start_single_ccw(unsigned int sid, int code, void *data, int count, - unsigned char flags); +struct ccw1 *ccw_alloc(int code, void *data, int count, unsigned char flags); void css_irq_io(void); int css_residual_count(unsigned int schid); diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c index 8e02371..6a0a0ec 100644 --- a/lib/s390x/css_lib.c +++ b/lib/s390x/css_lib.c @@ -18,6 +18,7 @@ #include #include +#include #include static struct schib schib; @@ -202,33 +203,20 @@ int start_ccw1_chain(unsigned int sid, struct ccw1 *ccw) return ssch(sid, &orb); } -/* - * In the future, we want to implement support for CCW chains; - * for that, we will need to work with ccw1 pointers. - */ -static struct ccw1 unique_ccw; - -int start_single_ccw(unsigned int sid, int code, void *data, int count, - unsigned char flags) +struct ccw1 *ccw_alloc(int code, void *data, int count, unsigned char flags) { - int cc; - struct ccw1 *ccw = &unique_ccw; + struct ccw1 *ccw; + + ccw = alloc_io_page(sizeof(*ccw)); + if (!ccw) + return NULL; - report_prefix_push("start_subchannel"); - /* Build the CCW chain with a single CCW */ ccw->code = code; ccw->flags = flags; ccw->count = count; ccw->data_address = (int)(unsigned long)data; - cc = start_ccw1_chain(sid, ccw); - if (cc) { - report(0, "cc = %d", cc); - report_prefix_pop(); - return cc; - } - report_prefix_pop(); - return 0; + return ccw; } /* wait_and_check_io_completion: diff --git a/s390x/css.c b/s390x/css.c index ee3bc83..4b0b6b1 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -17,13 +17,15 @@ #include #include +#include #include +#include #define DEFAULT_CU_TYPE 0x3832 /* virtio-ccw */ static unsigned long cu_type = DEFAULT_CU_TYPE; static int test_device_sid; -static struct senseid senseid; +static struct senseid *senseid; static void test_enumerate(void) { @@ -57,6 +59,7 @@ static void test_enable(void) */ static void test_sense(void) { + struct ccw1 *ccw; int ret; int len; @@ -80,9 +83,15 @@ static void test_sense(void) lowcore_ptr->io_int_param = 0; - memset(&senseid, 0, sizeof(senseid)); - ret = start_single_ccw(test_device_sid, CCW_CMD_SENSE_ID, - &senseid, sizeof(senseid), CCW_F_SLI); + senseid = alloc_io_page(sizeof(*senseid)); + if (!senseid) + goto error_senseid; + + ccw = ccw_alloc(CCW_CMD_SENSE_ID, senseid, sizeof(*senseid), CCW_F_SLI); + if (!ccw) + goto error_ccw; + + ret = start_ccw1_chain(test_device_sid, ccw); if (ret) goto error; @@ -97,7 +106,7 @@ static void test_sense(void) if (ret < 0) { report_info("no valid residual count"); } else if (ret != 0) { - len = sizeof(senseid) - ret; + len = sizeof(*senseid) - ret; if (ret && len < CSS_SENSEID_COMMON_LEN) { report(0, "transferred a too short length: %d", ret); goto error; @@ -105,21 +114,25 @@ static void test_sense(void) report_info("transferred a shorter length: %d", len); } - if (senseid.reserved != 0xff) { - report(0, "transferred garbage: 0x%02x", senseid.reserved); + if (senseid->reserved != 0xff) { + report(0, "transferred garbage: 0x%02x", senseid->reserved); goto error; } report_prefix_pop(); 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); + senseid->reserved, senseid->cu_type, senseid->cu_model, + senseid->dev_type, senseid->dev_model); - report(senseid.cu_type == cu_type, "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); error: + free_io_page(ccw); +error_ccw: + free_io_page(senseid); +error_senseid: unregister_io_int_func(css_irq_io); }