Project

General

Profile

Actions

Bug #14951

closed

fix ::sysregs under mdb-bhyve on AMD

Added by Patrick Mooney 3 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Category:
bhyve
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

Querying the sysregs under mdb-bhyve does not work on an AMD machine:

[0]> ::sysregs
mdb: failed to get system registers for CPU 0

It appears that this is due to the PDPTEs being considered part of the sysregs state. SVM does not explicitly cache the PDPTEs (PDPEs in AMD's parlance) in the same way that VMX does, thus they are not exposed as part of the VM state.

Actions #1

Updated by Electric Monk 3 months ago

  • Gerrit CR set to 2335
Actions #2

Updated by Patrick Mooney 3 months ago

For now, it seems reasonable to have SVM simply emit 0s for the PDPEs, since it's not holding cached versions of them. In the future we may way to enhance this to query their effective contents from guest memory if 32-bit PAE paging is enabled.

Actions #3

Updated by Patrick Mooney 3 months ago

With the proposed fix in place, sysregs works again on AMD:

[1]> ::sysregs
%efer = 0x1d01 <SCE,LME,LMA,NXE,SVME>
%cr0 = 0x80050033 <PE,MP,ET,NE,WP,AM,PG>
%cr2 = 0x000000001cf9f934 <0x7fb51cf9f934>
%cr3 = 0xbce7e000 <pfn:0xbce7e flags:>
%cr4 = 0x3406e0 <PAE,MCE,PGE,OSFXSR,OSXMMEXCPT,OSXSAVE,SMEP,SMAP>

%pdpte0 = 0x0000000000000000    %pdpte2 = 0x0000000000000000
%pdpte1 = 0x0000000000000000    %pdpte3 = 0x0000000000000000

%gdtr = 0xfffffe000002c000/0x7f
%idtr = 0xfffffe0000000000/0xfff
%ldtr = 0xfffffe0000000000/0x00000000 0x10000 <unusable, reserved, dpl 0, flags: 16b>
%tr   = 0xfffffe000002e000/0x0000206f 0x00089 <usable, 32b/64b TSS, available, dpl 0, flags: P,16b>
%cs   = 0x0000000000000000/0xffffffff 0x0209b <usable, code, non-conforming, execute-read, dpl 0, flags: P,64b,A>
%ss   = 0x0000000000000000/0xffffffff 0x0c093 <usable, data, up, read-write, dpl 0, flags: P,32b,G,A>
%ds   = 0x0000000000000000/0x00000000 0x10000 <unusable, reserved, dpl 0, flags: 16b>
%es   = 0x0000000000000000/0x00000000 0x10000 <unusable, reserved, dpl 0, flags: 16b>
%fs   = 0x0000000000000000/0x00000000 0x10000 <unusable, reserved, dpl 0, flags: 16b>
%gs   = 0xffff9b3240e80000/0x00000000 0x10000 <unusable, reserved, dpl 0, flags: 16b>
%intr_shadow = 0x1

Actions #4

Updated by Patrick Mooney 3 months ago

In addition to testing the mdb behavior in question, I also ran the standard test suite:

Test: /opt/bhyve-tests/tests/mevent/vnode_zvol (run as root)      [00:02] [PASS]
Test: /opt/bhyve-tests/tests/inst_emul/rdmsr (run as root)        [00:00] [PASS]
Test: /opt/bhyve-tests/tests/inst_emul/wrmsr (run as root)        [00:00] [PASS]
Test: /opt/bhyve-tests/tests/inst_emul/triple_fault (run as root) [00:00] [PASS]
Test: /opt/bhyve-tests/tests/kdev/vatpit_freq (run as root)       [00:00] [PASS]
Test: /opt/bhyve-tests/tests/kdev/vhpet_freq (run as root)        [00:00] [PASS]
Test: /opt/bhyve-tests/tests/kdev/vlapic_freq (run as root)       [00:00] [PASS]
Test: /opt/bhyve-tests/tests/kdev/vlapic_freq_periodic (run as root) [00:00] [PASS]
Test: /opt/bhyve-tests/tests/kdev/vlapic_mmio_access (run as root) [00:00] [PASS]
Test: /opt/bhyve-tests/tests/kdev/vlapic_msr_access (run as root) [00:00] [PASS]
Test: /opt/bhyve-tests/tests/kdev/vpmtmr_freq (run as root)       [00:00] [PASS]
Test: /opt/bhyve-tests/tests/mevent/lists_delete (run as root)    [00:00] [PASS]
Test: /opt/bhyve-tests/tests/mevent/read_disable (run as root)    [00:00] [PASS]
Test: /opt/bhyve-tests/tests/mevent/read_pause (run as root)      [00:00] [PASS]
Test: /opt/bhyve-tests/tests/mevent/read_requeue (run as root)    [00:00] [PASS]
Test: /opt/bhyve-tests/tests/mevent/vnode_file (run as root)      [00:09] [PASS]
Test: /opt/bhyve-tests/tests/viona/interface_version (run as root) [00:00] [PASS]
Test: /opt/bhyve-tests/tests/vmm/auto_destruct (run as root)      [00:00] [PASS]
Test: /opt/bhyve-tests/tests/vmm/drv_hold (run as root)           [00:00] [PASS]
Test: /opt/bhyve-tests/tests/vmm/fpu_getset (run as root)         [00:00] [PASS]
Test: /opt/bhyve-tests/tests/vmm/interface_version (run as root)  [00:00] [PASS]
Test: /opt/bhyve-tests/tests/vmm/mem_devmem (run as root)         [00:00] [PASS]
Test: /opt/bhyve-tests/tests/vmm/mem_partial (run as root)        [00:00] [PASS]
Test: /opt/bhyve-tests/tests/vmm/mem_seg_map (run as root)        [00:00] [PASS]

Results Summary
PASS      24

Running Time:   00:00:13
Percent passed: 100.0%
Log directory:  /var/tmp/test_results/20220907T151701

The machine had no issues booting guests either.

Actions #5

Updated by Electric Monk 3 months ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit d0eff808627a496edc82505a80bac88afa61304e

commit  d0eff808627a496edc82505a80bac88afa61304e
Author: Patrick Mooney <pmooney@pfmooney.com>
Date:   2022-09-07T19:54:19.000Z

    14951 fix ::sysregs under mdb-bhyve on AMD
    Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
    Reviewed by: Andy Fiddaman <andy@omniosce.org>
    Reviewed by: Dan Cross <cross@oxidecomputer.com>
    Approved by: Richard Lowe <richlowe@richlowe.net>

Actions

Also available in: Atom PDF