Project

General

Profile

Actions

Bug #13387

closed

bhyve should expose lfence serialize in DE_CFG MSR

Added by Patrick Mooney 7 months ago. Updated 6 months ago.

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

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

The DE_CFG MSR on modern AMD CPUs controls, among other things, whether the lfence instruction is serializing. While we cannot allow the guest to control the setting, we can at least expose whether it has been set (or not) in the host. Doing so will allow guests to safely use lfence; rdtsc for performing a TSC reading when rdtscp is not available.


Related issues

Related to illumos gate - Bug #12998: OpenBSD needs DE_CFG MSR on AMD bhyveClosedPatrick Mooney

Actions
Related to illumos gate - Bug #13383: generalize check for serializing LFENCEClosedPatrick Mooney

Actions
Actions #1

Updated by Patrick Mooney 7 months ago

  • Related to Bug #12998: OpenBSD needs DE_CFG MSR on AMD bhyve added
Actions #2

Updated by Patrick Mooney 7 months ago

  • Related to Bug #13383: generalize check for serializing LFENCE added
Actions #3

Updated by Electric Monk 7 months ago

  • Gerrit CR set to 1112
Actions #4

Updated by Patrick Mooney 6 months ago

Without this change, an OmniOSCE guest running inside bhyve was unable to detect serializing lfence, and thus fell back to normal retpolines for its spectre v2 mitigation. With the fix in place, the guest was then able to detect that serializing lfence was available and activated the appropriate AMD-specific retpoline. With #13383 and #13384 in place on the guest, it also chose lfence-rdtsc for performing TSC measurements instead of cpuid-rdtsc, since it detected the proper lfence behavior.

Actions #5

Updated by Electric Monk 6 months ago

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

git commit beed421eff10640141fe8f9da29a5c8033a97f52

commit  beed421eff10640141fe8f9da29a5c8033a97f52
Author: Patrick Mooney <pmooney@pfmooney.com>
Date:   2021-01-26T21:27:49.000Z

    13383 generalize check for serializing LFENCE
    13384 tsc_read() should use lfence when prudent
    13387 bhyve should expose lfence serialize in DE_CFG MSR
    Reviewed by: Robert Mustacchi <rm@fingolfin.org>
    Approved by: Dan McDonald <danmcd@joyent.com>

Actions

Also available in: Atom PDF