From patchwork Wed Dec 14 21:24:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 13073584 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3BC4C25B04 for ; Wed, 14 Dec 2022 21:25:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229798AbiLNVZO (ORCPT ); Wed, 14 Dec 2022 16:25:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbiLNVZD (ORCPT ); Wed, 14 Dec 2022 16:25:03 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB0A836D4B for ; Wed, 14 Dec 2022 13:25:02 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BELOJIo028777; Wed, 14 Dec 2022 21:24:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2022-7-12; bh=T7tNWcmTN8pqd2oZ/AD+r2Sev6BBX2Bt0pcO1iurtUk=; b=p7Gjs5y+G1GIqGgiBDMRC2j5+Wwh27htHOu9iyyAX6ZPC0VGnvHfYyf9TYEuH7tY27Dj 9VpkAsrA+lQikecVFZrZ91ibybMDLgHsu6uMXCwNSOXOrej2M1Dwq1ukb+eXtDGw3GtS Oz4iNhTiQEpqjCdyQfsCfHKdikXezKww9zECnkzlusIbfJJZEi108nDDkyyO1a8gQ1FQ tYLxKsTSXe3HOm/5rZg1QbGLk9wOAZAKlnbqieBTLdqJmjZTJA7MdargHTWFQvQqN4D5 ybnUHHaPlXrVHZliitbYCYBT2Jtixj9yvzsqFzCjIbO+uwyaCH8vRpToKTJav2uaVI7h YQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3meyeu3f08-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Dec 2022 21:24:59 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2BEL11SM003996; Wed, 14 Dec 2022 21:24:59 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3meyewpxjj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Dec 2022 21:24:59 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2BELOwGA024340; Wed, 14 Dec 2022 21:24:58 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3meyewpxhh-1; Wed, 14 Dec 2022 21:24:58 +0000 From: Steve Sistare To: kvm@vger.kernel.org Cc: Alex Williamson , Cornelia Huck , Jason Gunthorpe , Steve Sistare Subject: [PATCH V4 0/5] fixes for virtual address update Date: Wed, 14 Dec 2022 13:24:52 -0800 Message-Id: <1671053097-138498-1-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-14_11,2022-12-14_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212140175 X-Proofpoint-ORIG-GUID: V8k5Ya9xmunqIMyFSz5WIyTivtQJBX8l X-Proofpoint-GUID: V8k5Ya9xmunqIMyFSz5WIyTivtQJBX8l Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Fix bugs in the interfaces that allow the underlying memory object of an iova range to be mapped in a new address space. They allow userland to indefinitely block vfio mediated device kernel threads, and do not propagate the locked_vm count to a new mm. The fixes impose restrictions that eliminate waiting conditions, so revert the dead code: commit 898b9eaeb3fe ("vfio/type1: block on invalid vaddr") commit 487ace134053 ("vfio/type1: implement notify callback") commit ec5e32940cc9 ("vfio: iommu driver notify callback") Changes in V2 (thanks Alex): * do not allow group attach while vaddrs are invalid * add patches to delete dead code * add WARN_ON for never-should-happen conditions * check for changed mm in unmap. * check for vfio_lock_acct failure in remap Changes in V3 (ditto!): * return errno at WARN_ON sites, and make it unique * correctly check for dma task mm change * change dma owner to current when vaddr is updated * add Fixes to commit messages * refactored new code in vfio_dma_do_map Changes in V4: * misc cosmetic changes Steve Sistare (5): vfio/type1: exclude mdevs from VFIO_UPDATE_VADDR vfio/type1: prevent locked_vm underflow vfio/type1: revert "block on invalid vaddr" vfio/type1: revert "implement notify callback" vfio: revert "iommu driver notify callback" drivers/vfio/container.c | 5 - drivers/vfio/vfio.h | 7 -- drivers/vfio/vfio_iommu_type1.c | 199 +++++++++++++++++++--------------------- include/uapi/linux/vfio.h | 15 +-- 4 files changed, 103 insertions(+), 123 deletions(-)