Page MenuHomeFreeBSD

Various changes to the registers displayed in DDB for x86.
ClosedPublic

Authored by jhb on Jun 11 2015, 7:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 7:20 PM
Unknown Object (File)
Oct 27 2024, 2:52 AM
Unknown Object (File)
Oct 2 2024, 10:15 PM
Unknown Object (File)
Oct 1 2024, 3:53 PM
Unknown Object (File)
Oct 1 2024, 11:25 AM
Unknown Object (File)
Sep 30 2024, 11:36 PM
Unknown Object (File)
Sep 25 2024, 5:59 AM
Unknown Object (File)
Sep 21 2024, 5:57 AM
Subscribers

Details

Summary

Various changes to the registers displayed in DDB for x86.

  • Fix segment registers to only display the low 16 bits.
  • Remove unused handlers and entries for the debug registers.
  • Display xcr0 (if valid) in 'show sysregs'.
  • Add '0x' prefix to MSR values to match other values in 'show sysregs'.
  • MFamd64: Display various MSRs in 'show sysregs'.
  • Add a 'show dbregs' to display the value of debug registers.
  • Dynamically size the column width for register values to properly align columns on 64-bit platforms.
  • Display %gs for i386 in 'show registers'.
Test Plan
  • Check 'show registers' in DDB before and after on amd64 and i386.
  • Check 'show sysreg' and 'show dbreg' as well.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage

Event Timeline

jhb retitled this revision from to Various changes to the registers displayed in DDB for x86..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added a reviewer: kib.

There is 'show sysregs' which now duplicates partially the functionality. I think crX display should be removed from 'show sysregs' ?

sys/amd64/amd64/db_trace.c
169

CR4_OSXSAVE must be tested as well. If either CR4_XSAVE or CR4_OSXSAVE bits is cleared, xgetbv results in #UD.

jhb edited edge metadata.

Rebase.

In D2784#53324, @kib wrote:

There is 'show sysregs' which now duplicates partially the functionality. I think crX display should be removed from 'show sysregs' ?

Ugh, somehow I didn't find that earlier. Do you prefer having crX in 'show sysregs' or in 'show registers'? I don't mind either way but would probably place drX and xcr0 next to crX in whichever place.

sys/amd64/amd64/db_trace.c
169

%cr4 just has the XSAVE bit. cpuid features has XSAVE and OSXSAVE.

In D2784#53600, @jhb wrote:

Ugh, somehow I didn't find that earlier. Do you prefer having crX in 'show sysregs' or in 'show registers'? I don't mind either way but would probably place drX and xcr0 next to crX in whichever place.

I do not have a strong opinion there. I usually find it convenient to see the whole command output on single terminal screen without scrolling. From this PoV, it would be natural to 'show regs' to only show general-purpose registers, 'show sysregs' to show system controls, and might be 'show dbregs' for dbX.

sys/amd64/amd64/db_trace.c
169

Oh, yes, I was confused. But, the reason for the confusion is that SDM recommends to test CPUID flags (because code is supposed to run both in user and kernel space). Might be, cpuid feature bit test is more correct, I am not sure.

  • Move control regs into special DDB commands.
  • Just make db_gs explicit instead of a one-use macro.
sys/amd64/amd64/machdep.c
897

Note that accessing dr4 and dr5 is not safe, generally. See SDM Vol. 3A 17.2.2 Debug Registers DR4 and DR5:

Debug registers DR4 and DR5 are reserved when debug extensions are enabled (when the DE flag in control
register CR4 is set) and attempts to reference the DR4 and DR5 registers cause invalid-opcode exceptions (#UD).
When debug extensions are not enabled (when the DE flag is clear), these registers are aliased to debug registers
DR6 and DR7.

I have some followup fixes I've tested that I will upload once I've rebuilt arcanist on my laptop.

  • Don't display dr4/dr5.
  • Add more MSRs to i386 system regs.
  • Add 0x prefixes for MSRs to match other registers.
jhb edited the test plan for this revision. (Show Details)
jhb set the repository for this revision to rS FreeBSD src repository - subversion.
kib edited edge metadata.
This revision is now accepted and ready to land.Jul 21 2015, 6:30 PM
markj edited edge metadata.
jhb edited edge metadata.

Rebase after db_ss and get_rsp removal in HEAD.

This revision now requires review to proceed.Jul 22 2015, 12:35 AM
This revision was automatically updated to reflect the committed changes.