Skip to contentSkip to conversation

gdbstub: Update x86 control register bits

PATCH Applied Mathias Krause 4 participants 11 messages Mar 27 – Jun 19

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gdbstub: Update x86 control register bits

The control register bits haven't been updated in a few years, making them lack behind features QEMU ganied in these years.

Update them to the current version of the SDM and sort the 32bit version to be in line with all the other definitions (descending order).

This should remove confusion when debugging, for example, CET-enabled guests:

- before the change:
(gdb) info registers cr4
cr4 0x8000f0 [ PGE MCE PAE PSE ]

- after the change:
(gdb) info registers cr4
cr4 0x8000f0 [ CET PGE MCE PAE PSE ]

---
 gdbstub/gdb-xml/i386-32bit.xml | 47 +++++++++++++++++++---------------
 gdbstub/gdb-xml/i386-64bit.xml |  7 +++++
 2 files changed, 34 insertions(+), 20 deletions(-)
gdbstub/gdb-xml/i386-32bit.xml +27 -20
index 7a66a02b67e3..1dec40e1d2c1 100644
@@ -87,27 +87,34 @@
   </flags>
 
   <flags id="i386_cr4" size="4">
-	<field name="VME" start="0" end="0"/>
-	<field name="PVI" start="1" end="1"/>
-	<field name="TSD" start="2" end="2"/>
-	<field name="DE" start="3" end="3"/>
-	<field name="PSE" start="4" end="4"/>
-	<field name="PAE" start="5" end="5"/>
-	<field name="MCE" start="6" end="6"/>
-	<field name="PGE" start="7" end="7"/>
-	<field name="PCE" start="8" end="8"/>
-	<field name="OSFXSR" start="9" end="9"/>
-	<field name="OSXMMEXCPT" start="10" end="10"/>
-	<field name="UMIP" start="11" end="11"/>
-	<field name="LA57" start="12" end="12"/>
-	<field name="VMXE" start="13" end="13"/>
-	<field name="SMXE" start="14" end="14"/>
-	<field name="FSGSBASE" start="16" end="16"/>
-	<field name="PCIDE" start="17" end="17"/>
-	<field name="OSXSAVE" start="18" end="18"/>
-	<field name="SMEP" start="20" end="20"/>
+	<field name="LAM_SUP" start="28" end="28"/>
+	<field name="LASS" start="27" end="27"/>
+	<field name="UINTR" start="25" end="25"/>
+	<field name="PKS" start="24" end="24"/>
+	<field name="CET" start="23" end="23"/>
+	<field name="PKE" start="22" end="22"/>
+	<field name="PKE" start="22" end="22"/>
 	<field name="SMAP" start="21" end="21"/>
-	<field name="PKE" start="22" end="22"/>
+	<field name="SMEP" start="20" end="20"/>
+	<field name="KL" start="19" end="19"/>
+	<field name="OSXSAVE" start="18" end="18"/>
+	<field name="PCIDE" start="17" end="17"/>
+	<field name="FSGSBASE" start="16" end="16"/>
+	<field name="SMXE" start="14" end="14"/>
+	<field name="VMXE" start="13" end="13"/>
+	<field name="LA57" start="12" end="12"/>
+	<field name="UMIP" start="11" end="11"/>
+	<field name="OSXMMEXCPT" start="10" end="10"/>
+	<field name="OSFXSR" start="9" end="9"/>
+	<field name="PCE" start="8" end="8"/>
+	<field name="PGE" start="7" end="7"/>
+	<field name="MCE" start="6" end="6"/>
+	<field name="PAE" start="5" end="5"/>
+	<field name="PSE" start="4" end="4"/>
+	<field name="DE" start="3" end="3"/>
+	<field name="TSD" start="2" end="2"/>
+	<field name="PVI" start="1" end="1"/>
+	<field name="VME" start="0" end="0"/>
   </flags>
 
   <flags id="i386_efer" size="4">
gdbstub/gdb-xml/i386-64bit.xml +7 -0
index 6d889692114d..9ac9164e6a99 100644
@@ -102,9 +102,16 @@
   </flags>
 
   <flags id="x64_cr4" size="8">
+	<field name="FRED" start="32" end="32"/>
+	<field name="LAM_SUP" start="28" end="28"/>
+	<field name="LASS" start="27" end="27"/>
+	<field name="UINTR" start="25" end="25"/>
+	<field name="PKS" start="24" end="24"/>
+	<field name="CET" start="23" end="23"/>
 	<field name="PKE" start="22" end="22"/>
 	<field name="SMAP" start="21" end="21"/>
 	<field name="SMEP" start="20" end="20"/>
+	<field name="KL" start="19" end="19"/>
 	<field name="OSXSAVE" start="18" end="18"/>
 	<field name="PCIDE" start="17" end="17"/>
 	<field name="FSGSBASE" start="16" end="16"/>
Signature · 1 line
2.53.0
#1 lore raw
Quoted 5 lines · Mathias Krause

The control register bits haven't been updated in a few years, making them lack behind features QEMU ganied in these years.

Update them to the current version of the SDM and sort the 32bit version to be in line with all the other definitions (descending order).

Do these changes come from the gdb upstream (which is where all the XML originally comes from).

Quoted 98 lines

This should remove confusion when debugging, for example, CET-enabled guests:

- before the change:
(gdb) info registers cr4
cr4 0x8000f0 [ PGE MCE PAE PSE ]

- after the change:
(gdb) info registers cr4
cr4 0x8000f0 [ CET PGE MCE PAE PSE ]

---
 gdbstub/gdb-xml/i386-32bit.xml | 47 +++++++++++++++++++---------------
 gdbstub/gdb-xml/i386-64bit.xml |  7 +++++
 2 files changed, 34 insertions(+), 20 deletions(-)
gdbstub/gdb-xml/i386-32bit.xml +27 -20
index 7a66a02b67e3..1dec40e1d2c1 100644
@@ -87,27 +87,34 @@
   </flags>
 
   <flags id="i386_cr4" size="4">
-	<field name="VME" start="0" end="0"/>
-	<field name="PVI" start="1" end="1"/>
-	<field name="TSD" start="2" end="2"/>
-	<field name="DE" start="3" end="3"/>
-	<field name="PSE" start="4" end="4"/>
-	<field name="PAE" start="5" end="5"/>
-	<field name="MCE" start="6" end="6"/>
-	<field name="PGE" start="7" end="7"/>
-	<field name="PCE" start="8" end="8"/>
-	<field name="OSFXSR" start="9" end="9"/>
-	<field name="OSXMMEXCPT" start="10" end="10"/>
-	<field name="UMIP" start="11" end="11"/>
-	<field name="LA57" start="12" end="12"/>
-	<field name="VMXE" start="13" end="13"/>
-	<field name="SMXE" start="14" end="14"/>
-	<field name="FSGSBASE" start="16" end="16"/>
-	<field name="PCIDE" start="17" end="17"/>
-	<field name="OSXSAVE" start="18" end="18"/>
-	<field name="SMEP" start="20" end="20"/>
+	<field name="LAM_SUP" start="28" end="28"/>
+	<field name="LASS" start="27" end="27"/>
+	<field name="UINTR" start="25" end="25"/>
+	<field name="PKS" start="24" end="24"/>
+	<field name="CET" start="23" end="23"/>
+	<field name="PKE" start="22" end="22"/>
+	<field name="PKE" start="22" end="22"/>
 	<field name="SMAP" start="21" end="21"/>
-	<field name="PKE" start="22" end="22"/>
+	<field name="SMEP" start="20" end="20"/>
+	<field name="KL" start="19" end="19"/>
+	<field name="OSXSAVE" start="18" end="18"/>
+	<field name="PCIDE" start="17" end="17"/>
+	<field name="FSGSBASE" start="16" end="16"/>
+	<field name="SMXE" start="14" end="14"/>
+	<field name="VMXE" start="13" end="13"/>
+	<field name="LA57" start="12" end="12"/>
+	<field name="UMIP" start="11" end="11"/>
+	<field name="OSXMMEXCPT" start="10" end="10"/>
+	<field name="OSFXSR" start="9" end="9"/>
+	<field name="PCE" start="8" end="8"/>
+	<field name="PGE" start="7" end="7"/>
+	<field name="MCE" start="6" end="6"/>
+	<field name="PAE" start="5" end="5"/>
+	<field name="PSE" start="4" end="4"/>
+	<field name="DE" start="3" end="3"/>
+	<field name="TSD" start="2" end="2"/>
+	<field name="PVI" start="1" end="1"/>
+	<field name="VME" start="0" end="0"/>
   </flags>
 
   <flags id="i386_efer" size="4">
gdbstub/gdb-xml/i386-64bit.xml +7 -0
index 6d889692114d..9ac9164e6a99 100644
@@ -102,9 +102,16 @@
   </flags>
 
   <flags id="x64_cr4" size="8">
+	<field name="FRED" start="32" end="32"/>
+	<field name="LAM_SUP" start="28" end="28"/>
+	<field name="LASS" start="27" end="27"/>
+	<field name="UINTR" start="25" end="25"/>
+	<field name="PKS" start="24" end="24"/>
+	<field name="CET" start="23" end="23"/>
 	<field name="PKE" start="22" end="22"/>
 	<field name="SMAP" start="21" end="21"/>
 	<field name="SMEP" start="20" end="20"/>
+	<field name="KL" start="19" end="19"/>
 	<field name="OSXSAVE" start="18" end="18"/>
 	<field name="PCIDE" start="17" end="17"/>
 	<field name="FSGSBASE" start="16" end="16"/>
Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#2 lore raw
Quoted 10 lines · Alex Bennée
Quoted 5 lines · Mathias Krause

The control register bits haven't been updated in a few years, making them lack behind features QEMU ganied in these years.

Update them to the current version of the SDM and sort the 32bit version to be in line with all the other definitions (descending order).

Do these changes come from the gdb upstream (which is where all the XML originally comes from).

The upstream version has no control register coverage, that's QEMU specific and came with 7b0f97bade8a ("gdbstub: Fix i386/x86_64 machine description and add control registers").

Thanks,
Mathias

#4 lore raw
Quoted 1 line · Paolo Bonzini

Queued, thanks.

Ping! Is that queue visible somewhere on the Interwebs?

Should the patch be backported to 11.x to avoid the confusion related to CR4.CET I had?

Thanks,
Mathias

#5 lore raw
Quoted 4 lines · Mathias Krause
Quoted 1 line · Paolo Bonzini

Queued, thanks.

Ping! Is that queue visible somewhere on the Interwebs?

Alex, can you please pick up this patch and route it via the gdbstub tree? Paolo said, he queued it but it never appeared in QEMU upstream nor in his tree at https://gitlab.com/bonzini/qemu.git. He doesn't respond to requests either.

Quoted 3 lines

Should the patch be backported to 11.x to avoid the confusion related to CR4.CET I had?

That would still be relevant, imho. Dunno how to handle that.

Thanks,
Mathias

#7 lore raw
In reply to Mathias Krause
Quoted 13 lines · Mathias Krause

The control register bits haven't been updated in a few years, making them lack behind features QEMU ganied in these years.

Update them to the current version of the SDM and sort the 32bit version to be in line with all the other definitions (descending order).

This should remove confusion when debugging, for example, CET-enabled guests:

- before the change:
(gdb) info registers cr4
cr4 0x8000f0 [ PGE MCE PAE PSE ]

Quoted 5 lines

- after the change:
(gdb) info registers cr4
cr4 0x8000f0 [ CET PGE MCE PAE PSE ]

This feels like a qemu-stable material, is it not?

Thanks,

/mjt

#8 lore raw
Quoted 14 lines · Michael Tokarev
Quoted 13 lines · Mathias Krause

The control register bits haven't been updated in a few years, making them lack behind features QEMU ganied in these years.

Update them to the current version of the SDM and sort the 32bit version to be in line with all the other definitions (descending order).

This should remove confusion when debugging, for example, CET-enabled guests:

- before the change:
   (gdb) info registers cr4
   cr4            0x8000f0            [ PGE MCE PAE PSE ]

Quoted 7 lines
Quoted 5 lines

- after the change:
   (gdb) info registers cr4
   cr4            0x8000f0            [ CET PGE MCE PAE PSE ]

This feels like a qemu-stable material, is it not?

Yes, I think so too (see [1]). That's why I tried to get it into 11.0 before its release but that didn't happen, unfortunately. :/

Would be nice if it could be included in a 11.x release, as that's the first with CET virtualization support.

Thanks,
Mathias

[1]
https://lore.kernel.org/qemu-devel/[email protected]/

#9 lore raw
Quoted 6 lines · Mathias Krause
Quoted 3 lines
Quoted 3 lines

- after the change:
   (gdb) info registers cr4
   cr4            0x8000f0            [ CET PGE MCE PAE PSE ]

Would be nice if it could be included in a 11.x release, as that's the first with CET virtualization support.

Hmm. So it looks like this change is wrong for previous releases (10.0, 10.2), and should not be picked up there, right?

Thanks,

/mjt

#10 lore raw
Quoted 11 lines · Michael Tokarev
Quoted 6 lines · Mathias Krause
Quoted 3 lines
Quoted 3 lines

- after the change:
    (gdb) info registers cr4
    cr4            0x8000f0            [ CET PGE MCE PAE PSE ]

Would be nice if it could be included in a 11.x release, as that's the first with CET virtualization support.

Hmm.  So it looks like this change is wrong for previous releases (10.0, 10.2), and should not be picked up there, right?

It's not wrong, it's providing symbolic names to architecturally defined control register bits. If a guest doesn't use these (because it cannot because of QEMU/KVM lacking virtualization support for them), they just won't be used but they're still correct.

Looking at the git history, it looks like QEMU gained PKS support in e7e7bdababee ("target/i86: implement PKS"), which was v6.0. So this change should be backported to all still supported branches, imho.

Thanks,
Mathias