From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [v7][PATCH 15/16] xen/vtd: prevent from assign the device with shared rmrr Date: Mon, 13 Jul 2015 14:41:29 +0100 Message-ID: <55A3DC29020000780009037A@mail.emea.novell.com> References: <1436420047-25356-1-git-send-email-tiejun.chen@intel.com> <1436420047-25356-16-git-send-email-tiejun.chen@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1436420047-25356-16-git-send-email-tiejun.chen@intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Tiejun Chen Cc: Yang Zhang , Kevin Tian , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 09.07.15 at 07:34, wrote: > --- a/xen/drivers/passthrough/vtd/iommu.c > +++ b/xen/drivers/passthrough/vtd/iommu.c > @@ -2297,13 +2297,39 @@ static int intel_iommu_assign_device( > if ( list_empty(&acpi_drhd_units) ) > return -ENODEV; > > + seg = pdev->seg; > + bus = pdev->bus; > + /* > + * In rare cases one given rmrr is shared by multiple devices but > + * obviously this would put the security of a system at risk. So > + * we should prevent from this sort of device assignment. > + * > + * TODO: in the future we can introduce group device assignment > + * interface to make sure devices sharing RMRR are assigned to the > + * same domain together. > + */ > + for_each_rmrr_device( rmrr, bdf, i ) > + { > + if ( rmrr->segment == seg && > + PCI_BUS(bdf) == bus && > + PCI_DEVFN2(bdf) == devfn ) > + { > + if ( rmrr->scope.devices_cnt > 1 ) > + { > + printk(XENLOG_G_ERR VTDPREFIX > + " cannot assign %04x:%02x:%02x.%u" > + " with shared RMRR for Dom%d.\n", > + seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), > + d->domain_id); > + return -EPERM; > + } > + } Two if()-s like these should be folded into one. In your place I'd also consider also printing the RMRR base address for easier analysis of the issue. Jan