From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Chen, Tiejun" Subject: Re: [v3][PATCH 16/16] xen/vtd: prevent from assign the device with shared rmrr Date: Fri, 12 Jun 2015 16:44:21 +0800 Message-ID: <557A9BE5.4090206@intel.com> References: <1433985325-16676-1-git-send-email-tiejun.chen@intel.com> <1433985325-16676-17-git-send-email-tiejun.chen@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: "Tian, Kevin" , "jbeulich@suse.com" , "tim@xen.org" , "andrew.cooper3@citrix.com" , "Zhang, Yang Z" , "wei.liu2@citrix.com" , "ian.campbell@citrix.com" , "Ian.Jackson@eu.citrix.com" , "stefano.stabellini@citrix.com" Cc: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On 2015/6/11 18:25, Tian, Kevin wrote: >> From: Chen, Tiejun >> Sent: Thursday, June 11, 2015 9:15 AM >> >> Currently we're intending to cover this kind of devices > > we're -> we're not? I mean currently we want to handle this shared case *simply* so I think its still "we're", right? > >> with shared RMRR simply since the case of shared RMRR is >> a rare case according to our previous experiences. But >> late we can group these devices which shared rmrr, and >> then allow all devices within a group to be assigned to >> same domain. >> >> Signed-off-by: Tiejun Chen > > Acked-by: Kevin Tian except one text > comment. > >> --- >> xen/drivers/passthrough/vtd/iommu.c | 30 >> +++++++++++++++++++++++++++--- >> 1 file changed, 27 insertions(+), 3 deletions(-) >> >> diff --git a/xen/drivers/passthrough/vtd/iommu.c >> b/xen/drivers/passthrough/vtd/iommu.c >> index d3233b8..f220081 100644 >> --- a/xen/drivers/passthrough/vtd/iommu.c >> +++ b/xen/drivers/passthrough/vtd/iommu.c >> @@ -2277,13 +2277,37 @@ 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: actually we can group these devices which shared rmrr, and >> + * then allow all devices within a group to be assigned to same domain. > > TODO: in the future we can introduce group device assignment > interface to make sure devices sharing RMRR are assigned to the > same domain together. Thank you to rephrase this. Tiejun > >> + */ >> + 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 ) >> + { >> + ret = -EPERM; >> + printk(XENLOG_G_ERR VTDPREFIX >> + " cannot assign this device with shared RMRR for Dom%d (%d)\n", >> + d->domain_id, ret); >> + return ret; >> + } >> + } >> + } >> + >> ret = reassign_device_ownership(hardware_domain, d, devfn, pdev); >> if ( ret ) >> return ret; >> >> - seg = pdev->seg; >> - bus = pdev->bus; >> - >> /* Setup rmrr identity mapping */ >> for_each_rmrr_device( rmrr, bdf, i ) >> { >> -- >> 1.9.1 > >