From 91b56ee30d75f298385c7f20feb38b411d2846c9 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 30 Apr 2021 12:14:43 +0200 Subject: [PATCH 01/68] Backport: Reduce number of used unstable features of `x86_64` crate --- Cargo.toml | 2 +- example-kernel/Cargo.toml | 2 +- test-kernel/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index df352085..02cd5043 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ required-features = ["binary"] [dependencies] xmas-elf = { version = "0.6.2", optional = true } -x86_64 = { version = "0.13.2", optional = true } +x86_64 = { version = "0.13.2", optional = true, default-features = false, features = ["instructions", "inline_asm"] } usize_conversions = { version = "0.2.0", optional = true } fixedvec = { version = "0.2.4", optional = true } bit_field = { version = "0.10.0", optional = true } diff --git a/example-kernel/Cargo.toml b/example-kernel/Cargo.toml index 37431378..62593e09 100644 --- a/example-kernel/Cargo.toml +++ b/example-kernel/Cargo.toml @@ -5,4 +5,4 @@ authors = ["Philipp Oppermann "] edition = "2018" [dependencies] -x86_64 = "0.13.2" +x86_64 = { version = "0.13.2", default-features = false, features = ["instructions", "inline_asm"] } diff --git a/test-kernel/Cargo.toml b/test-kernel/Cargo.toml index f39f7503..228b7790 100644 --- a/test-kernel/Cargo.toml +++ b/test-kernel/Cargo.toml @@ -5,4 +5,4 @@ authors = ["Philipp Oppermann "] edition = "2018" [dependencies] -x86_64 = "0.13.2" +x86_64 = { version = "0.13.2", default-features = false, features = ["instructions", "inline_asm"] } From 6a78bec2ecdcf6c8563e9fba6dff4195d13123c1 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 30 Apr 2021 12:25:57 +0200 Subject: [PATCH 02/68] Update changelog --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index b247b483..226ce647 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +- Reduce the number of used unstable features of x86_64 crate (backport [#155](https://github.com/rust-osdev/bootloader/pull/140)) + # 0.9.16 – 2021-03-07 Replace all remaining `lea`s with `mov` + `offset` ([#140](https://github.com/rust-osdev/bootloader/pull/140)) From 0ac800fc25c3a7673241fdeb689a8d79d4cb60d5 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 30 Apr 2021 12:28:48 +0200 Subject: [PATCH 03/68] Release version 0.9.17 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 160b7020..e8bcc2cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,7 +22,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.16" +version = "0.9.17" dependencies = [ "bit_field 0.10.1", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index 02cd5043..8b97dd42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.16" +version = "0.9.17" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index 226ce647..c237631f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.17 – 2021-04-30 + - Reduce the number of used unstable features of x86_64 crate (backport [#155](https://github.com/rust-osdev/bootloader/pull/140)) # 0.9.16 – 2021-03-07 From eead1a57e0778f539131dd99be086dc44c4507df Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 20 May 2021 13:42:57 +0200 Subject: [PATCH 04/68] Fix nightly regerssion by manually passing `--gc-sections` Rust used to pass `--gc-section` automatically. In https://github.com/rust-lang/rust/pull/85274, this behavior was changed to only pass that flag for targets that use a GNU linker. So we have to add it manually, otherwise the bootloader grows too large to be loaded by our assembly stage. --- x86_64-bootloader.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x86_64-bootloader.json b/x86_64-bootloader.json index ad13109d..24be1991 100644 --- a/x86_64-bootloader.json +++ b/x86_64-bootloader.json @@ -5,8 +5,9 @@ "linker": "rust-lld", "pre-link-args": { "ld.lld": [ - "--script=linker.ld" - ] + "--script=linker.ld", + "--gc-sections" + ] }, "target-endian": "little", "target-pointer-width": "64", From 2afc7d778d327839231c6966e4bbb71e9dc7f33f Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 20 May 2021 13:47:54 +0200 Subject: [PATCH 05/68] Update changelog for #168 --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index c237631f..898000d2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +- Fix nightly regression by manually passing --gc-sections ([#168](https://github.com/rust-osdev/bootloader/pull/168)) + # 0.9.17 – 2021-04-30 - Reduce the number of used unstable features of x86_64 crate (backport [#155](https://github.com/rust-osdev/bootloader/pull/140)) From 88bc669f45a5f7eb77af253290cc298a46ec2585 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 20 May 2021 13:59:08 +0200 Subject: [PATCH 06/68] Replace tabs with spaces Co-authored-by: bjorn3 --- x86_64-bootloader.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x86_64-bootloader.json b/x86_64-bootloader.json index 24be1991..b003982b 100644 --- a/x86_64-bootloader.json +++ b/x86_64-bootloader.json @@ -5,9 +5,9 @@ "linker": "rust-lld", "pre-link-args": { "ld.lld": [ - "--script=linker.ld", + "--script=linker.ld", "--gc-sections" - ] + ] }, "target-endian": "little", "target-pointer-width": "64", From 3ae79b8972d5fae62b42549ad84aa52c9a8e4ea6 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 20 May 2021 13:59:40 +0200 Subject: [PATCH 07/68] One more tab->spaces replacement --- x86_64-bootloader.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x86_64-bootloader.json b/x86_64-bootloader.json index b003982b..ab1c5256 100644 --- a/x86_64-bootloader.json +++ b/x86_64-bootloader.json @@ -18,5 +18,5 @@ "disable-redzone": true, "panic": "abort", "executables": true, - "relocation_model": "static" + "relocation_model": "static" } From 861a49c411047bca7e8017bfa0b6d8d4018346e0 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 20 May 2021 14:22:41 +0200 Subject: [PATCH 08/68] Release version 0.9.18 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e8bcc2cf..aefd9717 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,7 +22,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.17" +version = "0.9.18" dependencies = [ "bit_field 0.10.1", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index 8b97dd42..2861ac5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.17" +version = "0.9.18" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index 898000d2..25d8b703 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.18 – 2021-05-20 + - Fix nightly regression by manually passing --gc-sections ([#168](https://github.com/rust-osdev/bootloader/pull/168)) # 0.9.17 – 2021-04-30 From 1a1cebb0933682e39f949a744ff45f377afafb67 Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Fri, 16 Jul 2021 08:36:10 +0200 Subject: [PATCH 09/68] Fix warnings about .intel_syntax attribute --- src/e820.s | 1 - src/stage_1.s | 1 - src/stage_2.s | 1 - src/stage_3.s | 1 - src/video_mode/vga_320x200.s | 1 - src/video_mode/vga_text_80x25.s | 1 - 6 files changed, 6 deletions(-) diff --git a/src/e820.s b/src/e820.s index 114de231..59d9c78b 100644 --- a/src/e820.s +++ b/src/e820.s @@ -1,5 +1,4 @@ .section .boot, "awx" -.intel_syntax noprefix .code16 # From http://wiki.osdev.org/Detecting_Memory_(x86)#Getting_an_E820_Memory_Map diff --git a/src/stage_1.s b/src/stage_1.s index cbab048d..09ada795 100644 --- a/src/stage_1.s +++ b/src/stage_1.s @@ -1,6 +1,5 @@ .section .boot-first-stage, "awx" .global _start -.intel_syntax noprefix .code16 # This stage initializes the stack, enables the A20 line, loads the rest of diff --git a/src/stage_2.s b/src/stage_2.s index f5ad1141..8cf26ea0 100644 --- a/src/stage_2.s +++ b/src/stage_2.s @@ -1,5 +1,4 @@ .section .boot, "awx" -.intel_syntax noprefix .code16 # This stage sets the target operating mode, loads the kernel from disk, diff --git a/src/stage_3.s b/src/stage_3.s index 112c68df..2f081afa 100644 --- a/src/stage_3.s +++ b/src/stage_3.s @@ -1,5 +1,4 @@ .section .boot, "awx" -.intel_syntax noprefix .code32 # This stage performs some checks on the CPU (cpuid, long mode), sets up an diff --git a/src/video_mode/vga_320x200.s b/src/video_mode/vga_320x200.s index 17d4a743..6cd20128 100644 --- a/src/video_mode/vga_320x200.s +++ b/src/video_mode/vga_320x200.s @@ -1,5 +1,4 @@ .section .boot, "awx" -.intel_syntax noprefix .code16 config_video_mode: diff --git a/src/video_mode/vga_text_80x25.s b/src/video_mode/vga_text_80x25.s index 0ddb0d6f..4e65216a 100644 --- a/src/video_mode/vga_text_80x25.s +++ b/src/video_mode/vga_text_80x25.s @@ -1,5 +1,4 @@ .section .boot, "awx" -.intel_syntax noprefix .code16 config_video_mode: From 36874961ec198bf562ec29427e8bb044586e49c4 Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Fri, 16 Jul 2021 08:42:57 +0200 Subject: [PATCH 10/68] Fix warnings about panic field in target json file --- x86_64-bootloader.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x86_64-bootloader.json b/x86_64-bootloader.json index ab1c5256..5a3376d6 100644 --- a/x86_64-bootloader.json +++ b/x86_64-bootloader.json @@ -16,7 +16,7 @@ "os": "none", "features": "-mmx,-sse,+soft-float", "disable-redzone": true, - "panic": "abort", + "panic-strategy": "abort", "executables": true, "relocation_model": "static" } From ce64f2e6113e3ac98f931c6a9a3406053a6949a8 Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Fri, 16 Jul 2021 08:48:43 +0200 Subject: [PATCH 11/68] Remove unused relocation_model field in target json file --- x86_64-bootloader.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x86_64-bootloader.json b/x86_64-bootloader.json index 5a3376d6..d8c0e494 100644 --- a/x86_64-bootloader.json +++ b/x86_64-bootloader.json @@ -17,6 +17,5 @@ "features": "-mmx,-sse,+soft-float", "disable-redzone": true, "panic-strategy": "abort", - "executables": true, - "relocation_model": "static" + "executables": true } From c96e1fb06717413a9b2413f46c37962d354d3d6e Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Sat, 17 Jul 2021 15:11:36 +0200 Subject: [PATCH 12/68] Fix relocation-model field name --- x86_64-bootloader.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x86_64-bootloader.json b/x86_64-bootloader.json index d8c0e494..ceb196e9 100644 --- a/x86_64-bootloader.json +++ b/x86_64-bootloader.json @@ -17,5 +17,6 @@ "features": "-mmx,-sse,+soft-float", "disable-redzone": true, "panic-strategy": "abort", - "executables": true + "executables": true, + "relocation-model": "static" } From 31cc018acb1b959f19ecd76bf9a54c41e16fcdc0 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 9 Aug 2021 10:06:14 +0200 Subject: [PATCH 13/68] Update changelog for #185 --- Changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Changelog.md b/Changelog.md index 25d8b703..6eb72158 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # Unreleased +- Set `relocation-model: static` and `panic-strategy: abort` and `fix .intel_syntax` warnings [#185](https://github.com/rust-osdev/bootloader/pull/185) + - Fixes warnings on the latest Rust nightlies. + - This effectively changes the `relocation-model` and `panic-strategy`. Please report if you encounter any issues because of this. + # 0.9.18 – 2021-05-20 - Fix nightly regression by manually passing --gc-sections ([#168](https://github.com/rust-osdev/bootloader/pull/168)) From 794c5b842e02c37fd82c606c26edf6a8899edd1e Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 9 Aug 2021 10:07:29 +0200 Subject: [PATCH 14/68] Release version 0.9.19 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aefd9717..8eb42f90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,7 +22,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.18" +version = "0.9.19" dependencies = [ "bit_field 0.10.1", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index 2861ac5e..325fa172 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.18" +version = "0.9.19" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index 6eb72158..da76b145 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.19 – 2021-08-09 + - Set `relocation-model: static` and `panic-strategy: abort` and `fix .intel_syntax` warnings [#185](https://github.com/rust-osdev/bootloader/pull/185) - Fixes warnings on the latest Rust nightlies. - This effectively changes the `relocation-model` and `panic-strategy`. Please report if you encounter any issues because of this. From 64e26c9eea4c1f77647ec1f982bab0191809818e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Nov 2021 20:43:57 +0100 Subject: [PATCH 15/68] Use new inline assembly syntax --- src/main.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3ccac477..21b8ceae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ #![feature(lang_items)] #![feature(global_asm)] -#![feature(llvm_asm)] +#![feature(asm)] #![no_std] #![no_main] @@ -42,8 +42,9 @@ global_asm!(include_str!("video_mode/vga_320x200.s")); global_asm!(include_str!("video_mode/vga_text_80x25.s")); unsafe fn context_switch(boot_info: VirtAddr, entry_point: VirtAddr, stack_pointer: VirtAddr) -> ! { - llvm_asm!("call $1; ${:private}.spin.${:uid}: jmp ${:private}.spin.${:uid}" :: - "{rsp}"(stack_pointer), "r"(entry_point), "{rdi}"(boot_info) :: "intel"); + asm!("movq {1}, %rsp; callq *{0}; 0: jmp 0b", + in(reg) entry_point.as_u64(), in(reg) stack_pointer.as_u64(), in("rdi") boot_info.as_u64(), + options(att_syntax)); ::core::hint::unreachable_unchecked() } @@ -88,8 +89,12 @@ extern "C" { #[no_mangle] pub unsafe extern "C" fn stage_4() -> ! { // Set stack segment - llvm_asm!("mov bx, 0x0 - mov ss, bx" ::: "bx" : "intel"); + asm!( + "push rbx + mov bx, 0x0 + mov ss, bx + pop rbx" + ); let kernel_start = 0x400000; let kernel_size = &_kernel_size as *const _ as u64; From 4057db1bed8c2851a7627466867d40d84bf53a0f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Nov 2021 20:44:47 +0100 Subject: [PATCH 16/68] Properly mark mmap_ent as global It currently happens to work fine using cg_llvm as the global_asm!() ends up in the same cgu as the use of this global. There is no guarantee that this will always be the case and in fact in case of cg_clif this happens to not be the case, thus causing a linker error. --- src/e820.s | 1 + 1 file changed, 1 insertion(+) diff --git a/src/e820.s b/src/e820.s index 59d9c78b..cb07e8e1 100644 --- a/src/e820.s +++ b/src/e820.s @@ -51,4 +51,5 @@ do_e820: stc # "function unsupported" error exit ret +.global mmap_ent mmap_ent: .word 0 From f5abf681ca3598a73469b3860a86dabfe16343f6 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 20 Dec 2021 08:20:16 +0100 Subject: [PATCH 17/68] Update x86_64 dependency to v0.14.7 to fix nightly breakage --- Cargo.lock | 21 +++++++++++---------- Cargo.toml | 2 +- example-kernel/Cargo.toml | 2 +- test-kernel/Cargo.toml | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8eb42f90..4bb82fc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "bit_field" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56" - [[package]] name = "bit_field" version = "0.10.1" @@ -24,7 +18,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" name = "bootloader" version = "0.9.19" dependencies = [ - "bit_field 0.10.1", + "bit_field", "fixedvec", "font8x8", "llvm-tools", @@ -80,14 +74,21 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f70329e2cbe45d6c97a5112daad40c34cd9a4e18edb5a2a18fefeb584d8d25e5" +[[package]] +name = "volatile" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4c2dbd44eb8b53973357e6e207e370f0c1059990df850aca1eca8947cf464f0" + [[package]] name = "x86_64" -version = "0.13.2" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b871116e3c83dad0795580b10b2b1dd05cb52ec719af36180371877b09681f7f" +checksum = "fb611915c917c6296d11e23f71ff1ecfe49c5766daba92cd3df52df6b58285b6" dependencies = [ - "bit_field 0.9.0", + "bit_field", "bitflags", + "volatile", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 325fa172..8a1aee40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ required-features = ["binary"] [dependencies] xmas-elf = { version = "0.6.2", optional = true } -x86_64 = { version = "0.13.2", optional = true, default-features = false, features = ["instructions", "inline_asm"] } +x86_64 = { version = "0.14.7", optional = true, default-features = false, features = ["instructions", "inline_asm"] } usize_conversions = { version = "0.2.0", optional = true } fixedvec = { version = "0.2.4", optional = true } bit_field = { version = "0.10.0", optional = true } diff --git a/example-kernel/Cargo.toml b/example-kernel/Cargo.toml index 62593e09..557284b7 100644 --- a/example-kernel/Cargo.toml +++ b/example-kernel/Cargo.toml @@ -5,4 +5,4 @@ authors = ["Philipp Oppermann "] edition = "2018" [dependencies] -x86_64 = { version = "0.13.2", default-features = false, features = ["instructions", "inline_asm"] } +x86_64 = { version = "0.14.7", default-features = false, features = ["instructions", "inline_asm"] } diff --git a/test-kernel/Cargo.toml b/test-kernel/Cargo.toml index 228b7790..d21177df 100644 --- a/test-kernel/Cargo.toml +++ b/test-kernel/Cargo.toml @@ -5,4 +5,4 @@ authors = ["Philipp Oppermann "] edition = "2018" [dependencies] -x86_64 = { version = "0.13.2", default-features = false, features = ["instructions", "inline_asm"] } +x86_64 = { version = "0.14.7", default-features = false, features = ["instructions", "inline_asm"] } From 857e48ed4e7214465f8b5a766bf6be5e96c76598 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 20 Dec 2021 08:32:42 +0100 Subject: [PATCH 18/68] Import `global_asm` macro which now lives under `core::arch` --- src/main.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3ccac477..7b552ca9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,8 +10,7 @@ compile_error!("The bootloader crate must be compiled for the `x86_64-bootloader extern crate rlibc; use bootloader::bootinfo::{BootInfo, FrameRange}; -use core::convert::TryInto; -use core::panic::PanicInfo; +use core::{arch::global_asm, convert::TryInto, panic::PanicInfo}; use core::{mem, slice}; use fixedvec::alloc_stack; use usize_conversions::usize_from; From 01818d509719a5e3bc9e485288f385350ca6b71e Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 20 Dec 2021 08:48:10 +0100 Subject: [PATCH 19/68] Update changelog for #208 --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index da76b145..5fb4ecc1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +- Update x86_64 dependency to v0.14.7 to fix nightly breakage ([#208](https://github.com/rust-osdev/bootloader/pull/208)) + # 0.9.19 – 2021-08-09 - Set `relocation-model: static` and `panic-strategy: abort` and `fix .intel_syntax` warnings [#185](https://github.com/rust-osdev/bootloader/pull/185) From cc055a7a5c2b124b593cc0bc3e2b9bb57c69f72f Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 20 Dec 2021 08:48:28 +0100 Subject: [PATCH 20/68] Release version 0.9.20 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4bb82fc7..87bbd9b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.19" +version = "0.9.20" dependencies = [ "bit_field", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index 8a1aee40..2926de32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.19" +version = "0.9.20" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index 5fb4ecc1..55905fa0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.20 – 2021-12-20 + - Update x86_64 dependency to v0.14.7 to fix nightly breakage ([#208](https://github.com/rust-osdev/bootloader/pull/208)) # 0.9.19 – 2021-08-09 From 4331e0d582bdefa8f962d4fa76b4fa4049be1186 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 9 Jan 2022 15:47:41 +0100 Subject: [PATCH 21/68] Use intel syntax again --- src/main.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 21b8ceae..209218cf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,9 +42,8 @@ global_asm!(include_str!("video_mode/vga_320x200.s")); global_asm!(include_str!("video_mode/vga_text_80x25.s")); unsafe fn context_switch(boot_info: VirtAddr, entry_point: VirtAddr, stack_pointer: VirtAddr) -> ! { - asm!("movq {1}, %rsp; callq *{0}; 0: jmp 0b", - in(reg) entry_point.as_u64(), in(reg) stack_pointer.as_u64(), in("rdi") boot_info.as_u64(), - options(att_syntax)); + asm!("mov rsp, {1}; call {0}; 2: jmp 2b", + in(reg) entry_point.as_u64(), in(reg) stack_pointer.as_u64(), in("rdi") boot_info.as_u64()); ::core::hint::unreachable_unchecked() } From bdb49cd0677d12294e11e40e79abcc7c8b335b93 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 9 Jan 2022 15:52:15 +0100 Subject: [PATCH 22/68] Update for latest nightly changes --- src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.rs b/src/main.rs index 209218cf..207a16d8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ compile_error!("The bootloader crate must be compiled for the `x86_64-bootloader extern crate rlibc; use bootloader::bootinfo::{BootInfo, FrameRange}; +use core::arch::asm; use core::convert::TryInto; use core::panic::PanicInfo; use core::{mem, slice}; From 1d845a3b9820063bf9bb5d5abe08173ad3d6372a Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 9 Jan 2022 16:08:44 +0100 Subject: [PATCH 23/68] Update changelog for #204 --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index 55905fa0..444fbcf1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +- Use new inline assembly syntax ([#204](https://github.com/rust-osdev/bootloader/pull/204)) + # 0.9.20 – 2021-12-20 - Update x86_64 dependency to v0.14.7 to fix nightly breakage ([#208](https://github.com/rust-osdev/bootloader/pull/208)) From 1b4fc9389c320b60fc120d67d257b11864221f6a Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 9 Jan 2022 16:11:31 +0100 Subject: [PATCH 24/68] Release version 0.9.21 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 87bbd9b4..fda26869 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.20" +version = "0.9.21" dependencies = [ "bit_field", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index 2926de32..6d388280 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.20" +version = "0.9.21" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index 444fbcf1..07dffdf1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.21 – 2022-01-09 + - Use new inline assembly syntax ([#204](https://github.com/rust-osdev/bootloader/pull/204)) # 0.9.20 – 2021-12-20 From 0ab2fe9e2afbb1ffab9f7461b858442776b4cfb4 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 1 Mar 2022 21:49:43 +0100 Subject: [PATCH 25/68] Remove the `asm` and `global_asm` features, which are now stable --- src/main.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index f63c65ed..c63156a6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,4 @@ #![feature(lang_items)] -#![feature(global_asm)] -#![feature(asm)] #![no_std] #![no_main] From fa4b5cf35c164126bf10474e6d4815a1e52e4e82 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 1 Mar 2022 21:55:38 +0100 Subject: [PATCH 26/68] Remove `lang_items` feature --- src/main.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index c63156a6..22094add 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,3 @@ -#![feature(lang_items)] #![no_std] #![no_main] @@ -378,12 +377,6 @@ pub fn panic(info: &PanicInfo) -> ! { loop {} } -#[lang = "eh_personality"] -#[no_mangle] -pub extern "C" fn eh_personality() { - loop {} -} - #[no_mangle] pub extern "C" fn _Unwind_Resume() { loop {} From 807583aaa6da183d76e9a41ca85151c8495a9212 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 1 Mar 2022 21:56:36 +0100 Subject: [PATCH 27/68] Update Cargo.lock Seems like we forgot to commit this when we updated the x86_64 dependency the last time. --- test-kernel/Cargo.lock | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/test-kernel/Cargo.lock b/test-kernel/Cargo.lock index 5d0ef56f..a76396ee 100644 --- a/test-kernel/Cargo.lock +++ b/test-kernel/Cargo.lock @@ -1,10 +1,12 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "bit_field" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56" +checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" [[package]] name = "bitflags" @@ -19,12 +21,19 @@ dependencies = [ "x86_64", ] +[[package]] +name = "volatile" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4c2dbd44eb8b53973357e6e207e370f0c1059990df850aca1eca8947cf464f0" + [[package]] name = "x86_64" -version = "0.13.2" +version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b871116e3c83dad0795580b10b2b1dd05cb52ec719af36180371877b09681f7f" +checksum = "958ab3202b01bc43ba2eb832102c4a487ed93151667a2289062e5f2b00058be2" dependencies = [ "bit_field", "bitflags", + "volatile", ] From 68ed739d47aa9e77ec3f054c1d0ad6cd4fe7c428 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 1 Mar 2022 22:19:33 +0100 Subject: [PATCH 28/68] Update changelog for #227 --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index 07dffdf1..e679df72 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +- Remove the `asm` and `global_asm` features, which are now stable ([#227](https://github.com/rust-osdev/bootloader/pull/227)) + # 0.9.21 – 2022-01-09 - Use new inline assembly syntax ([#204](https://github.com/rust-osdev/bootloader/pull/204)) From e4590b844e514be9aee6cbbc64baa4e1c68dd7c0 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 1 Mar 2022 22:21:05 +0100 Subject: [PATCH 29/68] Update cargo-release configuration to latest version --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6d388280..fee59b8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,9 +55,9 @@ features = [ "recursive_page_table", "map_physical_memory" ] default-target = "x86_64-unknown-linux-gnu" [package.metadata.release] -no-dev-version = true +dev-version = false pre-release-replacements = [ { file="Changelog.md", search="# Unreleased", replace="# Unreleased\n\n# {{version}} – {{date}}", exactly=1 }, ] pre-release-commit-message = "Release version {{version}}" -disable-publish = true +publish = false From 42da77b47558478c5a948d27cac80767b484eacc Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 1 Mar 2022 22:21:18 +0100 Subject: [PATCH 30/68] Release version 0.9.22 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fda26869..fb209882 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.21" +version = "0.9.22" dependencies = [ "bit_field", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index fee59b8e..1fae8207 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.21" +version = "0.9.22" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index e679df72..e21b0e3a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.22 – 2022-03-01 + - Remove the `asm` and `global_asm` features, which are now stable ([#227](https://github.com/rust-osdev/bootloader/pull/227)) # 0.9.21 – 2022-01-09 From 48716f806646bbebae188c7eb4aac46b92507ac0 Mon Sep 17 00:00:00 2001 From: Tom Dohrmann Date: Thu, 22 Sep 2022 22:43:08 +0200 Subject: [PATCH 31/68] allow allocating more than one level 4 entry --- src/level4_entries.rs | 14 +++++++++----- src/main.rs | 12 ++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/level4_entries.rs b/src/level4_entries.rs index 60ace846..c4c11140 100644 --- a/src/level4_entries.rs +++ b/src/level4_entries.rs @@ -31,15 +31,19 @@ impl UsedLevel4Entries { used } - pub fn get_free_entry(&mut self) -> PageTableIndex { - let (idx, entry) = self + pub fn get_free_entries(&mut self, num: u64) -> PageTableIndex { + let idx = self .entry_state - .iter_mut() + .windows(num as usize) .enumerate() - .find(|(_, &mut entry)| entry == false) + .find(|(_, entries)| entries.iter().all(|&entry| entry == false)) + .map(|(idx, _)| idx) .expect("no usable level 4 entries found"); - *entry = true; + for i in 0..num as usize { + self.entry_state[idx + i] = true; + } + PageTableIndex::new(idx.try_into().unwrap()) } } diff --git a/src/main.rs b/src/main.rs index 22094add..57250c9c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -169,7 +169,8 @@ fn bootloader_main( enable_nxe_bit(); // Create a recursive page table entry - let recursive_index = PageTableIndex::new(level4_entries.get_free_entry().try_into().unwrap()); + let recursive_index = + PageTableIndex::new(level4_entries.get_free_entries(1).try_into().unwrap()); let mut entry = PageTableEntry::new(); entry.set_addr( p4_physical, @@ -243,7 +244,7 @@ fn bootloader_main( let page: Page = match BOOT_INFO_ADDRESS { Some(addr) => Page::containing_address(VirtAddr::new(addr)), None => Page::from_page_table_indices( - level4_entries.get_free_entry(), + level4_entries.get_free_entries(1), PageTableIndex::new(0), PageTableIndex::new(0), PageTableIndex::new(0), @@ -286,11 +287,10 @@ fn bootloader_main( let physical_memory_offset = if cfg!(feature = "map_physical_memory") { let physical_memory_offset = PHYSICAL_MEMORY_OFFSET.unwrap_or_else(|| { - // If offset not manually provided, find a free p4 entry and map memory here. - // One level 4 entry spans 2^48/512 bytes (over 500gib) so this should suffice. - assert!(max_phys_addr < (1 << 48) / 512); + const LEVEL_4_SIZE: u64 = 4096 * 512 * 512 * 512; + let level_4_entries = (max_phys_addr + (LEVEL_4_SIZE - 1)) / LEVEL_4_SIZE; Page::from_page_table_indices_1gib( - level4_entries.get_free_entry(), + level4_entries.get_free_entries(level_4_entries), PageTableIndex::new(0), ) .start_address() From 7787567f6069fa6a9d8aa2ed94e5e702b5766d99 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 25 Sep 2022 10:40:55 +0200 Subject: [PATCH 32/68] Use choco instead of scoop for installing QEMU on Windows --- .github/workflows/build.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56fa6316..847e27d8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,14 +65,10 @@ jobs: HOMEBREW_NO_AUTO_UPDATE: 1 HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: 1 HOMEBREW_NO_INSTALL_CLEANUP: 1 - - name: Install Scoop (Windows) - run: | - Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh') - echo "$HOME\scoop\shims" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - if: runner.os == 'Windows' - shell: pwsh - name: Install QEMU (Windows) - run: scoop install qemu + run: | + choco install qemu --version 2021.5.5 + echo "$Env:Programfiles\qemu" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append if: runner.os == 'Windows' shell: pwsh - name: "Print QEMU Version" From 852e1db05496a3b2d08ec397ab39cac295b8dba6 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 25 Sep 2022 11:13:27 +0200 Subject: [PATCH 33/68] Update changelog for #259 --- Changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog.md b/Changelog.md index e21b0e3a..5513b1ba 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Unreleased +- Fix boot for machines that report memory regions at high physical addresses (see #259) + - Allow allocating more than one level 4 entry ([#264](https://github.com/rust-osdev/bootloader/pull/264)) + # 0.9.22 – 2022-03-01 - Remove the `asm` and `global_asm` features, which are now stable ([#227](https://github.com/rust-osdev/bootloader/pull/227)) From 38c11a6d198c05e643bfe567b547585cf0445e9b Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 25 Sep 2022 11:13:36 +0200 Subject: [PATCH 34/68] Release version 0.9.23 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb209882..b1409eb3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.22" +version = "0.9.23" dependencies = [ "bit_field", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index 1fae8207..6a22bfaa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.22" +version = "0.9.23" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index 5513b1ba..7d5c22dd 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.23 – 2022-09-25 + - Fix boot for machines that report memory regions at high physical addresses (see #259) - Allow allocating more than one level 4 entry ([#264](https://github.com/rust-osdev/bootloader/pull/264)) From 0d5048ee5095b72f389555e21151e8dfd528b8eb Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 28 Jan 2024 11:29:37 +0100 Subject: [PATCH 35/68] Fix data layout for `x86_64-bootloader` target --- x86_64-bootloader.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x86_64-bootloader.json b/x86_64-bootloader.json index ceb196e9..f40a2b6f 100644 --- a/x86_64-bootloader.json +++ b/x86_64-bootloader.json @@ -1,6 +1,6 @@ { "llvm-target": "x86_64-unknown-none-gnu", - "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-f80:128-n8:16:32:64-S128", "linker-flavor": "ld.lld", "linker": "rust-lld", "pre-link-args": { From cb31d5a63f143e53a5eed2be502044bf59720ffc Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 28 Jan 2024 11:31:57 +0100 Subject: [PATCH 36/68] Fix data layout for example kernels too --- example-kernel/x86_64-example-kernel.json | 2 +- test-kernel/x86_64-test-kernel.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example-kernel/x86_64-example-kernel.json b/example-kernel/x86_64-example-kernel.json index 9afe809f..bcb4c8bf 100644 --- a/example-kernel/x86_64-example-kernel.json +++ b/example-kernel/x86_64-example-kernel.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-f80:128-n8:16:32:64-S128", "arch": "x86_64", "target-endian": "little", "target-pointer-width": "64", diff --git a/test-kernel/x86_64-test-kernel.json b/test-kernel/x86_64-test-kernel.json index 9afe809f..bcb4c8bf 100644 --- a/test-kernel/x86_64-test-kernel.json +++ b/test-kernel/x86_64-test-kernel.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-f80:128-n8:16:32:64-S128", "arch": "x86_64", "target-endian": "little", "target-pointer-width": "64", From 5da41ad7e4e29e584d2a1a9c030925050a7de7a9 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 28 Jan 2024 11:38:11 +0100 Subject: [PATCH 37/68] Update changelog for #415 --- Changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog.md b/Changelog.md index 7d5c22dd..33308981 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Unreleased +- Fix data layout for `x86_64-bootloader` target ([#415](https://github.com/rust-osdev/bootloader/pull/415)) + - Fixes build on latest Rust nightly + # 0.9.23 – 2022-09-25 - Fix boot for machines that report memory regions at high physical addresses (see #259) From d543dc07f10e6cece1ac496a7c6188d73a915161 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 28 Jan 2024 11:39:03 +0100 Subject: [PATCH 38/68] Update cargo-release configuration to latest version --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6a22bfaa..e86e6711 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,6 @@ features = [ "recursive_page_table", "map_physical_memory" ] default-target = "x86_64-unknown-linux-gnu" [package.metadata.release] -dev-version = false pre-release-replacements = [ { file="Changelog.md", search="# Unreleased", replace="# Unreleased\n\n# {{version}} – {{date}}", exactly=1 }, ] From e615ce2759c32aca513f0530edcf442d500a4efa Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 28 Jan 2024 11:40:02 +0100 Subject: [PATCH 39/68] Release version 0.9.24 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b1409eb3..76dcc1e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.23" +version = "0.9.24" dependencies = [ "bit_field", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index e86e6711..af12c08f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.23" +version = "0.9.24" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index 33308981..92827ce8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.24 – 2024-01-28 + - Fix data layout for `x86_64-bootloader` target ([#415](https://github.com/rust-osdev/bootloader/pull/415)) - Fixes build on latest Rust nightly From 2fe7c2e769203ea7700f6a67516e5c1606aecb48 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 16 Feb 2024 12:28:28 +0100 Subject: [PATCH 40/68] Fix data layout for custom targets for LLVM 18 --- example-kernel/x86_64-example-kernel.json | 2 +- test-kernel/x86_64-test-kernel.json | 2 +- x86_64-bootloader.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example-kernel/x86_64-example-kernel.json b/example-kernel/x86_64-example-kernel.json index bcb4c8bf..7a0cd61a 100644 --- a/example-kernel/x86_64-example-kernel.json +++ b/example-kernel/x86_64-example-kernel.json @@ -1,6 +1,6 @@ { "llvm-target": "x86_64-unknown-none", - "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-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", diff --git a/test-kernel/x86_64-test-kernel.json b/test-kernel/x86_64-test-kernel.json index bcb4c8bf..7a0cd61a 100644 --- a/test-kernel/x86_64-test-kernel.json +++ b/test-kernel/x86_64-test-kernel.json @@ -1,6 +1,6 @@ { "llvm-target": "x86_64-unknown-none", - "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-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", diff --git a/x86_64-bootloader.json b/x86_64-bootloader.json index f40a2b6f..35fc07a3 100644 --- a/x86_64-bootloader.json +++ b/x86_64-bootloader.json @@ -1,6 +1,6 @@ { "llvm-target": "x86_64-unknown-none-gnu", - "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-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", "linker-flavor": "ld.lld", "linker": "rust-lld", "pre-link-args": { From 3261e9e8149f78fc5e3df8a3fd445567d1744433 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 16 Feb 2024 12:33:04 +0100 Subject: [PATCH 41/68] Update changelog for #421 --- Changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog.md b/Changelog.md index 92827ce8..a2c70d09 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Unreleased +- [Fix data layout for custom targets for LLVM 18](https://github.com/rust-osdev/bootloader/pull/421) + - Fixes build on latest Rust nightly + # 0.9.24 – 2024-01-28 - Fix data layout for `x86_64-bootloader` target ([#415](https://github.com/rust-osdev/bootloader/pull/415)) From 9a915f1a973c0fbc99aea68550542d68cba48bd2 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 16 Feb 2024 12:33:57 +0100 Subject: [PATCH 42/68] Release version 0.9.25 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 76dcc1e6..ef7a6790 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.24" +version = "0.9.25" dependencies = [ "bit_field", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index af12c08f..cbacad0f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.24" +version = "0.9.25" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index a2c70d09..2c409bbf 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.25 – 2024-02-16 + - [Fix data layout for custom targets for LLVM 18](https://github.com/rust-osdev/bootloader/pull/421) - Fixes build on latest Rust nightly From f317b0de5f8b3a5d8719e7d30433aa0b454dd4a8 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 16 Feb 2024 13:01:30 +0100 Subject: [PATCH 43/68] Don't error if a kernel page is already mapped to the correct frame This can happen if one frame contains two loadable sections. --- src/page_table.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/page_table.rs b/src/page_table.rs index ed2ac136..c28890fe 100644 --- a/src/page_table.rs +++ b/src/page_table.rs @@ -96,8 +96,15 @@ pub(crate) fn map_segment( for frame in PhysFrame::range_inclusive(start_frame, end_frame) { let offset = frame - start_frame; let page = start_page + offset; - unsafe { map_page(page, frame, page_table_flags, page_table, frame_allocator)? } - .flush(); + match unsafe { + map_page(page, frame, page_table_flags, page_table, frame_allocator) + } { + Ok(flusher) => flusher.flush(), + Err(MapToError::PageAlreadyMapped(to)) if to == frame => { + // nothing to do, page is already mapped to the correct frame + } + Err(err) => return Err(err), + } } if mem_size > file_size { From 949a297d91bb33bc5bf374a090c495b51371d52a Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 16 Feb 2024 13:03:05 +0100 Subject: [PATCH 44/68] Fix: unmap temp page again to enable multiple bss-like sections --- src/page_table.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/page_table.rs b/src/page_table.rs index c28890fe..c666de79 100644 --- a/src/page_table.rs +++ b/src/page_table.rs @@ -124,7 +124,7 @@ pub(crate) fn map_segment( unsafe { map_page( temp_page.clone(), - new_frame.clone(), + new_frame, page_table_flags, page_table, frame_allocator, @@ -152,6 +152,11 @@ pub(crate) fn map_segment( }); } + // unmap temp page again + let (new_frame, flusher) = page_table.unmap(temp_page).unwrap(); + flusher.flush(); + + // map last page to new frame unsafe { map_page( last_page, From 9209b0c34cd9446810b9fceef4de0091292471d3 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 16 Feb 2024 13:06:47 +0100 Subject: [PATCH 45/68] Update changelog for #422 --- Changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Changelog.md b/Changelog.md index 2c409bbf..24cd6238 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ # Unreleased + +- [Fix map errors during kernel loading](https://github.com/rust-osdev/bootloader/pull/422) + - Don't error if a kernel page is already mapped to the correct frame + - Fix: unmap temp page again to enable multiple bss-like sections + # 0.9.25 – 2024-02-16 - [Fix data layout for custom targets for LLVM 18](https://github.com/rust-osdev/bootloader/pull/421) From 5186c62a8e8d6b5045bf5ebebb28f9574c3d711e Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 16 Feb 2024 13:12:31 +0100 Subject: [PATCH 46/68] Release version 0.9.26 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ef7a6790..8a4eb188 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.25" +version = "0.9.26" dependencies = [ "bit_field", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index cbacad0f..6b414294 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.25" +version = "0.9.26" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index 24cd6238..8b5db859 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.26 – 2024-02-16 + - [Fix map errors during kernel loading](https://github.com/rust-osdev/bootloader/pull/422) - Don't error if a kernel page is already mapped to the correct frame From 6b49d248e9529669e042eb79f7e4851f8a9a8379 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 16 Feb 2024 14:04:11 +0100 Subject: [PATCH 47/68] Fix: unify flags if multiple segments are mapped to same frame with different flags --- src/page_table.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/page_table.rs b/src/page_table.rs index c666de79..fce0bd22 100644 --- a/src/page_table.rs +++ b/src/page_table.rs @@ -2,9 +2,10 @@ use crate::frame_allocator::FrameAllocator; use bootloader::bootinfo::MemoryRegionType; use bootloader::bootinfo::TlsTemplate; use fixedvec::FixedVec; -use x86_64::structures::paging::mapper::{MapToError, MapperFlush, UnmapError}; +use x86_64::structures::paging::mapper::{MapToError, MapperFlush, TranslateResult, UnmapError}; use x86_64::structures::paging::{ self, Mapper, Page, PageSize, PageTableFlags, PhysFrame, RecursivePageTable, Size4KiB, + Translate, }; use x86_64::{align_up, PhysAddr, VirtAddr}; use xmas_elf::program::{self, ProgramHeader64}; @@ -101,6 +102,18 @@ pub(crate) fn map_segment( } { Ok(flusher) => flusher.flush(), Err(MapToError::PageAlreadyMapped(to)) if to == frame => { + let flags = match page_table.translate(page.start_address()) { + TranslateResult::Mapped { flags, .. } => flags, + _ => unreachable!(), + }; + if flags != page_table_flags { + unsafe { + page_table + .update_flags(page, flags | page_table_flags) + .unwrap() + .flush() + }; + } // nothing to do, page is already mapped to the correct frame } Err(err) => return Err(err), From a9a47872acd27bb91a518e4ca854fe93d1186f00 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 16 Feb 2024 14:05:16 +0100 Subject: [PATCH 48/68] Update changelog for #423 --- Changelog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 8b5db859..dc2e07bb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,7 +1,8 @@ # Unreleased -# 0.9.26 – 2024-02-16 +- [Fix: unify flags if multiple segments are mapped to same frame with different flags](https://github.com/rust-osdev/bootloader/pull/423) +# 0.9.26 – 2024-02-16 - [Fix map errors during kernel loading](https://github.com/rust-osdev/bootloader/pull/422) - Don't error if a kernel page is already mapped to the correct frame From 4b80d28d7187682725358ed45f0454d50f810d14 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 16 Feb 2024 15:47:35 +0100 Subject: [PATCH 49/68] Fix invalid mapping to zero page caused by off-by-one bug The `zero_end` bound is exclusive, but we treat the `end_page` as inclusive. So when `zero_end` is page-aligned, we allocate one additional bss page. If this page was already mapped to some other segment, we remap it to a page with random content. This is the same bug as https://github.com/rust-osdev/bootloader/pull/362. --- src/page_table.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/page_table.rs b/src/page_table.rs index fce0bd22..5daca1d5 100644 --- a/src/page_table.rs +++ b/src/page_table.rs @@ -187,7 +187,7 @@ pub(crate) fn map_segment( zero_start.as_u64(), Size4KiB::SIZE, ))); - let end_page = Page::containing_address(zero_end); + let end_page = Page::containing_address(zero_end - 1usize); for page in Page::range_inclusive(start_page, end_page) { let frame = frame_allocator .allocate_frame(MemoryRegionType::Kernel) From 265314f5582937422e0b226dfd799fa6dafb85a6 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 16 Feb 2024 15:50:45 +0100 Subject: [PATCH 50/68] Panic again when segements overlap This seems like a good indicator for bugs in the mapping code. This reverts PR #423 and commit https://github.com/rust-osdev/bootloader/pull/422/commits/f317b0de5f8b3a5d8719e7d30433aa0b454dd4a8. --- src/page_table.rs | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/page_table.rs b/src/page_table.rs index 5daca1d5..35880725 100644 --- a/src/page_table.rs +++ b/src/page_table.rs @@ -97,27 +97,14 @@ pub(crate) fn map_segment( for frame in PhysFrame::range_inclusive(start_frame, end_frame) { let offset = frame - start_frame; let page = start_page + offset; - match unsafe { - map_page(page, frame, page_table_flags, page_table, frame_allocator) - } { - Ok(flusher) => flusher.flush(), - Err(MapToError::PageAlreadyMapped(to)) if to == frame => { - let flags = match page_table.translate(page.start_address()) { - TranslateResult::Mapped { flags, .. } => flags, - _ => unreachable!(), - }; - if flags != page_table_flags { - unsafe { - page_table - .update_flags(page, flags | page_table_flags) - .unwrap() - .flush() - }; - } - // nothing to do, page is already mapped to the correct frame - } - Err(err) => return Err(err), - } + unsafe { map_page(page, frame, page_table_flags, page_table, frame_allocator) } + .unwrap_or_else(|err| { + panic!( + "failed to map segment starting at {:?}: failed to map page {:?} to frame {:?}: {:?}", + start_page, page, frame, err + ) + }) + .flush(); } if mem_size > file_size { From 14e926e96b39294b65d62c01d05fabb4f9e1fe7b Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 16 Feb 2024 15:51:55 +0100 Subject: [PATCH 51/68] Update changelog for #424 --- Changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index dc2e07bb..2f2ed992 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,6 @@ # Unreleased -- [Fix: unify flags if multiple segments are mapped to same frame with different flags](https://github.com/rust-osdev/bootloader/pull/423) +- [Fix invalid mapping to zero page caused by off-by-one bug](https://github.com/rust-osdev/bootloader/pull/424) # 0.9.26 – 2024-02-16 From b1259488db00c076014ff0d01a0563a0b7ae3914 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 16 Feb 2024 15:57:52 +0100 Subject: [PATCH 52/68] Release version 0.9.27 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8a4eb188..fa3dc2be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.26" +version = "0.9.27" dependencies = [ "bit_field", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index 6b414294..bc066888 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.26" +version = "0.9.27" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index 2f2ed992..2bd8208b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.27 – 2024-02-16 + - [Fix invalid mapping to zero page caused by off-by-one bug](https://github.com/rust-osdev/bootloader/pull/424) # 0.9.26 – 2024-02-16 From 035da74bc2242ca700f7baa2d281b8c6f47cfadb Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Wed, 28 Feb 2024 09:32:35 +0100 Subject: [PATCH 53/68] Remove unused paging imports --- src/page_table.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/page_table.rs b/src/page_table.rs index 35880725..2163c3a2 100644 --- a/src/page_table.rs +++ b/src/page_table.rs @@ -2,10 +2,9 @@ use crate::frame_allocator::FrameAllocator; use bootloader::bootinfo::MemoryRegionType; use bootloader::bootinfo::TlsTemplate; use fixedvec::FixedVec; -use x86_64::structures::paging::mapper::{MapToError, MapperFlush, TranslateResult, UnmapError}; +use x86_64::structures::paging::mapper::{MapToError, MapperFlush, UnmapError}; use x86_64::structures::paging::{ self, Mapper, Page, PageSize, PageTableFlags, PhysFrame, RecursivePageTable, Size4KiB, - Translate, }; use x86_64::{align_up, PhysAddr, VirtAddr}; use xmas_elf::program::{self, ProgramHeader64}; From 56674c0cfca132ed485810bf689f66afa292fefe Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 28 Feb 2024 09:55:43 +0100 Subject: [PATCH 54/68] Update changelog for #430 --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index 2bd8208b..a459f58b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +- Fix warnings: [Remove unused paging imports](https://github.com/rust-osdev/bootloader/pull/430) + # 0.9.27 – 2024-02-16 - [Fix invalid mapping to zero page caused by off-by-one bug](https://github.com/rust-osdev/bootloader/pull/424) From 4312531bde93673a0ad36b3fc2f9ff9cbcc82c49 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 28 Feb 2024 09:56:12 +0100 Subject: [PATCH 55/68] Release version 0.9.28 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa3dc2be..2f270b76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.27" +version = "0.9.28" dependencies = [ "bit_field", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index bc066888..9706f9be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.27" +version = "0.9.28" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index a459f58b..b452a6a2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.28 – 2024-02-28 + - Fix warnings: [Remove unused paging imports](https://github.com/rust-osdev/bootloader/pull/430) # 0.9.27 – 2024-02-16 From fc48fe618342d190db813e779c227d0223b715ba Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 30 Apr 2024 13:37:32 +0200 Subject: [PATCH 56/68] Silence dead code warning The field is not read anywhere, but printed as part of the Debug output on error. --- src/page_table.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/page_table.rs b/src/page_table.rs index 2163c3a2..62a2be07 100644 --- a/src/page_table.rs +++ b/src/page_table.rs @@ -17,7 +17,11 @@ pub struct MemoryInfo { #[derive(Debug)] pub enum MapKernelError { - Mapping(MapToError), + Mapping( + /// This field is never read, but still printed as part of the Debug output on error. + #[allow(dead_code)] + MapToError, + ), MultipleTlsSegments, } From 90928c66fc684942ff8dd7d608a63c8208786c6a Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 30 Apr 2024 13:45:20 +0200 Subject: [PATCH 57/68] Rename `.cargo/config` to `.cargo/config.toml` Fixes a deprecation warning. --- .cargo/{config => config.toml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .cargo/{config => config.toml} (100%) diff --git a/.cargo/config b/.cargo/config.toml similarity index 100% rename from .cargo/config rename to .cargo/config.toml From 318b60e9bd86659a833f185f5de328c0ddde09ad Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 30 Apr 2024 13:52:20 +0200 Subject: [PATCH 58/68] Replace `cargo xbuild` calls with `cargo build -Zbuild-std=core` --- .github/workflows/build.yml | 11 ++++------- README.md | 10 +++++----- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 847e27d8..b5ef0f5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,17 +36,16 @@ jobs: - name: "Install Rustup Components" run: rustup component add rust-src llvm-tools-preview - - name: "Install cargo-xbuild" - run: cargo install cargo-xbuild --debug + - name: "Install cargo-binutils" run: cargo install cargo-binutils --version 0.1.7 --debug - - run: cargo xbuild + - run: cargo build -Zbuild-std=core working-directory: test-kernel name: 'Build Test Kernel' - name: 'Build Bootloader' - run: cargo xbuild --bin bootloader --features binary --release + run: cargo build -Zbuild-std=core --bin bootloader --features binary --release env: KERNEL: "test-kernel/target/x86_64-test-kernel/debug/test-kernel" KERNEL_MANIFEST: "test-kernel/Cargo.toml" @@ -96,10 +95,8 @@ jobs: - uses: actions/checkout@v1 - name: "Install Rustup Components" run: rustup component add rust-src llvm-tools-preview - - name: "Install cargo-xbuild" - run: cargo install cargo-xbuild --debug - name: 'Build Example Kernel' - run: cargo xbuild + run: cargo build -Zbuild-std=core working-directory: example-kernel diff --git a/README.md b/README.md index 5a5db560..945efcc3 100644 --- a/README.md +++ b/README.md @@ -108,28 +108,28 @@ Note that the addresses **must** be given as strings (in either hex or decimal f ## Requirements -You need a nightly [Rust](https://www.rust-lang.org) compiler and [cargo xbuild](https://github.com/rust-osdev/cargo-xbuild). You also need the `llvm-tools-preview` component, which can be installed through `rustup component add llvm-tools-preview`. +You need a nightly [Rust](https://www.rust-lang.org) compiler. You also need the `llvm-tools-preview` component, which can be installed through `rustup component add llvm-tools-preview`. ## Build The simplest way to use the bootloader is in combination with the [bootimage](https://github.com/rust-osdev/bootimage) tool. This crate **requires at least bootimage 0.7.7**. With the tool installed, you can add a normal cargo dependency on the `bootloader` crate to your kernel and then run `bootimage build` to create a bootable disk image. You can also execute `bootimage run` to run your kernel in [QEMU](https://www.qemu.org/) (needs to be installed). -To compile the bootloader manually, you need to invoke `cargo xbuild` with two environment variables: +To compile the bootloader manually, you need to invoke `cargo build -Zbuild-std=core` with two environment variables: * `KERNEL`: points to your kernel executable (in the ELF format) * `KERNEL_MANIFEST`: points to the `Cargo.toml` describing your kernel For example: ``` -KERNEL=/path/to/your/kernel/target/debug/your_kernel KERNEL_MANIFEST=/path/to/your/kernel/Cargo.toml cargo xbuild +KERNEL=/path/to/your/kernel/target/debug/your_kernel KERNEL_MANIFEST=/path/to/your/kernel/Cargo.toml cargo build -Zbuild-std=core ``` As an example, you can build the bootloader with example kernel from the `example-kernel` directory with the following commands: ``` cd example-kernel -cargo xbuild +cargo build -Zbuild-std=core cd .. -KERNEL=example-kernel/target/x86_64-example-kernel/debug/example-kernel KERNEL_MANIFEST=example-kernel/Cargo.toml cargo xbuild --release --features binary +KERNEL=example-kernel/target/x86_64-example-kernel/debug/example-kernel KERNEL_MANIFEST=example-kernel/Cargo.toml cargo build -Zbuild-std=core --release --features binary ``` The `binary` feature is required to enable the dependencies required for compiling the bootloader executable. The command results in a bootloader executable at `target/x86_64-bootloader.json/release/bootloader`. This executable is still an ELF file, which can't be run directly. From 72e52ccd8a669234ea16c4aad902ab71f9f21cda Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 30 Apr 2024 15:36:29 +0200 Subject: [PATCH 59/68] Update changelog --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index b452a6a2..52a0bdd3 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +- Fix warnings ([#436](https://github.com/rust-osdev/bootloader/pull/436) and [#437](https://github.com/rust-osdev/bootloader/pull/437)) + # 0.9.28 – 2024-02-28 - Fix warnings: [Remove unused paging imports](https://github.com/rust-osdev/bootloader/pull/430) From 08602a8e42ef46c34f6e40a9de2bf172a0e1c577 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 30 Apr 2024 15:36:53 +0200 Subject: [PATCH 60/68] Release version 0.9.29 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2f270b76..b01735fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.28" +version = "0.9.29" dependencies = [ "bit_field", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index 9706f9be..d09190b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.28" +version = "0.9.29" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index 52a0bdd3..3ad42efb 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.29 – 2024-04-30 + - Fix warnings ([#436](https://github.com/rust-osdev/bootloader/pull/436) and [#437](https://github.com/rust-osdev/bootloader/pull/437)) # 0.9.28 – 2024-02-28 From fcdd1d81586abb9d7ddf92963b7b7f8cbad47987 Mon Sep 17 00:00:00 2001 From: Tom Dohrmann Date: Tue, 4 Feb 2025 07:33:35 +0100 Subject: [PATCH 61/68] change rustc-abi in custom targets to x86-softfloat With the latest nightly, setting "+soft-float" in "features" is only allowed if "rustc-abi" is set to "x86-softfloat". --- example-kernel/x86_64-example-kernel.json | 3 ++- test-kernel/x86_64-test-kernel.json | 3 ++- x86_64-bootloader.json | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/example-kernel/x86_64-example-kernel.json b/example-kernel/x86_64-example-kernel.json index 7a0cd61a..6f5613c2 100644 --- a/example-kernel/x86_64-example-kernel.json +++ b/example-kernel/x86_64-example-kernel.json @@ -11,5 +11,6 @@ "linker": "rust-lld", "panic-strategy": "abort", "disable-redzone": true, - "features": "-mmx,-sse,+soft-float" + "features": "-mmx,-sse,+soft-float", + "rustc-abi": "x86-softfloat" } diff --git a/test-kernel/x86_64-test-kernel.json b/test-kernel/x86_64-test-kernel.json index 7a0cd61a..6f5613c2 100644 --- a/test-kernel/x86_64-test-kernel.json +++ b/test-kernel/x86_64-test-kernel.json @@ -11,5 +11,6 @@ "linker": "rust-lld", "panic-strategy": "abort", "disable-redzone": true, - "features": "-mmx,-sse,+soft-float" + "features": "-mmx,-sse,+soft-float", + "rustc-abi": "x86-softfloat" } diff --git a/x86_64-bootloader.json b/x86_64-bootloader.json index 35fc07a3..9f4a2591 100644 --- a/x86_64-bootloader.json +++ b/x86_64-bootloader.json @@ -18,5 +18,6 @@ "disable-redzone": true, "panic-strategy": "abort", "executables": true, - "relocation-model": "static" + "relocation-model": "static", + "rustc-abi": "x86-softfloat" } From 074496ccba001c9ae89c92ea6741ac843ec7d35c Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 10 Feb 2025 10:58:12 +0100 Subject: [PATCH 62/68] Update changelog for #492 --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index 3ad42efb..d45f4377 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +- [change rustc-abi in custom targets to x86-softfloat](https://github.com/rust-osdev/bootloader/pull/492) + # 0.9.29 – 2024-04-30 - Fix warnings ([#436](https://github.com/rust-osdev/bootloader/pull/436) and [#437](https://github.com/rust-osdev/bootloader/pull/437)) From ce5da20cc50f3f103a59f79ec9a05801b78adcca Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 10 Feb 2025 10:58:26 +0100 Subject: [PATCH 63/68] Release version 0.9.30 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b01735fe..61d51144 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "bit_field" @@ -16,7 +16,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.29" +version = "0.9.30" dependencies = [ "bit_field", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index d09190b6..0b5bbfd7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.29" +version = "0.9.30" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index d45f4377..5708e743 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.30 – 2025-02-10 + - [change rustc-abi in custom targets to x86-softfloat](https://github.com/rust-osdev/bootloader/pull/492) # 0.9.29 – 2024-04-30 From 2c48aacda0b22162f41f63860d14f4bbd85f6743 Mon Sep 17 00:00:00 2001 From: Tom Dohrmann Date: Sat, 22 Mar 2025 07:36:00 +0100 Subject: [PATCH 64/68] remove #[no_mangle] from panic handler A recent change on rustc nightly broke panic handlers that also have the #[no_mangle] attribute. It looks like they don't consider this to be a bug. Let's just remove it. --- src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 57250c9c..2c72adfa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -370,7 +370,6 @@ fn enable_write_protect_bit() { } #[panic_handler] -#[no_mangle] pub fn panic(info: &PanicInfo) -> ! { use core::fmt::Write; write!(printer::Printer, "{}", info).unwrap(); From f1d0530320f8f20b0f93497f4636fc21989d84b9 Mon Sep 17 00:00:00 2001 From: Tom Dohrmann Date: Sat, 22 Mar 2025 07:45:54 +0100 Subject: [PATCH 65/68] update changelog --- Changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog.md b/Changelog.md index 5708e743..f810d5c4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +- [remove #[no_mangle] from panic handler](https://github.com/rust-osdev/bootloader/pull/500) + # 0.9.30 – 2025-02-10 - [change rustc-abi in custom targets to x86-softfloat](https://github.com/rust-osdev/bootloader/pull/492) From 050fde2b650ae1ccc458dc9d4210c3fb98de46ce Mon Sep 17 00:00:00 2001 From: Tom Dohrmann Date: Sat, 22 Mar 2025 07:49:59 +0100 Subject: [PATCH 66/68] release 0.9.31 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 61d51144..99f51012 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bootloader" -version = "0.9.30" +version = "0.9.31" dependencies = [ "bit_field", "fixedvec", diff --git a/Cargo.toml b/Cargo.toml index 0b5bbfd7..a2172910 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bootloader" -version = "0.9.30" +version = "0.9.31" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/Changelog.md b/Changelog.md index f810d5c4..df54e95b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,7 @@ # Unreleased +# 0.9.31 – 2025-03-22 + - [remove #[no_mangle] from panic handler](https://github.com/rust-osdev/bootloader/pull/500) # 0.9.30 – 2025-02-10 From ba5c12460b08ed97472d27fc49252c1738bb7c8b Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 24 Mar 2025 10:38:37 +0100 Subject: [PATCH 67/68] Rename `.cargo/config` files of example and test kernel to `config.toml` --- example-kernel/.cargo/{config => config.toml} | 0 test-kernel/.cargo/{config => config.toml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename example-kernel/.cargo/{config => config.toml} (100%) rename test-kernel/.cargo/{config => config.toml} (100%) diff --git a/example-kernel/.cargo/config b/example-kernel/.cargo/config.toml similarity index 100% rename from example-kernel/.cargo/config rename to example-kernel/.cargo/config.toml diff --git a/test-kernel/.cargo/config b/test-kernel/.cargo/config.toml similarity index 100% rename from test-kernel/.cargo/config rename to test-kernel/.cargo/config.toml From 8bb91e53f39c8a032deb4ce474bbab30c1c4d69f Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 24 Mar 2025 10:45:50 +0100 Subject: [PATCH 68/68] Build example kernel with `-Zbuild-std-features=compiler-builtins-mem` --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b5ef0f5b..53de4a22 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,7 +96,7 @@ jobs: - name: "Install Rustup Components" run: rustup component add rust-src llvm-tools-preview - name: 'Build Example Kernel' - run: cargo build -Zbuild-std=core + run: cargo build -Zbuild-std=core -Zbuild-std-features=compiler-builtins-mem working-directory: example-kernel