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.
This commit is contained in:
kleines Filmröllchen 2022-12-30 11:41:48 +01:00 committed by Andrew Kaster
parent 984348ed0d
commit 5d00e21852
Notes: sideshowbarker 2024-07-17 02:26:00 +09:00

View file

@ -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)