From 4fbe86a9cee6e69936faf2ed1fbc41a29a221e8e Mon Sep 17 00:00:00 2001 From: jD91mZM2 <me@krake.one> Date: Thu, 16 Jul 2020 16:32:48 +0200 Subject: [PATCH] Fix random userspace page faults I was an idiot and forgot rbx wasn't always backed up. As a result, we should never ever write to it --- src/arch/x86_64/interrupt/handler.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/arch/x86_64/interrupt/handler.rs b/src/arch/x86_64/interrupt/handler.rs index 070454b..274d8d6 100644 --- a/src/arch/x86_64/interrupt/handler.rs +++ b/src/arch/x86_64/interrupt/handler.rs @@ -281,11 +281,13 @@ macro_rules! push_fs { push fs // Load kernel tls - // We can't load the value directly into `fs`. We also can't use `rax` - // as the temporary value, as during errors that's already used for the - // error code. - mov rbx, 0x18 - mov fs, bx + // + // NOTE: We can't load the value directly into `fs`. So we need to use a + // scratch register (as preserved registers aren't backed up by the + // interrupt! macro) to store it. We also can't use `rax` as the temporary + // value, as during errors that's already used for the error code. + mov rcx, 0x18 + mov fs, cx " }; } #[macro_export] -- GitLab