git: 60490b72ba46 - stable/13 - x86: cpufunc: Add rdtscp_aux()

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 10 Oct 2021 09:23:56 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=60490b72ba46b6c9e82be047fa8738379bf81310

commit 60490b72ba46b6c9e82be047fa8738379bf81310
Author:     Adam Fenn <adam@fenn.io>
AuthorDate: 2021-07-26 19:59:55 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-10-10 09:21:16 +0000

    x86: cpufunc: Add rdtscp_aux()
    
    (cherry picked from commit 908e277230ef1a80589f85687f5b422b0e863e79)
---
 sys/amd64/include/cpufunc.h | 9 +++++++++
 sys/i386/include/cpufunc.h  | 9 +++++++++
 2 files changed, 18 insertions(+)

diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h
index 8ef298e1d7d5..49975e826fb9 100644
--- a/sys/amd64/include/cpufunc.h
+++ b/sys/amd64/include/cpufunc.h
@@ -364,6 +364,15 @@ rdtscp(void)
 	return (low | ((uint64_t)high << 32));
 }
 
+static __inline uint64_t
+rdtscp_aux(uint32_t *aux)
+{
+	uint32_t low, high;
+
+	__asm __volatile("rdtscp" : "=a" (low), "=d" (high), "=c" (*aux));
+	return (low | ((uint64_t)high << 32));
+}
+
 static __inline uint32_t
 rdtsc32(void)
 {
diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h
index 9646590a6a40..7b99978facc3 100644
--- a/sys/i386/include/cpufunc.h
+++ b/sys/i386/include/cpufunc.h
@@ -403,6 +403,15 @@ rdtscp(void)
 	return (rv);
 }
 
+static __inline uint64_t
+rdtscp_aux(uint32_t *aux)
+{
+	uint64_t rv;
+
+	__asm __volatile("rdtscp" : "=A" (rv), "=c" (*aux));
+	return (rv);
+}
+
 static __inline uint32_t
 rdtsc32(void)
 {