Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Aug 2021 12:58:10 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 908e277230ef - main - x86: cpufunc: Add rdtscp_aux()
Message-ID:  <202108141258.17ECwAIJ031079@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=908e277230ef1a80589f85687f5b422b0e863e79

commit 908e277230ef1a80589f85687f5b422b0e863e79
Author:     Adam Fenn <adam@fenn.io>
AuthorDate: 2021-07-26 19:59:55 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-08-14 12:57:53 +0000

    x86: cpufunc: Add rdtscp_aux()
    
    Add a variant of 'rdtscp()' that retains and returns the 'IA32_TSC_AUX'
    value read by 'rdtscp'.
    
    Sponsored By:   Juniper Networks, Inc.
    Sponsored By:   Klara, Inc.
    Reviewed by:    markj, kib
    Differential Revision:  https://reviews.freebsd.org/D31415
---
 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)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108141258.17ECwAIJ031079>