From 730130056d54f8408a9b3577e43c300dad8f71af Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 3 Jan 2025 11:45:15 -0800 Subject: [PATCH] chore: get kernel compiling on nightly-2025-01-01 (#502) Update our Rust toolchain to nightly-2025-01-01, and update `bootloader` to compile on that version. It currently panics because the latest bootloader maps some stuff on huge pages which we don't expect... --- Cargo.lock | 24 ++++++++++++++++-------- hal-core/Cargo.toml | 2 +- hal-x86_64/Cargo.toml | 2 +- hal-x86_64/src/segment.rs | 9 +++++++-- inoculate/Cargo.toml | 4 ++-- rust-toolchain.toml | 2 +- src/arch/x86_64/oops.rs | 5 +---- x86_64-mycelium.json | 4 ++-- 8 files changed, 31 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 03fbda48..0e7d398a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -404,9 +404,9 @@ dependencies = [ [[package]] name = "bootloader" -version = "0.11.5" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0668e5a71825bbf8d9af46b68441e4426f070e7465b45070464977214dfada9e" +checksum = "8bace22e5c5b93f2e97859d0b74fa1338b8878009cdf752c377d1e8b44eccf26" dependencies = [ "anyhow", "async-process", @@ -423,9 +423,9 @@ dependencies = [ [[package]] name = "bootloader-boot-config" -version = "0.11.5" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be20fe897a953c6f2e63d392ea067237af98d02cd15ef97a48fef2768c1ed269" +checksum = "1efd4468bc7632e80a35b231c9694d20abff7bc5367b7dff8ce162d3b145a3dd" dependencies = [ "serde", ] @@ -1672,6 +1672,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" version = "0.1.45" @@ -2453,12 +2459,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.31" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -2473,10 +2480,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.16" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" dependencies = [ + "num-conv", "time-core", ] diff --git a/hal-core/Cargo.toml b/hal-core/Cargo.toml index e8ed4b69..1e872026 100644 --- a/hal-core/Cargo.toml +++ b/hal-core/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Eliza Weisman ", "iximeow "] edition = "2021" license = "MIT" -rust_version = "1.81.0" +rust-version = "1.81.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/hal-x86_64/Cargo.toml b/hal-x86_64/Cargo.toml index 64b662a5..2d243f70 100644 --- a/hal-x86_64/Cargo.toml +++ b/hal-x86_64/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Eliza Weisman ", "iximeow "] edition = "2021" license = "MIT" -rust_version = "1.81.0" +rust-version = "1.81.0" [features] default = ["alloc"] diff --git a/hal-x86_64/src/segment.rs b/hal-x86_64/src/segment.rs index 6f052949..a422d8eb 100644 --- a/hal-x86_64/src/segment.rs +++ b/hal-x86_64/src/segment.rs @@ -237,10 +237,15 @@ impl Selector { tracing::trace!("setting code segment..."); asm!( "push {selector}", - "lea {retaddr}, [1f + rip]", + "lea {retaddr}, [2f + rip]", "push {retaddr}", "retfq", - "1:", + // This is cool: apparently we can't use '0' or '1' as a label in + // LLVM assembly, due to an LLVM bug: + // https://github.com/llvm/llvm-project/issues/99547 + // + // So, this is 2 instead of 1. lmao. + "2:", selector = in(reg) self.0 as u64, retaddr = lateout(reg) _, options(preserves_flags), diff --git a/inoculate/Cargo.toml b/inoculate/Cargo.toml index 1110d224..e05b77fc 100644 --- a/inoculate/Cargo.toml +++ b/inoculate/Cargo.toml @@ -16,7 +16,7 @@ tracing = "0.1.23" tracing-subscriber = "0.3.16" tracing-error = "0.2" color-eyre = "0.6" -bootloader = "0.11.2" +bootloader = "0.11.9" bootloader-boot-config = "0.11.3" locate-cargo-manifest = "0.2" wait-timeout = "0.2" @@ -25,4 +25,4 @@ atty = "0.2" mycotest = { path = "../mycotest", features = ["alloc"] } heck = "0.3.3" # used for UEFI booting in QEMU -ovmf-prebuilt = "0.1.0-alpha.1" \ No newline at end of file +ovmf-prebuilt = "0.1.0-alpha.1" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index eaeebf9e..0087141f 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2024-01-20" +channel = "nightly-2025-01-01" components = [ "clippy", "rustfmt", diff --git a/src/arch/x86_64/oops.rs b/src/arch/x86_64/oops.rs index 7e20ac8a..825b00f4 100644 --- a/src/arch/x86_64/oops.rs +++ b/src/arch/x86_64/oops.rs @@ -111,10 +111,7 @@ pub fn oops(oops: Oops<'_>) -> ! { } => writeln!(mk_writer.make_writer(), "a {kind} occurred!\n").unwrap(), OopsSituation::Panic(panic) => { let mut writer = mk_writer.make_writer(); - match panic.message() { - Some(msg) => writeln!(writer, "mycelium panicked: {msg}").unwrap(), - None => writeln!(writer, "mycelium panicked!").unwrap(), - } + write!(writer, "mycelium panicked: {}", panic.message()).unwrap(); if let Some(loc) = panic.location() { writeln!(writer, "at {}:{}:{}", loc.file(), loc.line(), loc.column()).unwrap(); } diff --git a/x86_64-mycelium.json b/x86_64-mycelium.json index 653e62d4..b53f3461 100644 --- a/x86_64-mycelium.json +++ b/x86_64-mycelium.json @@ -1,6 +1,6 @@ { "llvm-target": "x86_64-unknown-none", - "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", + "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", "arch": "x86_64", "target-endian": "little", "target-pointer-width": "64", @@ -21,4 +21,4 @@ "panic-strategy": "abort", "disable-redzone": true, "features": "-mmx,-sse,+soft-float" -} \ No newline at end of file +}