diff options
author | kleines Filmröllchen <filmroellchen@serenityos.org> | 2022-12-30 11:41:48 +0100 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-12-30 08:32:46 -0700 |
commit | 5d00e21852d956fada51d45481a5549f9fbd5ed3 (patch) | |
tree | b0801b513d514e21e055efa65851a6f7edce863a | |
parent | 984348ed0d8a7861a046804a6a884cc60957217a (diff) | |
download | serenity-5d00e21852d956fada51d45481a5549f9fbd5ed3.zip |
Kernel/aarch64: Implement wait_cycles as a pause loop
The hand-written assembly does not compile under Clang due to register
size mismatches. Using a loop is slower (~6 instructions on O2 as
opposed to 2 with hand-written assembly), but using the pause
instruction makes this more efficient even under TCG.
-rw-r--r-- | Kernel/Arch/aarch64/ASM_wrapper.h | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Kernel/Arch/aarch64/ASM_wrapper.h b/Kernel/Arch/aarch64/ASM_wrapper.h index b4ac85f45d..9f879b2469 100644 --- a/Kernel/Arch/aarch64/ASM_wrapper.h +++ b/Kernel/Arch/aarch64/ASM_wrapper.h @@ -62,13 +62,10 @@ inline ExceptionLevel get_current_exception_level() inline void wait_cycles(int n) { - // This is probably too fast when caching and branch prediction is turned on. // FIXME: Make timer-based. - asm("mov x0, %[value]\n" - "0:\n" - " subs x0, x0, #1\n" - " bne 0b" ::[value] "r"(n) - : "x0"); + for (int volatile i = 0; i < n; i = i + 1) { + Processor::pause(); + } } inline void el1_vector_table_install(void* vector_table) |