From: "Jan Beulich" Subject: RE: [PATCH] VT-d: don't reject possibly valid DRHD or RMRR Date: Fri, 07 Oct 2011 08:17:34 +0100 Message-ID: <4E8EC3AE0200007800059E25@nat28.tlf.novell.com> References: <4E8B0A5F0200007800059286@nat28.tlf.novell.com> <987664A83D2D224EAE907B061CE93D5301EE709B4D@orsmsx505.amr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <987664A83D2D224EAE907B061CE93D5301EE709B4D@orsmsx505.amr.corp.intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Allen M Kay Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org >>> On 07.10.11 at 03:51, "Kay, Allen M" wrote: > For RMRR case, looks like you miss the following change (or something=20 > similar): >=20 > -for ( i =3D 0; i < rmrru->scope.devices_cnt; i++ ) > +for (; i < rmrru->scope.devices_cnt; i++ ) Indeed. > Otherwise, the logic for handling non-zero PCI segments looks reasonable.= So do I take this as an acked-by-with-above-change? > Allen >=20 > -----Original Message----- > From: Jan Beulich [mailto:JBeulich@suse.com]=20 > Sent: Tuesday, October 04, 2011 4:30 AM > To: xen-devel@lists.xensource.com=20 > Cc: Kay, Allen M > Subject: [PATCH] VT-d: don't reject possibly valid DRHD or RMRR >=20 > If a non-zero PCI segment isn't accessible during Xen boot (because > firmware decided to not enter the necessary MMIO space into the E820 > table), devices referred to on those segments through DRHD or RMRR > structures should not be rejected just because the devices can't be > found. >=20 > This is in line with what is being done in at least one other case > already: Systems with more than one PCI segment (usually high end > ones) are assumed to have valid firmware provided data, while systems > with just segment 0 continue to have their firmware tables validated. >=20 > Signed-off-by: Jan Beulich >=20 > --- a/xen/drivers/passthrough/pci.c > +++ b/xen/drivers/passthrough/pci.c > @@ -53,6 +53,11 @@ static inline struct pci_seg *get_pseg(u > return radix_tree_lookup(&pci_segments, seg); > } > =20 > +bool_t pci_known_segment(u16 seg) > +{ > + return get_pseg(seg) !=3D NULL; > +} > + > static struct pci_seg *alloc_pseg(u16 seg) > { > struct pci_seg *pseg =3D get_pseg(seg); > --- a/xen/drivers/passthrough/vtd/dmar.c > +++ b/xen/drivers/passthrough/vtd/dmar.c > @@ -444,10 +444,14 @@ acpi_parse_one_drhd(struct acpi_dmar_ent > else > { > u8 b, d, f; > - int i, invalid_cnt =3D 0; > + unsigned int i =3D 0, invalid_cnt =3D 0; > void *p; > =20 > - for ( i =3D 0, p =3D dev_scope_start; i < dmaru->scope.devices_c= nt; > + /* Skip checking if segment is not accessible yet. */ > + if ( !pci_known_segment(drhd->segment) ) > + i =3D UINT_MAX; > + > + for ( p =3D dev_scope_start; i < dmaru->scope.devices_cnt; > i++, p +=3D ((struct acpi_dev_scope *)p)->length ) > { > if ( ((struct acpi_dev_scope *)p)->dev_type =3D=3D = ACPI_DEV_IOAPIC || > @@ -549,7 +553,12 @@ acpi_parse_one_rmrr(struct acpi_dmar_ent > else > { > u8 b, d, f; > - int i, ignore =3D 0; > + bool_t ignore =3D 0; > + unsigned int i =3D 0; > + > + /* Skip checking if segment is not accessible yet. */ > + if ( !pci_known_segment(rmrr->segment) ) > + i =3D UINT_MAX; > =20 > for ( i =3D 0; i < rmrru->scope.devices_cnt; i++ ) > { > --- a/xen/include/xen/pci.h > +++ b/xen/include/xen/pci.h > @@ -82,6 +82,7 @@ enum { > DEV_TYPE_PCI, > }; > =20 > +bool_t pci_known_segment(u16 seg); > int pci_device_detect(u16 seg, u8 bus, u8 dev, u8 func); > int scan_pci_devices(void); > int pdev_type(u16 seg, u8 bus, u8 devfn);