diff --git a/Cargo.lock b/Cargo.lock index c378ae7..ab56f82 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" dependencies = [ - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -55,7 +55,7 @@ checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -139,9 +139,9 @@ checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "clap" -version = "4.5.40" +version = "4.5.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f" +checksum = "be92d32e80243a54711e5d7ce823c35c41c9d929dc4ab58e1276f625841aadf9" dependencies = [ "clap_builder", "clap_derive", @@ -149,9 +149,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.40" +version = "4.5.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e" +checksum = "707eab41e9622f9139419d573eca0900137718000c517d47da73045f54331c3d" dependencies = [ "anstream", "anstyle", @@ -161,14 +161,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.40" +version = "4.5.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce" +checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.102", + "syn 2.0.104", ] [[package]] @@ -332,9 +332,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.172" +version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" [[package]] name = "log" @@ -364,7 +364,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db335f4760b14ead6290116f2427bf33a14d4f0617d49f78a246de10c1831224" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -400,12 +400,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "rustversion" -version = "1.0.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" - [[package]] name = "scroll" version = "0.13.0" @@ -423,7 +417,7 @@ checksum = "22fc4f90c27b57691bbaf11d8ecc7cfbfe98a4da6dbe60226115d322aa80c06e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.102", + "syn 2.0.104", ] [[package]] @@ -445,12 +439,13 @@ dependencies = [ [[package]] name = "shared_child" -version = "1.0.2" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e297bd52991bbe0686c086957bee142f13df85d1e79b0b21630a99d374ae9dc" +checksum = "1e362d9935bc50f019969e2f9ecd66786612daae13e8f277be7bfb66e8bed3f7" dependencies = [ "libc", - "windows-sys", + "sigchld", + "windows-sys 0.60.2", ] [[package]] @@ -459,6 +454,36 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7a6f98357c6bb0ebace19b22220e5543801d9de90ffe77f8abb27c056bac064" +[[package]] +name = "sigchld" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47106eded3c154e70176fc83df9737335c94ce22f821c32d17ed1db1f83badb1" +dependencies = [ + "libc", + "os_pipe", + "signal-hook", +] + +[[package]] +name = "signal-hook" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" +dependencies = [ + "libc", +] + [[package]] name = "spin" version = "0.9.8" @@ -491,24 +516,23 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" -version = "0.27.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f64def088c51c9510a8579e3c5d67c65349dcf755e5479ad3d010aa6454e2c32" +checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" dependencies = [ "strum_macros", ] [[package]] name = "strum_macros" -version = "0.27.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77a8c5abcaf0f9ce05d62342b7d298c346515365c36b673df4ebe3ced01fde8" +checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" dependencies = [ "heck", "proc-macro2", "quote", - "rustversion", - "syn 2.0.102", + "syn 2.0.104", ] [[package]] @@ -524,9 +548,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.102" +version = "2.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6397daf94fa90f058bd0fd88429dd9e5738999cca8d701813c80723add80462" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" dependencies = [ "proc-macro2", "quote", @@ -569,7 +593,16 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.2", ] [[package]] @@ -578,14 +611,30 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c66f69fcc9ce11da9966ddb31a40968cad001c5bedeb5c2b82ede4253ab48aef" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", ] [[package]] @@ -594,48 +643,96 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + [[package]] name = "x86" version = "0.52.0" @@ -650,7 +747,7 @@ dependencies = [ [[package]] name = "xmodem" version = "0.4.0" -source = "git+https://github.com/oxidecomputer/xmodem.rs#e0e71d32dcfd92076f913fe3267e70067ee57d2d" +source = "git+https://github.com/oxidecomputer/xmodem.rs#196cb902d799d272519793db9dfdd573f69485a1" dependencies = [ "crc16", "log", diff --git a/rust-toolchain.toml b/rust-toolchain.toml index dcd9b2d..66cb0ac 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-06-12" +channel = "nightly-2025-07-22" components = [ "rustfmt", "rust-src", "llvm-tools", "clippy", "miri", "rust-analyzer" ] diff --git a/src/bldb.rs b/src/bldb.rs index 58284d5..9bddaf7 100644 --- a/src/bldb.rs +++ b/src/bldb.rs @@ -274,14 +274,13 @@ pub fn gpio_page_addr() -> mem::V4KA { mem::V4KA::new(0xfed8_1000) } -const PHBL_MIN: usize = 2 * mem::GIB - 256 * mem::MIB; -const PHBL_BASE: *mut u8 = core::ptr::without_provenance_mut(PHBL_MIN); - /// Returns a zeroed slice over the given region. fn zeroed_region_mut(start: usize, end: usize) -> &'static mut [u8] { + const PHBL_MIN: usize = 2 * mem::GIB - 256 * mem::MIB; + let phbl_base = core::ptr::with_exposed_provenance_mut::(PHBL_MIN); assert!(PHBL_MIN <= start && start < end && end <= saddr().addr()); let len = end - start; - let ptr = PHBL_BASE.with_addr(start); + let ptr = phbl_base.with_addr(start); unsafe { core::ptr::write_bytes(ptr, 0, len); core::slice::from_raw_parts_mut(ptr, len) diff --git a/src/loader.rs b/src/loader.rs index ea46d38..9c4a1b3 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -177,14 +177,14 @@ fn load_segment( file: &T, ) -> Result<(*mut u8, usize)> { let pa = segment.p_paddr; - if pa % mem::P4KA::ALIGN != 0 { + if !pa.is_multiple_of(mem::P4KA::ALIGN) { return Err(Error::ElfSegPAlign); } let vm = segment.vm_range(); if vm.contains(&mem::LOW_CANON_SUP) || vm.contains(&mem::HI_CANON_INF) { return Err(Error::ElfSegNonCanon); } - if vm.start % mem::V4KA::ALIGN != 0 { + if !vm.start.is_multiple_of(mem::V4KA::ALIGN) { return Err(Error::ElfSegVAlign); } if vm.end <= vm.start { diff --git a/src/mmu.rs b/src/mmu.rs index 0bca8b3..7cb8edd 100644 --- a/src/mmu.rs +++ b/src/mmu.rs @@ -180,7 +180,7 @@ impl Frame for PFN1G { const SIZE: usize = 1 << 30; fn new(addr: u64) -> PFN1G { - assert_eq!(addr % Self::SIZE as u64, 0); + assert!(addr.is_multiple_of(Self::SIZE as u64)); PFN1G(addr) } @@ -1074,8 +1074,8 @@ impl PageTable { let attrs = region.attrs(); while start != end { let len = if end.wrapping_sub(start) >= PFN1G::SIZE - && start % PFN1G::SIZE == 0 - && (pa as usize) % PFN1G::SIZE == 0 + && start.is_multiple_of(PFN1G::SIZE) + && (pa as usize).is_multiple_of(PFN1G::SIZE) { unsafe { self.map(Page1G::new(start), PFN1G::new(pa), attrs); @@ -1083,8 +1083,8 @@ impl PageTable { self.flush_page(start); PFN1G::SIZE } else if end.wrapping_sub(start) >= PFN2M::SIZE - && start % PFN2M::SIZE == 0 - && (pa as usize) % PFN2M::SIZE == 0 + && start.is_multiple_of(PFN2M::SIZE) + && (pa as usize).is_multiple_of(PFN2M::SIZE) { unsafe { self.map(Page2M::new(start), PFN2M::new(pa), attrs); @@ -1092,8 +1092,8 @@ impl PageTable { self.flush_page(start); PFN2M::SIZE } else if end.wrapping_sub(start) >= PFN4K::SIZE - && start % PFN4K::SIZE == 0 - && (pa as usize) % PFN4K::SIZE == 0 + && start.is_multiple_of(PFN4K::SIZE) + && (pa as usize).is_multiple_of(PFN4K::SIZE) { unsafe { self.map(Page4K::new(start), PFN4K::new(pa), attrs); @@ -1128,21 +1128,21 @@ impl PageTable { assert!(mem::is_canonical_range(start, end)); while start != end { let len = if end.wrapping_sub(start) >= PFN1G::SIZE - && start % PFN1G::SIZE == 0 + && start.is_multiple_of(PFN1G::SIZE) { unsafe { self.unmap(Page1G::new(start)) } .ok_or(Error::Unmapped)?; self.flush_page(start); PFN1G::SIZE } else if end.wrapping_sub(start) >= PFN2M::SIZE - && start % PFN2M::SIZE == 0 + && start.is_multiple_of(PFN2M::SIZE) { unsafe { self.unmap(Page2M::new(start)) } .ok_or(Error::Unmapped)?; self.flush_page(start); PFN2M::SIZE } else if end.wrapping_sub(start) >= PFN4K::SIZE - && start % PFN4K::SIZE == 0 + && start.is_multiple_of(PFN4K::SIZE) { unsafe { self.unmap(Page4K::new(start)) } .ok_or(Error::Unmapped)?; diff --git a/src/repl/vm.rs b/src/repl/vm.rs index 048a010..c45fc65 100644 --- a/src/repl/vm.rs +++ b/src/repl/vm.rs @@ -23,10 +23,10 @@ fn check_phys_addr(pair: (u64, usize)) -> Result<(u64, usize)> { fn check_virt_range(va: *const (), len: usize) -> Result<*const ()> { let addr = va.addr(); - if (addr % mem::V4KA::SIZE) != 0 { + if !addr.is_multiple_of(mem::V4KA::SIZE) { return Err(Error::PageAlign); } - if (len % mem::V4KA::SIZE) != 0 { + if !len.is_multiple_of(mem::V4KA::SIZE) { return Err(Error::PageAlign); } if !mem::is_canonical_range(addr, addr + len) {