summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/include
diff options
context:
space:
mode:
authorRobert Nagy <robert@cvs.openbsd.org>2022-09-22 04:57:09 +0000
committerRobert Nagy <robert@cvs.openbsd.org>2022-09-22 04:57:09 +0000
commita274f46d499af0b92234f72ed57ff134014630f9 (patch)
treefaac5c22fbed700bf85502b2b7edc3be3edf5b04 /sys/arch/amd64/include
parent3a382a986ca6791e7c431cdf9c7847b982996e6d (diff)
use the always serializing RDTSCP instruction in tsc and usertc if available
tweaks from cheloha@; ok deraadt@, sthen@, cheloha@
Diffstat (limited to 'sys/arch/amd64/include')
-rw-r--r--sys/arch/amd64/include/cpufunc.h11
-rw-r--r--sys/arch/amd64/include/timetc.h5
2 files changed, 13 insertions, 3 deletions
diff --git a/sys/arch/amd64/include/cpufunc.h b/sys/arch/amd64/include/cpufunc.h
index 7ca9130db77..2a8ddd34fd1 100644
--- a/sys/arch/amd64/include/cpufunc.h
+++ b/sys/arch/amd64/include/cpufunc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpufunc.h,v 1.36 2020/09/13 11:53:16 jsg Exp $ */
+/* $OpenBSD: cpufunc.h,v 1.37 2022/09/22 04:57:08 robert Exp $ */
/* $NetBSD: cpufunc.h,v 1.3 2003/05/08 10:27:43 fvdl Exp $ */
/*-
@@ -303,6 +303,15 @@ rdtsc(void)
}
static __inline u_int64_t
+rdtscp(void)
+{
+ uint32_t hi, lo;
+
+ __asm volatile("rdtscp" : "=d" (hi), "=a" (lo) : : "ecx");
+ return (((uint64_t)hi << 32) | (uint64_t) lo);
+}
+
+static __inline u_int64_t
rdtsc_lfence(void)
{
uint32_t hi, lo;
diff --git a/sys/arch/amd64/include/timetc.h b/sys/arch/amd64/include/timetc.h
index 48e1b57d410..733da2a9e8d 100644
--- a/sys/arch/amd64/include/timetc.h
+++ b/sys/arch/amd64/include/timetc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: timetc.h,v 1.2 2020/07/08 09:17:48 kettenis Exp $ */
+/* $OpenBSD: timetc.h,v 1.3 2022/09/22 04:57:08 robert Exp $ */
/*
* Copyright (c) 2020 Paul Irofti <paul@irofti.net>
*
@@ -18,6 +18,7 @@
#ifndef _MACHINE_TIMETC_H_
#define _MACHINE_TIMETC_H_
-#define TC_TSC 1
+#define TC_TSC_LFENCE 1
+#define TC_TSC_RDTSCP 2
#endif /* _MACHINE_TIMETC_H_ */