Skip to content

Commit 38af052

Browse files
committed
Do not write to EBX and ESI using in("<register>"), since it is forbidden in newer rust toolchains
1 parent 41630fd commit 38af052

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/boot/mod.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,13 @@ impl<'a> PreparedEntry<'a> {
298298
"cli",
299299
// virtual 8086 mode can't be set, as we're 32 or 64 bit code
300300
// (and changing that flag is rather difficult)
301-
301+
302+
// Writing to RBX (and thus EBX) using in("ebx") is forbidden,
303+
// since this register is used internally by LLVM.
304+
// Thus, we need to write the mulitboot information address to EAX
305+
// and copy it into EBX here.
306+
"mov ebx, eax",
307+
302308
// > ‘CR0’ Bit 31 (PG) must be cleared. Bit 0 (PE) must be set.
303309
// > Other bits are all undefined.
304310
"mov ecx, cr0",
@@ -315,7 +321,7 @@ impl<'a> PreparedEntry<'a> {
315321
"mov cr4, ecx",
316322

317323
// TODO: Only do this on x86_64?
318-
// x86_64: switch from compatiblity mode to protected mode
324+
// x86_64: switch from compatibility mode to protected mode
319325
// get the EFER
320326
"mov ecx, 0xC0000080",
321327
"rdmsr",
@@ -326,11 +332,11 @@ impl<'a> PreparedEntry<'a> {
326332
// write the signature to EAX
327333
"mov eax, {}",
328334
// finally jump to the kernel
329-
"jmp esi",
335+
"jmp edi",
330336

331337
const SIGNATURE_EAX,
332-
in("ebx") &self.multiboot_information,
333-
in("esi") entry_address,
338+
in("eax") &self.multiboot_information,
339+
in("edi") entry_address,
334340
options(noreturn),
335341
);
336342
}

0 commit comments

Comments
 (0)