Skip to contentSkip to conversation

x86/IDT: Fix IDT generation for INT $0x80

PATCH In review Andrew Cooper 3 participants 6 messages Mar 11, 2025 – Mar 12, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/IDT: Fix IDT generation for INT $0x80

When PV is enabled, entry_int80 needs to be DPL3, not DPL0.

This causes the XSA-259 PoC to fail with:

--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels) XSA-259 PoC
Error: Unexpected fault 0x800d0802, #GP[IDT[256]] Test result: ERROR

(Clearly I have a bug in XTF's rendering of the error code too.)

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Luca Fancellu <[email protected]>

---
 xen/arch/x86/include/asm/gen-idt.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/include/asm/gen-idt.h +1 -1
index 9c8810edf9d7..d1da73248c1c 100644
@@ -77,7 +77,7 @@ GEN16(6);
 GEN16(7);
 
 #ifdef CONFIG_PV
-GEN(0x80, entry_int80,      DPL0, manual);
+GEN(0x80, entry_int80,      DPL3, manual);
 #else
 GEN(0x80, entry_0x80,       DPL0, autogen);
 #endif
Signature · 1 line
2.39.5
#1 lore raw
Quoted 11 lines · Andrew Cooper

When PV is enabled, entry_int80 needs to be DPL3, not DPL0.

This causes the XSA-259 PoC to fail with:

--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels) XSA-259 PoC
Error: Unexpected fault 0x800d0802, #GP[IDT[256]] Test result: ERROR

(Clearly I have a bug in XTF's rendering of the error code too.)

Fixes 3da2149cf4dc ("x86/IDT: Generate bsp_idt[] at build time")

Adjusted locally.

~Andrew

Quoted 23 lines

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Luca Fancellu <[email protected]>

---
 xen/arch/x86/include/asm/gen-idt.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/include/asm/gen-idt.h +1 -1
index 9c8810edf9d7..d1da73248c1c 100644
@@ -77,7 +77,7 @@ GEN16(6);
 GEN16(7);
 
 #ifdef CONFIG_PV
-GEN(0x80, entry_int80,      DPL0, manual);
+GEN(0x80, entry_int80,      DPL3, manual);
 #else
 GEN(0x80, entry_0x80,       DPL0, autogen);
 #endif
#2 lore raw
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Andrew Cooper

When PV is enabled, entry_int80 needs to be DPL3, not DPL0.

This causes the XSA-259 PoC to fail with:

Quoted 7 lines
Quoted 7 lines

--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels) XSA-259 PoC
Error: Unexpected fault 0x800d0802, #GP[IDT[256]] Test result: ERROR

(Clearly I have a bug in XTF's rendering of the error code too.)

Nope, it's a QEMU bug.  Under QEMU, we get:

--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels)
XSA-259 PoC
(XEN) [    3.982447] *** #GP/IDT ec 00000802
(XEN) [    3.982668] *** #GP/IDT ec 00000802, not permitted (XEN) [    3.982849] *** #GP inject ec 00000802
Error: Unexpected fault 0x800d0802, #GP[IDT[256]] Test result: ERROR

On real hardware:

(d1) --- Xen Test Framework ---
(d1) Environment: PV 64bit (Long mode 4 levels)
(d1) XSA-259 PoC
(XEN) *** #GP/IDT ec 00000402
(XEN) *** #GP/IDT ec 00000402, not permitted
(XEN) *** #GP inject ec 00000402
(d1) Success: Not vulnerable to XSA-259
(d1) Test result: SUCCESS

So it's by chance that Luca's testing even picked up this failure.  The XSA-259 PoC can't distinguish between the #GP INT emulation path and the INT80 fastpath's error path which injects #GP.

~Andrew

#3 lore raw
Quoted 36 lines · Andrew Cooper
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Andrew Cooper

When PV is enabled, entry_int80 needs to be DPL3, not DPL0.

This causes the XSA-259 PoC to fail with:

Quoted 7 lines
Quoted 7 lines

--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels) XSA-259 PoC
Error: Unexpected fault 0x800d0802, #GP[IDT[256]] Test result: ERROR

(Clearly I have a bug in XTF's rendering of the error code too.)

Nope, it's a QEMU bug.  Under QEMU, we get:

--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels)
XSA-259 PoC
(XEN) [    3.982447] *** #GP/IDT ec 00000802
(XEN) [    3.982668] *** #GP/IDT ec 00000802, not permitted (XEN) [    3.982849] *** #GP inject ec 00000802
Error: Unexpected fault 0x800d0802, #GP[IDT[256]] Test result: ERROR

On real hardware:

(d1) --- Xen Test Framework ---
(d1) Environment: PV 64bit (Long mode 4 levels)
(d1) XSA-259 PoC
(XEN) *** #GP/IDT ec 00000402
(XEN) *** #GP/IDT ec 00000402, not permitted
(XEN) *** #GP inject ec 00000402
(d1) Success: Not vulnerable to XSA-259
(d1) Test result: SUCCESS

Quoted 3 lines

So it's by chance that Luca's testing even picked up this failure.  The XSA-259 PoC can't distinguish between the #GP INT emulation path and the INT80 fastpath's error path which injects #GP.

And a patch submitted.

https://lore.kernel.org/qemu-devel/[email protected]/T/#u

~Andrew

Reviewed-by
#4 lore raw
In reply to Andrew Cooper
Quoted 11 lines · Andrew Cooper
Quoted 10 lines · Andrew Cooper

When PV is enabled, entry_int80 needs to be DPL3, not DPL0.

This causes the XSA-259 PoC to fail with:

--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels) XSA-259 PoC
Error: Unexpected fault 0x800d0802, #GP[IDT[256]] Test result: ERROR

Quoted 3 lines
Quoted 1 line

(Clearly I have a bug in XTF's rendering of the error code too.)

Fixes 3da2149cf4dc ("x86/IDT: Generate bsp_idt[] at build time")

Jan

Tested-by on v1 1/1
#5 lore raw
In reply to Andrew Cooper

Hi Andrew,

Quoted 12 lines · Andrew Cooper

When PV is enabled, entry_int80 needs to be DPL3, not DPL0.

This causes the XSA-259 PoC to fail with:

--- Xen Test Framework ---
Environment: PV 64bit (Long mode 4 levels) XSA-259 PoC
Error: Unexpected fault 0x800d0802, #GP[IDT[256]] Test result: ERROR

Quoted 4 lines

(Clearly I have a bug in XTF's rendering of the error code too.)

I’ve runned XTF on this one and I confirm it solves the issue: