From beed421eff10640141fe8f9da29a5c8033a97f52 Mon Sep 17 00:00:00 2001 From: Patrick Mooney Date: Tue, 22 Dec 2020 17:58:43 +0000 Subject: 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 Approved by: Dan McDonald --- usr/src/lib/commpage/amd64/cp_subr.s | 11 ++++++----- usr/src/lib/commpage/common/cp_main.c | 1 - usr/src/lib/commpage/i386/cp_subr.s | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) (limited to 'usr/src/lib') diff --git a/usr/src/lib/commpage/amd64/cp_subr.s b/usr/src/lib/commpage/amd64/cp_subr.s index 09b8deaf8d..ebae0ed307 100644 --- a/usr/src/lib/commpage/amd64/cp_subr.s +++ b/usr/src/lib/commpage/amd64/cp_subr.s @@ -11,6 +11,7 @@ /* * Copyright 2019 Joyent, Inc. + * Copyright 2020 Oxide Computer Company */ #include @@ -110,11 +111,11 @@ movl %edx, %r10d 3: - cmpl $TSC_RDTSC_MFENCE, %esi - jne 4f - mfence - rdtsc - jmp 7f + /* + * TSC_RDTSC_MFENCE was used in the past for AMD chips, but has been + * supplanted by TSC_RDTSC_LFENCE, which works on Intel and AMD (when + * lfence can be confirmed as serializing). + */ 4: cmpl $TSC_RDTSC_LFENCE, %esi diff --git a/usr/src/lib/commpage/common/cp_main.c b/usr/src/lib/commpage/common/cp_main.c index 13a9aea3d7..42cc37d6b8 100644 --- a/usr/src/lib/commpage/common/cp_main.c +++ b/usr/src/lib/commpage/common/cp_main.c @@ -25,7 +25,6 @@ __cp_can_gettime(comm_page_t *cp) { switch (cp->cp_tsc_type) { case TSC_TSCP: - case TSC_RDTSC_MFENCE: case TSC_RDTSC_LFENCE: case TSC_RDTSC_CPUID: return (1); diff --git a/usr/src/lib/commpage/i386/cp_subr.s b/usr/src/lib/commpage/i386/cp_subr.s index d1e07008c4..83b7dcff56 100644 --- a/usr/src/lib/commpage/i386/cp_subr.s +++ b/usr/src/lib/commpage/i386/cp_subr.s @@ -11,6 +11,7 @@ /* * Copyright 2019 Joyent, Inc. + * Copyright 2020 Oxide Computer Company */ #include @@ -88,11 +89,11 @@ movl CP_TSC_TYPE(%edi), %eax 4: - cmpl $TSC_RDTSC_MFENCE, %eax - jne 5f - mfence - rdtsc - jmp 8f + /* + * TSC_RDTSC_MFENCE was used in the past for AMD chips, but has been + * supplanted by TSC_RDTSC_LFENCE, which works on Intel and AMD (when + * lfence can be confirmed as serializing). + */ 5: cmpl $TSC_RDTSC_LFENCE, %eax -- cgit v1.2.3