From mboxrd@z Thu Jan 1 00:00:00 1970 From: Weidong Han Subject: Re: [PATCH] VT-d: improve RMRR validity checking Date: Thu, 11 Mar 2010 16:30:05 +0800 Message-ID: <4B98AA0D.2070609@intel.com> References: <4B59098B.6000108@intel.com> <4B590FA4.4000008@jp.fujitsu.com> <4B59132B.40607@intel.com> <4B59188C.50901@jp.fujitsu.com> <4B59660F.4000909@intel.com> <7162ab21003091339i4adb8669safd5e074607386a2@mail.gmail.com> <4B9706B3.3050903@intel.com> <1268191101.3015.30.camel@2710p.home> <4B9711CF.7030908@intel.com> <1268192253.3015.37.camel@2710p.home> <4B971F57.9000903@intel.com> <1268196438.3015.56.camel@2710p.home> <4B974438.3050806@intel.com> <1268229408.14039.151.camel@8530w.home> <1268244414.14039.206.camel@8530w.home> <4B985150.1000001@intel.com> <1268274721.3015.64.camel@2710p.home> <4B986736.9000204@intel.com> <1268283150.3015.69.camel@2710p.home> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1268283150.3015.69.camel@2710p.home> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Alex Williamson Cc: "xen-devel@lists.xensource.com" , Noboru Iwamatsu , "Cihula, Joseph" , "Kay, Allen M" , "linux@eikelenboom.it" , "keir.fraser@eu.citrix.com" List-Id: xen-devel@lists.xenproject.org Alex Williamson wrote: > On Thu, 2010-03-11 at 11:44 +0800, Weidong Han wrote: > >> good suggestion to check the device type. I cooked a new patch. It skips >> checking IOAPIC and HPET. pls have a try. >> > > I like this approach better, but the patch doesn't work as is. The > problem is acpi_scope is getting incremented as a structure instead of > by length bytes. It either needs to be cast on the increment, or maybe > cast on use like this: > > Signed-off-by: Alex Williamson > > diff -r 132ac04cbdba xen/drivers/passthrough/vtd/dmar.c > --- a/xen/drivers/passthrough/vtd/dmar.c Tue Mar 09 18:18:19 2010 +0000 > +++ b/xen/drivers/passthrough/vtd/dmar.c Wed Mar 10 21:46:49 2010 -0700 > @@ -407,9 +407,15 @@ > { > u8 b, d, f; > int i, invalid_cnt = 0; > + void *p; > > - for ( i = 0; i < dmaru->scope.devices_cnt; i++ ) > + for ( i = 0, p = dev_scope_start; i < dmaru->scope.devices_cnt; > + i++, p += ((struct acpi_dev_scope *)p)->length ) > { > + if ( ((struct acpi_dev_scope *)p)->dev_type == ACPI_DEV_IOAPIC || > + ((struct acpi_dev_scope *)p)->dev_type == ACPI_DEV_MSI_HPET ) > + continue; > + > b = PCI_BUS(dmaru->scope.devices[i]); > d = PCI_SLOT(dmaru->scope.devices[i]); > f = PCI_FUNC(dmaru->scope.devices[i]); > Acked-by: Weidong Han Regards, Weidong > > >> diff -r cadf1bae9ee2 xen/drivers/passthrough/vtd/dmar.c >> --- a/xen/drivers/passthrough/vtd/dmar.c Thu Feb 25 18:26:45 2010 +0800 >> +++ b/xen/drivers/passthrough/vtd/dmar.c Thu Mar 11 19:39:45 2010 +0800 >> @@ -407,9 +407,15 @@ acpi_parse_one_drhd(struct acpi_dmar_ent >> { >> u8 b, d, f; >> int i, invalid_cnt = 0; >> + struct acpi_dev_scope *acpi_scope = dev_scope_start; >> >> for ( i = 0; i < dmaru->scope.devices_cnt; i++ ) >> { >> + acpi_scope += (i == 0) ? 0 : acpi_scope->length; >> + if ( acpi_scope->dev_type == ACPI_DEV_IOAPIC || >> + acpi_scope->dev_type == ACPI_DEV_MSI_HPET ) >> + continue; >> + >> b = PCI_BUS(dmaru->scope.devices[i]); >> d = PCI_SLOT(dmaru->scope.devices[i]); >> f = PCI_FUNC(dmaru->scope.devices[i]); >> >> >> > > >