AMD IOMMU: only translate remapped IO-APIC RTEs
PATCH 1/1 AMD IOMMU: only translate remapped IO-APIC RTEs
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.
xen/drivers/passthrough/amd/iommu_intr.c +4 -2
@@ -365,15 +365,17 @@ unsigned int amd_iommu_read_ioapic_from_ unsigned int apic, unsigned int reg) {unsigned int val =__io_apic_read (apic, reg); +unsigned int pin = (reg -0x10 ) /2 ; +unsigned int offset = ioapic_sbdf[IO_APIC_ID (apic)].pin_2_idx[pin]; -if ( !(reg &1 ) ) +if ( !(reg &1 ) && offset <INTREMAP_ENTRIES ) { -unsigned int offset = val & (INTREMAP_ENTRIES -1 );u16 bdf = ioapic_sbdf[IO_APIC_ID (apic)].bdf;u16 seg = ioapic_sbdf[IO_APIC_ID (apic)].seg;u16 req_id =get_intremap_requestor_id (seg, bdf);const u32 *entry =get_intremap_entry (seg, req_id, offset); +ASSERT (offset == (val & (INTREMAP_ENTRIES -1 ))); val &= ~(INTREMAP_ENTRIES -1 ); val |= get_field_from_reg_u32(*entry, INT_REMAP_ENTRY_INTTYPE_MASK,
AMD IOMMU: only translate remapped IO-APIC RTEs
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.
xen/drivers/passthrough/amd/iommu_intr.c +4 -2
@@ -365,15 +365,17 @@ unsigned int amd_iommu_read_ioapic_from_ unsigned int apic, unsigned int reg) {unsigned int val =__io_apic_read (apic, reg); +unsigned int pin = (reg -0x10 ) /2 ; +unsigned int offset = ioapic_sbdf[IO_APIC_ID (apic)].pin_2_idx[pin]; -if ( !(reg &1 ) ) +if ( !(reg &1 ) && offset <INTREMAP_ENTRIES ) { -unsigned int offset = val & (INTREMAP_ENTRIES -1 );u16 bdf = ioapic_sbdf[IO_APIC_ID (apic)].bdf;u16 seg = ioapic_sbdf[IO_APIC_ID (apic)].seg;u16 req_id =get_intremap_requestor_id (seg, bdf);const u32 *entry =get_intremap_entry (seg, req_id, offset); +ASSERT (offset == (val & (INTREMAP_ENTRIES -1 ))); val &= ~(INTREMAP_ENTRIES -1 ); val |= get_field_from_reg_u32(*entry, INT_REMAP_ENTRY_INTTYPE_MASK,
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 19 lines · Jan Beulich
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 in2ca9fbd739("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 <[email protected]>Signed-off-by Jan Beulich <[email protected]>xen/drivers/passthrough/amd/iommu_intr.c +2
-0@@ -365,15 +365,17 @@ unsigned int amd_iommu_read_ioapic_from_ unsigned int apic, unsigned int reg) {unsigned int val =__io_apic_read (apic, reg); +unsigned int pin = (reg -0x10 ) /2 ; +unsigned int offset = ioapic_sbdf[IO_APIC_ID (apic)].pin_2_idx[pin];
xen/drivers/passthrough/amd/iommu_intr.c unsigned int amd_iommu_read_ioapic_from_ · line 378
Quoted 10 lines
xen/drivers/passthrough/amd/iommu_intr.c +2
-2-if ( !(reg &1 ) ) +if ( !(reg &1 ) && offset <INTREMAP_ENTRIES ) { -unsigned int offset = val & (INTREMAP_ENTRIES -1 );u16 bdf = ioapic_sbdf[IO_APIC_ID (apic)].bdf;u16 seg = ioapic_sbdf[IO_APIC_ID (apic)].seg;u16 req_id =get_intremap_requestor_id (seg, bdf);const u32 *entry =get_intremap_entry (seg, req_id, offset); +ASSERT (offset == (val & (INTREMAP_ENTRIES -1 )));
Jan, could you please explain why the ASSERT is needed here?
Thanks,
Suravee
Quoted 6 lines
xen/drivers/passthrough/amd/iommu_intr.c +0
-0val &= ~(INTREMAP_ENTRIES -1 ); val |= get_field_from_reg_u32(*entry, INT_REMAP_ENTRY_INTTYPE_MASK,
Quoted 33 lines
Quoted 1 line
Quoted 1 line · On 23.04.15 at 15:31, <[email protected]> wrote:
Quoted 28 lines · Jan Beulich
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 in2ca9fbd739("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 <[email protected]>Signed-off-by Jan Beulich <[email protected]>xen/drivers/passthrough/amd/iommu_intr.c +3
-2@@ -365,15 +365,17 @@ unsigned int amd_iommu_read_ioapic_from_ unsigned int apic, unsigned int reg) {unsigned int val =__io_apic_read (apic, reg); +unsigned int pin = (reg -0x10 ) /2 ; +unsigned int offset = ioapic_sbdf[IO_APIC_ID (apic)].pin_2_idx[pin]; -if ( !(reg &1 ) ) +if ( !(reg &1 ) && offset <INTREMAP_ENTRIES ) { -unsigned int offset = val & (INTREMAP_ENTRIES -1 );u16 bdf = ioapic_sbdf[IO_APIC_ID (apic)].bdf;u16 seg = ioapic_sbdf[IO_APIC_ID (apic)].seg;u16 req_id =get_intremap_requestor_id (seg, bdf);const u32 *entry =get_intremap_entry (seg, req_id, offset);
Quoted 3 lines
xen/drivers/passthrough/amd/iommu_intr.c unsigned int amd_iommu_read_ioapic_from_ · line 378
Quoted 1 line
xen/drivers/passthrough/amd/iommu_intr.c +1
-0+ASSERT (offset == (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
Suthikulpanit, Suravee
Acked-byQuoted 37 lines · Jan Beulich
Quoted 33 lines
Quoted 1 line
Quoted 1 line · On 23.04.15 at 15:31, <[email protected]> wrote:
Quoted 28 lines · Jan Beulich
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 in2ca9fbd739("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 <[email protected]>Signed-off-by Jan Beulich <[email protected]>xen/drivers/passthrough/amd/iommu_intr.c +3
-2@@ -365,15 +365,17 @@ unsigned int amd_iommu_read_ioapic_from_ unsigned int apic, unsigned int reg) {unsigned int val =__io_apic_read (apic, reg); +unsigned int pin = (reg -0x10 ) /2 ; +unsigned int offset = ioapic_sbdf[IO_APIC_ID (apic)].pin_2_idx[pin]; -if ( !(reg &1 ) ) +if ( !(reg &1 ) && offset <INTREMAP_ENTRIES ) { -unsigned int offset = val & (INTREMAP_ENTRIES -1 );u16 bdf = ioapic_sbdf[IO_APIC_ID (apic)].bdf;u16 seg = ioapic_sbdf[IO_APIC_ID (apic)].seg;u16 req_id =get_intremap_requestor_id (seg, bdf);const u32 *entry =get_intremap_entry (seg, req_id, offset);Quoted 3 lines
xen/drivers/passthrough/amd/iommu_intr.c unsigned int amd_iommu_read_ioapic_from_ · line 378
Quoted 1 line
xen/drivers/passthrough/amd/iommu_intr.c +1
-0+ASSERT (offset == (val & (INTREMAP_ENTRIES -1 )));Jan, could you please explain why the ASSERT is needed here?
Quoted 5 lines
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¹t think this is caused by the patch.
I¹m looking into the issue. I also went back and tested it with 4.5 on the same setup and didn¹t see the issue.
Thanks,
Suravee
Quoted 57 lines · Jan Beulich
Quoted 38 lines
Quoted 34 lines
Quoted 2 lines
Quoted 2 lines · On 23.04.15 at 15:31, <[email protected]> wrote:
Quoted 28 lines · Jan Beulich
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 in2ca9fbd739("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 <[email protected]>Signed-off-by Jan Beulich <[email protected]>xen/drivers/passthrough/amd/iommu_intr.c +3
-2@@ -365,15 +365,17 @@ unsigned int amd_iommu_read_ioapic_from_ unsigned int apic, unsigned int reg) {unsigned int val =__io_apic_read (apic, reg); +unsigned int pin = (reg -0x10 ) /2 ; +unsigned int offset = ioapic_sbdf[IO_APIC_ID (apic)].pin_2_idx[pin]; -if ( !(reg &1 ) ) +if ( !(reg &1 ) && offset <INTREMAP_ENTRIES ) { -unsigned int offset = val & (INTREMAP_ENTRIES -1 );u16 bdf = ioapic_sbdf[IO_APIC_ID (apic)].bdf;u16 seg = ioapic_sbdf[IO_APIC_ID (apic)].seg;u16 req_id =get_intremap_requestor_id (seg, bdf);const u32 *entry =get_intremap_entry (seg, req_id, offset);Quoted 3 lines
xen/drivers/passthrough/amd/iommu_intr.c unsigned int amd_iommu_read_ioapic_from_ · line 378
Quoted 1 line
xen/drivers/passthrough/amd/iommu_intr.c +1
-0+ASSERT (offset == (val & (INTREMAP_ENTRIES -1 )));Jan, could you please explain why the ASSERT is needed here?
Quoted 5 lines
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¹t think this is caused by the patch.
Quoted 7 lines
I¹m looking into the issue. I also went back and tested it with 4.5 on the same setup and didn¹t see the issue.
Thanks,
Suravee
If it crashes with:
That problem is likely solved by another patch:
http://lists.xen.org/archives/html/xen-devel/2015-04/msg02253.html
Quoted 68 lines · Sander Eikelenboom
Quoted 59 lines · Jan Beulich
Quoted 40 lines
Quoted 36 lines
Quoted 2 lines
Quoted 2 lines · On 23.04.15 at 15:31, <[email protected]> wrote:
Quoted 30 lines · Jan Beulich
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 in2ca9fbd739("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 <[email protected]>Signed-off-by Jan Beulich <[email protected]>xen/drivers/passthrough/amd/iommu_intr.c +3
-2@@ -365,15 +365,17 @@ unsigned int amd_iommu_read_ioapic_from_ unsigned int apic, unsigned int reg) {unsigned int val =__io_apic_read (apic, reg); +unsigned int pin = (reg -0x10 ) /2 ; +unsigned int offset = ioapic_sbdf[IO_APIC_ID (apic)].pin_2_idx[pin]; -if ( !(reg &1 ) ) +if ( !(reg &1 ) && offset <INTREMAP_ENTRIES ) { -unsigned int offset = val & (INTREMAP_ENTRIES -1 );u16 bdf = ioapic_sbdf[IO_APIC_ID (apic)].bdf;u16 seg = ioapic_sbdf[IO_APIC_ID (apic)].seg;u16 req_id =get_intremap_requestor_id (seg, bdf);const u32 *entry =get_intremap_entry (seg, req_id, offset);Quoted 3 lines
xen/drivers/passthrough/amd/iommu_intr.c unsigned int amd_iommu_read_ioapic_from_ · line 379
Quoted 1 line
xen/drivers/passthrough/amd/iommu_intr.c +1
-0+ASSERT (offset == (val & (INTREMAP_ENTRIES -1 )));Jan, could you please explain why the ASSERT is needed here?
Quoted 5 lines
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¹t think this is caused by the patch.
Quoted 8 lines
I¹m looking into the issue. I also went back and tested it with 4.5 on the
same setup and didn¹t see the issue.Thanks,
Suravee
Quoted 7 lines
If it crashes with:
That problem is likely solved by another patch:
http://lists.xen.org/archives/html/xen-devel/2015-04/msg02253.html
Yes, this has fixed the crash.
Thanks,
Suravee
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 75 lines · you
Quoted 73 lines · Sander Eikelenboom
Quoted 59 lines · Jan Beulich
Quoted 40 lines
Quoted 36 lines
Quoted 2 lines
Quoted 2 lines · On 23.04.15 at 15:31, <[email protected]> wrote:
Quoted 30 lines · Jan Beulich
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 in2ca9fbd739("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 <[email protected]>Signed-off-by Jan Beulich <[email protected]>xen/drivers/passthrough/amd/iommu_intr.c +3
-2@@ -365,15 +365,17 @@ unsigned int amd_iommu_read_ioapic_from_ unsigned int apic, unsigned int reg) {unsigned int val =__io_apic_read (apic, reg); +unsigned int pin = (reg -0x10 ) /2 ; +unsigned int offset = ioapic_sbdf[IO_APIC_ID (apic)].pin_2_idx[pin]; -if ( !(reg &1 ) ) +if ( !(reg &1 ) && offset <INTREMAP_ENTRIES ) { -unsigned int offset = val & (INTREMAP_ENTRIES -1 );u16 bdf = ioapic_sbdf[IO_APIC_ID (apic)].bdf;u16 seg = ioapic_sbdf[IO_APIC_ID (apic)].seg;u16 req_id =get_intremap_requestor_id (seg, bdf);const u32 *entry =get_intremap_entry (seg, req_id, offset);Quoted 3 lines
xen/drivers/passthrough/amd/iommu_intr.c unsigned int amd_iommu_read_ioapic_from_ · line 379
Quoted 1 line
xen/drivers/passthrough/amd/iommu_intr.c +1
-0+ASSERT (offset == (val & (INTREMAP_ENTRIES -1 )));Jan, could you please explain why the ASSERT is needed here?
Quoted 5 lines
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¹t think this is caused by the patch.
Quoted 8 lines
I¹m looking into the issue. I also went back and tested it with 4.5 on the
same setup and didn¹t see the issue.Thanks,
SuraveeIf it crashes with:
That problem is likely solved by another patch:
Quoted 8 lines
Yes, this has fixed the crash.
Thanks,
Suravee
Hi Jan,
I see you commited "AMD IOMMU: only translate remapped IO-APIC RTEs" to staging, any reason why your patch in http://lists.xen.org/archives/html/xen-devel/2015-04/msg02253.html
isn't commited yet ?
(still waiting for an formal ack from someone ? as Suravee also seems to have tested it)
--
Sander
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 24.04.15 at 16:05, <[email protected]> wrote:
I see you commited "AMD IOMMU: only translate remapped IO-APIC RTEs" to staging,
any reason why your patch in
http://lists.xen.org/archives/html/xen-devel/2015-04/msg02253.html
isn't commited yet ?(still waiting for an formal ack from someone ? as Suravee also seems to have tested it)
This wasn't even submitted as a patch for inclusion yet (hence it necessarily lacks required acks). And that is because irrespective of it being confirmed to work in some cases, I'm still being concerned about Tim's warning regarding there being possible races left.
Jan
Quoted 10 lines · you
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 24.04.15 at 16:05, <[email protected]> wrote:
I see you commited "AMD IOMMU: only translate remapped IO-APIC RTEs" to staging,
any reason why your patch in
http://lists.xen.org/archives/html/xen-devel/2015-04/msg02253.html
isn't commited yet ?(still waiting for an formal ack from someone ? as Suravee also seems to have tested it)
Quoted 6 lines
This wasn't even submitted as a patch for inclusion yet (hence it necessarily lacks required acks). And that is because irrespective of it being confirmed to work in some cases, I'm still being concerned about Tim's warning regarding there being possible races left.
Jan
Ah OK that's clear, i wasn't aware you had some concerns left. Thanks for the explanation !
--
Sander
Quoted 49 lines · Suravee
Quoted 37 lines · Jan Beulich
Quoted 33 lines
Quoted 1 line
Quoted 1 line · On 23.04.15 at 15:31, <[email protected]> wrote:
Quoted 28 lines · Jan Beulich
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 in2ca9fbd739("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 <[email protected]>Signed-off-by Jan Beulich <[email protected]>xen/drivers/passthrough/amd/iommu_intr.c +3
-2@@ -365,15 +365,17 @@ unsigned int amd_iommu_read_ioapic_from_ unsigned int apic, unsigned int reg) {unsigned int val =__io_apic_read (apic, reg); +unsigned int pin = (reg -0x10 ) /2 ; +unsigned int offset = ioapic_sbdf[IO_APIC_ID (apic)].pin_2_idx[pin]; -if ( !(reg &1 ) ) +if ( !(reg &1 ) && offset <INTREMAP_ENTRIES ) { -unsigned int offset = val & (INTREMAP_ENTRIES -1 );u16 bdf = ioapic_sbdf[IO_APIC_ID (apic)].bdf;u16 seg = ioapic_sbdf[IO_APIC_ID (apic)].seg;u16 req_id =get_intremap_requestor_id (seg, bdf);const u32 *entry =get_intremap_entry (seg, req_id, offset);Quoted 3 lines
xen/drivers/passthrough/amd/iommu_intr.c unsigned int amd_iommu_read_ioapic_from_ · line 378
Quoted 1 line
xen/drivers/passthrough/amd/iommu_intr.c +1
-0+ASSERT (offset == (val & (INTREMAP_ENTRIES -1 )));Jan, could you please explain why the ASSERT is needed here?
Quoted 5 lines
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,
Quoted 8 lines
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¹t think this is caused by the patch.
Is it by any chance " BUG at iommu_map.c:455" ?
Quoted 15 lines
I¹m looking into the issue. I also went back and tested it with 4.5 on the same setup and didn¹t see the issue.
Thanks,
Suravee_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 9 lines · Konrad Rzeszutek Wilk
Quoted 7 lines
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¹t think this is caused by the patch.Is it by any chance " BUG at iommu_map.c:455" ?
Yes, the patch from Jan to fix the “BUG at iommu_map.c:455” fixed the issue.
Thanks,
Suravee
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel