From: Konrad Rzeszutek Wilk Subject: Re: [PATCH] AMD IOMMU: only translate remapped IO-APIC RTEs Date: Thu, 23 Apr 2015 14:06:21 -0400 Message-ID: <20150423180621.GB12600@l.oracle.com> References: <5539140002000078000752D8@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YlLWF-0003gg-11 for xen-devel@lists.xenproject.org; Thu, 23 Apr 2015 18:06:35 +0000 Content-Disposition: inline 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: "Suthikulpanit, Suravee" Cc: SanderEikelenboom , Tim Deegan , "Gopalakrishnan, Aravind" , Jan Beulich , xen-devel List-Id: xen-devel@lists.xenproject.org On Thu, Apr 23, 2015 at 05:51:05PM +0000, Suthikulpanit, Suravee wrote: > = > = > On 4/23/15, 08:47, "Jan Beulich" wrote: > = > >>>> On 23.04.15 at 15:31, wrote: > > > >> = > >> On 4/17/15, 10:27, "Jan Beulich" wrote: > >> = > >>>1aeb1156fa ("x86 don't change affinity with interrupt unmasked") > >>>introducing RTE reads prior to the respective interrupt having got > >>>enabled for the first time uncovered a bug in 2ca9fbd739 ("AMD IOMMU: > >>>allocate IRTE entries instead of using a static mapping"): We obviously > >>>shouldn't be translating RTEs for which remapping didn't get set up > >>>yet. > >>> > >>>Reported-by: Sander Eikelenboom > >>>Signed-off-by: Jan Beulich > >>> > >>>--- a/xen/drivers/passthrough/amd/iommu_intr.c > >>>+++ b/xen/drivers/passthrough/amd/iommu_intr.c > >>>@@ -365,15 +365,17 @@ unsigned int amd_iommu_read_ioapic_from_ > >>> unsigned int apic, unsigned int reg) > >>> { > >>> unsigned int val =3D __io_apic_read(apic, reg); > >>>+ unsigned int pin =3D (reg - 0x10) / 2; > >>>+ unsigned int offset =3D ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx[p= in]; > >>> = > >>>- if ( !(reg & 1) ) > >>>+ if ( !(reg & 1) && offset < INTREMAP_ENTRIES ) > >>> { > >>>- unsigned int offset =3D val & (INTREMAP_ENTRIES - 1); > >>> u16 bdf =3D ioapic_sbdf[IO_APIC_ID(apic)].bdf; > >>> u16 seg =3D ioapic_sbdf[IO_APIC_ID(apic)].seg; > >>> u16 req_id =3D get_intremap_requestor_id(seg, bdf); > >>> const u32 *entry =3D get_intremap_entry(seg, req_id, offset); > >>> = > >>>+ ASSERT(offset =3D=3D (val & (INTREMAP_ENTRIES - 1))); > >> = > >> Jan, could you please explain why the ASSERT is needed here? > > > >The previous value "offset" got assigned was calculated using > >the right side expression. I.e. the assert makes sure that what > >we used before and what we use now is the same. > > > >Jan > = > Jan, > = > I have tested this patch w/ staging branch booting Dom0, and this patch > got rid of the following error from xl dmesg: > (XEN) APIC error on CPU0: 00(40) > (XEN) APIC error on CPU2: 00(40) > = > However, when I tried starting a guest w/ PCI device passthrough, the > system crashed and reboot. Although, I don=B9t think this is caused by the > patch. = Is it by any chance " BUG at iommu_map.c:455" ? > = > Acked-by: Suravee Suthikulpanit > = > I=B9m looking into the issue. I also went back and tested it with 4.5 on = the > same setup and didn=B9t see the issue. > = > = > Thanks, > Suravee > = > = > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel