From patchwork Mon Feb 27 01:45:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Gao X-Patchwork-Id: 9592839 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AB72E60578 for ; Mon, 27 Feb 2017 08:50:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1E3428454 for ; Mon, 27 Feb 2017 08:50:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 967CD28452; Mon, 27 Feb 2017 08:50:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 44A4428456 for ; Mon, 27 Feb 2017 08:50:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ciGyc-0005sT-Fw; Mon, 27 Feb 2017 08:48:14 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ciGyb-0005rT-PB for xen-devel@lists.xen.org; Mon, 27 Feb 2017 08:48:13 +0000 Received: from [85.158.137.68] by server-16.bemta-3.messagelabs.com id D0/4F-21625-DC7E3B85; Mon, 27 Feb 2017 08:48:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRWlGSWpSXmKPExsXS1taRonvm+eY IgxuHrSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oz+i61MBTs4Kzr6P7A0MD5m62Lk5BASqJRY 8LCZBcSWEOCVOLJsBiuEHSCx8vFSVoiacol9bUfB6tkElCUufu0Fs0UEpCWufb7M2MXIxcEsc JxJ4trVeYwgCWEBP4lzX6eAFbEIqErsXLyWHcTmFXCSODLvODPEAgWJKQ/fg9mcAs4St7d0QS 1zkrg84RnjBEbeBYwMqxg1ilOLylKLdI3M9JKKMtMzSnITM3N0DQ2M9XJTi4sT01NzEpOK9ZL zczcxAsOhnoGBcQdjw16/Q4ySHExKoryLjDdGCPEl5adUZiQWZ8QXleakFh9ilOHgUJLgPf5s c4SQYFFqempFWmYOMDBh0hIcPEoivBtB0rzFBYm5xZnpEKlTjIpS4ryHQBICIImM0jy4Nlg0X GKUlRLmZWRgYBDiKUgtys0sQZV/xSjOwagkzLsFZApPZl4J3PRXQIuZgBbPBrmZt7gkESEl1c AYf85+2t+UasnGoqYH01N5VbgMEg3/tN29o9abllAq9IZbPeCy8pGAhR+c76qlyAU0tlaUP7H v2jtVP1Z1d9K+lYmf0rZuTQ+QWRC9unnGi5qadbf59/Dazm+8usil5Zf193bLHW/vTrziHv9z bw0D6y7tBt1k802GzvXh/QEpXTnPVVrfByuxFGckGmoxFxUnAgDlxDOTgQIAAA== X-Env-Sender: chao.gao@intel.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1488185284!29477171!3 X-Originating-IP: [134.134.136.100] X-SpamReason: No, hits=0.8 required=7.0 tests=DATE_IN_PAST_06_12 X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39238 invoked from network); 27 Feb 2017 08:48:12 -0000 Received: from mga07.intel.com (HELO mga07.intel.com) (134.134.136.100) by server-4.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 27 Feb 2017 08:48:12 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP; 27 Feb 2017 00:48:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.35,213,1484035200"; d="scan'208"; a="1135354057" Received: from skl-2s3.sh.intel.com ([10.239.48.35]) by fmsmga002.fm.intel.com with ESMTP; 27 Feb 2017 00:48:10 -0800 From: Chao Gao To: xen-devel@lists.xen.org Date: Mon, 27 Feb 2017 09:45:43 +0800 Message-Id: <1488159949-15011-3-git-send-email-chao.gao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1488159949-15011-1-git-send-email-chao.gao@intel.com> References: <1488159949-15011-1-git-send-email-chao.gao@intel.com> Cc: Kevin Tian , Jun Nakajima , George Dunlap , Andrew Cooper , Dario Faggioli , Jan Beulich , Chao Gao Subject: [Xen-devel] [PATCH v9 2/8] xen/passthrough: Reject self-(de)assignment of devices X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP That is to say, don't support a domain assigns a device to itself or detachs a device from itself. Signed-off-by: Chao Gao Acked-by: Jan Beulich --- v9: - Newly added xen/drivers/passthrough/pci.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 338d6b4..a80d59e 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -1603,6 +1603,13 @@ int iommu_do_pci_domctl( break; case XEN_DOMCTL_assign_device: + /* Don't support self-(de)assignment of devices */ + if ( d == current->domain ) + { + ret = -EINVAL; + break; + } + ret = -ENODEV; if ( domctl->u.assign_device.dev != XEN_DOMCTL_DEV_PCI ) break; @@ -1643,6 +1650,13 @@ int iommu_do_pci_domctl( break; case XEN_DOMCTL_deassign_device: + /* Don't support self-(de)assignment of devices */ + if ( d == current->domain ) + { + ret = -EINVAL; + break; + } + ret = -ENODEV; if ( domctl->u.assign_device.dev != XEN_DOMCTL_DEV_PCI ) break;