From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9963FC433E1 for ; Fri, 3 Jul 2020 03:48:00 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6EF4E20C56 for ; Fri, 3 Jul 2020 03:48:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=intel.onmicrosoft.com header.i=@intel.onmicrosoft.com header.b="FFDA2TjL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6EF4E20C56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 6281B87C81; Fri, 3 Jul 2020 03:48:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OXLt8vAH8DIB; Fri, 3 Jul 2020 03:47:59 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id B70DD87A05; Fri, 3 Jul 2020 03:47:59 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A41A9C0888; Fri, 3 Jul 2020 03:47:59 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id B6E6DC0733 for ; Fri, 3 Jul 2020 03:47:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id A41FB88C56 for ; Fri, 3 Jul 2020 03:47:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BD6omC0sV52X for ; Fri, 3 Jul 2020 03:47:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by whitealder.osuosl.org (Postfix) with ESMTPS id BC49986C34 for ; Fri, 3 Jul 2020 03:47:55 +0000 (UTC) IronPort-SDR: OK325U59JRoptOahgqE5gshvLPbdKcWYGfeG/GtblLz91IYdlVd0QynytmTDry/odYaFL0O3jN NBK00RnhwfMg== X-IronPort-AV: E=McAfee;i="6000,8403,9670"; a="165143697" X-IronPort-AV: E=Sophos;i="5.75,306,1589266800"; d="scan'208";a="165143697" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 20:47:55 -0700 IronPort-SDR: NHlSew2WVAObW6PUwpn6BR0RxDE1nGnYjgIdOYdNI1WXq5+oDDCQbOcMtLaDy2Co6qcqvr2Rz0 X7Fqr/X9QAaA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,306,1589266800"; d="scan'208";a="322296027" Received: from orsmsx108.amr.corp.intel.com ([10.22.240.6]) by orsmga007.jf.intel.com with ESMTP; 02 Jul 2020 20:47:55 -0700 Received: from orsmsx159.amr.corp.intel.com (10.22.240.24) by ORSMSX108.amr.corp.intel.com (10.22.240.6) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 2 Jul 2020 20:47:54 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by ORSMSX159.amr.corp.intel.com (10.22.240.24) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 2 Jul 2020 20:47:54 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.46) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 2 Jul 2020 20:47:54 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CxIQqYduZOymK5ePbSS7KZ7f5J+RI3oMI/5CwLZf5Yxa78/uLO6r01pQeq+xADoA6Yna9T9KxZfxlD1vsd2evGgjJpMoqYiS3/foAD++m2brpY0t23FK18bXDsQOJKLFg4e9Ql9AtvQCkMC26aq9+1ZcvWePKOkYZReJqJqL2cVP9oOJQi/N6pw1HN2+3DL7ZRrtPPJBAgvKr9wOoy0W6sgLghzkHGCzGJLpVHEBmVs+4iIQ8hJtqQN5r3akCnqVJ9FVFuKhYP2FvHNa/MOYlbycbrikCWr2jWdOIhaa6OoLRx4VCeV87mw2HOsDMY1foqNoK52qACCdPq5XbinFfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dPCx35ypU/85vmciz/rik3BuObPJp1GVePHAzBnEGyY=; b=HP5ZV31+T+v4+4Zeibb3bVUCtk2hfLvBOT7LRX6GIbS8GLdUwRO7QFITJyUxYnDWqEH8kp7LuIHUFRiM1LR5sg1rjUDXEEx/EzC6uhsUE/Jxqoa4SCzur+SFRWnzJRj2TYdFE92iVbKg1hyqjzQ6eMSICSGtjTtdr5Z1k39cueCv8C67mTAyfE7xadgq5x+uKJLmLv1pKQA5lJcrH68ofVRuA3+8xGwOjLlOq6dKnZmrZrFkXmLk072B6drMbJuatVS0Cix9hhTgoBqFm6Z2XuZBHgjizkJZ3CDuGErXQSgDzHvSBynXccIp7MvEvBBhL87BHT7tGPGcZlG+SF71cQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dPCx35ypU/85vmciz/rik3BuObPJp1GVePHAzBnEGyY=; b=FFDA2TjLycvLM3jcAMoClv0fycT6Pmeq2TDRBKgR0X9bp36lcadP0StvlH/6erhKKthQZP8GRGgzNzLtfdvZiQroxfVtxQ3A8Kuzuz8hMMPsthYHOcehcwvrTrndltBLqKt+7Pf+H0NMZ78WpF4DSi3MX+lPMfXA7OldTmGSn/U= Received: from DM5PR11MB1435.namprd11.prod.outlook.com (2603:10b6:4:7::18) by DM6PR11MB4076.namprd11.prod.outlook.com (2603:10b6:5:197::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Fri, 3 Jul 2020 03:47:53 +0000 Received: from DM5PR11MB1435.namprd11.prod.outlook.com ([fe80::2c3d:98d9:4e81:c86c]) by DM5PR11MB1435.namprd11.prod.outlook.com ([fe80::2c3d:98d9:4e81:c86c%6]) with mapi id 15.20.3131.033; Fri, 3 Jul 2020 03:47:53 +0000 From: "Liu, Yi L" To: Alex Williamson Subject: RE: [PATCH v3 10/14] vfio/type1: Allow invalidating first-level/stage IOMMU cache Thread-Topic: [PATCH v3 10/14] vfio/type1: Allow invalidating first-level/stage IOMMU cache Thread-Index: AQHWSgRSMvsXtUpGHUCWFHE3eZ3aa6j02QoAgABsIQA= Date: Fri, 3 Jul 2020 03:47:52 +0000 Message-ID: References: <1592988927-48009-1-git-send-email-yi.l.liu@intel.com> <1592988927-48009-11-git-send-email-yi.l.liu@intel.com> <20200702151958.430a979d@x1.home> In-Reply-To: <20200702151958.430a979d@x1.home> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.2.0.6 dlp-product: dlpe-windows authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.205] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 204832c0-9804-4b19-d5ac-08d81f03dd53 x-ms-traffictypediagnostic: DM6PR11MB4076: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6108; x-forefront-prvs: 045315E1EE x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: W5BJfzt/O7qE6xXgtyIG0n3aCLyMaBmzH83cc7yLAXLbZyyACFo7MvgrJYQ9WJOfYNhHjcWBY+EDB9INSXLAtGOH+8OJ2yZiTeQbu9w6eM2Wb+ziML3J3WgiEWj5SVmBwQQ3EE/TCiDfYCIPSv0Q1telGjQ4uzfEpHKC1sTApCR9b3HE3Jom0bprQ/rjUlOH1XktjHpLXITPpKyzhg+80pzZ/S1mC4+B3s5tYy832x3y1tF+vkNOJvzgBbH44QPKz07GA285LowfvbEmhZxu9rQsgduMFXbW9rVapJO3TSE1eYmD/as9knWZtEWZaXfUgZA0FhVVzRtHk3wGlV1gkg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR11MB1435.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(52536014)(7696005)(186003)(76116006)(2906002)(54906003)(86362001)(66476007)(5660300002)(316002)(66946007)(478600001)(33656002)(66446008)(64756008)(66556008)(6506007)(26005)(8676002)(6916009)(8936002)(83380400001)(7416002)(55016002)(71200400001)(9686003)(4326008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: n3CDPsyNqjYNAgCE94TlALuXwAWh5fw6+K788pkVt5GvaxAmq48ZLWYACmP2W9gOYjhHN1+eiH1reqly1Xh8rE6P3TKPJa+svc+l+ZLZ2EAIft3cRY3HMpRzC9TaBl+M7KaYqFPCC/PY8dLcrexlZBVKI4/XVIgTLk/IRGeKmq1eDIDoBKYqiLNbHSGnsZMvyxxYA8e4HFPD6ThItRsgnGEymVYEaSHosG8PJvBSICUvh1JkBBwUp6HSq7MQkFxQNIkM9vZ1+BNWaY9vq+Xq/172zMKoUB1Aa/sh24uQgajS6tKQ3bOPkv0kkYw4OXhHjnKgCfkzl9TlWhPpSCJWtImrtJVVeRT9T0r6wJ4hx4zDBdNIW2u02wn+obvpZmqSDq24ahAkfLYXeqdCLTHmOGJVdg6vM9l8B7YLywpsQDMf/YFO5wK8Jso27q3u3OwGZ1qYRWZD3S/MVCqDxanHYPd0X8Cq3Zt4lB+3NA7MBzwAQNTXefGZVg14RJubtYUv MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM5PR11MB1435.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 204832c0-9804-4b19-d5ac-08d81f03dd53 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jul 2020 03:47:52.9817 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: la1GVbMa3ImeL5r6UEAuuOgJE6vFWWTLLh8Kclc3Y/2i+zKKD/IJ2i6RN8KJL2qCUMAPrPXYLE6B6lvD58XHGA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4076 X-OriginatorOrg: intel.com Cc: "jean-philippe@linaro.org" , "Tian, Kevin" , "Raj, Ashok" , "kvm@vger.kernel.org" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "Sun, Yi Y" , "Wu, Hao" , "Tian, Jun J" X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" > From: Williamson < alex.williamson@redhat.com > > Sent: Friday, July 3, 2020 5:20 AM > > On Wed, 24 Jun 2020 01:55:23 -0700 > Liu Yi L wrote: > > > This patch provides an interface allowing the userspace to invalidate > > IOMMU cache for first-level page table. It is required when the first > > level IOMMU page table is not managed by the host kernel in the nested > > translation setup. > > > > Cc: Kevin Tian > > CC: Jacob Pan > > Cc: Alex Williamson > > Cc: Eric Auger > > Cc: Jean-Philippe Brucker > > Cc: Joerg Roedel > > Cc: Lu Baolu > > Signed-off-by: Liu Yi L > > Signed-off-by: Eric Auger > > Signed-off-by: Jacob Pan > > --- > > v1 -> v2: > > *) rename from "vfio/type1: Flush stage-1 IOMMU cache for nesting type" > > *) rename vfio_cache_inv_fn() to vfio_dev_cache_invalidate_fn() > > *) vfio_dev_cache_inv_fn() always successful > > *) remove VFIO_IOMMU_CACHE_INVALIDATE, and reuse > VFIO_IOMMU_NESTING_OP > > --- > > drivers/vfio/vfio_iommu_type1.c | 52 > +++++++++++++++++++++++++++++++++++++++++ > > include/uapi/linux/vfio.h | 3 +++ > > 2 files changed, 55 insertions(+) > > > > diff --git a/drivers/vfio/vfio_iommu_type1.c > > b/drivers/vfio/vfio_iommu_type1.c index 5926533..4c21300 100644 > > --- a/drivers/vfio/vfio_iommu_type1.c > > +++ b/drivers/vfio/vfio_iommu_type1.c > > @@ -3080,6 +3080,53 @@ static long vfio_iommu_handle_pgtbl_op(struct > vfio_iommu *iommu, > > return ret; > > } > > > > +static int vfio_dev_cache_invalidate_fn(struct device *dev, void > > +*data) { > > + struct domain_capsule *dc = (struct domain_capsule *)data; > > + unsigned long arg = *(unsigned long *) dc->data; > > + > > + iommu_cache_invalidate(dc->domain, dev, (void __user *) arg); > > + return 0; > > +} > > + > > +static long vfio_iommu_invalidate_cache(struct vfio_iommu *iommu, > > + unsigned long arg) > > +{ > > + struct domain_capsule dc = { .data = &arg }; > > + struct vfio_group *group; > > + struct vfio_domain *domain; > > + int ret = 0; > > + struct iommu_nesting_info *info; > > + > > + mutex_lock(&iommu->lock); > > + /* > > + * Cache invalidation is required for any nesting IOMMU, > > + * so no need to check system-wide PASID support. > > + */ > > + info = iommu->nesting_info; > > + if (!info || !(info->features & IOMMU_NESTING_FEAT_CACHE_INVLD)) { > > + ret = -ENOTSUPP; > > + goto out_unlock; > > + } > > + > > + group = vfio_find_nesting_group(iommu); > > + if (!group) { > > + ret = -EINVAL; > > + goto out_unlock; > > + } > > + > > + domain = list_first_entry(&iommu->domain_list, > > + struct vfio_domain, next); > > + dc.group = group; > > + dc.domain = domain->domain; > > + iommu_group_for_each_dev(group->iommu_group, &dc, > > + vfio_dev_cache_invalidate_fn); > > + > > +out_unlock: > > + mutex_unlock(&iommu->lock); > > + return ret; > > +} > > + > > static long vfio_iommu_type1_nesting_op(struct vfio_iommu *iommu, > > unsigned long arg) > > { > > @@ -3102,6 +3149,11 @@ static long vfio_iommu_type1_nesting_op(struct > vfio_iommu *iommu, > > case VFIO_IOMMU_NESTING_OP_UNBIND_PGTBL: > > ret = vfio_iommu_handle_pgtbl_op(iommu, false, arg + minsz); > > break; > > + case VFIO_IOMMU_NESTING_OP_CACHE_INVLD: > > + { > > + ret = vfio_iommu_invalidate_cache(iommu, arg + minsz); > > + break; > > + } > > > Why the {} brackets? Thanks, should be removed. will do it. Regards, Yi Liu > Alex > > > > default: > > ret = -EINVAL; > > } > > diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h > > index 2c9def8..7f8678e 100644 > > --- a/include/uapi/linux/vfio.h > > +++ b/include/uapi/linux/vfio.h > > @@ -1213,6 +1213,8 @@ struct vfio_iommu_type1_pasid_request { > > * +-----------------+-----------------------------------------------+ > > * | UNBIND_PGTBL | struct iommu_gpasid_bind_data | > > * > > +-----------------+-----------------------------------------------+ > > + * | CACHE_INVLD | struct iommu_cache_invalidate_info | > > + * > > + +-----------------+-----------------------------------------------+ > > * > > * returns: 0 on success, -errno on failure. > > */ > > @@ -1225,6 +1227,7 @@ struct vfio_iommu_type1_nesting_op { > > > > #define VFIO_IOMMU_NESTING_OP_BIND_PGTBL (0) > > #define VFIO_IOMMU_NESTING_OP_UNBIND_PGTBL (1) > > +#define VFIO_IOMMU_NESTING_OP_CACHE_INVLD (2) > > > > #define VFIO_IOMMU_NESTING_OP _IO(VFIO_TYPE, > VFIO_BASE + 19) > > _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu