From patchwork Thu Sep 17 14:20:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Rosato X-Patchwork-Id: 11782667 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 C7A97618 for ; Thu, 17 Sep 2020 14:40:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A437220684 for ; Thu, 17 Sep 2020 14:40:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="UK4j2/bd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726986AbgIQOjv (ORCPT ); Thu, 17 Sep 2020 10:39:51 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35302 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727555AbgIQOiV (ORCPT ); Thu, 17 Sep 2020 10:38:21 -0400 X-Greylist: delayed 1029 seconds by postgrey-1.27 at vger.kernel.org; Thu, 17 Sep 2020 10:38:21 EDT 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 08HE5J80048938; Thu, 17 Sep 2020 10:20:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=pp1; bh=pFzLdR4oh7vJzXza9CYBsTxnTeFiRc6b489PWMFCmhQ=; b=UK4j2/bdBgaFZJv32T9SHjYFfPMyUcaxDdZkfXW9A3hIj995knRWS7mknk/qRZLnoq90 jQm38RneC+P/cMgAwaN10/fVg6CIo06K9u798TWvsemc7LElmm8C83txw1vtqFw6rYHa RVREWG+pEQk5mtLTXnPVN5qws9YWD2c5A3v+lTrt3qdDiAPIOWbfnI2l/D7tpjazWFvd AeIiXD8Skcx92vY1wZD1q5W2xq1qS8ED4Gseo6LgbImwPavjkGkWtZZ+jL7fbJ2Aox+J N9Hra2ZrdTk7XiiL8ajpdARHjHW/kkt3yVqMv9avxe929WcP+nWxeXUnB9x44v0tZyjJ Gw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 33m92r8v30-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Sep 2020 10:20:54 -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 08HE5anx050067; Thu, 17 Sep 2020 10:20:54 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 33m92r8v2h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Sep 2020 10:20:54 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 08HEISc8021857; Thu, 17 Sep 2020 14:20:53 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma02wdc.us.ibm.com with ESMTP id 33k67c4w0e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Sep 2020 14:20:53 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 08HEKq7a55771482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Sep 2020 14:20:52 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A3DDAAC059; Thu, 17 Sep 2020 14:20:52 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6EFD1AC05B; Thu, 17 Sep 2020 14:20:49 +0000 (GMT) Received: from oc4221205838.ibm.com (unknown [9.163.85.51]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 17 Sep 2020 14:20:49 +0000 (GMT) From: Matthew Rosato To: alex.williamson@redhat.com, cohuck@redhat.com Cc: pmorel@linux.ibm.com, schnelle@linux.ibm.com, rth@twiddle.net, david@redhat.com, thuth@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, pbonzini@redhat.com, philmd@redhat.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [PATCH v4 0/5] s390x/pci: Accomodate vfio DMA limiting Date: Thu, 17 Sep 2020 10:20:40 -0400 Message-Id: <1600352445-21110-1-git-send-email-mjrosato@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-17_09:2020-09-16,2020-09-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 clxscore=1015 suspectscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009170104 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Kernel commit 492855939bdb added a limit to the number of outstanding DMA requests for a type1 vfio container. However, lazy unmapping in s390 can in fact cause quite a large number of outstanding DMA requests to build up prior to being purged, potentially the entire guest DMA space. This results in unexpected 'VFIO_MAP_DMA failed: No space left on device' conditions seen in QEMU. This patchset adds support to qemu to retrieve the number of allowable DMA requests via the VFIO_IOMMU_GET_INFO ioctl. The patches are separated into vfio hits which add support for reading in VFIO_IOMMU_GET_INFO capability chains and getting the per-container dma_avail value, and s390 hits to track DMA usage on a per-container basis. Associated kernel patch: https://marc.info/?l=kvm&m=160019703922812&w=2 Changes from v3: - Patch 2,3: Added RBs provided (thank you!) - Patch 4: retry the ioctl in the same manner as vfio_get_region_info - Patch 5: switch to static inline functions - Patch 5: relocate more code to s390-pci-vfio.* Matthew Rosato (5): linux-headers: update against 5.9-rc5 vfio: Create shared routine for scanning info capabilities vfio: Find DMA available capability s390x/pci: Add routine to get the vfio dma available count s390x/pci: Honor DMA limits set by vfio hw/s390x/meson.build | 1 + hw/s390x/s390-pci-bus.c | 16 ++- hw/s390x/s390-pci-bus.h | 9 ++ hw/s390x/s390-pci-inst.c | 45 ++++++- hw/s390x/s390-pci-inst.h | 3 + hw/s390x/s390-pci-vfio.c | 96 ++++++++++++++ hw/s390x/s390-pci-vfio.h | 22 ++++ hw/vfio/common.c | 52 ++++++-- include/hw/vfio/vfio-common.h | 2 + include/standard-headers/drm/drm_fourcc.h | 140 +++++++++++++++++++++ include/standard-headers/linux/ethtool.h | 87 +++++++++++++ include/standard-headers/linux/input-event-codes.h | 3 +- include/standard-headers/linux/vhost_types.h | 11 ++ include/standard-headers/linux/virtio_9p.h | 4 +- include/standard-headers/linux/virtio_blk.h | 26 ++-- include/standard-headers/linux/virtio_config.h | 8 +- include/standard-headers/linux/virtio_console.h | 8 +- include/standard-headers/linux/virtio_net.h | 6 +- include/standard-headers/linux/virtio_scsi.h | 20 +-- linux-headers/asm-generic/unistd.h | 6 +- linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/kvm.h | 5 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-s390/kvm.h | 7 +- linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 1 + linux-headers/linux/kvm.h | 10 +- linux-headers/linux/vfio.h | 17 ++- linux-headers/linux/vhost.h | 2 + 35 files changed, 554 insertions(+), 62 deletions(-) create mode 100644 hw/s390x/s390-pci-vfio.c create mode 100644 hw/s390x/s390-pci-vfio.h