From nobody Sat May 18 12:47:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1607546961; cv=none; d=zohomail.com; s=zohoarc; b=QHTXYsqTGnacpETnCeRNGUtt+k41R7/W/PFjrfDamFU7xo/lQkxEyhknqh9xJQ1lsoa0sZ9YBfD4s7XFfZ+jRYFkkXkUxC2a0Mb3jjluboiH9CYIvhRbXfZyAS8bMEs+owm1xWAPooaTl58OxeeCBD/IjSg+mpRysr++WBJiPR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607546961; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=+VOenNa/Ew2Ovbc52GSfSSssDjm1R7I105Vvzh13QSg=; b=cgArVRGd1DRcY90wujIg02PRxjxsWap/bxJf9rjSIdYNeMkDjuw8r10pQoXJn1PASe4vPzba4bhdH6JhMhkvx/E/k2/F17lP/+r8FWoAGAtRhGE5OP1sDZTT1whMFuNHJntgGifqmryNrxOBuXYlRHwcT+XOkewQKDCr0DuJyqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607546961135699.946738149462; Wed, 9 Dec 2020 12:49:21 -0800 (PST) Received: from localhost ([::1]:35206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kn6Om-0008Ig-0O for importer@patchew.org; Wed, 09 Dec 2020 15:49:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6Aq-00009x-A3; Wed, 09 Dec 2020 15:34:57 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38102) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6Ah-0005mz-J7; Wed, 09 Dec 2020 15:34:56 -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 0B9KWw1a064185; Wed, 9 Dec 2020 15:34:37 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 35b3gdkne7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:37 -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 0B9KYass073204; Wed, 9 Dec 2020 15:34:36 -0500 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 35b3gdkndn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:36 -0500 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0B9KVqfl003371; Wed, 9 Dec 2020 20:34:35 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma04wdc.us.ibm.com with ESMTP id 3581u9jare-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 20:34:35 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0B9KYZYg25559362 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Dec 2020 20:34:35 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 01C42124055; Wed, 9 Dec 2020 20:34:35 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 401E1124054; Wed, 9 Dec 2020 20:34:32 +0000 (GMT) Received: from oc4221205838.ibm.com (unknown [9.163.37.122]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 9 Dec 2020 20:34:32 +0000 (GMT) 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=+VOenNa/Ew2Ovbc52GSfSSssDjm1R7I105Vvzh13QSg=; b=SaC3LYR7A8xneIJZmHNdRFsJp/x0ELRIzUJOqjOIE/hkmbBSsxIX0VJMyPDBG1a7J23H K0HUjcbeD7CehS3w9NyfBv6mnrVOONS+IgcL3MK4EYj/uaj7aiK/0szAULRCfhx3448Y a+w5GW897BcZPXZgFTxebMC0H53mtoIVlPBZDTqrwvb3CaeypuGbaKr/7uNiSJRHDOKX 67wiouQUNiXU3PHGkCrzSIAth/2WjaefWCB8Vj6qVEreKevIRUTu7hxdjcns6dDsNgO1 xmAoTsTrYTAyxoG43AOvuk4xjZx0xvAVturan4qWgIB1UYQlzH1jReqgfhJ47fJd2eJZ Uw== From: Matthew Rosato To: cohuck@redhat.com, thuth@redhat.com Subject: [RFC 1/8] linux-headers: update against 5.10-rc7 Date: Wed, 9 Dec 2020 15:34:19 -0500 Message-Id: <1607546066-2240-2-git-send-email-mjrosato@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> References: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2020-12-09_16:2020-12-09, 2020-12-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 mlxscore=0 bulkscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012090140 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=mjrosato@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pmorel@linux.ibm.com, david@redhat.com, schnelle@linux.ibm.com, richard.henderson@linaro.org, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, pasic@linux.ibm.com, borntraeger@de.ibm.com, alex.williamson@redhat.com, mst@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Placeholder commit to pull in changes from "vfio-pci/zdev: Pass the relaxed alignment flag" and "vfio-pci/zdev: Introduce the PCISTB vfio region" Signed-off-by: Matthew Rosato --- include/standard-headers/asm-x86/kvm_para.h | 1 + .../infiniband/hw/vmw_pvrdma/pvrdma_verbs.h | 2 +- include/standard-headers/linux/vhost_types.h | 9 ++++++ linux-headers/linux/vfio.h | 4 +++ linux-headers/linux/vfio_zdev.h | 33 ++++++++++++++++++= ++++ linux-headers/linux/vhost.h | 4 +++ 6 files changed, 52 insertions(+), 1 deletion(-) diff --git a/include/standard-headers/asm-x86/kvm_para.h b/include/standard= -headers/asm-x86/kvm_para.h index 07877d3..215d01b 100644 --- a/include/standard-headers/asm-x86/kvm_para.h +++ b/include/standard-headers/asm-x86/kvm_para.h @@ -32,6 +32,7 @@ #define KVM_FEATURE_POLL_CONTROL 12 #define KVM_FEATURE_PV_SCHED_YIELD 13 #define KVM_FEATURE_ASYNC_PF_INT 14 +#define KVM_FEATURE_MSI_EXT_DEST_ID 15 =20 #define KVM_HINTS_REALTIME 0 =20 diff --git a/include/standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrd= ma_verbs.h b/include/standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrd= ma_verbs.h index 0a8c7c9..1677208 100644 --- a/include/standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verb= s.h +++ b/include/standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verb= s.h @@ -176,7 +176,7 @@ struct pvrdma_port_attr { uint8_t subnet_timeout; uint8_t init_type_reply; uint8_t active_width; - uint16_t active_speed; + uint8_t active_speed; uint8_t phys_state; uint8_t reserved[2]; }; diff --git a/include/standard-headers/linux/vhost_types.h b/include/standar= d-headers/linux/vhost_types.h index 486630b..0bd2684 100644 --- a/include/standard-headers/linux/vhost_types.h +++ b/include/standard-headers/linux/vhost_types.h @@ -138,6 +138,15 @@ struct vhost_vdpa_config { uint8_t buf[0]; }; =20 +/* vhost vdpa IOVA range + * @first: First address that can be mapped by vhost-vDPA + * @last: Last address that can be mapped by vhost-vDPA + */ +struct vhost_vdpa_iova_range { + uint64_t first; + uint64_t last; +}; + /* Feature bits */ /* Log all write descriptors. Can be changed while device is active. */ #define VHOST_F_LOG_ALL 26 diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index b92dcc4..703c20c 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -338,6 +338,10 @@ struct vfio_region_info_cap_type { * to do TLB invalidation on a GPU. */ #define VFIO_REGION_SUBTYPE_IBM_NVLINK2_ATSD (1) +/* + * IBM zPCI I/O region + */ +#define VFIO_REGION_SUBTYPE_IBM_ZPCI_IO (2) =20 /* sub-types for VFIO_REGION_TYPE_GFX */ #define VFIO_REGION_SUBTYPE_GFX_EDID (1) diff --git a/linux-headers/linux/vfio_zdev.h b/linux-headers/linux/vfio_zde= v.h index b430939..22d3408 100644 --- a/linux-headers/linux/vfio_zdev.h +++ b/linux-headers/linux/vfio_zdev.h @@ -43,6 +43,7 @@ struct vfio_device_info_cap_zpci_group { __u64 msi_addr; /* MSI address */ __u64 flags; #define VFIO_DEVICE_INFO_ZPCI_FLAG_REFRESH 1 /* Program-specified TLB refr= esh */ +#define VFIO_DEVICE_INFO_ZPCI_FLAG_RELAXED 2 /* Relaxed Length and Alignme= nt */ __u16 mui; /* Measurement Block Update Interval */ __u16 noi; /* Maximum number of MSIs */ __u16 maxstbl; /* Maximum Store Block Length */ @@ -75,4 +76,36 @@ struct vfio_device_info_cap_zpci_pfip { __u8 pfip[]; }; =20 +/** + * VFIO_REGION_SUBTYPE_IBM_ZPCI_IO - VFIO zPCI PCI Direct I/O Region + * + * This region is used to transfer I/O operations from the guest directly + * to the host zPCI I/O layer. + * + * The _hdr area is user-readable and is used to provide setup information. + * The _req area is user-writable and is used to provide the I/O operation. + */ +struct vfio_zpci_io_hdr { + __u64 flags; + __u16 max; /* Max block operation size allowed */ + __u16 reserved; + __u32 reserved2; +}; + +struct vfio_zpci_io_req { + __u64 flags; +#define VFIO_ZPCI_IO_FLAG_READ (1 << 0) /* Read Operation Specified */ +#define VFIO_ZPCI_IO_FLAG_BLOCKW (1 << 1) /* Block Write Operation Specifi= ed */ + __u64 gaddr; /* Address of guest data */ + __u64 offset; /* Offset into target PCI Address Space */ + __u32 reserved; + __u16 len; /* Length of guest operation */ + __u8 pcias; /* Target PCI Address Space */ + __u8 reserved2; +}; + +struct vfio_region_zpci_io { + struct vfio_zpci_io_hdr hdr; + struct vfio_zpci_io_req req; +}; #endif diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h index 7523218..c998860 100644 --- a/linux-headers/linux/vhost.h +++ b/linux-headers/linux/vhost.h @@ -146,4 +146,8 @@ =20 /* Set event fd for config interrupt*/ #define VHOST_VDPA_SET_CONFIG_CALL _IOW(VHOST_VIRTIO, 0x77, int) + +/* Get the valid iova range */ +#define VHOST_VDPA_GET_IOVA_RANGE _IOR(VHOST_VIRTIO, 0x78, \ + struct vhost_vdpa_iova_range) #endif --=20 1.8.3.1 From nobody Sat May 18 12:47:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1607547522; cv=none; d=zohomail.com; s=zohoarc; b=MmliSW+rvN2qqOPra5XF8E3BxsN17t/vJo4qQsjF7F2JvlJZ67rHA712dkcnIUokFD/cusFheZeIM30lrx/9StGUtjkrg5hRP4WHCGBf3cEpaLLjGMUHWLQpIpbjw1/Jph10nKxcu55sZ0skMpOTqDssNLd2guF9GQWuFKkmu1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607547522; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=rY4FktaovWN1oujeMMBADEwDeSEaSmcYbVUrYkO0qvE=; b=hKPzGalNYCe2WuyTHDspt6cYOoyCr9JfnsmIPAWng3VQcpTkr82z59ugixepvysJi8HOZqaSb5N/uw11ASakM23cTpbIID+LDmT41GuRbj+pYm9J2/vo5zybAYP6dLWrkeXdxHRyMRtLhJv4RckCbOCg1A1uesed0e3GE4O/1A4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607547522188246.2915992639878; Wed, 9 Dec 2020 12:58:42 -0800 (PST) Received: from localhost ([::1]:58548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kn6Dj-0002oJ-9I for importer@patchew.org; Wed, 09 Dec 2020 15:37:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6Ar-0000BQ-Ng; Wed, 09 Dec 2020 15:34:57 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:41412) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6Ah-0005nT-Ty; Wed, 09 Dec 2020 15:34:57 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0B9KXDue057289; Wed, 9 Dec 2020 15:34:39 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 35avw5hweq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:39 -0500 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0B9KY9uu060993; Wed, 9 Dec 2020 15:34:39 -0500 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 35avw5hwe9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:39 -0500 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0B9KWZ8A023410; Wed, 9 Dec 2020 20:34:38 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma03dal.us.ibm.com with ESMTP id 3581u9jsw9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 20:34:38 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0B9KYbY226673712 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Dec 2020 20:34:37 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8087912405B; Wed, 9 Dec 2020 20:34:37 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B2A0124052; Wed, 9 Dec 2020 20:34:35 +0000 (GMT) Received: from oc4221205838.ibm.com (unknown [9.163.37.122]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 9 Dec 2020 20:34:35 +0000 (GMT) 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=rY4FktaovWN1oujeMMBADEwDeSEaSmcYbVUrYkO0qvE=; b=eWjlL3kN/QpFlPmn6+sNBgRp2Jtmh4IwLY5MOlMMVKWqaqdUvAPaD+o8vFF3hpyHE1uT xX0zLWcrF8RPzYL5FkbSgrR29HHBi3MW4BBAmJPJ4UsBGX3S+FfIMj/ngaDWeyKMt+yq xvEEkqJuygXWGltfVlgCLXlxezCuaVCspaMFDV0Dg0sugdKw+Ej0ukwS+hvkxhJrvlj9 UDO5iqXDgZ4jxmbrjAATv2oB5VBKjqFBuWLqZ3BAhTtTVsvIx6BrrElcaD71YPNJdxVC GitjFg6Ajhoj4Q5kuZ1gJaqMSYwW4Eb2Ou9tNqAH12dl0OfSKRw37pcjH3ud8j2v4FTi AA== From: Matthew Rosato To: cohuck@redhat.com, thuth@redhat.com Subject: [RFC 2/8] s390x/pci: MSI-X isn't strictly required for passthrough Date: Wed, 9 Dec 2020 15:34:20 -0500 Message-Id: <1607546066-2240-3-git-send-email-mjrosato@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> References: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2020-12-09_16:2020-12-09, 2020-12-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=2 malwarescore=0 mlxlogscore=999 spamscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012090143 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=mjrosato@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pmorel@linux.ibm.com, david@redhat.com, schnelle@linux.ibm.com, richard.henderson@linaro.org, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, pasic@linux.ibm.com, borntraeger@de.ibm.com, alex.williamson@redhat.com, mst@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" s390 PCI currently disallows PCI devices without the MSI-X capability. However, this fence doesn't make sense for passthrough devices. Move the check to only fence emulated devices (e.g., virtio). Signed-off-by: Matthew Rosato Reviewed-by: Pierre Morel --- hw/s390x/s390-pci-bus.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 05f7460..afad048 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -1028,12 +1028,12 @@ static void s390_pcihost_plug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, s390_pci_get_clp_info(pbdev); } else { pbdev->fh |=3D FH_SHM_EMUL; - } =20 - if (s390_pci_msix_init(pbdev)) { - error_setg(errp, "MSI-X support is mandatory " - "in the S390 architecture"); - return; + if (s390_pci_msix_init(pbdev)) { + error_setg(errp, "MSI-X support is mandatory " + "in the S390 architecture"); + return; + } } =20 if (dev->hotplugged) { @@ -1073,7 +1073,9 @@ static void s390_pcihost_unplug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, devfn =3D pci_dev->devfn; qdev_unrealize(dev); =20 - s390_pci_msix_free(pbdev); + if (pbdev->fh & FH_SHM_EMUL) { + s390_pci_msix_free(pbdev); + } s390_pci_iommu_free(s, bus, devfn); pbdev->pdev =3D NULL; pbdev->state =3D ZPCI_FS_RESERVED; --=20 1.8.3.1 From nobody Sat May 18 12:47:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1607547656; cv=none; d=zohomail.com; s=zohoarc; b=FXz1E/NiRdJbhldAD8QOB1tJUI4Mc44TmCj73lOJFcAd36xKVP7z2622pybWH0VDjryNi4LgM1lGogbsDI7cjMXJ8J4oFmV9rf7/w/13TAxP98Ew2RpgAUKKEyH29Pew1ShgKObPevObknAnhsnFjdT0/nK2gApbMXPLP9Ggozg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607547656; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=LdsjPsU4tgFdv/ZBL9VRZ8B2P8HQBWn5e1Ra9CERVHg=; b=A7N51uq97cEHiniP2NklpIIkIexqAuN6SZirvMvjZsYhj38OPgG6CdjM2HKft0KcqEiKZltGLMGqEQmkftqJpSF7ydUW+V4gnvImKM6O9FnD0gOoJ/PfiRRJGenepPX+0i/8SdGJObfofRgcq2MD5clf1myHVwuT7rfTsm95AHI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607547656750953.7319788321312; Wed, 9 Dec 2020 13:00:56 -0800 (PST) Received: from localhost ([::1]:35854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kn6F9-00053o-VD for importer@patchew.org; Wed, 09 Dec 2020 15:39:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6Ar-0000A4-8l; Wed, 09 Dec 2020 15:34:57 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:6248 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6Ah-0005ne-Ub; Wed, 09 Dec 2020 15:34:57 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0B9KWb99148320; Wed, 9 Dec 2020 15:34:42 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 35awxt7c1u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:42 -0500 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0B9KYZ5l160883; Wed, 9 Dec 2020 15:34:41 -0500 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 35awxt7c1b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:41 -0500 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0B9KWbgQ023421; Wed, 9 Dec 2020 20:34:41 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma03dal.us.ibm.com with ESMTP id 3581u9jswm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 20:34:41 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0B9KYen326280210 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Dec 2020 20:34:40 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2D723124058; Wed, 9 Dec 2020 20:34:40 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BBEE812405E; Wed, 9 Dec 2020 20:34:37 +0000 (GMT) Received: from oc4221205838.ibm.com (unknown [9.163.37.122]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 9 Dec 2020 20:34:37 +0000 (GMT) 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=LdsjPsU4tgFdv/ZBL9VRZ8B2P8HQBWn5e1Ra9CERVHg=; b=sNxRs7V/CIujT7DbxAnWsw9rL7ON8vA9w5MgcN4/oVf1MGr8lO+bRge82ZWPZskc2aax BWiYxMVtsuiQOuJHI8Pbi+xfzoiht12rldF1Ikz8rgckf4lvzp+7FEyN4dCjbrsdnJj9 jcVXJOtQR9nggNOujzhjUEYnTVF2bE7zY4UMQsHBx3F9Ht9jirsXRP1hwR67ChtQSxwj +Yh5ADu64BlJtN9UOqqEpbZoZlkWHHHuKtWf3mFhtTI3LjFqHiyuwTs0plQ5FysJ3w2P ZmJp/yyxbEjijoTYRd6bNZA/O9t3HBCPZ52hlAAxiCwVXGIoqLPf75Kf/tDqeynIVLaR fQ== From: Matthew Rosato To: cohuck@redhat.com, thuth@redhat.com Subject: [RFC 3/8] s390x/pci: fix pcistb length Date: Wed, 9 Dec 2020 15:34:21 -0500 Message-Id: <1607546066-2240-4-git-send-email-mjrosato@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> References: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2020-12-09_16:2020-12-09, 2020-12-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 phishscore=0 priorityscore=1501 spamscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=812 clxscore=1015 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012090140 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=mjrosato@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pmorel@linux.ibm.com, david@redhat.com, schnelle@linux.ibm.com, richard.henderson@linaro.org, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, pasic@linux.ibm.com, borntraeger@de.ibm.com, alex.williamson@redhat.com, mst@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In pcistb_service_call, we are grabbing 8 bits from a guest register to indicate the length of the store operation -- but per the architecture the length is actually defined by 13 bits of the guest register. Signed-off-by: Matthew Rosato Reviewed-by: Pierre Morel --- hw/s390x/s390-pci-inst.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 70bfd91..db86f12 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -750,7 +750,7 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8= _t r3, uint64_t gaddr, int i; uint32_t fh; uint8_t pcias; - uint8_t len; + uint16_t len; uint8_t buffer[128]; =20 if (env->psw.mask & PSW_MASK_PSTATE) { @@ -760,7 +760,7 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8= _t r3, uint64_t gaddr, =20 fh =3D env->regs[r1] >> 32; pcias =3D (env->regs[r1] >> 16) & 0xf; - len =3D env->regs[r1] & 0xff; + len =3D env->regs[r1] & 0x1fff; offset =3D env->regs[r3]; =20 if (!(fh & FH_MASK_ENABLE)) { --=20 1.8.3.1 From nobody Sat May 18 12:47:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1607547170; cv=none; d=zohomail.com; s=zohoarc; b=ZsprO+Fl+eqU8X3keI4I8drn+eZ1B7yTMeYKxOuFCyVxNl3/5tI1QN1W40uOeOdFFG3xpKLXMDztqlJPCFCsKKu2lKymxy6gpZ5/emEd4pKbY/Mxg6jtvSMnrVtCitFCVlP1dx0rrfQyd4aJNclP9m57uhTZBzb3ln+A+f+R0iM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607547170; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=4wfYD8ldZSphZzUrnY0nzOTFXMq2nKGe3iUC6aQVaN4=; b=ioPE6u6aPEj0Y8dH7ySWL/p/z9FdrVQRJqAawJG0CkweI4EReBE4GQ2oT+Oeta04eSI0QUGTrIyRQ5qC+SSJsuSmrvEaaXHAlHv2G2NsuH7kFu4cFmMDxWBYibPBD6yVbAHwun1/W+3rVG1wVePiThhzXd2fWBEyS0s+qLXW/CA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607547170581741.8692511019548; Wed, 9 Dec 2020 12:52:50 -0800 (PST) Received: from localhost ([::1]:43774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kn6I1-0008RH-4n for importer@patchew.org; Wed, 09 Dec 2020 15:42:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6As-0000CZ-8Q; Wed, 09 Dec 2020 15:34:58 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6Ai-0005pT-09; Wed, 09 Dec 2020 15:34:58 -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 0B9KX9iR151555; Wed, 9 Dec 2020 15:34:45 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 35b444as7r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:45 -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 0B9KXRN3155490; Wed, 9 Dec 2020 15:34:44 -0500 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 35b444as7a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:44 -0500 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0B9KW5Sf002121; Wed, 9 Dec 2020 20:34:43 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma01dal.us.ibm.com with ESMTP id 3581u9jtj1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 20:34:43 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0B9KYgSL10945018 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Dec 2020 20:34:42 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BA90912405B; Wed, 9 Dec 2020 20:34:42 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7B425124058; Wed, 9 Dec 2020 20:34:40 +0000 (GMT) Received: from oc4221205838.ibm.com (unknown [9.163.37.122]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 9 Dec 2020 20:34:40 +0000 (GMT) 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=4wfYD8ldZSphZzUrnY0nzOTFXMq2nKGe3iUC6aQVaN4=; b=hNs9VZCTnPSb+ewH3ZpyT3XpSWvJZjDM19+GCVv3rxG0juXCvo0c+U0P1rMF2XDnM95O lDl9P+/yby31cgcK5gVrovsqWGcjdRhEhRmUHnC9LIGSclBp9pK35x00U0uo4JCBg6pk B7LxqrFzsdSried7iteA0HkY7VOTvyevQ8EDvVJfrito+w4XLYh1n/QEhN+Asef8IW84 OEnay65G+vcbVkWaAHvO6MxYBtTg7fgxSCMH9dn+GQesfXpPaD9pKHChMWw+eYuwQuiH 20wXw6TwFKKjBp8AkB+XQVeYI/z/Yt/zlmneVti2zkarYspkk0cKcpb5Z/GDcB6Q33N7 xg== From: Matthew Rosato To: cohuck@redhat.com, thuth@redhat.com Subject: [RFC 4/8] s390x/pci: Introduce the ZpciOps structure Date: Wed, 9 Dec 2020 15:34:22 -0500 Message-Id: <1607546066-2240-5-git-send-email-mjrosato@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> References: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2020-12-09_16:2020-12-09, 2020-12-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=2 bulkscore=0 adultscore=0 impostorscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 priorityscore=1501 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012090143 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=mjrosato@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pmorel@linux.ibm.com, david@redhat.com, schnelle@linux.ibm.com, richard.henderson@linaro.org, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, pasic@linux.ibm.com, borntraeger@de.ibm.com, alex.williamson@redhat.com, mst@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As inftrastructure to introduce different PCI instruction handlers, introduce the ZpciOps structure to contain function pointers for the handlers. Add default handlers for the PCISTG, PCILG and PCISTB instructions. Signed-off-by: Matthew Rosato --- hw/s390x/s390-pci-bus.c | 3 + hw/s390x/s390-pci-inst.c | 238 ++++++++++++++++++++++++++---------= ---- include/hw/s390x/s390-pci-bus.h | 22 ++++ include/hw/s390x/s390-pci-inst.h | 1 + 4 files changed, 185 insertions(+), 79 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index afad048..7d31ded 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -1020,6 +1020,7 @@ static void s390_pcihost_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, pbdev->iommu->pbdev =3D pbdev; pbdev->state =3D ZPCI_FS_DISABLED; set_pbdev_info(pbdev); + zpci_assign_default_ops(pbdev); =20 if (object_dynamic_cast(OBJECT(dev), "vfio-pci")) { pbdev->fh |=3D FH_SHM_VFIO; @@ -1079,6 +1080,8 @@ static void s390_pcihost_unplug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, s390_pci_iommu_free(s, bus, devfn); pbdev->pdev =3D NULL; pbdev->state =3D ZPCI_FS_RESERVED; + if (pbdev->pcistb_buf) + qemu_vfree(pbdev->pcistb_buf); } else if (object_dynamic_cast(OBJECT(dev), TYPE_S390_PCI_DEVICE)) { pbdev =3D S390_PCI_DEVICE(dev); pbdev->fid =3D 0; diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index db86f12..b07ef2a 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -404,16 +404,49 @@ static MemTxResult zpci_read_bar(S390PCIBusDevice *pb= dev, uint8_t pcias, MEMTXATTRS_UNSPECIFIED); } =20 +static int pcilg_default(S390PCIBusDevice *pbdev, uint64_t *data, uint8_t = pcias, + uint16_t len, uint64_t offset) +{ + MemTxResult result; + + switch (pcias) { + case ZPCI_IO_BAR_MIN...ZPCI_IO_BAR_MAX: + if (!len || (len > (8 - (offset & 0x7)))) { + return -EINVAL; + } + result =3D zpci_read_bar(pbdev, pcias, offset, data, len); + if (result !=3D MEMTX_OK) { + return -EINVAL; + } + break; + case ZPCI_CONFIG_BAR: + if (!len || (len > (4 - (offset & 0x3))) || len =3D=3D 3) { + return -EINVAL; + } + *data =3D pci_host_config_read_common( + pbdev->pdev, offset, pci_config_size(pbdev->pdev), len); + + if (zpci_endian_swap(data, len)) { + return -EINVAL; + } + break; + default: + return -EFAULT; + } + + return 0; +} + int pcilg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2, uintptr_t ra) { CPUS390XState *env =3D &cpu->env; S390PCIBusDevice *pbdev; uint64_t offset; uint64_t data; - MemTxResult result; uint8_t len; uint32_t fh; uint8_t pcias; + int ret; =20 if (env->psw.mask & PSW_MASK_PSTATE) { s390_program_interrupt(env, PGM_PRIVILEGED, ra); @@ -452,35 +485,21 @@ int pcilg_service_call(S390CPU *cpu, uint8_t r1, uint= 8_t r2, uintptr_t ra) break; } =20 - switch (pcias) { - case ZPCI_IO_BAR_MIN...ZPCI_IO_BAR_MAX: - if (!len || (len > (8 - (offset & 0x7)))) { - s390_program_interrupt(env, PGM_OPERAND, ra); - return 0; - } - result =3D zpci_read_bar(pbdev, pcias, offset, &data, len); - if (result !=3D MEMTX_OK) { - s390_program_interrupt(env, PGM_OPERAND, ra); - return 0; - } - break; - case ZPCI_CONFIG_BAR: - if (!len || (len > (4 - (offset & 0x3))) || len =3D=3D 3) { - s390_program_interrupt(env, PGM_OPERAND, ra); - return 0; - } - data =3D pci_host_config_read_common( - pbdev->pdev, offset, pci_config_size(pbdev->pdev), len); + ret =3D pbdev->ops.pcilg(pbdev, &data, pcias, len, offset); =20 - if (zpci_endian_swap(&data, len)) { - s390_program_interrupt(env, PGM_OPERAND, ra); - return 0; - } - break; - default: + switch (ret) { + case -EINVAL: + s390_program_interrupt(env, PGM_OPERAND, ra); + return 0; + case -EFAULT: DPRINTF("pcilg invalid space\n"); setcc(cpu, ZPCI_PCI_LS_ERR); s390_set_status_code(env, r2, ZPCI_PCI_ST_INVAL_AS); + case 0: + break; + default: + DPRINTF("pcilg unexpected return %d from op\n", ret); + s390_program_interrupt(env, PGM_OPERAND, ra); return 0; } =20 @@ -504,15 +523,55 @@ static MemTxResult zpci_write_bar(S390PCIBusDevice *p= bdev, uint8_t pcias, MEMTXATTRS_UNSPECIFIED); } =20 +static int pcistg_default(S390PCIBusDevice *pbdev, uint64_t data, uint8_t = pcias, + uint16_t len, uint64_t offset) +{ + MemTxResult result; + + switch (pcias) { + /* A ZPCI PCI card may use any BAR from BAR 0 to BAR 5 */ + case ZPCI_IO_BAR_MIN...ZPCI_IO_BAR_MAX: + /* + * Check length: + * A length of 0 is invalid and length should not cross a double w= ord + */ + if (!len || (len > (8 - (offset & 0x7)))) { + return -EINVAL; + } + + result =3D zpci_write_bar(pbdev, pcias, offset, data, len); + if (result !=3D MEMTX_OK) { + return -EINVAL; + } + break; + case ZPCI_CONFIG_BAR: + /* ZPCI uses the pseudo BAR number 15 as configuration space */ + /* possible access lengths are 1,2,4 and must not cross a word */ + if (!len || (len > (4 - (offset & 0x3))) || len =3D=3D 3) { + return -EINVAL; + } + /* len =3D 1,2,4 so we do not need to test */ + zpci_endian_swap(&data, len); + pci_host_config_write_common(pbdev->pdev, offset, + pci_config_size(pbdev->pdev), + data, len); + break; + default: + return -EFAULT; + } + + return 0; +} + int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2, uintptr_t ra) { CPUS390XState *env =3D &cpu->env; uint64_t offset, data; S390PCIBusDevice *pbdev; - MemTxResult result; uint8_t len; uint32_t fh; uint8_t pcias; + int ret; =20 if (env->psw.mask & PSW_MASK_PSTATE) { s390_program_interrupt(env, PGM_PRIVILEGED, ra); @@ -555,40 +614,21 @@ int pcistg_service_call(S390CPU *cpu, uint8_t r1, uin= t8_t r2, uintptr_t ra) break; } =20 - switch (pcias) { - /* A ZPCI PCI card may use any BAR from BAR 0 to BAR 5 */ - case ZPCI_IO_BAR_MIN...ZPCI_IO_BAR_MAX: - /* Check length: - * A length of 0 is invalid and length should not cross a double w= ord - */ - if (!len || (len > (8 - (offset & 0x7)))) { - s390_program_interrupt(env, PGM_OPERAND, ra); - return 0; - } + ret =3D pbdev->ops.pcistg(pbdev, data, pcias, len, offset); =20 - result =3D zpci_write_bar(pbdev, pcias, offset, data, len); - if (result !=3D MEMTX_OK) { - s390_program_interrupt(env, PGM_OPERAND, ra); - return 0; - } - break; - case ZPCI_CONFIG_BAR: - /* ZPCI uses the pseudo BAR number 15 as configuration space */ - /* possible access lengths are 1,2,4 and must not cross a word */ - if (!len || (len > (4 - (offset & 0x3))) || len =3D=3D 3) { - s390_program_interrupt(env, PGM_OPERAND, ra); - return 0; - } - /* len =3D 1,2,4 so we do not need to test */ - zpci_endian_swap(&data, len); - pci_host_config_write_common(pbdev->pdev, offset, - pci_config_size(pbdev->pdev), - data, len); - break; - default: + switch (ret) { + case -EINVAL: + s390_program_interrupt(env, PGM_OPERAND, ra); + return 0; + case -EFAULT: DPRINTF("pcistg invalid space\n"); setcc(cpu, ZPCI_PCI_LS_ERR); s390_set_status_code(env, r2, ZPCI_PCI_ST_INVAL_AS); + case 0: + break; + default: + DPRINTF("pcistg unexpected return %d from op\n", ret); + s390_program_interrupt(env, PGM_OPERAND, ra); return 0; } =20 @@ -739,19 +779,53 @@ err: return 0; } =20 +/* + * The default PCISTB handler will break PCISTB instructions into a series= of + * 8B memory operations. + */ +static int pcistb_default(S390PCIBusDevice *pbdev, S390CPU *cpu, + uint64_t gaddr, uint8_t ar, uint8_t pcias, + uint16_t len, uint64_t offset) +{ + MemTxResult result; + MemoryRegion *mr; + int i; + + mr =3D pbdev->pdev->io_regions[pcias].memory; + mr =3D s390_get_subregion(mr, offset, len); + offset -=3D mr->addr; + + if (!memory_region_access_valid(mr, offset, len, true, + MEMTXATTRS_UNSPECIFIED)) { + return -EINVAL; + } + + if (s390_cpu_virt_mem_read(cpu, gaddr, ar, pbdev->pcistb_buf, len)) { + return -EACCES; + } + + for (i =3D 0; i < len / 8; i++) { + result =3D memory_region_dispatch_write(mr, offset + i * 8, + ldq_p(pbdev->pcistb_buf + i = * 8), + MO_64, MEMTXATTRS_UNSPECIFIE= D); + if (result !=3D MEMTX_OK) { + return -EINVAL; + } + } + + return 0; +} + int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gad= dr, uint8_t ar, uintptr_t ra) { CPUS390XState *env =3D &cpu->env; S390PCIBusDevice *pbdev; - MemoryRegion *mr; - MemTxResult result; uint64_t offset; - int i; uint32_t fh; uint8_t pcias; uint16_t len; - uint8_t buffer[128]; + int ret; =20 if (env->psw.mask & PSW_MASK_PSTATE) { s390_program_interrupt(env, PGM_PRIVILEGED, ra); @@ -812,29 +886,21 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uin= t8_t r3, uint64_t gaddr, goto specification_error; } =20 - mr =3D pbdev->pdev->io_regions[pcias].memory; - mr =3D s390_get_subregion(mr, offset, len); - offset -=3D mr->addr; + ret =3D pbdev->ops.pcistb(pbdev, cpu, gaddr, ar, pcias, len, offset); =20 - if (!memory_region_access_valid(mr, offset, len, true, - MEMTXATTRS_UNSPECIFIED)) { + switch (ret) { + case -EINVAL: s390_program_interrupt(env, PGM_OPERAND, ra); return 0; - } - - if (s390_cpu_virt_mem_read(cpu, gaddr, ar, buffer, len)) { + case -EACCES: s390_cpu_virt_mem_handle_exc(cpu, ra); return 0; - } - - for (i =3D 0; i < len / 8; i++) { - result =3D memory_region_dispatch_write(mr, offset + i * 8, - ldq_p(buffer + i * 8), - MO_64, MEMTXATTRS_UNSPECIFIE= D); - if (result !=3D MEMTX_OK) { - s390_program_interrupt(env, PGM_OPERAND, ra); - return 0; - } + case 0: + break; + default: + DPRINTF("pcistb unexpected return %d from op\n", ret); + s390_program_interrupt(env, PGM_OPERAND, ra); + return 0; } =20 pbdev->fmb.counter[ZPCI_FMB_CNT_STB]++; @@ -1298,3 +1364,17 @@ out: setcc(cpu, cc); return 0; } + +void zpci_assign_default_ops(S390PCIBusDevice *pbdev) +{ + /* + * As PCISTB operations are not allowed to cross a page boundary, use + * qemu_memalign to get a single page for all subseqent PCISTB + * operations. + */ + pbdev->pcistb_buf =3D qemu_memalign(PAGE_SIZE, PAGE_SIZE); + + pbdev->ops.pcistg =3D pcistg_default; + pbdev->ops.pcilg =3D pcilg_default; + pbdev->ops.pcistb =3D pcistb_default; +} diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index 49ae9f0..bf0034f 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -325,6 +325,26 @@ typedef struct S390PCIGroup { S390PCIGroup *s390_group_create(int id); S390PCIGroup *s390_group_find(int id); =20 +typedef struct ZpciOps { + int (*pcistg)(S390PCIBusDevice *pbdev, + uint64_t data, + uint8_t pcias, + uint16_t len, + uint64_t offset); + int (*pcilg)(S390PCIBusDevice *pbdev, + uint64_t *data, + uint8_t pcias, + uint16_t len, + uint64_t offset); + int (*pcistb)(S390PCIBusDevice *pbdev, + S390CPU *cpu, + uint64_t gaddr, + uint8_t ar, + uint8_t pcias, + uint16_t len, + uint64_t offset); +} ZpciOps; + struct S390PCIBusDevice { DeviceState qdev; PCIDevice *pdev; @@ -350,6 +370,8 @@ struct S390PCIBusDevice { MemoryRegion msix_notify_mr; IndAddr *summary_ind; IndAddr *indicator; + ZpciOps ops; + uint8_t *pcistb_buf; bool pci_unplug_request_processed; bool unplug_requested; QTAILQ_ENTRY(S390PCIBusDevice) link; diff --git a/include/hw/s390x/s390-pci-inst.h b/include/hw/s390x/s390-pci-i= nst.h index a55c448..c9fe3f1 100644 --- a/include/hw/s390x/s390-pci-inst.h +++ b/include/hw/s390x/s390-pci-inst.h @@ -111,6 +111,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint6= 4_t fiba, uint8_t ar, int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t = ar, uintptr_t ra); void fmb_timer_free(S390PCIBusDevice *pbdev); +void zpci_assign_default_ops(S390PCIBusDevice *pbdev); =20 #define ZPCI_IO_BAR_MIN 0 #define ZPCI_IO_BAR_MAX 5 --=20 1.8.3.1 From nobody Sat May 18 12:47:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1607547203; cv=none; d=zohomail.com; s=zohoarc; b=Nqv2/X+3PB3VThBtr/w678x35qSxV7qrmbmlvgYHmsVxgXyJlSOaU7qDFtQ8V0acnmoDL5P1Dox6lvsNkGE6JcXUWpMSU3pUrEcTA3zhNxlELVyVVhREuL3r4RY1h/jEuqiT93CpGnwX+JL5qv5xilFtGJZR5fntUrw8PuVhyk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607547203; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=lSrMk9vc/Y0P+rqHalkd/CAcLUKtTLCmJMpYGGZ3ixs=; b=i332a+q0khqZMtL5Km8uiAkPqkEVPHJqoYgWMjMTZPbk7FcPkJZAi4tQuh5SQ1hVGlEJaW+XJSNlFkEA0IhHPgQYCXMGr3lmwc4kTQtEACAuPbcIY6kfcH5YjAlbPu5/nzmxOogJu+v75QhO6P4VbFuiM5actisaTAdh3bQtTGc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607547203916564.2576251285943; Wed, 9 Dec 2020 12:53:23 -0800 (PST) Received: from localhost ([::1]:41502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kn6Sg-0002i1-Sj for importer@patchew.org; Wed, 09 Dec 2020 15:53:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6Au-0000FX-N2; Wed, 09 Dec 2020 15:35:00 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:46252) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6Ao-0005rP-Mx; Wed, 09 Dec 2020 15:35:00 -0500 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 0B9KXfP0079094; Wed, 9 Dec 2020 15:34:48 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 35b5b9gkgb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:48 -0500 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 0B9KYlim085674; Wed, 9 Dec 2020 15:34:47 -0500 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 35b5b9gkg1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:47 -0500 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0B9KX4kD016367; Wed, 9 Dec 2020 20:34:46 GMT Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by ppma04dal.us.ibm.com with ESMTP id 3581u9tvtc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 20:34:46 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0B9KYjhk21954878 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Dec 2020 20:34:45 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B1CE5124053; Wed, 9 Dec 2020 20:34:45 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B4CD124052; Wed, 9 Dec 2020 20:34:43 +0000 (GMT) Received: from oc4221205838.ibm.com (unknown [9.163.37.122]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 9 Dec 2020 20:34:42 +0000 (GMT) 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=lSrMk9vc/Y0P+rqHalkd/CAcLUKtTLCmJMpYGGZ3ixs=; b=UfzSpdBsLuMEdzpv7Pw9eed1WICwtrkd33AD92nod30FFueoch9iXNCmvEe3hp/8PX5N n4RepY8Jg53MwFDLh5DEUhfQzS7gBE/8iM/DtgMnUE5N8GBXqUFIai+iwJ9L3OyPpkME LCk7el7eSVCuRCq/MhNN+v/xsvMA2DZv9ft83s4ZNYjsLR81Ys5fez7v+hYTT0xZC4Si JJkyWXy9sizpy5F1oqZMnF7MMVOnDgxjqbQtCg89t5kXqfKcoC85W/iicQFq0hmuTy/G LOTlwqIsTi7wUqnyn9PvAOIun8TkrdWEVRRcp47+T9839EtAybLitNQ4WMmKQlRK0RyC cA== From: Matthew Rosato To: cohuck@redhat.com, thuth@redhat.com Subject: [RFC 5/8] s390x/pci: Fix memory_region_access_valid call Date: Wed, 9 Dec 2020 15:34:23 -0500 Message-Id: <1607546066-2240-6-git-send-email-mjrosato@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> References: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2020-12-09_16:2020-12-09, 2020-12-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 mlxlogscore=971 impostorscore=0 suspectscore=0 phishscore=0 adultscore=0 mlxscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012090143 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=mjrosato@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pmorel@linux.ibm.com, david@redhat.com, schnelle@linux.ibm.com, richard.henderson@linaro.org, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, pasic@linux.ibm.com, borntraeger@de.ibm.com, alex.williamson@redhat.com, mst@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In pcistb_service_handler, a call is made to validate that the memory region can be accessed. However, the call is made using the entire length of the pcistb operation, which can be larger than the allowed memory access size (8). Since we already know that the provided buffer is a multiple of 8, fix the call to memory_region_access_valid to iterate over the memory region in the same way as the subsequent call to memory_region_dispatch_write. Signed-off-by: Matthew Rosato --- hw/s390x/s390-pci-inst.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index b07ef2a..a5270d0 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -795,9 +795,11 @@ static int pcistb_default(S390PCIBusDevice *pbdev, S39= 0CPU *cpu, mr =3D s390_get_subregion(mr, offset, len); offset -=3D mr->addr; =20 - if (!memory_region_access_valid(mr, offset, len, true, - MEMTXATTRS_UNSPECIFIED)) { - return -EINVAL; + for (i =3D 0; i < len / 8; i++) { + if (!memory_region_access_valid(mr, offset + i * 8, 8, true, + MEMTXATTRS_UNSPECIFIED)) { + return -EINVAL; + } } =20 if (s390_cpu_virt_mem_read(cpu, gaddr, ar, pbdev->pcistb_buf, len)) { --=20 1.8.3.1 From nobody Sat May 18 12:47:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1607547447; cv=none; d=zohomail.com; s=zohoarc; b=I/nil4IQqMe2QeorPoJ5j+CLhC5GHKYZsP3zq7RbUKOvv9Nonkka3/gZvzgQyU6PBUhnV03YlPF8Wcf6Y/0UxKZHOufoD95vgMAU7/+d+cYsn/S/kzRkNUHkPmLpmFcHJMgFPxFbfjNmhhY/3dPa23vpC4eqG3zIiS6Ztk4nbTg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607547447; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=/NsgMwaSt0gd7MGEoAG/B0qEbfeohH1qg5XJV9rC2Pw=; b=BkJq81LYUFkFneZaXjU2oQRF+wWbOpoX2Y71BlE4Fz0fPsjPQtKun7ROr03VDyKREpSxHsavpQ/Okbqdd5adyTP5W9BNGCI2pJ6U7ZUHKns/t9wqjQIpwVHIdMWkQ5u4zJgU2diIOChl+7yB8EWfRn8ChpApjQstaPJi5d8Iu3c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607547447887316.731045662381; Wed, 9 Dec 2020 12:57:27 -0800 (PST) Received: from localhost ([::1]:36920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kn6FN-0005Vu-Uu for importer@patchew.org; Wed, 09 Dec 2020 15:39:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6At-0000EK-8W; Wed, 09 Dec 2020 15:34:59 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:25934 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6Ap-0005ro-JF; Wed, 09 Dec 2020 15:34:58 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0B9KWXpA148027; Wed, 9 Dec 2020 15:34:50 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 35awxt7c66-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:50 -0500 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0B9KX9Hn151978; Wed, 9 Dec 2020 15:34:49 -0500 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0b-001b2d01.pphosted.com with ESMTP id 35awxt7c5j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:49 -0500 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0B9KWAv6029279; Wed, 9 Dec 2020 20:34:48 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma01wdc.us.ibm.com with ESMTP id 3581u9gf1d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 20:34:48 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0B9KYmu823003674 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Dec 2020 20:34:48 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 177F1124054; Wed, 9 Dec 2020 20:34:48 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB682124052; Wed, 9 Dec 2020 20:34:45 +0000 (GMT) Received: from oc4221205838.ibm.com (unknown [9.163.37.122]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 9 Dec 2020 20:34:45 +0000 (GMT) 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=/NsgMwaSt0gd7MGEoAG/B0qEbfeohH1qg5XJV9rC2Pw=; b=aFokOL+Hvc/XDzwwPXn0v1c5fI5Irj+25AyUUf2POOkR6lQEqmH0/XA/eNYErQQh5szO UOb6aLDZxaCg49NQzjsMIJOCjk/vEf6KaI8ddkIdJUWwXGaTwQrcr7hLUJdb6JwykK42 dyt7hA1g/e2KnkFgWjbUiRt7u/aiUav2D3nSDErSdwxsBxx41KjmPnbxfm/7msdyKtZt 5Brbs00eE8lXP/WsJIsp58Svsy+IfQj86ZOOSfvN3U/x/OrL2TOmRABEu/RKz4wPHsYO rjzpYkm42XMVY8+NA3uot1mg4FCS0yevPWUI7rfXtBJcchF1ZSqyQsxrZlmT5jXpCaNj ug== From: Matthew Rosato To: cohuck@redhat.com, thuth@redhat.com Subject: [RFC 6/8] s390x/pci: Handle devices that support relaxed alignment Date: Wed, 9 Dec 2020 15:34:24 -0500 Message-Id: <1607546066-2240-7-git-send-email-mjrosato@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> References: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2020-12-09_16:2020-12-09, 2020-12-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 phishscore=0 priorityscore=1501 spamscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 clxscore=1015 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012090140 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=mjrosato@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pmorel@linux.ibm.com, david@redhat.com, schnelle@linux.ibm.com, richard.henderson@linaro.org, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, pasic@linux.ibm.com, borntraeger@de.ibm.com, alex.williamson@redhat.com, mst@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Certain zPCI device types (e.g. ISM) allow for a different set of address alignment rules for PCISTB instructions. Recognize this distinction and perform only a subset of alignment checks for intercepted PCISTB instructions. Signed-off-by: Matthew Rosato --- hw/s390x/s390-pci-inst.c | 34 ++++++++++++++++++++-------------- hw/s390x/s390-pci-vfio.c | 3 +++ include/hw/s390x/s390-pci-clp.h | 1 + 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index a5270d0..30698e5 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -868,25 +868,31 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uin= t8_t r3, uint64_t gaddr, return 0; } =20 - /* Verify the address, offset and length */ - /* offset must be a multiple of 8 */ - if (offset % 8) { - goto specification_error; - } - /* Length must be greater than 8, a multiple of 8 */ - /* and not greater than maxstbl */ - if ((len <=3D 8) || (len % 8) || - (len > pbdev->pci_group->zpci_group.maxstbl)) { - goto specification_error; + /* + * If the specified device supports relaxed alignment, some checks can + * be skipped. + */ + if (!(pbdev->pci_group->zpci_group.fr & CLP_RSP_QPCIG_MASK_RELAXED)) { + /* Verify the address, offset and length */ + /* offset must be a multiple of 8 */ + if (offset % 8) { + goto specification_error; + } + /* Length must be greater than 8, a multiple of 8 */ + /* and not greater than maxstbl */ + if ((len <=3D 8) || (len % 8) || + (len > pbdev->pci_group->zpci_group.maxstbl)) { + goto specification_error; + } + /* Guest address must be double word aligned */ + if (gaddr & 0x07UL) { + goto specification_error; + } } /* Do not cross a 4K-byte boundary */ if (((offset & 0xfff) + len) > 0x1000) { goto specification_error; } - /* Guest address must be double word aligned */ - if (gaddr & 0x07UL) { - goto specification_error; - } =20 ret =3D pbdev->ops.pcistb(pbdev, cpu, gaddr, ar, pcias, len, offset); =20 diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c index 9296e1b..9439fe1 100644 --- a/hw/s390x/s390-pci-vfio.c +++ b/hw/s390x/s390-pci-vfio.c @@ -156,6 +156,9 @@ static void s390_pci_read_group(S390PCIBusDevice *pbdev, if (cap->flags & VFIO_DEVICE_INFO_ZPCI_FLAG_REFRESH) { resgrp->fr =3D 1; } + if (cap->flags & VFIO_DEVICE_INFO_ZPCI_FLAG_RELAXED) { + resgrp->fr |=3D CLP_RSP_QPCIG_MASK_RELAXED; + } resgrp->dasm =3D cap->dasm; resgrp->msia =3D cap->msi_addr; resgrp->mui =3D cap->mui; diff --git a/include/hw/s390x/s390-pci-clp.h b/include/hw/s390x/s390-pci-cl= p.h index 96b8e3f..73a28a0 100644 --- a/include/hw/s390x/s390-pci-clp.h +++ b/include/hw/s390x/s390-pci-clp.h @@ -158,6 +158,7 @@ typedef struct ClpRspQueryPciGrp { #define CLP_RSP_QPCIG_MASK_NOI 0xfff uint16_t i; uint8_t version; +#define CLP_RSP_QPCIG_MASK_RELAXED 0x8 #define CLP_RSP_QPCIG_MASK_FRAME 0x2 #define CLP_RSP_QPCIG_MASK_REFRESH 0x1 uint8_t fr; --=20 1.8.3.1 From nobody Sat May 18 12:47:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1607549061; cv=none; d=zohomail.com; s=zohoarc; b=F1vdPfY08yeRlPA8V2kxlUpn/igmdRk5qkoxgaMhnyHUWzpc/wbEe0UXl2sctPeS7tdR0yXpYIY0lMA1n5FsaJLgCjtuueOSpCJT8QIDDT9/HTbdt1KQLXDVcHiYRIti9Wmq61H88cxioAE0Tcnd8Ivbe77XYMhBhy1BCfs7DRI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607549061; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ofHxB8QcV7LwlQ3ZqO97RDGTsqphpEk0ru6/Cwn2OFY=; b=XhzRHPb9/k91+Gh+JVRpW8GKfa32batqUgWnVI3Q56VU+eF0O9GdOyCz7cCJIKIDvXoWO9Au2ErT1dDZnEy6HuS47+Ro9+c7QlV47793N1kwZxchDzFSjpfQbwKA3SfYVWcxM0lS2x7RoVBKFpfY4MFUApc0vh6spkQiZA4dcVQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607549061089925.6863089528663; Wed, 9 Dec 2020 13:24:21 -0800 (PST) Received: from localhost ([::1]:44826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kn6II-0000Re-8D for importer@patchew.org; Wed, 09 Dec 2020 15:42:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6Au-0000Ez-CO; Wed, 09 Dec 2020 15:35:00 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:25732) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6Ap-0005sH-OX; Wed, 09 Dec 2020 15:35:00 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0B9KXDhV057276; Wed, 9 Dec 2020 15:34:53 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 35avw5hwpa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:53 -0500 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0B9KXVSA058219; Wed, 9 Dec 2020 15:34:53 -0500 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 35avw5hwnj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:52 -0500 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0B9KWFo6029324; Wed, 9 Dec 2020 20:34:51 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma01wdc.us.ibm.com with ESMTP id 3581u9gf1r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 20:34:51 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0B9KYodZ33489392 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Dec 2020 20:34:50 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D0D3C124058; Wed, 9 Dec 2020 20:34:50 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5B11D124054; Wed, 9 Dec 2020 20:34:48 +0000 (GMT) Received: from oc4221205838.ibm.com (unknown [9.163.37.122]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 9 Dec 2020 20:34:48 +0000 (GMT) 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=ofHxB8QcV7LwlQ3ZqO97RDGTsqphpEk0ru6/Cwn2OFY=; b=dC+mgLAU4RbuhSTpNKL2W1G7n0MPz1ND19oE5iD4BsheneXFX/A+Ej3H8OZm2cDxhV6Z iwTqsFy/wbEMy8MerbHCZNADZ0hNFk7RsZSU25vzWiEYXWcAqwYje9eCdE2h5lUE/AYg pFsV5WfUrhKhT+OEooAp5+0v5qgX7WFl1SblnpMJH7WAzYlh8EhbdBd4UgpRALb4NnV/ DnJ/B+ZL5vJAb+ON7OyUHDw1/yGnduyfee+cmbgwjBUdTw0k4ugHUFu2lJHprayjrfyK KVYXBk8TzMnKVUzMlmpwQYxoh3ymxizeoLW25AX3D2VwPXBtz7YVxgpd2Dr+K6mXGwnx uA== From: Matthew Rosato To: cohuck@redhat.com, thuth@redhat.com Subject: [RFC 7/8] s390x/pci: PCISTB via the vfio zPCI I/O region Date: Wed, 9 Dec 2020 15:34:25 -0500 Message-Id: <1607546066-2240-8-git-send-email-mjrosato@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> References: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2020-12-09_16:2020-12-09, 2020-12-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=2 malwarescore=0 mlxlogscore=999 spamscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012090143 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=mjrosato@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pmorel@linux.ibm.com, david@redhat.com, schnelle@linux.ibm.com, richard.henderson@linaro.org, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, pasic@linux.ibm.com, borntraeger@de.ibm.com, alex.williamson@redhat.com, mst@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For ISM devices, use the vfio region to handle intercepted PCISTB instructions. This region will allow large block I/O instructions intercepted from the guest to be performed as a single I/O instruction on the host. This ensure that proper write patterns that are expected by the underlying device are respected and ensures that a non-MIO instruction is used to perform the operation (as ISM devices do not support the MIO instruction set). Furthermore, add a requirement that the I/O region must be available in order to pass the device through to the guest. Signed-off-by: Matthew Rosato --- hw/s390x/s390-pci-bus.c | 15 ++++++ hw/s390x/s390-pci-inst.c | 8 +++ hw/s390x/s390-pci-vfio.c | 108 +++++++++++++++++++++++++++++++++++= ++++ include/hw/s390x/s390-pci-bus.h | 2 + include/hw/s390x/s390-pci-inst.h | 1 + include/hw/s390x/s390-pci-vfio.h | 15 ++++++ 6 files changed, 149 insertions(+) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 7d31ded..e77c448 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -977,6 +977,7 @@ static void s390_pcihost_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev, S390pciState *s =3D S390_PCI_HOST_BRIDGE(hotplug_dev); PCIDevice *pdev =3D NULL; S390PCIBusDevice *pbdev =3D NULL; + int ret; =20 if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) { PCIBridge *pb =3D PCI_BRIDGE(dev); @@ -1027,6 +1028,20 @@ static void s390_pcihost_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, pbdev->iommu->dma_limit =3D s390_pci_start_dma_count(s, pbdev); /* Fill in CLP information passed via the vfio region */ s390_pci_get_clp_info(pbdev); + + /* + * For a relaxed-alignment device, setup the special I/O region + * if available. Otherwise, the device cannot be passed throu= gh. + */ + ret =3D 0; + if (pbdev->pci_group->zpci_group.fr & CLP_RSP_QPCIG_MASK_RELAX= ED) { + ret =3D s390_pci_get_zpci_io_region(pbdev); + } + if (ret) { + error_setg(errp, "vfio zPCI I/O region support is mandator= y " + "for %02x:%02x.%01x", pci_dev_bus_num(pdev), + PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); + } } else { pbdev->fh |=3D FH_SHM_EMUL; =20 diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 30698e5..d4c79f6 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -19,6 +19,7 @@ #include "sysemu/hw_accel.h" #include "hw/s390x/s390-pci-inst.h" #include "hw/s390x/s390-pci-bus.h" +#include "hw/s390x/s390-pci-vfio.h" #include "hw/s390x/tod.h" =20 #ifndef DEBUG_S390PCI_INST @@ -897,6 +898,8 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8= _t r3, uint64_t gaddr, ret =3D pbdev->ops.pcistb(pbdev, cpu, gaddr, ar, pcias, len, offset); =20 switch (ret) { + case -EIO: + /* fall through */ case -EINVAL: s390_program_interrupt(env, PGM_OPERAND, ra); return 0; @@ -1386,3 +1389,8 @@ void zpci_assign_default_ops(S390PCIBusDevice *pbdev) pbdev->ops.pcilg =3D pcilg_default; pbdev->ops.pcistb =3D pcistb_default; } + +void zpci_assign_ops_vfio_io_region(S390PCIBusDevice *pbdev) +{ + pbdev->ops.pcistb =3D s390_pci_vfio_pcistb; +} diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c index 9439fe1..ad50a62 100644 --- a/hw/s390x/s390-pci-vfio.c +++ b/hw/s390x/s390-pci-vfio.c @@ -17,6 +17,7 @@ #include "trace.h" #include "hw/s390x/s390-pci-bus.h" #include "hw/s390x/s390-pci-clp.h" +#include "hw/s390x/s390-pci-inst.h" #include "hw/s390x/s390-pci-vfio.h" #include "hw/vfio/pci.h" #include "hw/vfio/vfio-common.h" @@ -277,3 +278,110 @@ retry: =20 return; } + +/* + * This function will look for the VFIO_REGION_SUBTYPE_IBM_ZPCI_IO vfio + * device region, which is used for performing block I/O operations. + */ +int s390_pci_get_zpci_io_region(S390PCIBusDevice *pbdev) +{ + VFIOPCIDevice *vfio_pci; + VFIODevice *vdev; + struct vfio_region_info *info; + int ret; + + vfio_pci =3D container_of(pbdev->pdev, VFIOPCIDevice, pdev); + vdev =3D &vfio_pci->vbasedev; + + if (vdev->num_regions < VFIO_PCI_NUM_REGIONS + 1) { + return -ENOENT; + } + + /* Get the I/O region if it's available */ + if (vfio_get_dev_region_info(vdev, + PCI_VENDOR_ID_IBM | + VFIO_REGION_TYPE_PCI_VENDOR_TYPE, + VFIO_REGION_SUBTYPE_IBM_ZPCI_IO, &info)) { + return -ENOENT; + } + + /* If the size is unexpectedly small, don't use the region */ + if (sizeof(*pbdev->io_region) > info->size) { + return -EINVAL; + } + + pbdev->io_region =3D g_malloc0(info->size); + + /* Check the header for setup information */ + ret =3D pread(vfio_pci->vbasedev.fd, &pbdev->io_region->hdr, + sizeof(struct vfio_zpci_io_hdr), info->offset); + if (ret !=3D sizeof(struct vfio_zpci_io_hdr)) { + g_free(pbdev->io_region); + pbdev->io_region =3D 0; + ret =3D -EINVAL; + } else { + pbdev->io_region_op_offset =3D info->offset + + offsetof(struct vfio_region_zpci_io, = req); + /* All devices in this group will use the I/O region for PCISTB */ + pbdev->pci_group->zpci_group.maxstbl =3D MIN(PAGE_SIZE, + pbdev->io_region->hdr.max); + ret =3D 0; + } + g_free(info); + + /* Register the new handlers for the device if region available */ + if (pbdev->io_region) { + zpci_assign_ops_vfio_io_region(pbdev); + } + + return ret; +} + +int s390_pci_vfio_pcistb(S390PCIBusDevice *pbdev, S390CPU *cpu, uint64_t g= addr, + uint8_t ar, uint8_t pcias, uint16_t len, + uint64_t offset) +{ + struct vfio_region_zpci_io *region =3D pbdev->io_region; + VFIOPCIDevice *vfio_pci; + uint8_t *buffer; + int ret; + + if (region =3D=3D NULL) { + return -EIO; + } + + vfio_pci =3D container_of(pbdev->pdev, VFIOPCIDevice, pdev); + + /* + * We've already ensured the input can be no larger than a page. PCIS= TB + * requires that the operation payload does not cross a page boundary, + * otherwise the operation will be rejected. Therefore, just get a si= ngle + * page for the write. + */ + buffer =3D qemu_memalign(PAGE_SIZE, PAGE_SIZE); + + if (s390_cpu_virt_mem_read(cpu, gaddr, ar, buffer, len)) { + ret =3D -EACCES; + goto out; + } + + region->req.gaddr =3D (uint64_t)buffer; + region->req.offset =3D offset; + region->req.len =3D len; + region->req.pcias =3D pcias; + region->req.flags =3D VFIO_ZPCI_IO_FLAG_BLOCKW; + + ret =3D pwrite(vfio_pci->vbasedev.fd, ®ion->req, + sizeof(struct vfio_zpci_io_req), + pbdev->io_region_op_offset); + if (ret !=3D sizeof(struct vfio_zpci_io_req)) { + ret =3D -EIO; + } else { + ret =3D 0; + } + +out: + qemu_vfree(buffer); + + return ret; +} diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index bf0034f..8986a5f 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -355,6 +355,8 @@ struct S390PCIBusDevice { uint32_t fh; uint32_t fid; bool fid_defined; + uint64_t io_region_op_offset; + struct vfio_region_zpci_io *io_region; uint64_t fmb_addr; ZpciFmb fmb; QEMUTimer *fmb_timer; diff --git a/include/hw/s390x/s390-pci-inst.h b/include/hw/s390x/s390-pci-i= nst.h index c9fe3f1..7ed6175 100644 --- a/include/hw/s390x/s390-pci-inst.h +++ b/include/hw/s390x/s390-pci-inst.h @@ -112,6 +112,7 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint= 64_t fiba, uint8_t ar, uintptr_t ra); void fmb_timer_free(S390PCIBusDevice *pbdev); void zpci_assign_default_ops(S390PCIBusDevice *pbdev); +void zpci_assign_ops_vfio_io_region(S390PCIBusDevice *pbdev); =20 #define ZPCI_IO_BAR_MIN 0 #define ZPCI_IO_BAR_MAX 5 diff --git a/include/hw/s390x/s390-pci-vfio.h b/include/hw/s390x/s390-pci-v= fio.h index ff708ae..f0a994f 100644 --- a/include/hw/s390x/s390-pci-vfio.h +++ b/include/hw/s390x/s390-pci-vfio.h @@ -21,6 +21,10 @@ S390PCIDMACount *s390_pci_start_dma_count(S390pciState *= s, S390PCIBusDevice *pbdev); void s390_pci_end_dma_count(S390pciState *s, S390PCIDMACount *cnt); void s390_pci_get_clp_info(S390PCIBusDevice *pbdev); +int s390_pci_get_zpci_io_region(S390PCIBusDevice *pbdev); +int s390_pci_vfio_pcistb(S390PCIBusDevice *pbdev, S390CPU *cpu, uint64_t g= addr, + uint8_t ar, uint8_t pcias, uint16_t len, + uint64_t offset); #else static inline bool s390_pci_update_dma_avail(int fd, unsigned int *avail) { @@ -34,6 +38,17 @@ static inline S390PCIDMACount *s390_pci_start_dma_count(= S390pciState *s, static inline void s390_pci_end_dma_count(S390pciState *s, S390PCIDMACount *cnt) { } static inline void s390_pci_get_clp_info(S390PCIBusDevice *pbdev) { } +static inline int s390_pci_get_zpci_io_region(S390PCIBusDevice *pbdev) +{ + return -EINVAL; +} +static inline int s390_pci_vfio_pcistb(S390PCIBusDevice *pbdev, S390CPU *c= pu, + uint64_t gaddr, uint8_t ar, + uint8_t pcias, uint16_t len, + uint64_t offset) +{ + return -EIO; +} #endif =20 #endif --=20 1.8.3.1 From nobody Sat May 18 12:47:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1607547176; cv=none; d=zohomail.com; s=zohoarc; b=gu/3IGn2/QZdR/jK7Ue06Sxfbe9Izpnqc18f0+RitClEJ9TwUr9myJ6lESaInzSRwqDlDTE3o54+RfKpb7VoG1KtsCrqIldbCw8yyeFnHbbgJA/2yhS4EMMgDClCF9v5U4d32V5mAtLhEj1tcUscFGc86xCsCjtaI6lORmRyOzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607547176; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ufIbCzqUWz2XGJ1ioiCfhTbGRneo/t1YxF6E6SX5Xn8=; b=buzz621LWk8lZDZzgQ8p1cCvEG1ZMqJnc0rb+EVrP0QxAw3kTz1mTydUJLeJ/PD6pq3NLlHF4mWv39NnxI2x4he54s5CWBRNjRi2P0t8mPE2N/LZigaIaXcCZnYLYRj6HsXQElRi8sF7DL5Gk0T69uqgf9yYhF8K7rZr9VDtsn8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607547176551444.28075500339685; Wed, 9 Dec 2020 12:52:56 -0800 (PST) Received: from localhost ([::1]:51394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kn6Jy-0003AA-Sl for importer@patchew.org; Wed, 09 Dec 2020 15:44:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6Av-0000Gz-9K; Wed, 09 Dec 2020 15:35:01 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:46324) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn6As-0005su-4P; Wed, 09 Dec 2020 15:35:00 -0500 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 0B9KXhEc079244; Wed, 9 Dec 2020 15:34:56 -0500 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 35b5b9gkm8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:56 -0500 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 0B9KY2Q8080533; Wed, 9 Dec 2020 15:34:55 -0500 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 35b5b9gkkn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 15:34:55 -0500 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0B9KVg93012897; Wed, 9 Dec 2020 20:34:54 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma03wdc.us.ibm.com with ESMTP id 3581u9a9n7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Dec 2020 20:34:54 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0B9KYrtT12059066 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Dec 2020 20:34:53 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C4942124054; Wed, 9 Dec 2020 20:34:53 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3AB2D124053; Wed, 9 Dec 2020 20:34:51 +0000 (GMT) Received: from oc4221205838.ibm.com (unknown [9.163.37.122]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 9 Dec 2020 20:34:50 +0000 (GMT) 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=ufIbCzqUWz2XGJ1ioiCfhTbGRneo/t1YxF6E6SX5Xn8=; b=TpUhYhat8ii5f7lLk/oCBTutfDTKlCiEoYfa9Kt/eJooGt7etjkwwfDJuRG9hI2aXloW Jt6x8zR/DLAJvKP7NWOjfQacJSkc6r4q1ZafpSTQ4cCzXwoE9husWwqtOT0txKJAh6yZ UdCjCctX1NIc85VSIHmz7SBNVMuoRzNhQrpdvW3tEIOdLmZibwyuKenSqcofuP09TboW 61wv0Vl8A6qWItTqTLSMFkyGc/HH6BnalVIdiK9LZdMddSgmL2PUKSqp7iBNx9lO2bhf wr3KNcumGdjmIE1CEz5fQh3xBF8vAhFeYt/TjS/u6hDJN+Tm5xzCam1fwdRlAcqWEbBU Ug== From: Matthew Rosato To: cohuck@redhat.com, thuth@redhat.com Subject: [RFC 8/8] s390x/pci: PCILG via the vfio zPCI I/O region Date: Wed, 9 Dec 2020 15:34:26 -0500 Message-Id: <1607546066-2240-9-git-send-email-mjrosato@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> References: <1607546066-2240-1-git-send-email-mjrosato@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2020-12-09_16:2020-12-09, 2020-12-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 mlxlogscore=999 impostorscore=0 suspectscore=0 phishscore=0 adultscore=0 mlxscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012090143 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=mjrosato@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pmorel@linux.ibm.com, david@redhat.com, schnelle@linux.ibm.com, richard.henderson@linaro.org, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, pasic@linux.ibm.com, borntraeger@de.ibm.com, alex.williamson@redhat.com, mst@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For ISM devices, use the vfio region to handle intercepted PCILG instructions. This will allow read I/Os intercepted from the guest to be performed as single operations that ensure the same non-MIO PCI instruction is used on the host as specified in the guest. Signed-off-by: Matthew Rosato --- hw/s390x/s390-pci-inst.c | 3 ++- hw/s390x/s390-pci-vfio.c | 53 ++++++++++++++++++++++++++++++++++++= ++++ include/hw/s390x/s390-pci-inst.h | 1 + include/hw/s390x/s390-pci-vfio.h | 8 ++++++ 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index d4c79f6..33186dc 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -352,7 +352,7 @@ out: * @ptr: a pointer to a uint64_t data field * @len: the length of the valid data, must be 1,2,4 or 8 */ -static int zpci_endian_swap(uint64_t *ptr, uint8_t len) +int zpci_endian_swap(uint64_t *ptr, uint8_t len) { uint64_t data =3D *ptr; =20 @@ -1392,5 +1392,6 @@ void zpci_assign_default_ops(S390PCIBusDevice *pbdev) =20 void zpci_assign_ops_vfio_io_region(S390PCIBusDevice *pbdev) { + pbdev->ops.pcilg =3D s390_pci_vfio_pcilg; pbdev->ops.pcistb =3D s390_pci_vfio_pcistb; } diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c index ad50a62..baba6b0 100644 --- a/hw/s390x/s390-pci-vfio.c +++ b/hw/s390x/s390-pci-vfio.c @@ -337,6 +337,59 @@ int s390_pci_get_zpci_io_region(S390PCIBusDevice *pbde= v) return ret; } =20 +int s390_pci_vfio_pcilg(S390PCIBusDevice *pbdev, uint64_t *data, uint8_t p= cias, + uint16_t len, uint64_t offset) +{ + struct vfio_region_zpci_io *region =3D pbdev->io_region; + VFIOPCIDevice *vfio_pci; + int ret; + + if (region =3D=3D NULL) { + return -EIO; + } + + vfio_pci =3D container_of(pbdev->pdev, VFIOPCIDevice, pdev); + + /* Perform Length/Alignment checks */ + switch (pcias) { + case ZPCI_IO_BAR_MIN...ZPCI_IO_BAR_MAX: + if (!len || (len > (8 - (offset & 0x7)))) { + return -EINVAL; + } + region->req.gaddr =3D (uint64_t)data; + region->req.offset =3D offset; + region->req.len =3D len; + region->req.pcias =3D pcias; + region->req.flags =3D VFIO_ZPCI_IO_FLAG_READ; + + ret =3D pwrite(vfio_pci->vbasedev.fd, ®ion->req, + sizeof(struct vfio_zpci_io_req), + pbdev->io_region_op_offset); + if (ret !=3D sizeof(struct vfio_zpci_io_req)) { + ret =3D -EIO; + } else { + ret =3D 0; + } + break; + case ZPCI_CONFIG_BAR: + if (!len || (len > (4 - (offset & 0x3))) || len =3D=3D 3) { + return -EINVAL; + } + *data =3D pci_host_config_read_common( + pbdev->pdev, offset, pci_config_size(pbdev->pdev), = len); + + if (zpci_endian_swap(data, len)) { + ret =3D -EINVAL; + } + ret =3D 0; + break; + default: + return -EFAULT; + } + + return ret; +} + int s390_pci_vfio_pcistb(S390PCIBusDevice *pbdev, S390CPU *cpu, uint64_t g= addr, uint8_t ar, uint8_t pcias, uint16_t len, uint64_t offset) diff --git a/include/hw/s390x/s390-pci-inst.h b/include/hw/s390x/s390-pci-i= nst.h index 7ed6175..fe368fb 100644 --- a/include/hw/s390x/s390-pci-inst.h +++ b/include/hw/s390x/s390-pci-inst.h @@ -101,6 +101,7 @@ typedef struct ZpciFib { int pci_dereg_irqs(S390PCIBusDevice *pbdev); void pci_dereg_ioat(S390PCIIOMMU *iommu); int clp_service_call(S390CPU *cpu, uint8_t r2, uintptr_t ra); +int zpci_endian_swap(uint64_t *ptr, uint8_t len); int pcilg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2, uintptr_t ra); int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2, uintptr_t ra= ); int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2, uintptr_t ra); diff --git a/include/hw/s390x/s390-pci-vfio.h b/include/hw/s390x/s390-pci-v= fio.h index f0a994f..d9fb3a4 100644 --- a/include/hw/s390x/s390-pci-vfio.h +++ b/include/hw/s390x/s390-pci-vfio.h @@ -22,6 +22,8 @@ S390PCIDMACount *s390_pci_start_dma_count(S390pciState *s, void s390_pci_end_dma_count(S390pciState *s, S390PCIDMACount *cnt); void s390_pci_get_clp_info(S390PCIBusDevice *pbdev); int s390_pci_get_zpci_io_region(S390PCIBusDevice *pbdev); +int s390_pci_vfio_pcilg(S390PCIBusDevice *pbdev, uint64_t *data, uint8_t p= cias, + uint16_t len, uint64_t offset); int s390_pci_vfio_pcistb(S390PCIBusDevice *pbdev, S390CPU *cpu, uint64_t g= addr, uint8_t ar, uint8_t pcias, uint16_t len, uint64_t offset); @@ -42,6 +44,12 @@ static inline int s390_pci_get_zpci_io_region(S390PCIBus= Device *pbdev) { return -EINVAL; } +static inline int s390_pci_vfio_pcilg(S390PCIBusDevice *pbdev, uint64_t *d= ata, + uint8_t pcias, uint16_t len, + uint64_t offset) +{ + return -EIO; +} static inline int s390_pci_vfio_pcistb(S390PCIBusDevice *pbdev, S390CPU *c= pu, uint64_t gaddr, uint8_t ar, uint8_t pcias, uint16_t len, --=20 1.8.3.1