summaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2023-04-12 23:33:29 +0200
committerJan Janssen <medhefgo@web.de>2023-04-13 15:36:27 +0200
commit09614b35c01702b73c757d9ec374bf381d51b008 (patch)
treebf76fc9875aa635cb19650c86abf6eff1a8e7998 /src/boot
parentfde55f3a327c4eef3bbdeb199b05e7c385d1f331 (diff)
downloadsystemd-09614b35c01702b73c757d9ec374bf381d51b008.tar.gz
boot: Use compiler intrinsic for TSC
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/efi/ticks.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/src/boot/efi/ticks.c b/src/boot/efi/ticks.c
index 13972528cd..84dfdc4542 100644
--- a/src/boot/efi/ticks.c
+++ b/src/boot/efi/ticks.c
@@ -4,28 +4,15 @@
#include "util.h"
#include "vmm.h"
-#ifdef __x86_64__
+#if defined(__i386__) || defined(__x86_64__)
static uint64_t ticks_read(void) {
- uint64_t a, d;
-
/* The TSC might or might not be virtualized in VMs (and thus might not be accurate or start at zero
* at boot), depending on hypervisor and CPU functionality. If it's not virtualized it's not useful
* for keeping time, hence don't attempt to use it. */
if (in_hypervisor())
return 0;
- __asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
- return (d << 32) | a;
-}
-#elif defined(__i386__)
-static uint64_t ticks_read(void) {
- uint64_t val;
-
- if (in_hypervisor())
- return 0;
-
- __asm__ volatile ("rdtsc" : "=A" (val));
- return val;
+ return __builtin_ia32_rdtsc();
}
#elif defined(__aarch64__)
static uint64_t ticks_read(void) {