Skip to content

Global asm

jD91mZM2 requested to merge jD91mZM2/kernel:global-asm into master

The main idea behind this is that @bjorn3 pointed out that leaving an inline asm block with a different rsp register is undefined behavior. This gcc asm guide specifies that you're not allowed to clobber the stack pointer, and the new asm! rfc states that new assembly implementations may be implemented using an external assembler (therefore using a function call and thus modifying the stack)

While LLVM supports inline assembly, rustc may gain alternative backends such as Cranelift or GCC. If a back-end does not support inline assembly natively then we can fall back to invoking an external assembler.

While I hate to ruin the otherwise clean code, this has a number of advantages:

  1. Follows specification
  2. Will support bjorn3's cranelift backend where inline asm is implemented using an external function call.
  3. Works way better in debug mode! It still doesn't boot, but it doesn't spam stack traces like the master version does without --release. Once we do an overview of our code correctness elsewhere (such as while context switching), I'm sure we'll get a debug-mode kernel to compile! It boots!
Edited by jD91mZM2

Merge request reports