From 625e20f5c6b09f60198cb5542640b8a5d11fb041 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 8 Jan 2024 12:47:34 +0000 Subject: [PATCH 01/15] Remove #![feature(slice_ptr_get)] Signed-off-by: Nick Spinale --- .../http-server/helpers/virtio-hal-impl/src/lib.rs | 3 +-- crates/sel4-dlmalloc/src/lib.rs | 3 +-- crates/sel4-newlib/src/heap.rs | 13 ++++++++----- crates/sel4-newlib/src/lib.rs | 1 - .../unstable-feature-monitoring/wishlist/src/lib.rs | 5 +++++ 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/crates/examples/microkit/http-server/helpers/virtio-hal-impl/src/lib.rs b/crates/examples/microkit/http-server/helpers/virtio-hal-impl/src/lib.rs index 208ba83cc..748a87d59 100644 --- a/crates/examples/microkit/http-server/helpers/virtio-hal-impl/src/lib.rs +++ b/crates/examples/microkit/http-server/helpers/virtio-hal-impl/src/lib.rs @@ -5,7 +5,6 @@ // #![no_std] -#![feature(slice_ptr_get)] use core::alloc::Layout; use core::ptr::{self, NonNull}; @@ -81,7 +80,7 @@ unsafe impl Hal for HalImpl { .as_mut_ptr() .index(bounce_buffer_range.clone()); bounce_buffer_ptr.fill(0); - let vaddr = bounce_buffer_ptr.as_raw_ptr().as_non_null_ptr(); + let vaddr = bounce_buffer_ptr.as_raw_ptr().cast::(); let paddr = state.offset_to_paddr(bounce_buffer_range.start); (paddr, vaddr) } diff --git a/crates/sel4-dlmalloc/src/lib.rs b/crates/sel4-dlmalloc/src/lib.rs index 00e9727f3..fc761772e 100644 --- a/crates/sel4-dlmalloc/src/lib.rs +++ b/crates/sel4-dlmalloc/src/lib.rs @@ -5,7 +5,6 @@ // #![no_std] -#![feature(slice_ptr_get)] #![feature(slice_ptr_len)] use core::alloc::{GlobalAlloc, Layout}; @@ -83,7 +82,7 @@ struct Free { impl Free { fn new(bounds: *mut [u8]) -> Self { - let start = bounds.as_mut_ptr(); + let start = bounds.cast::(); let end = start.wrapping_add(bounds.len()); Self { watermark: start, diff --git a/crates/sel4-newlib/src/heap.rs b/crates/sel4-newlib/src/heap.rs index 0a55d8ac1..795139a37 100644 --- a/crates/sel4-newlib/src/heap.rs +++ b/crates/sel4-newlib/src/heap.rs @@ -8,7 +8,6 @@ use super::*; use core::cell::UnsafeCell; use core::ffi::{c_int, c_void}; -use core::ptr; use core::sync::atomic::{AtomicIsize, Ordering}; use sel4_panicking_env::abort; @@ -24,8 +23,12 @@ impl BackingMemory { Self(UnsafeCell::new([0; N])) } - fn bounds(&self) -> *mut [u8] { - ptr::slice_from_raw_parts_mut(self.0.get().cast(), N) + const fn start(&self) -> *mut u8 { + self.0.get().cast() + } + + const fn size(&self) -> usize { + N } } @@ -57,12 +60,12 @@ impl StaticHeap { if new < 0 { abort!("program break below data segment start") } - if new > N.try_into().unwrap_or_else(|_| abort!()) { + if new > self.memory.size().try_into().unwrap_or_else(|_| abort!()) { self.watermark.fetch_sub(incr, Ordering::SeqCst); errno::set_errno(errno::values::ENOMEM); return usize::MAX as *mut c_void; } - unsafe { self.memory.bounds().as_mut_ptr().offset(old).cast() } + self.memory.start().wrapping_offset(old).cast::() } } diff --git a/crates/sel4-newlib/src/lib.rs b/crates/sel4-newlib/src/lib.rs index a81657c71..4e85e0681 100644 --- a/crates/sel4-newlib/src/lib.rs +++ b/crates/sel4-newlib/src/lib.rs @@ -7,7 +7,6 @@ // TODO address thread safety and reentrancy (init reentrancy structs and figure out what's up with errno) #![no_std] -#![feature(slice_ptr_get)] #[allow(unused_imports)] use core::ffi::{c_char, c_int, c_uint}; diff --git a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs index 4bb9c1e71..b7f80ad6f 100644 --- a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs +++ b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs @@ -14,3 +14,8 @@ #![feature(strict_provenance)] #![feature(sync_unsafe_cell)] #![feature(variant_count)] + +// For operations on *(const|mut) [T]: +// - pointer::as_mut_ptr +// - NonNull::as_non_null_ptr +#![feature(slice_ptr_get)] From bd54dac847063f8cd64ecd1c6dce0cfaac44ac1a Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 8 Jan 2024 12:54:03 +0000 Subject: [PATCH 02/15] Remove #![feature(associated_type_defaults)] Signed-off-by: Nick Spinale --- crates/examples/microkit/hello/pds/hello/src/main.rs | 5 ++++- crates/sel4-kernel-loader/embed-page-tables/src/lib.rs | 2 -- crates/sel4-kernel-loader/embed-page-tables/src/scheme.rs | 2 -- crates/sel4-microkit/src/handler.rs | 2 +- crates/sel4-microkit/src/lib.rs | 1 - crates/sel4-shared-ring-buffer/block-io/src/owned.rs | 2 ++ crates/sel4-shared-ring-buffer/bookkeeping/src/lib.rs | 1 - .../sel4-shared-ring-buffer/bookkeeping/src/slot_tracker.rs | 6 +++--- crates/sel4-shared-ring-buffer/smoltcp/src/inner.rs | 2 ++ hacking/unstable-feature-monitoring/wishlist/src/lib.rs | 3 +++ 10 files changed, 15 insertions(+), 11 deletions(-) diff --git a/crates/examples/microkit/hello/pds/hello/src/main.rs b/crates/examples/microkit/hello/pds/hello/src/main.rs index caa5218f5..5cde1fad8 100644 --- a/crates/examples/microkit/hello/pds/hello/src/main.rs +++ b/crates/examples/microkit/hello/pds/hello/src/main.rs @@ -6,6 +6,7 @@ #![no_std] #![no_main] +#![feature(never_type)] use sel4_microkit::{debug_println, protection_domain, Handler}; @@ -17,4 +18,6 @@ fn init() -> HandlerImpl { struct HandlerImpl; -impl Handler for HandlerImpl {} +impl Handler for HandlerImpl { + type Error = !; +} diff --git a/crates/sel4-kernel-loader/embed-page-tables/src/lib.rs b/crates/sel4-kernel-loader/embed-page-tables/src/lib.rs index 0ffc53694..b26d7df82 100644 --- a/crates/sel4-kernel-loader/embed-page-tables/src/lib.rs +++ b/crates/sel4-kernel-loader/embed-page-tables/src/lib.rs @@ -4,8 +4,6 @@ // SPDX-License-Identifier: BSD-2-Clause // -#![feature(associated_type_defaults)] - mod embed; mod glue; mod regions; diff --git a/crates/sel4-kernel-loader/embed-page-tables/src/scheme.rs b/crates/sel4-kernel-loader/embed-page-tables/src/scheme.rs index 84dc9fa0a..6c89c5fad 100644 --- a/crates/sel4-kernel-loader/embed-page-tables/src/scheme.rs +++ b/crates/sel4-kernel-loader/embed-page-tables/src/scheme.rs @@ -27,8 +27,6 @@ pub trait Scheme { const SYMBOLIC_BRANCH_DESCRIPTOR_OFFSET: Self::WordPrimitive; const RUNTIME_SCHEME_IDENT: &'static str; - - type Hepers = SchemeHelpers; } pub trait SchemeLeafDescriptor { diff --git a/crates/sel4-microkit/src/handler.rs b/crates/sel4-microkit/src/handler.rs index d039cfc3b..6f02afcb9 100644 --- a/crates/sel4-microkit/src/handler.rs +++ b/crates/sel4-microkit/src/handler.rs @@ -17,7 +17,7 @@ const EVENT_TYPE_MASK: sel4::Word = 1 << (sel4::WORD_SIZE - 1); /// Trait for the application-specific part of a protection domain's main loop. pub trait Handler { /// Error type returned by this protection domain's entrypoints. - type Error: fmt::Display = !; + type Error: fmt::Display; /// This method has the same meaning and type as its analog in `libmicrokit`. /// diff --git a/crates/sel4-microkit/src/lib.rs b/crates/sel4-microkit/src/lib.rs index d0ae64d8c..bc87e8b42 100644 --- a/crates/sel4-microkit/src/lib.rs +++ b/crates/sel4-microkit/src/lib.rs @@ -5,7 +5,6 @@ // #![no_std] -#![feature(associated_type_defaults)] #![feature(cfg_target_thread_local)] #![feature(never_type)] #![feature(pointer_is_aligned)] diff --git a/crates/sel4-shared-ring-buffer/block-io/src/owned.rs b/crates/sel4-shared-ring-buffer/block-io/src/owned.rs index c4f391648..db3625797 100644 --- a/crates/sel4-shared-ring-buffer/block-io/src/owned.rs +++ b/crates/sel4-shared-ring-buffer/block-io/src/owned.rs @@ -36,6 +36,8 @@ const NUM_SLOT_POOLS: usize = 2; enum StateTypesImpl {} impl SlotStateTypes for StateTypesImpl { + type Common = (); + type Free = (); type Occupied = Occupied; } diff --git a/crates/sel4-shared-ring-buffer/bookkeeping/src/lib.rs b/crates/sel4-shared-ring-buffer/bookkeeping/src/lib.rs index c7e856f5a..68669b177 100644 --- a/crates/sel4-shared-ring-buffer/bookkeeping/src/lib.rs +++ b/crates/sel4-shared-ring-buffer/bookkeeping/src/lib.rs @@ -6,7 +6,6 @@ #![no_std] #![feature(associated_type_bounds)] -#![feature(associated_type_defaults)] extern crate alloc; diff --git a/crates/sel4-shared-ring-buffer/bookkeeping/src/slot_tracker.rs b/crates/sel4-shared-ring-buffer/bookkeeping/src/slot_tracker.rs index d5ca3fea1..abe86e33e 100644 --- a/crates/sel4-shared-ring-buffer/bookkeeping/src/slot_tracker.rs +++ b/crates/sel4-shared-ring-buffer/bookkeeping/src/slot_tracker.rs @@ -13,9 +13,9 @@ use core::mem; type Result = core::result::Result; pub trait SlotStateTypes { - type Common = (); - type Free = (); - type Occupied = (); + type Common; + type Free; + type Occupied; } pub struct SlotTracker { diff --git a/crates/sel4-shared-ring-buffer/smoltcp/src/inner.rs b/crates/sel4-shared-ring-buffer/smoltcp/src/inner.rs index e3b1785df..654e375fe 100644 --- a/crates/sel4-shared-ring-buffer/smoltcp/src/inner.rs +++ b/crates/sel4-shared-ring-buffer/smoltcp/src/inner.rs @@ -50,6 +50,8 @@ pub(crate) type TxBufferIndex = usize; enum TxStateTypesImpl {} impl SlotStateTypes for TxStateTypesImpl { + type Common = (); + type Free = (); type Occupied = TxOccupied; } diff --git a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs index b7f80ad6f..968dd8dcc 100644 --- a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs +++ b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs @@ -19,3 +19,6 @@ // - pointer::as_mut_ptr // - NonNull::as_non_null_ptr #![feature(slice_ptr_get)] + +// For sel4_microkit::Handler::Error = ! +#![feature(associated_type_defaults)] From 815ffb84fa2dd78026511dc588b91b965b072176 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 8 Jan 2024 13:05:02 +0000 Subject: [PATCH 03/15] Remove some instances of #![feature(associated_type_bounds)] Signed-off-by: Nick Spinale --- crates/sel4-async/block-io/src/lib.rs | 21 +++++++++++++------ .../cli/src/bin/sel4-embed-debug-info.rs | 12 +++++------ crates/sel4-kernel-loader/src/main.rs | 1 - .../bookkeeping/src/lib.rs | 1 - .../bookkeeping/src/slot_tracker.rs | 8 +++++-- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/crates/sel4-async/block-io/src/lib.rs b/crates/sel4-async/block-io/src/lib.rs index aac33fb1f..dc42141e3 100644 --- a/crates/sel4-async/block-io/src/lib.rs +++ b/crates/sel4-async/block-io/src/lib.rs @@ -5,7 +5,6 @@ // #![no_std] -#![feature(associated_type_bounds)] #![feature(never_type)] #[cfg(feature = "alloc")] @@ -214,7 +213,10 @@ impl NextBlockSizeAdapter { wrapper_methods!(T); } -impl> BlockIOLayout for NextBlockSizeAdapter { +impl BlockIOLayout for NextBlockSizeAdapter +where + T::BlockSize: HasNextBlockSize, +{ type Error = T::Error; type BlockSize = ::NextBlockSize; @@ -230,7 +232,10 @@ impl> BlockIOLayout for NextBlockS } } -impl, A: Access> BlockIO for NextBlockSizeAdapter { +impl, A: Access> BlockIO for NextBlockSizeAdapter +where + T::BlockSize: HasNextBlockSize, +{ async fn read_or_write_blocks( &self, start_block_idx: u64, @@ -256,7 +261,10 @@ impl PrevBlockSizeAdapter { wrapper_methods!(T); } -impl> BlockIOLayout for PrevBlockSizeAdapter { +impl BlockIOLayout for PrevBlockSizeAdapter +where + T::BlockSize: HasPrevBlockSize, +{ type Error = T::Error; type BlockSize = ::PrevBlockSize; @@ -270,8 +278,9 @@ impl> BlockIOLayout for PrevBlockS } } -impl, A: ReadAccess> BlockIO - for PrevBlockSizeAdapter +impl, A: ReadAccess> BlockIO for PrevBlockSizeAdapter +where + T::BlockSize: HasPrevBlockSize, { async fn read_or_write_blocks( &self, diff --git a/crates/sel4-backtrace/embedded-debug-info/cli/src/bin/sel4-embed-debug-info.rs b/crates/sel4-backtrace/embedded-debug-info/cli/src/bin/sel4-embed-debug-info.rs index e18f42706..cc33dd225 100644 --- a/crates/sel4-backtrace/embedded-debug-info/cli/src/bin/sel4-embed-debug-info.rs +++ b/crates/sel4-backtrace/embedded-debug-info/cli/src/bin/sel4-embed-debug-info.rs @@ -4,8 +4,6 @@ // SPDX-License-Identifier: BSD-2-Clause // -#![feature(associated_type_bounds)] - use std::fs; use std::io; @@ -63,10 +61,12 @@ fn main() -> Result<(), io::Error> { fs::write(out_elf_path, out_elf) } -fn with_bit_width>( - image_elf: &[u8], - content: &[u8], -) -> Vec { +fn with_bit_width(image_elf: &[u8], content: &[u8]) -> Vec +where + T: FileHeaderExt, + T::Word: PrimInt, + T::Sword: PrimInt, +{ let content_len = NumCast::from(content.len()).unwrap(); let mut input = Input::::default(); input.symbolic_injections.push(SymbolicInjection { diff --git a/crates/sel4-kernel-loader/src/main.rs b/crates/sel4-kernel-loader/src/main.rs index 0e0f98467..aa3dc7f82 100644 --- a/crates/sel4-kernel-loader/src/main.rs +++ b/crates/sel4-kernel-loader/src/main.rs @@ -6,7 +6,6 @@ #![no_std] #![no_main] -#![feature(associated_type_bounds)] #![feature(proc_macro_hygiene)] #![cfg_attr( any(target_arch = "riscv32", target_arch = "riscv64"), diff --git a/crates/sel4-shared-ring-buffer/bookkeeping/src/lib.rs b/crates/sel4-shared-ring-buffer/bookkeeping/src/lib.rs index 68669b177..58411d2a8 100644 --- a/crates/sel4-shared-ring-buffer/bookkeeping/src/lib.rs +++ b/crates/sel4-shared-ring-buffer/bookkeeping/src/lib.rs @@ -5,7 +5,6 @@ // #![no_std] -#![feature(associated_type_bounds)] extern crate alloc; diff --git a/crates/sel4-shared-ring-buffer/bookkeeping/src/slot_tracker.rs b/crates/sel4-shared-ring-buffer/bookkeeping/src/slot_tracker.rs index abe86e33e..8edd6c4a7 100644 --- a/crates/sel4-shared-ring-buffer/bookkeeping/src/slot_tracker.rs +++ b/crates/sel4-shared-ring-buffer/bookkeeping/src/slot_tracker.rs @@ -69,7 +69,9 @@ impl SlotTracker { pub fn new_with_capacity(common: T::Common, free: T::Free, capacity: usize) -> Self where - T: SlotStateTypes, + T: SlotStateTypes, + T::Common: Clone, + T::Free: Clone, { Self::new(iter::repeat((common, free)).take(capacity)) } @@ -94,7 +96,9 @@ impl SlotTracker { capacity: usize, ) -> Self where - T: SlotStateTypes, + T: SlotStateTypes, + T::Common: Clone, + T::Occupied: Clone, { Self::new_occupied(iter::repeat((common, occupied)).take(capacity)) } From af2a2dca4192bc1f74b4a596bc877071b142d5c8 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 8 Jan 2024 13:19:44 +0000 Subject: [PATCH 04/15] Remove remaining instances of #![feature(associated_type_bounds)] Signed-off-by: Nick Spinale --- .../add-spec/src/main.rs | 1 - .../add-spec/src/render_elf.rs | 4 +- .../add-payload/src/main.rs | 11 +--- .../add-payload/src/render_elf.rs | 5 +- .../add-payload/src/serialize_payload.rs | 34 ++++++---- crates/sel4-render-elf-with-data/src/lib.rs | 65 ++++++++++++------- .../wishlist/src/lib.rs | 3 + 7 files changed, 75 insertions(+), 48 deletions(-) diff --git a/crates/sel4-capdl-initializer/add-spec/src/main.rs b/crates/sel4-capdl-initializer/add-spec/src/main.rs index 4733fb6bc..1f8bbe093 100644 --- a/crates/sel4-capdl-initializer/add-spec/src/main.rs +++ b/crates/sel4-capdl-initializer/add-spec/src/main.rs @@ -4,7 +4,6 @@ // SPDX-License-Identifier: BSD-2-Clause // -#![feature(associated_type_bounds)] #![feature(never_type)] #![feature(unwrap_infallible)] diff --git a/crates/sel4-capdl-initializer/add-spec/src/render_elf.rs b/crates/sel4-capdl-initializer/add-spec/src/render_elf.rs index ceca0c75c..795424820 100644 --- a/crates/sel4-capdl-initializer/add-spec/src/render_elf.rs +++ b/crates/sel4-capdl-initializer/add-spec/src/render_elf.rs @@ -4,7 +4,7 @@ // SPDX-License-Identifier: BSD-2-Clause // -use num::{NumCast, One, PrimInt, Zero}; +use num::{NumCast, One, Zero}; use sel4_render_elf_with_data::{FileHeaderExt, Input, SymbolicInjection, SymbolicValue}; @@ -16,7 +16,7 @@ pub(crate) struct RenderElfArgs<'a> { } impl<'a> RenderElfArgs<'a> { - pub(crate) fn call_with>(&self) -> Vec { + pub(crate) fn call_with(&self) -> Vec { let data_len: T::Word = NumCast::from(self.data.len()).unwrap(); let heap_size: T::Word = NumCast::from(self.heap_size).unwrap(); let align_modulus = T::Word::one() << self.granule_size_bits; diff --git a/crates/sel4-kernel-loader/add-payload/src/main.rs b/crates/sel4-kernel-loader/add-payload/src/main.rs index eeaf89732..5b709f3ab 100644 --- a/crates/sel4-kernel-loader/add-payload/src/main.rs +++ b/crates/sel4-kernel-loader/add-payload/src/main.rs @@ -4,8 +4,6 @@ // SPDX-License-Identifier: BSD-2-Clause // -#![feature(associated_type_bounds)] - use std::fs::{self, File}; use anyhow::Result; @@ -48,12 +46,9 @@ fn main() -> Result<()> { fn continue_with_word_size(args: &Args) -> Result<()> where - T: FileHeaderExt - + FileHeader< - Word: PrimInt + WrappingSub + Integer + Serialize, - Sword: PrimInt, - Endian = Endianness, - >, + T: FileHeaderExt + FileHeader, + T::Word: PrimInt + WrappingSub + Integer + Serialize, + T::Sword: PrimInt, { let loader_bytes = fs::read(&args.loader_path)?; diff --git a/crates/sel4-kernel-loader/add-payload/src/render_elf.rs b/crates/sel4-kernel-loader/add-payload/src/render_elf.rs index d3184bed3..9c451327b 100644 --- a/crates/sel4-kernel-loader/add-payload/src/render_elf.rs +++ b/crates/sel4-kernel-loader/add-payload/src/render_elf.rs @@ -4,14 +4,13 @@ // SPDX-License-Identifier: BSD-2-Clause // -use num::{NumCast, One, PrimInt, Zero}; -use object::{read::elf::FileHeader, Endianness}; +use num::{NumCast, One, Zero}; use sel4_render_elf_with_data::{FileHeaderExt, Input, SymbolicInjection, SymbolicValue}; pub fn render_elf(orig_elf: &[u8], serialized_payload: &[u8]) -> Vec where - T: FileHeaderExt + FileHeader, + T: FileHeaderExt, { let align_modulus = T::Word::one(); let align_residue = T::Word::one(); diff --git a/crates/sel4-kernel-loader/add-payload/src/serialize_payload.rs b/crates/sel4-kernel-loader/add-payload/src/serialize_payload.rs index a6c83a9b0..88fa0ffe8 100644 --- a/crates/sel4-kernel-loader/add-payload/src/serialize_payload.rs +++ b/crates/sel4-kernel-loader/add-payload/src/serialize_payload.rs @@ -30,14 +30,16 @@ struct PlatformInfoForBuildSystem { devices: Ranges, } -pub fn serialize_payload< - T: FileHeader, ->( +pub fn serialize_payload( kernel_path: impl AsRef, app_path: impl AsRef, dtb_path: impl AsRef, platform_info_path: impl AsRef, -) -> Vec { +) -> Vec +where + T: FileHeader, + T::Word: PrimInt + WrappingSub + Integer + Serialize, +{ let platform_info: PlatformInfoForBuildSystem = serde_yaml::from_reader(fs::File::open(&platform_info_path).unwrap()).unwrap(); @@ -90,7 +92,11 @@ struct Builder { actual_content: Vec, } -impl> Builder { +impl Builder +where + T: FileHeader, + T::Word: PrimInt + WrappingSub + Integer, +{ fn new() -> Self { Self { regions: HeaplessVec::new(), @@ -185,9 +191,12 @@ where f(&elf) } -fn elf_virt_addr_range<'a, T: FileHeader, R: ReadRef<'a>>( - elf: &ElfFile<'a, T, R>, -) -> Range { +fn elf_virt_addr_range<'a, T, R>(elf: &ElfFile<'a, T, R>) -> Range +where + T: FileHeader, + T::Word: PrimInt, + R: ReadRef<'a>, +{ let endian = elf.endian(); let virt_min = elf .raw_segments() @@ -210,9 +219,12 @@ fn elf_virt_addr_range<'a, T: FileHeader, R: virt_min..virt_max } -fn elf_phys_to_vaddr_offset<'a, T: FileHeader, R: ReadRef<'a>>( - elf: &ElfFile<'a, T, R>, -) -> T::Word { +fn elf_phys_to_vaddr_offset<'a, T, R>(elf: &ElfFile<'a, T, R>) -> T::Word +where + T: FileHeader, + T::Word: PrimInt + WrappingSub, + R: ReadRef<'a>, +{ let endian = elf.endian(); unified( elf.raw_segments() diff --git a/crates/sel4-render-elf-with-data/src/lib.rs b/crates/sel4-render-elf-with-data/src/lib.rs index c8933dfb7..ad0299ede 100644 --- a/crates/sel4-render-elf-with-data/src/lib.rs +++ b/crates/sel4-render-elf-with-data/src/lib.rs @@ -4,8 +4,6 @@ // SPDX-License-Identifier: BSD-2-Clause // -#![feature(associated_type_bounds)] - use anyhow::{bail, Result}; use num::{NumCast, PrimInt}; use object::{ @@ -35,29 +33,46 @@ impl ElfBitWidth { pub type ConcreteFileHeader32 = FileHeader32; pub type ConcreteFileHeader64 = FileHeader64; +// NOTE(rustc_wishlist) +// +// This is much simpler with #![feature(associated_type_bounds)]: +// ``` +// pub trait FileHeaderExt: +// FileHeader +// ``` +// pub trait FileHeaderExt: - FileHeader + FileHeader + FileHeader { - fn checked_add_signed(x: Self::Word, y: Self::Sword) -> Option; - fn write_word_bytes(endian: impl Endian, n: Self::Word) -> Vec; + type ExtWord: PrimInt + Into; + type ExtSword: PrimInt + Into; + + fn checked_add_signed(x: Self::ExtWord, y: Self::ExtSword) -> Option; + fn write_word_bytes(endian: impl Endian, n: Self::ExtWord) -> Vec; } impl FileHeaderExt for ConcreteFileHeader32 { - fn checked_add_signed(x: Self::Word, y: Self::Sword) -> Option { + type ExtWord = u32; + type ExtSword = i32; + + fn checked_add_signed(x: Self::ExtWord, y: Self::ExtSword) -> Option { x.checked_add_signed(y) } - fn write_word_bytes(endian: impl Endian, n: Self::Word) -> Vec { + fn write_word_bytes(endian: impl Endian, n: Self::ExtWord) -> Vec { endian.write_u32_bytes(n).to_vec() } } impl FileHeaderExt for ConcreteFileHeader64 { - fn checked_add_signed(x: Self::Word, y: Self::Sword) -> Option { + type ExtWord = u64; + type ExtSword = i64; + + fn checked_add_signed(x: Self::ExtWord, y: Self::ExtSword) -> Option { x.checked_add_signed(y) } - fn write_word_bytes(endian: impl Endian, n: Self::Word) -> Vec { + fn write_word_bytes(endian: impl Endian, n: Self::ExtWord) -> Vec { endian.write_u64_bytes(n).to_vec() } } @@ -86,31 +101,31 @@ impl<'a, T: FileHeaderExt> Default for Input<'a, T> { type Symbol = String; -type ConcreteValue = ::Word; +type ConcreteValue = ::ExtWord; pub struct SymbolicInjection<'a, T: FileHeaderExt> { - pub align_modulus: T::Word, - pub align_residue: T::Word, + pub align_modulus: T::ExtWord, + pub align_residue: T::ExtWord, pub content: &'a [u8], - pub memsz: T::Word, + pub memsz: T::ExtWord, pub patches: Vec<(Symbol, SymbolicValue)>, } #[derive(Debug)] pub struct SymbolicValue { - pub addend: T::Sword, + pub addend: T::ExtSword, } impl<'a, T: FileHeaderExt> SymbolicInjection<'a, T> { - fn filesz(&self) -> T::Word { + fn filesz(&self) -> T::ExtWord { NumCast::from(self.content.len()).unwrap() } - fn align_from(&self, addr: T::Word) -> T::Word { + fn align_from(&self, addr: T::ExtWord) -> T::ExtWord { align_from::(addr, self.align_modulus, self.align_residue) } - fn locate(&self, vaddr: T::Word) -> Result> { + fn locate(&self, vaddr: T::ExtWord) -> Result> { Ok(Injection { vaddr, content: self.content, @@ -130,22 +145,22 @@ impl<'a, T: FileHeaderExt> SymbolicInjection<'a, T> { } pub struct Injection<'a, T: FileHeaderExt> { - pub vaddr: T::Word, + pub vaddr: T::ExtWord, pub content: &'a [u8], - pub memsz: T::Word, + pub memsz: T::ExtWord, pub patches: Vec<(Symbol, ConcreteValue)>, } impl<'a, T: FileHeaderExt> Injection<'a, T> { - fn vaddr(&self) -> T::Word { + fn vaddr(&self) -> T::ExtWord { self.vaddr } - fn filesz(&self) -> T::Word { + fn filesz(&self) -> T::ExtWord { NumCast::from(self.content.len()).unwrap() } - fn memsz(&self) -> T::Word { + fn memsz(&self) -> T::ExtWord { self.memsz } @@ -158,6 +173,10 @@ impl<'a, T: FileHeaderExt> Injection<'a, T> { } } -fn align_from(addr: T::Word, modulus: T::Word, residue: T::Word) -> T::Word { +fn align_from( + addr: T::ExtWord, + modulus: T::ExtWord, + residue: T::ExtWord, +) -> T::ExtWord { addr + (modulus + residue - addr % modulus) % modulus } diff --git a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs index 968dd8dcc..8044e9942 100644 --- a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs +++ b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs @@ -22,3 +22,6 @@ // For sel4_microkit::Handler::Error = ! #![feature(associated_type_defaults)] + +// Would greatly simplify sel4_render_elf_with_data::FileHeaderExt +#![feature(associated_type_bounds)] From b95b1f1a6275122e62a89835c7ab0d7f4ccb4e0f Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 8 Jan 2024 13:47:57 +0000 Subject: [PATCH 05/15] Remove #![feature(allocator_api)] and #![feature(btreemap_alloc)] Signed-off-by: Nick Spinale --- .../sel4-bounce-buffer-allocator/src/basic.rs | 24 +++++++++---------- .../sel4-bounce-buffer-allocator/src/lib.rs | 2 -- .../wishlist/src/lib.rs | 4 ++++ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/crates/sel4-bounce-buffer-allocator/src/basic.rs b/crates/sel4-bounce-buffer-allocator/src/basic.rs index 46512aa9e..d0f88d3da 100644 --- a/crates/sel4-bounce-buffer-allocator/src/basic.rs +++ b/crates/sel4-bounce-buffer-allocator/src/basic.rs @@ -4,36 +4,36 @@ // SPDX-License-Identifier: BSD-2-Clause // -use alloc::alloc::Global; use alloc::collections::BTreeMap; -use core::alloc::{Allocator, Layout}; +use core::alloc::Layout; use core::ops::Bound; use crate::{AbstractBounceBufferAllocator, Offset, Size}; const GRANULE_SIZE: usize = 2048; -pub struct Basic { - holes: BTreeMap, +// NOTE(rustc_wishlist) +// +// #![feature(allocator_api)] and #![feature(btreemap_alloc)] +// +// Should be parameterized with an allocator A, to enable this type to be used without a global +// allocator. +// +pub struct Basic { + holes: BTreeMap, } impl Basic { pub fn new(size: Size) -> Self { - Self::new_in(Global, size) - } -} - -impl Basic { - pub fn new_in(alloc: A, size: Size) -> Self { assert_eq!(size % GRANULE_SIZE, 0); let offset = 0; - let mut holes = BTreeMap::new_in(alloc.clone()); + let mut holes = BTreeMap::new(); holes.insert(offset, size); Self { holes } } } -impl AbstractBounceBufferAllocator for Basic { +impl AbstractBounceBufferAllocator for Basic { type Error = (); fn allocate(&mut self, layout: Layout) -> Result { diff --git a/crates/sel4-bounce-buffer-allocator/src/lib.rs b/crates/sel4-bounce-buffer-allocator/src/lib.rs index a391b0fd0..b7d979d6f 100644 --- a/crates/sel4-bounce-buffer-allocator/src/lib.rs +++ b/crates/sel4-bounce-buffer-allocator/src/lib.rs @@ -5,9 +5,7 @@ // #![no_std] -#![feature(allocator_api)] #![feature(btree_cursors)] -#![feature(btreemap_alloc)] #![feature(pointer_is_aligned)] extern crate alloc; diff --git a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs index 8044e9942..a2d31cc55 100644 --- a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs +++ b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs @@ -25,3 +25,7 @@ // Would greatly simplify sel4_render_elf_with_data::FileHeaderExt #![feature(associated_type_bounds)] + +// Would enable sel4_bounce_buffer_allocator::Basic without a global heap +#![feature(allocator_api)] +#![feature(btreemap_alloc)] From 74d646ecc273a559bb97913032223c98f5f760b1 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 8 Jan 2024 22:13:54 +0000 Subject: [PATCH 06/15] Remove #![feature(stdsimd)] and #![feature(riscv_ext_intrinsics)] Signed-off-by: Nick Spinale --- .../sel4-kernel-loader/src/arch/riscv/mod.rs | 20 +++++-------------- crates/sel4-kernel-loader/src/main.rs | 4 ---- .../extra-used-unstable-features.rs | 3 --- .../wishlist/src/lib.rs | 7 +++++++ 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/crates/sel4-kernel-loader/src/arch/riscv/mod.rs b/crates/sel4-kernel-loader/src/arch/riscv/mod.rs index 6a3f6c6e8..23528d34d 100644 --- a/crates/sel4-kernel-loader/src/arch/riscv/mod.rs +++ b/crates/sel4-kernel-loader/src/arch/riscv/mod.rs @@ -124,25 +124,15 @@ sel4_cfg_if! { fn switch_page_tables() { #[cfg(target_pointer_width = "32")] - unsafe fn by_ptr_width(ppn: usize) { - use core::arch::riscv32::{fence_i, sfence_vma_all}; - - sfence_vma_all(); - satp::set(satp::Mode::Sv32, 0, ppn); - fence_i(); - } + const MODE: satp::Mode = satp::Mode::Sv32; #[cfg(target_pointer_width = "64")] - unsafe fn by_ptr_width(ppn: usize) { - use core::arch::riscv64::{fence_i, sfence_vma_all}; - - sfence_vma_all(); - satp::set(satp::Mode::Sv39, 0, ppn); - fence_i(); - } + const MODE: satp::Mode = satp::Mode::Sv39; unsafe { let ppn = kernel_boot_level_0_table.root() as usize >> 12; - by_ptr_width(ppn); + asm!("sfence.vma", options(nostack)); + satp::set(MODE, 0, ppn); + asm!("fence.i", options(nostack)); } } diff --git a/crates/sel4-kernel-loader/src/main.rs b/crates/sel4-kernel-loader/src/main.rs index aa3dc7f82..377ff7ee7 100644 --- a/crates/sel4-kernel-loader/src/main.rs +++ b/crates/sel4-kernel-loader/src/main.rs @@ -7,10 +7,6 @@ #![no_std] #![no_main] #![feature(proc_macro_hygiene)] -#![cfg_attr( - any(target_arch = "riscv32", target_arch = "riscv64"), - feature(riscv_ext_intrinsics, stdsimd) -)] #![allow(dead_code)] #![allow(unreachable_code)] #![allow(clippy::reversed_empty_ranges)] diff --git a/hacking/unstable-feature-monitoring/extra-used-unstable-features.rs b/hacking/unstable-feature-monitoring/extra-used-unstable-features.rs index cb1c28eb1..14cf23d79 100644 --- a/hacking/unstable-feature-monitoring/extra-used-unstable-features.rs +++ b/hacking/unstable-feature-monitoring/extra-used-unstable-features.rs @@ -3,6 +3,3 @@ // // SPDX-License-Identifier: BSD-2-Clause // - -#![feature(riscv_ext_intrinsics)] -#![feature(stdsimd)] diff --git a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs index a2d31cc55..247f19e15 100644 --- a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs +++ b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs @@ -29,3 +29,10 @@ // Would enable sel4_bounce_buffer_allocator::Basic without a global heap #![feature(allocator_api)] #![feature(btreemap_alloc)] + +// For core::arch::riscv* +#![feature(stdsimd)] +#![cfg_attr( + any(target_arch = "riscv32", target_arch = "riscv64"), + feature(riscv_ext_intrinsics), +)] From 67f4ee2522f49dac8e986dd660f512c0bed36af1 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 8 Jan 2024 13:48:43 +0000 Subject: [PATCH 07/15] Remove unecessary feature from wishlist Signed-off-by: Nick Spinale --- hacking/unstable-feature-monitoring/wishlist/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs index 247f19e15..07b5c17f9 100644 --- a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs +++ b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs @@ -5,7 +5,6 @@ // #![feature(array_methods)] -#![feature(array_try_from_fn)] #![feature(cell_update)] #![feature(exclusive_wrapper)] #![feature(exposed_provenance)] From 3d5790a03befca1d92975d8e8e9c750d0edda228 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 8 Jan 2024 21:19:48 +0000 Subject: [PATCH 08/15] crates/sel4-async/time: Clean up Cargo.nix Signed-off-by: Nick Spinale --- crates/sel4-async/time/Cargo.nix | 7 ------- 1 file changed, 7 deletions(-) diff --git a/crates/sel4-async/time/Cargo.nix b/crates/sel4-async/time/Cargo.nix index 07a8000df..4d7aaa5e4 100644 --- a/crates/sel4-async/time/Cargo.nix +++ b/crates/sel4-async/time/Cargo.nix @@ -10,12 +10,5 @@ mk { package.name = "sel4-async-time"; dependencies = { inherit (versions) log pin-project; - # futures = { - # version = versions.futures; - # default-features = false; - # features = [ - # "alloc" - # ]; - # }; }; } From eea7608663b2dc22d289312a1f99b4243ec3f33d Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 8 Jan 2024 21:22:36 +0000 Subject: [PATCH 09/15] Remove #![feature(btree_cursors)] from async time crate Signed-off-by: Nick Spinale --- crates/sel4-async/time/src/lib.rs | 1 - crates/sel4-async/time/src/timer_queue.rs | 105 ++++++++++++++-------- 2 files changed, 70 insertions(+), 36 deletions(-) diff --git a/crates/sel4-async/time/src/lib.rs b/crates/sel4-async/time/src/lib.rs index ce8ce7a04..822d75874 100644 --- a/crates/sel4-async/time/src/lib.rs +++ b/crates/sel4-async/time/src/lib.rs @@ -5,7 +5,6 @@ // #![no_std] -#![feature(btree_cursors)] extern crate alloc; diff --git a/crates/sel4-async/time/src/timer_queue.rs b/crates/sel4-async/time/src/timer_queue.rs index 19abcb3b9..e2ffdc5ad 100644 --- a/crates/sel4-async/time/src/timer_queue.rs +++ b/crates/sel4-async/time/src/timer_queue.rs @@ -4,8 +4,7 @@ // SPDX-License-Identifier: BSD-2-Clause // -use alloc::collections::btree_map::{BTreeMap, CursorMut}; -use core::ops::Bound; +use alloc::collections::btree_map::{BTreeMap, Entry}; use crate::SubKey; @@ -16,8 +15,14 @@ use crate::SubKey; // TODO: Add feature like `tokio::time::Interval` +// NOTE(rustc_wishlist) +// +// Once #![feature(btree_cursors)] stabilizes, revert back to using it for a simpler, more +// lightweight, and more efficient (on the small scale) implementation. See git history for such an +// implementation. + pub struct TimerQueue { - pending: BTreeMap, V>, + pending: BTreeMap>, } #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] @@ -40,35 +45,57 @@ impl TimerQueue { } pub fn peek_next_absolute_expiry(&self) -> Option<&T> { - let (key, _value) = self.pending.first_key_value()?; - Some(key.absolute_expiry()) + let (absolute_expiry, _value) = self.pending.first_key_value()?; + Some(absolute_expiry) } pub fn insert(&mut self, absolute_expiry: T, value: V) -> Key { - let upper_bound = Key { - absolute_expiry: absolute_expiry.clone(), - sub_key: SubKey::max(), - }; - let mut cursor = self.pending.upper_bound_mut(Bound::Included(&upper_bound)); - let sub_key = match cursor.key() { - None => SubKey::min(), - Some(prev_key) if prev_key.absolute_expiry() == &absolute_expiry => prev_key - .sub_key - .succ() - .expect("too many timers for one instant"), - Some(_) => SubKey::max(), + let sub_key = match self.pending.entry(absolute_expiry.clone()) { + Entry::Vacant(entry) => { + let sub_key = ::min(); + entry.insert(BTreeMap::new()).insert(sub_key.clone(), value); + sub_key + } + Entry::Occupied(mut entry) => { + let sub_map = entry.get_mut(); + let sub_key = sub_map + .last_entry() + .unwrap() + .key() + .succ() + .expect("too many timers for one instant"); + sub_map.insert(sub_key.clone(), value); + sub_key + } }; - let key = Key { + + Key { absolute_expiry, sub_key, - }; - cursor.insert_after(key.clone(), value); - key + } } pub fn try_remove(&mut self, key: &Key) -> Option> { - let (key, value) = self.pending.remove_entry(key)?; - Some(Expired { key, value }) + match self + .pending + .entry(key.absolute_expiry().clone() /* HACK silly clone */) + { + Entry::Vacant(_) => None, + Entry::Occupied(mut entry) => { + let sub_map = entry.get_mut(); + let (sub_key, value) = sub_map.remove_entry(&key.sub_key)?; + if sub_map.is_empty() { + entry.remove(); + } + Some(Expired { + key: Key { + absolute_expiry: key.absolute_expiry().clone(), + sub_key, + }, + value, + }) + } + } } pub fn remove(&mut self, key: &Key) -> Expired { @@ -76,10 +103,7 @@ impl TimerQueue { } pub fn iter_expired(&mut self, now: T) -> IterExpired<'_, T, U, V> { - IterExpired { - now, - cursor: self.pending.lower_bound_mut(Bound::Unbounded), - } + IterExpired { now, queue: self } } } @@ -107,19 +131,30 @@ impl Expired { pub struct IterExpired<'a, T, U, V> { now: T, - cursor: CursorMut<'a, Key, V>, + queue: &'a mut TimerQueue, } -impl<'a, T: Ord, U: Ord, V> Iterator for IterExpired<'a, T, U, V> { +impl<'a, T: Ord + Clone, U: Ord, V> Iterator for IterExpired<'a, T, U, V> { type Item = Expired; fn next(&mut self) -> Option { - let key = self.cursor.key()?; - if key.absolute_expiry() <= &self.now { - let (key, value) = self.cursor.remove_current().unwrap(); - Some(Expired { key, value }) - } else { - None + let mut entry = self.queue.pending.first_entry()?; + if entry.key() > &self.now { + return None; } + let sub_map = entry.get_mut(); + let (sub_key, value) = sub_map.pop_first().unwrap(); + let absolute_expiry = if sub_map.is_empty() { + entry.remove_entry().0 + } else { + entry.key().clone() + }; + Some(Expired { + key: Key { + absolute_expiry, + sub_key, + }, + value, + }) } } From 6365f677714e93e93a3f36ee96d15568fa9312d9 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Tue, 9 Jan 2024 03:58:53 +0000 Subject: [PATCH 10/15] Remove #![feature(pointer_is_aligned)] Signed-off-by: Nick Spinale --- crates/sel4-bounce-buffer-allocator/src/lib.rs | 3 +-- crates/sel4-capdl-initializer/core/src/lib.rs | 1 - crates/sel4-capdl-initializer/types/src/frame_init.rs | 2 +- crates/sel4-capdl-initializer/types/src/lib.rs | 1 - crates/sel4-microkit/src/lib.rs | 1 - crates/sel4-microkit/src/memory_region.rs | 8 ++++++-- crates/sel4/src/bootinfo.rs | 2 +- crates/sel4/src/ipc_buffer.rs | 2 +- crates/sel4/src/lib.rs | 1 - hacking/unstable-feature-monitoring/wishlist/src/lib.rs | 9 +++++++++ 10 files changed, 19 insertions(+), 11 deletions(-) diff --git a/crates/sel4-bounce-buffer-allocator/src/lib.rs b/crates/sel4-bounce-buffer-allocator/src/lib.rs index b7d979d6f..07c6f51ad 100644 --- a/crates/sel4-bounce-buffer-allocator/src/lib.rs +++ b/crates/sel4-bounce-buffer-allocator/src/lib.rs @@ -6,7 +6,6 @@ #![no_std] #![feature(btree_cursors)] -#![feature(pointer_is_aligned)] extern crate alloc; @@ -53,7 +52,7 @@ impl BounceBufferAllocator { } pub fn check_alignment(&self, region: *mut u8) { - assert!(region.is_aligned_to(self.max_alignment())); + assert_eq!(region.cast::<()>().align_offset(self.max_alignment()), 0); // sanity check } } diff --git a/crates/sel4-capdl-initializer/core/src/lib.rs b/crates/sel4-capdl-initializer/core/src/lib.rs index 008bd043e..50ec0f280 100644 --- a/crates/sel4-capdl-initializer/core/src/lib.rs +++ b/crates/sel4-capdl-initializer/core/src/lib.rs @@ -6,7 +6,6 @@ #![no_std] #![feature(never_type)] -#![feature(pointer_is_aligned)] #![feature(proc_macro_hygiene)] #![feature(stmt_expr_attributes)] diff --git a/crates/sel4-capdl-initializer/types/src/frame_init.rs b/crates/sel4-capdl-initializer/types/src/frame_init.rs index 269fc4901..de490390d 100644 --- a/crates/sel4-capdl-initializer/types/src/frame_init.rs +++ b/crates/sel4-capdl-initializer/types/src/frame_init.rs @@ -88,7 +88,7 @@ impl EmbeddedFrame { } pub fn check(&self, frame_size: usize) { - assert!(self.ptr().is_aligned_to(frame_size)); + assert_eq!(self.ptr().cast::<()>().align_offset(frame_size), 0); } } diff --git a/crates/sel4-capdl-initializer/types/src/lib.rs b/crates/sel4-capdl-initializer/types/src/lib.rs index 831294f73..69b3947b5 100644 --- a/crates/sel4-capdl-initializer/types/src/lib.rs +++ b/crates/sel4-capdl-initializer/types/src/lib.rs @@ -6,7 +6,6 @@ #![cfg_attr(not(feature = "std"), no_std)] #![feature(never_type)] -#![feature(pointer_is_aligned)] #![feature(proc_macro_hygiene)] #![feature(stmt_expr_attributes)] #![feature(unwrap_infallible)] diff --git a/crates/sel4-microkit/src/lib.rs b/crates/sel4-microkit/src/lib.rs index bc87e8b42..45df6815d 100644 --- a/crates/sel4-microkit/src/lib.rs +++ b/crates/sel4-microkit/src/lib.rs @@ -7,7 +7,6 @@ #![no_std] #![feature(cfg_target_thread_local)] #![feature(never_type)] -#![feature(pointer_is_aligned)] #![feature(proc_macro_hygiene)] #![feature(stmt_expr_attributes)] #![feature(unwrap_infallible)] diff --git a/crates/sel4-microkit/src/memory_region.rs b/crates/sel4-microkit/src/memory_region.rs index 84d526e60..e78a94ba1 100644 --- a/crates/sel4-microkit/src/memory_region.rs +++ b/crates/sel4-microkit/src/memory_region.rs @@ -75,15 +75,19 @@ macro_rules! memory_region_symbol { pub fn cast_memory_region_checked(bytes_ptr: NonNull<[u8]>) -> NonNull { let ptr = bytes_ptr.cast::(); - assert!(ptr.as_ptr().is_aligned()); + assert!(is_aligned(ptr.as_ptr())); assert!(mem::size_of::() <= bytes_ptr.len()); ptr } pub fn cast_memory_region_to_slice_checked(bytes_ptr: NonNull<[u8]>) -> NonNull<[T]> { let ptr = bytes_ptr.cast::(); - assert!(ptr.as_ptr().is_aligned()); + assert!(is_aligned(ptr.as_ptr())); assert!(bytes_ptr.len() % mem::size_of::() == 0); let n = bytes_ptr.len() / mem::size_of::(); NonNull::slice_from_raw_parts(ptr, n) } + +fn is_aligned(p: *mut T) -> bool { + p.cast::<()>().align_offset(mem::align_of::()) == 0 +} diff --git a/crates/sel4/src/bootinfo.rs b/crates/sel4/src/bootinfo.rs index 209c0b9ff..0cf70034d 100644 --- a/crates/sel4/src/bootinfo.rs +++ b/crates/sel4/src/bootinfo.rs @@ -28,7 +28,7 @@ pub struct BootInfo { impl BootInfo { #[allow(clippy::missing_safety_doc)] pub unsafe fn from_ptr(ptr: *const sys::seL4_BootInfo) -> Self { - assert!(ptr.is_aligned_to(GRANULE_SIZE.bytes())); // sanity check + assert_eq!(ptr.cast::<()>().align_offset(GRANULE_SIZE.bytes()), 0); // sanity check Self { ptr } } diff --git a/crates/sel4/src/ipc_buffer.rs b/crates/sel4/src/ipc_buffer.rs index 3784b9c4e..c17113f37 100644 --- a/crates/sel4/src/ipc_buffer.rs +++ b/crates/sel4/src/ipc_buffer.rs @@ -22,7 +22,7 @@ unsafe impl Sync for IPCBuffer {} impl IPCBuffer { #[allow(clippy::missing_safety_doc)] pub unsafe fn from_ptr(ptr: *mut sys::seL4_IPCBuffer) -> Self { - assert!(ptr.is_aligned_to(GRANULE_SIZE.bytes())); // sanity check + assert_eq!(ptr.cast::<()>().align_offset(GRANULE_SIZE.bytes()), 0); // sanity check Self { ptr } } diff --git a/crates/sel4/src/lib.rs b/crates/sel4/src/lib.rs index d3d771fac..0c0cf985d 100644 --- a/crates/sel4/src/lib.rs +++ b/crates/sel4/src/lib.rs @@ -42,7 +42,6 @@ #![no_std] #![feature(cfg_target_thread_local)] -#![feature(pointer_is_aligned)] #![feature(proc_macro_hygiene)] #![feature(stmt_expr_attributes)] #![feature(thread_local)] diff --git a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs index 07b5c17f9..f7603e917 100644 --- a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs +++ b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs @@ -35,3 +35,12 @@ any(target_arch = "riscv32", target_arch = "riscv64"), feature(riscv_ext_intrinsics), )] + +// For pointer::is_aligned(_to)? +// +// For now, use: +// ``` +// assert_eq!(ptr.cast::<()>().align_offset(x), 0) +// ``` +// (See definitions of pointer::is_aligned(_to)?) +#![feature(pointer_is_aligned)] From 7fa4f626f6163245cc6709b8bad8eff368f66274 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Tue, 9 Jan 2024 06:53:32 +0000 Subject: [PATCH 11/15] Remove #![feature(btree_cursors)] from bound buffer allocator crate Signed-off-by: Nick Spinale --- .../sel4-bounce-buffer-allocator/src/basic.rs | 107 ++++++++++++------ .../sel4-bounce-buffer-allocator/src/lib.rs | 1 - 2 files changed, 73 insertions(+), 35 deletions(-) diff --git a/crates/sel4-bounce-buffer-allocator/src/basic.rs b/crates/sel4-bounce-buffer-allocator/src/basic.rs index d0f88d3da..e1b9867ca 100644 --- a/crates/sel4-bounce-buffer-allocator/src/basic.rs +++ b/crates/sel4-bounce-buffer-allocator/src/basic.rs @@ -6,19 +6,26 @@ use alloc::collections::BTreeMap; use core::alloc::Layout; -use core::ops::Bound; use crate::{AbstractBounceBufferAllocator, Offset, Size}; const GRANULE_SIZE: usize = 2048; +// TODO +// This is just a temporary implementation to server as a stand-in. + // NOTE(rustc_wishlist) // // #![feature(allocator_api)] and #![feature(btreemap_alloc)] // // Should be parameterized with an allocator A, to enable this type to be used without a global // allocator. + +// NOTE(rustc_wishlist) // +// #![feature(btree_cursors)] would make this stand-in implementation simpler and more efficient. +// See git history. + pub struct Basic { holes: BTreeMap, } @@ -42,51 +49,83 @@ impl AbstractBounceBufferAllocator for Basic { layout.align().max(GRANULE_SIZE), ) .unwrap(); - let mut cursor = self.holes.lower_bound_mut(Bound::Unbounded); - loop { - if let Some((&hole_offset, &hole_size)) = cursor.key_value() { + + let (buffer_offset, hole_offset, hole_size) = self + .holes + .iter() + .find_map(|(&hole_offset, &hole_size)| { let buffer_offset = hole_offset.next_multiple_of(layout.align()); if buffer_offset + layout.size() <= hole_offset + hole_size { - cursor.remove_current(); - if hole_offset < buffer_offset { - cursor.insert_before(hole_offset, buffer_offset - hole_offset); - } - if buffer_offset + layout.size() < hole_offset + hole_size { - cursor.insert_before( - buffer_offset + layout.size(), - (hole_offset + hole_size) - (buffer_offset + layout.size()), - ); - } - return Ok(buffer_offset); + Some((buffer_offset, hole_offset, hole_size)) } else { - cursor.move_next(); + None } - } else { - return Err(()); - } + }) + .ok_or(())?; + + self.holes.remove(&hole_offset).unwrap(); + + if hole_offset < buffer_offset { + self.holes.insert(hole_offset, buffer_offset - hole_offset); + } + + if buffer_offset + layout.size() < hole_offset + hole_size { + self.holes.insert( + buffer_offset + layout.size(), + (hole_offset + hole_size) - (buffer_offset + layout.size()), + ); } + + Ok(buffer_offset) } fn deallocate(&mut self, offset: Offset, size: Size) { assert_eq!(offset % GRANULE_SIZE, 0); let size = size.next_multiple_of(GRANULE_SIZE); - let mut cursor = self.holes.upper_bound_mut(Bound::Included(&offset)); - if let Some((&prev_hole_offset, prev_hole_size)) = cursor.key_value_mut() { - assert!(prev_hole_offset + *prev_hole_size <= offset); - if prev_hole_offset + *prev_hole_size == offset { - *prev_hole_size += size; - return; + + let holes = self + .holes + .range(..&offset) + .rev() + .next() + .map(copy_typle_fields) + .map(|prev_hole| { + ( + prev_hole, + self.holes.range(&offset..).next().map(copy_typle_fields), + ) + }); + + let mut island = true; + + if let Some(((prev_hole_offset, prev_hole_size), next_hole)) = holes { + assert!(prev_hole_offset + prev_hole_size <= offset); + let adjacent_to_prev = prev_hole_offset + prev_hole_size == offset; + if adjacent_to_prev { + island = false; + *self.holes.get_mut(&prev_hole_offset).unwrap() += size; } - } - cursor.move_next(); - if let Some((&next_hole_offset, &next_hole_size)) = cursor.key_value() { - assert!(offset + size <= next_hole_offset); - if offset + size == next_hole_offset { - cursor.remove_current(); - cursor.insert_before(offset, size + next_hole_size); - return; + if let Some((next_hole_offset, next_hole_size)) = next_hole { + assert!(offset + size <= next_hole_offset); + let adjacent_to_next = offset + size == next_hole_offset; + if adjacent_to_next { + island = false; + self.holes.remove(&next_hole_offset).unwrap(); + if adjacent_to_prev { + *self.holes.get_mut(&prev_hole_offset).unwrap() += next_hole_size; + } else { + self.holes.insert(offset, size + next_hole_size); + } + } } } - cursor.insert_before(offset, size); + + if island { + self.holes.insert(offset, size); + } } } + +fn copy_typle_fields((&t, &u): (&T, &U)) -> (T, U) { + (t, u) +} diff --git a/crates/sel4-bounce-buffer-allocator/src/lib.rs b/crates/sel4-bounce-buffer-allocator/src/lib.rs index 07c6f51ad..37901c592 100644 --- a/crates/sel4-bounce-buffer-allocator/src/lib.rs +++ b/crates/sel4-bounce-buffer-allocator/src/lib.rs @@ -5,7 +5,6 @@ // #![no_std] -#![feature(btree_cursors)] extern crate alloc; From 2fa6b26f2dc86e05413f7ef1b12d73e7c2c408f7 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Tue, 9 Jan 2024 08:16:12 +0000 Subject: [PATCH 12/15] Remove #![feature(slice_ptr_len)] Signed-off-by: Nick Spinale --- .../runtime/src/global_allocator.rs | 4 +- .../sel4-simple-task/runtime/src/lib.rs | 6 +-- crates/sel4-capdl-initializer/src/main.rs | 13 ++++--- crates/sel4-dlmalloc/src/lib.rs | 37 ++++++++++++------- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/crates/private/support/sel4-simple-task/runtime/src/global_allocator.rs b/crates/private/support/sel4-simple-task/runtime/src/global_allocator.rs index f2a9b46a0..ad00788ae 100644 --- a/crates/private/support/sel4-simple-task/runtime/src/global_allocator.rs +++ b/crates/private/support/sel4-simple-task/runtime/src/global_allocator.rs @@ -4,7 +4,7 @@ // SPDX-License-Identifier: BSD-2-Clause // -use sel4_dlmalloc::StaticDlmallocGlobalAlloc; +use sel4_dlmalloc::{StaticDlmallocGlobalAlloc, StaticHeapBounds}; use sel4_sync::AbstractMutexSyncOps; use crate::{get_static_heap_bounds, get_static_heap_mutex_notification}; @@ -13,7 +13,7 @@ use crate::{get_static_heap_bounds, get_static_heap_mutex_notification}; #[allow(clippy::type_complexity)] static GLOBAL_ALLOCATOR: StaticDlmallocGlobalAlloc< AbstractMutexSyncOps, - fn() -> *mut [u8], + fn() -> StaticHeapBounds, > = StaticDlmallocGlobalAlloc::new( AbstractMutexSyncOps { signal: || { diff --git a/crates/private/support/sel4-simple-task/runtime/src/lib.rs b/crates/private/support/sel4-simple-task/runtime/src/lib.rs index 7b17e0c23..46facc551 100644 --- a/crates/private/support/sel4-simple-task/runtime/src/lib.rs +++ b/crates/private/support/sel4-simple-task/runtime/src/lib.rs @@ -13,11 +13,11 @@ extern crate alloc; use core::ffi::{c_char, c_void}; -use core::ptr; use core::slice; use sel4::Endpoint; use sel4_backtrace_simple::SimpleBacktracing; +use sel4_dlmalloc::StaticHeapBounds; use sel4_immediate_sync_once_cell::ImmediateSyncOnceCell; use sel4_panicking::ExternalPanicInfo; use sel4_panicking_env::{abort, AbortInfo}; @@ -134,9 +134,9 @@ fn panic_hook(info: &ExternalPanicInfo<'_>) { get_backtracing().collect_and_send(); } -fn get_static_heap_bounds() -> *mut [u8] { +fn get_static_heap_bounds() -> StaticHeapBounds { let addrs = CONFIG.get().unwrap().static_heap().unwrap(); - ptr::slice_from_raw_parts_mut( + StaticHeapBounds::new( usize::try_from(addrs.start).unwrap() as *mut _, (addrs.end - addrs.start).try_into().unwrap(), ) diff --git a/crates/sel4-capdl-initializer/src/main.rs b/crates/sel4-capdl-initializer/src/main.rs index c01140a35..c26225647 100644 --- a/crates/sel4-capdl-initializer/src/main.rs +++ b/crates/sel4-capdl-initializer/src/main.rs @@ -20,6 +20,7 @@ use sel4_capdl_initializer_types::{ IndirectDeflatedBytesContent, IndirectEmbeddedFrame, IndirectObjectName, SpecWithIndirection, SpecWithSources, }; +use sel4_dlmalloc::StaticHeapBounds; use sel4_logging::{LevelFilter, Logger, LoggerBuilder}; use sel4_root_task::root_task; @@ -102,9 +103,9 @@ fn user_image_bounds() -> Range { } } -fn static_heap_bounds() -> *mut [u8] { +fn static_heap_bounds() -> StaticHeapBounds { unsafe { - ptr::slice_from_raw_parts_mut( + StaticHeapBounds::new( sel4_capdl_initializer_heap_start, sel4_capdl_initializer_heap_size, ) @@ -112,12 +113,14 @@ fn static_heap_bounds() -> *mut [u8] { } mod heap { - use sel4_dlmalloc::StaticDlmallocGlobalAlloc; + use sel4_dlmalloc::{StaticDlmallocGlobalAlloc, StaticHeapBounds}; use sel4_sync::PanickingMutexSyncOps; use super::static_heap_bounds; #[global_allocator] - static GLOBAL_ALLOCATOR: StaticDlmallocGlobalAlloc *mut [u8]> = - StaticDlmallocGlobalAlloc::new(PanickingMutexSyncOps::new(), static_heap_bounds); + static GLOBAL_ALLOCATOR: StaticDlmallocGlobalAlloc< + PanickingMutexSyncOps, + fn() -> StaticHeapBounds, + > = StaticDlmallocGlobalAlloc::new(PanickingMutexSyncOps::new(), static_heap_bounds); } diff --git a/crates/sel4-dlmalloc/src/lib.rs b/crates/sel4-dlmalloc/src/lib.rs index fc761772e..553a40bf8 100644 --- a/crates/sel4-dlmalloc/src/lib.rs +++ b/crates/sel4-dlmalloc/src/lib.rs @@ -5,7 +5,6 @@ // #![no_std] -#![feature(slice_ptr_len)] use core::alloc::{GlobalAlloc, Layout}; use core::cell::{RefCell, UnsafeCell}; @@ -81,11 +80,10 @@ struct Free { } impl Free { - fn new(bounds: *mut [u8]) -> Self { - let start = bounds.cast::(); - let end = start.wrapping_add(bounds.len()); + fn new(bounds: StaticHeapBounds) -> Self { + let end = bounds.ptr.wrapping_add(bounds.size); Self { - watermark: start, + watermark: bounds.ptr, end, } } @@ -110,7 +108,7 @@ impl StaticDlmallocAllocator { } } -impl StaticDlmallocAllocatorState { +impl StaticDlmallocAllocatorState { fn as_free(&mut self) -> &mut Free { if matches!(self, Self::Uninitialized { .. }) { if let Self::Uninitialized { get_initial_bounds } = @@ -131,7 +129,7 @@ impl StaticDlmallocAllocatorState { } } -unsafe impl DlmallocAllocator for StaticDlmallocAllocator { +unsafe impl DlmallocAllocator for StaticDlmallocAllocator { fn alloc(&self, size: usize) -> (*mut u8, usize, u32) { match self.state.borrow_mut().as_free().alloc(size) { Some(start) => (start, size, 0), @@ -165,12 +163,23 @@ unsafe impl DlmallocAllocator for StaticDlmallocAllo } } -pub trait StaticHeapBounds { - fn bounds(self) -> *mut [u8]; +pub trait GetStaticHeapBounds { + fn bounds(self) -> StaticHeapBounds; } -impl *mut [u8]> StaticHeapBounds for T { - fn bounds(self) -> *mut [u8] { +pub struct StaticHeapBounds { + ptr: *mut u8, + size: usize, +} + +impl StaticHeapBounds { + pub fn new(ptr: *mut u8, size: usize) -> Self { + Self { ptr, size } + } +} + +impl StaticHeapBounds> GetStaticHeapBounds for T { + fn bounds(self) -> StaticHeapBounds { (self)() } } @@ -189,8 +198,8 @@ impl StaticHeap { } } -impl StaticHeapBounds for &StaticHeap { - fn bounds(self) -> *mut [u8] { - ptr::slice_from_raw_parts_mut(self.0.get().cast(), N) +impl GetStaticHeapBounds for &StaticHeap { + fn bounds(self) -> StaticHeapBounds { + StaticHeapBounds::new(self.0.get().cast(), N) } } From 983b3a1c88b945cff65a4e0c211e32af8ad78884 Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Tue, 9 Jan 2024 08:19:31 +0000 Subject: [PATCH 13/15] Remove unstable macro features from sel4-microkit crate Signed-off-by: Nick Spinale --- crates/sel4-microkit/src/lib.rs | 2 -- crates/sel4-microkit/src/panicking.rs | 7 ++++--- hacking/unstable-feature-monitoring/wishlist/src/lib.rs | 5 +++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/sel4-microkit/src/lib.rs b/crates/sel4-microkit/src/lib.rs index 45df6815d..4bcdae88e 100644 --- a/crates/sel4-microkit/src/lib.rs +++ b/crates/sel4-microkit/src/lib.rs @@ -7,8 +7,6 @@ #![no_std] #![feature(cfg_target_thread_local)] #![feature(never_type)] -#![feature(proc_macro_hygiene)] -#![feature(stmt_expr_attributes)] #![feature(unwrap_infallible)] #![feature(used_with_arg)] diff --git a/crates/sel4-microkit/src/panicking.rs b/crates/sel4-microkit/src/panicking.rs index 7698a299a..6e537e5e0 100644 --- a/crates/sel4-microkit/src/panicking.rs +++ b/crates/sel4-microkit/src/panicking.rs @@ -43,8 +43,9 @@ pub(crate) fn init_panicking() { #[no_mangle] #[allow(unused_variables)] fn sel4_runtime_debug_put_char(c: u8) { - #[sel4::sel4_cfg(PRINTING)] - { - sel4::debug_put_char(c as core::ffi::c_char) + sel4::sel4_cfg_if! { + if #[cfg(PRINTING)] { + sel4::debug_put_char(c as core::ffi::c_char) + } } } diff --git a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs index f7603e917..d81552822 100644 --- a/hacking/unstable-feature-monitoring/wishlist/src/lib.rs +++ b/hacking/unstable-feature-monitoring/wishlist/src/lib.rs @@ -44,3 +44,8 @@ // ``` // (See definitions of pointer::is_aligned(_to)?) #![feature(pointer_is_aligned)] + +// Without these, the more invasive sel4_cfg_if! must be used instead of #[sel4_cfg] on +// expressions. +#![feature(proc_macro_hygiene)] +#![feature(stmt_expr_attributes)] From 2c1020c210b9e0ebc37f7ce167877d3c5f33669e Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Tue, 9 Jan 2024 09:05:42 +0000 Subject: [PATCH 14/15] Remove #![feature(cfg_target_has_atomic_equal_alignment)] Signed-off-by: Nick Spinale --- .../sel4-externally-shared/src/atomics/mod.rs | 51 ++++++++++++++----- crates/sel4-externally-shared/src/lib.rs | 5 +- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/crates/sel4-externally-shared/src/atomics/mod.rs b/crates/sel4-externally-shared/src/atomics/mod.rs index 51d179cd1..a49fe372f 100644 --- a/crates/sel4-externally-shared/src/atomics/mod.rs +++ b/crates/sel4-externally-shared/src/atomics/mod.rs @@ -6,7 +6,9 @@ use core::fmt; use core::marker::PhantomData; +use core::mem; use core::ptr::NonNull; +use core::sync::atomic; use volatile::access::{ReadOnly, ReadWrite, WriteOnly}; @@ -41,6 +43,10 @@ impl fmt::Debug for AtomicPtr<'_, T, A> { } impl<'a, T, A> AtomicPtr<'a, T, A> { + /// # Safety + /// + /// Necessary but not sufficient: + /// * `pointer` must be aligned to `align_of::()` #[allow(clippy::missing_safety_doc)] pub const unsafe fn new(pointer: NonNull) -> Self { AtomicPtr { @@ -65,6 +71,7 @@ impl<'a, T, A> AtomicPtr<'a, T, A> { #[allow(clippy::missing_safety_doc)] pub unsafe trait Atomic: AtomicSealed + Copy { + const ALIGNMENT: usize; const IS_SIGNED: bool; } @@ -75,11 +82,16 @@ mod sealing { } macro_rules! impl_atomic { - ($t:ty, $target_has_atomic_key:literal, $is_signed:literal) => { + ( + $t:ty, + $target_has_atomic_key:literal, + $is_signed:literal, + $analog_for_alignment:path + ) => { // TODO these attributes are overly conservative #[cfg(target_has_atomic = $target_has_atomic_key)] - #[cfg(target_has_atomic_equal_alignment = $target_has_atomic_key)] unsafe impl Atomic for $t { + const ALIGNMENT: usize = mem::align_of::<$analog_for_alignment>(); const IS_SIGNED: bool = $is_signed; } @@ -88,20 +100,35 @@ macro_rules! impl_atomic { } macro_rules! impl_atomic_for_each_signedness { - ($t_unsigned:ty, $t_signed:ty, $target_has_atomic_key:literal) => { - impl_atomic!($t_unsigned, $target_has_atomic_key, false); - impl_atomic!($t_signed, $target_has_atomic_key, true); + ( + $t_unsigned:ty, + $t_signed:ty, + $target_has_atomic_key:literal, + $unsigned_analog_for_alignment:path, + $signed_analog_for_alignment:path + ) => { + impl_atomic!( + $t_unsigned, + $target_has_atomic_key, + false, + $unsigned_analog_for_alignment + ); + impl_atomic!( + $t_signed, + $target_has_atomic_key, + true, + $signed_analog_for_alignment + ); }; } -impl_atomic_for_each_signedness!(u8, i8, "8"); -impl_atomic_for_each_signedness!(u16, i16, "16"); -impl_atomic_for_each_signedness!(u32, i32, "32"); -impl_atomic_for_each_signedness!(u64, i64, "64"); -impl_atomic_for_each_signedness!(u128, i128, "128"); +impl_atomic_for_each_signedness!(u8, i8, "8", atomic::AtomicU8, atomic::AtomicI8); +impl_atomic_for_each_signedness!(u16, i16, "16", atomic::AtomicU16, atomic::AtomicI16); +impl_atomic_for_each_signedness!(u32, i32, "32", atomic::AtomicU32, atomic::AtomicI32); +impl_atomic_for_each_signedness!(u64, i64, "64", atomic::AtomicU64, atomic::AtomicI64); #[cfg(target_pointer_width = "32")] -impl_atomic_for_each_signedness!(usize, isize, "32"); +impl_atomic_for_each_signedness!(usize, isize, "32", atomic::AtomicUsize, atomic::AtomicIsize); #[cfg(target_pointer_width = "64")] -impl_atomic_for_each_signedness!(usize, isize, "64"); +impl_atomic_for_each_signedness!(usize, isize, "64", atomic::AtomicUsize, atomic::AtomicIsize); diff --git a/crates/sel4-externally-shared/src/lib.rs b/crates/sel4-externally-shared/src/lib.rs index d56d07095..38866b6d5 100644 --- a/crates/sel4-externally-shared/src/lib.rs +++ b/crates/sel4-externally-shared/src/lib.rs @@ -5,7 +5,6 @@ // #![no_std] -#![feature(cfg_target_has_atomic_equal_alignment)] #![feature(core_intrinsics)] #![allow(internal_features)] @@ -55,6 +54,8 @@ impl<'a, T: ?Sized, A> ExternallySharedPtrExt<'a, T, A> for ExternallySharedPtr< where T: Atomic, { - unsafe { AtomicPtr::new(self.as_raw_ptr()) } + let p = self.as_raw_ptr(); + assert_eq!(p.as_ptr().align_offset(T::ALIGNMENT), 0); + unsafe { AtomicPtr::new(p) } } } From 25caf1cd0440f78221d11fba477c1e88dad9d7ee Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Tue, 9 Jan 2024 09:11:04 +0000 Subject: [PATCH 15/15] Remove unecessary instance of #![feature(never_type)] Signed-off-by: Nick Spinale --- crates/sel4-microkit/message/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/sel4-microkit/message/src/lib.rs b/crates/sel4-microkit/message/src/lib.rs index e6696f15d..8a305054d 100644 --- a/crates/sel4-microkit/message/src/lib.rs +++ b/crates/sel4-microkit/message/src/lib.rs @@ -5,7 +5,6 @@ // #![no_std] -#![feature(never_type)] #![feature(unwrap_infallible)] use core::fmt;