Bug #15676
openSVM feature detection broken in bhyve
0%
Description
The SVM portion of bhyve references a svm_feature
variable which is supposed to contain the SVM features portion (%edx
) of the 0x8000000a
leaf. This was accidentally removed when bhyve was ported to illumos. It has gone unnoticed because 1. svm_features
was being initialized with all-ones 2. people were using modern AMD CPUs to run bhyve, meaning all utilized features happened to be present.
For the sake of safety, the svm_feature
population code should be reinstated. The coarse checks in hma_svm_init()
prevent bhyve from running if the most basic (NPT, nRIP, etc) features are missing, but subsequent additions like TSC scaling which are not checked by HMA need to be properly queried.
Related issues
Updated by Patrick Mooney 17 days ago
- Subject changed from svm feature detection broken in bhyve to SVM feature detection broken in bhyve
Updated by Patrick Mooney 12 days ago
I booted an AMD machine onto bits featuring the proposed fix for this issue. Firstly, I checked that svm_feature
was being populated from the CPUID data:
mdb -ke 'svm_feature/X' svm_feature: svm_feature: 13bcff
Next, I ran the tsc_freq_ctrl
test (not yet included in the default runfile for bhyve-tests) which exercises functionality which depends on detection from said feature bits. It properly found the TSC ratio feature and utilized it:
testing 2x host_freq: guest_freq=5589441180, host_freq=2794720590 558944288 ticks in 100000279 ns (error 2 ppm) 558944288 ticks in 99999146 ns (error 8 ppm) 558944288 ticks in 99999207 ns (error 8 ppm) 558944323 ticks in 100007221 ns (error 71 ppm) 558944288 ticks in 99994378 ns (error 56 ppm) 558944288 ticks in 99999237 ns (error 7 ppm) 558944288 ticks in 100000248 ns (error 2 ppm) 558944288 ticks in 99999548 ns (error 4 ppm) 558944232 ticks in 100000229 ns (error 2 ppm) 558944288 ticks in 99999777 ns (error 2 ppm) testing 0.5x host_freq: guest_freq=1397360295, host_freq=2794720590 139736086 ticks in 100001211 ns (error 11 ppm) 139736072 ticks in 99999377 ns (error 6 ppm) 139736072 ticks in 100000259 ns (error 2 ppm) 139736072 ticks in 99999817 ns (error 2 ppm) 139736086 ticks in 100001521 ns (error 14 ppm) 139736072 ticks in 99998475 ns (error 15 ppm) 139736072 ticks in 100000319 ns (error 2 ppm) 139736072 ticks in 99999417 ns (error 6 ppm) 139736072 ticks in 100000459 ns (error 4 ppm) 139736072 ticks in 99999868 ns (error 1 ppm) testing 1/3 host_freq: guest_freq=931573530, host_freq=2794720590 93157381 ticks in 100000839 ns (error 8 ppm) 93157372 ticks in 100000389 ns (error 3 ppm) 93157372 ticks in 99999918 ns (error 1 ppm) 93157381 ticks in 99999798 ns (error 2 ppm) 93157381 ticks in 100000058 ns (error 0 ppm) 93157382 ticks in 99999748 ns (error 2 ppm) 93157381 ticks in 99999998 ns (error 0 ppm) 93157381 ticks in 99999728 ns (error 3 ppm) 93157382 ticks in 99999928 ns (error 1 ppm) 93157372 ticks in 100000479 ns (error 4 ppm) testing 1x host_freq: guest_freq=2794720590, host_freq=2794720590 279472116 ticks in 100001160 ns (error 11 ppm) 279472144 ticks in 100000089 ns (error 0 ppm) 279472116 ticks in 99999687 ns (error 3 ppm) 279472116 ticks in 100000909 ns (error 8 ppm) 279472116 ticks in 99999067 ns (error 9 ppm) 279472116 ticks in 100000038 ns (error 0 ppm) 279472144 ticks in 100000209 ns (error 1 ppm) 279472116 ticks in 99999748 ns (error 2 ppm) 279472116 ticks in 100000228 ns (error 2 ppm) 279472144 ticks in 99999908 ns (error 1 ppm) PASS tsc_freq_ctrl
I also ran the main test suite:
Test: /opt/bhyve-tests/tests/mevent/vnode_zvol (run as root) [00:02] [PASS] Test: /opt/bhyve-tests/tests/inst_emul/cpuid (run as root) [00:00] [PASS] Test: /opt/bhyve-tests/tests/inst_emul/imul (run as root) [00:00] [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/inst_emul/exit_paging (run as root) [00:00] [PASS] Test: /opt/bhyve-tests/tests/inst_emul/page_dirty (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/kdev/vrtc_ops (run as root) [00:03] [PASS] Test: /opt/bhyve-tests/tests/kdev/wrmsr_tsc (run as root) [00:00] [PASS] Test: /opt/bhyve-tests/tests/kdev/rdmsr_tsc (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/cpuid_ioctl (run as root) [00:00] [PASS] Test: /opt/bhyve-tests/tests/vmm/datarw_constraints (run as root) [00:00] [PASS] Test: /opt/bhyve-tests/tests/vmm/datarw_vcpu (run as root) [00:00] [PASS] Test: /opt/bhyve-tests/tests/vmm/default_capabs (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/import_vlapic (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/legacy_destruct (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] Test: /opt/bhyve-tests/tests/vmm/pause_resume (run as root) [00:00] [PASS] Test: /opt/bhyve-tests/tests/vmm/self_destruct (run as root) [00:00] [PASS] Results Summary PASS 39 Running Time: 00:00:18 Percent passed: 100.0%
All indications point to feature detection working just as it did before the change. I do not have any old AMD hardware which would be missing features which we use today (where the old logic would have mistakenly believe said features were present).
Updated by Patrick Mooney 12 days ago
- Related to Bug #15677: SVM should not blindly enable LBR-virt added
Updated by Patrick Mooney 11 days ago
- Related to Bug #15693: vmm-data should allow specific MSR reads added