45 lines
1.5 KiB
Diff
45 lines
1.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
|
|
Date: Mon, 12 Aug 2024 16:13:18 +0200
|
|
Subject: [PATCH] kern/riscv/efi/init: Use time register in
|
|
grub_efi_get_time_ms()
|
|
|
|
The cycle register is not guaranteed to count at constant frequency.
|
|
If it is counting at all depends on the state the performance monitoring
|
|
unit. Use the time register to measure time.
|
|
|
|
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
---
|
|
grub-core/kern/riscv/efi/init.c | 15 +++++++--------
|
|
1 file changed, 7 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/grub-core/kern/riscv/efi/init.c b/grub-core/kern/riscv/efi/init.c
|
|
index 38795fe6741..0d7de4f541a 100644
|
|
--- a/grub-core/kern/riscv/efi/init.c
|
|
+++ b/grub-core/kern/riscv/efi/init.c
|
|
@@ -33,16 +33,15 @@ grub_efi_get_time_ms (void)
|
|
grub_uint64_t tmr;
|
|
|
|
#if __riscv_xlen == 64
|
|
- asm volatile ("rdcycle %0" : "=r" (tmr));
|
|
+ asm volatile ("rdtime %0" : "=r"(tmr));
|
|
#else
|
|
grub_uint32_t lo, hi, tmp;
|
|
- asm volatile (
|
|
- "1:\n"
|
|
- "rdcycleh %0\n"
|
|
- "rdcycle %1\n"
|
|
- "rdcycleh %2\n"
|
|
- "bne %0, %2, 1b"
|
|
- : "=&r" (hi), "=&r" (lo), "=&r" (tmp));
|
|
+ asm volatile ("1:\n"
|
|
+ "rdtimeh %0\n"
|
|
+ "rdtime %1\n"
|
|
+ "rdtimeh %2\n"
|
|
+ "bne %0, %2, 1b"
|
|
+ : "=&r" (hi), "=&r" (lo), "=&r" (tmp));
|
|
tmr = ((grub_uint64_t)hi << 32) | lo;
|
|
#endif
|
|
|