Project

General

Profile

Actions

Bug #13384

closed

tsc_read() should use lfence when prudent

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

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

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

At startup, tsc_read() contains text which uses CPUID to serialize the instruction stream before issuing a RDTSC. Once information has been gathered about the available CPU features, that function is potentially updated to use more efficient serialization methods. Those currently are:
1. RDTSCP (which is serializing itself, so it requires no extra)
2. MFENCE (on AMD chips with family <= 0xf)
3. LFENCE (on Intel chips with family <= 6 and SSE2)

With i386 support removed, all CPUs are presumed to support SSE2 (a requirement in the amd64 specification), which means they will all support LFENCE, although it is not necessarily serializing. On later model AMD chips, the LFENCE serialization behavior is controlled by the DE_CFG MSR, which we're inclined to enable for Spectre retpolines anyway. In the absence of RDTSCP (the best tsc_read() choice), we should prefer LFENCE when we can ensure it is serializing. It would remove the need for the MFENCE implementation (since the chips where it is currently preferred have a serializing LFENCE) and improve performance in cases were RDTSCP may not be exposed.


Related issues

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

Actions
Actions

Also available in: Atom PDF