Skip to content

build: Bump toolchain to nightly-2025-05-25 #383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions aarch64-unknown-none.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"llvm-target": "aarch64-unknown-none",
"abi": "softfloat",
"arch": "aarch64",
"data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32",
"disable-redzone": true,
"features": "+strict-align,-neon,-fp-armv8",
"linker": "rust-lld",
"linker-flavor": "ld.lld",
"linker-flavor": "gnu-lld",
"os": "none",
"executables": true,
"max-atomic-width": 128,
Expand All @@ -15,6 +15,9 @@
"relocation-model": "pic",
"target-pointer-width": "64",
"pre-link-args": {
"ld.lld": ["--script=aarch64-unknown-none.ld", "--oformat=binary"]
"gnu-lld": [
"--script=aarch64-unknown-none.ld",
"--oformat=binary"
]
}
}
}
1 change: 1 addition & 0 deletions aarch64-unknown-none.ld
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ SECTIONS
data_start = .;
.data : { *(.data .data.*) }
.rodata : { *(.rodata .rodata.*) }
.got : { *(.got .got.*) }

/* The BSS section isn't mapped from file data. It is just zeroed in RAM. */
.bss : {
Expand Down
11 changes: 6 additions & 5 deletions riscv64gcv-unknown-none-elf.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
"eh-frame-header": false,
"emit-debug-gdb-scripts": false,
"features": "+m,+a,-f,+d,+c,-v",
"is-builtin": false,
"linker": "rust-lld",
"linker-flavor": "ld.lld",
"linker-flavor": "gnu-lld",
"llvm-abiname": "lp64d",
"llvm-target": "riscv64",
"max-atomic-width": 64,
"panic-strategy": "abort",
"relocation-model": "static",
"target-pointer-width": "64",
"pre-link-args": {
"ld.lld": ["--script=riscv64gcv-unknown-none-elf.ld"]
"pre-link-args": {
"gnu-lld": [
"--script=riscv64gcv-unknown-none-elf.ld"
]
}
}
}
1 change: 1 addition & 0 deletions riscv64gcv-unknown-none-elf.ld
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SECTIONS
}

.rodata : { *(.rodata .rodata.*) }
.got : { *(.got .got.*) }

/* The BSS section isn't mapped from file data. It is just zeroed in RAM. */
.bss : {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "nightly-2024-05-13"
channel = "nightly-2025-05-25"
components = ["rust-src", "clippy", "rustfmt"]
targets = [
"aarch64-unknown-linux-gnu",
Expand Down
6 changes: 5 additions & 1 deletion src/arch/aarch64/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,17 @@ impl interface::Mmu for MemoryManagementUnit {
self.setup_mair();

// Populate translation tables.
#[allow(static_mut_refs)]
KERNEL_TABLES
.get_mut()
.populate_tt_entries()
.map_err(MmuEnableError::Other)?;

// Set the "Translation Table Base Register".
TTBR0_EL1.set_baddr(KERNEL_TABLES.get_mut().phys_base_address());
TTBR0_EL1.set_baddr(
#[allow(static_mut_refs)]
KERNEL_TABLES.get_mut().phys_base_address(),
);

self.configure_translation_control();

Expand Down
4 changes: 1 addition & 3 deletions src/arch/x86_64/gdt.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2020 Google LLC

use core::mem::size_of;

bitflags::bitflags! {
// An extension of x86_64::structures::gdt::DescriptorFlags
struct Descriptor: u64 {
Expand Down Expand Up @@ -43,7 +41,7 @@ struct Pointer {

impl Pointer {
const fn new(gdt: &'static [Descriptor]) -> Self {
let size = gdt.len() * size_of::<Descriptor>();
let size = core::mem::size_of_val(gdt);
Self {
limit: size as u16 - 1,
base: &gdt[0],
Expand Down
3 changes: 2 additions & 1 deletion src/arch/x86_64/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ static mut L2_TABLES: SyncUnsafeCell<[PageTable; ADDRESS_SPACE_GIB]> =
pub fn setup() {
// SAFETY: This function is idempontent and only writes to static memory and
// CR3. Thus, it is safe to run multiple times or on multiple threads.
#[allow(static_mut_refs)]
let (l4, l3, l2s) = unsafe { (L4_TABLE.get_mut(), L3_TABLE.get_mut(), L2_TABLES.get_mut()) };
info!("Setting up {} GiB identity mapping", ADDRESS_SPACE_GIB);
info!("Setting up {ADDRESS_SPACE_GIB} GiB identity mapping");
let pt_flags = PageTableFlags::PRESENT | PageTableFlags::WRITABLE;

// Setup Identity map using L2 huge pages
Expand Down
4 changes: 2 additions & 2 deletions src/efi/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Allocator {
}

pub fn page_count(&self, size: usize) -> u64 {
((size + self.page_size as usize - 1) / self.page_size as usize) as u64
size.div_ceil(self.page_size as usize) as u64
}

// Assume called in order with non-overlapping sections.
Expand Down Expand Up @@ -338,7 +338,7 @@ impl Allocator {
}

pub fn allocate_pool(&mut self, memory_type: MemoryType, size: usize) -> (Status, u64) {
let page_count = (size as u64 + self.page_size - 1) / self.page_size;
let page_count = (size as u64).div_ceil(self.page_size);
let (status, address) =
self.allocate_pages(efi::ALLOCATE_ANY_PAGES, memory_type, page_count, 0);

Expand Down
4 changes: 2 additions & 2 deletions src/efi/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
};

#[allow(dead_code)]
#[repr(packed)]
#[repr(C, packed)]
pub struct ControllerDevicePathProtocol {
pub device_path: DevicePathProtocol,
pub controller: u32,
Expand Down Expand Up @@ -121,7 +121,7 @@ impl<'a> BlockWrapper<'a> {
start_lba: u64,
last_lba: u64,
uuid: [u8; 16],
) -> *mut BlockWrapper {
) -> *mut BlockWrapper<'a> {
let last_block = (*block).get_capacity() - 1;

let (status, new_address) = super::ALLOCATOR
Expand Down
10 changes: 8 additions & 2 deletions src/efi/boot_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ pub extern "efiapi" fn locate_handle(
handles: *mut Handle,
) -> Status {
if unsafe { *guid } == r_efi::protocols::block_io::PROTOCOL_GUID {
#[allow(static_mut_refs)]
let count = unsafe { BLOCK_WRAPPERS.get_mut().count };
if unsafe { *size } < size_of::<Handle>() * count {
unsafe { *size = size_of::<Handle>() * count };
Expand All @@ -286,7 +287,8 @@ pub extern "efiapi" fn locate_handle(

let wrappers_as_handles: &[Handle] = unsafe {
core::slice::from_raw_parts_mut(
BLOCK_WRAPPERS.get_mut().wrappers.as_mut_ptr() as *mut Handle,
(#[allow(static_mut_refs)]
BLOCK_WRAPPERS.get_mut().wrappers.as_mut_ptr()) as *mut Handle,
count,
)
};
Expand All @@ -310,7 +312,9 @@ pub extern "efiapi" fn locate_device_path(
}

pub extern "efiapi" fn install_configuration_table(guid: *mut Guid, table: *mut c_void) -> Status {
#[allow(static_mut_refs)]
let st = unsafe { ST.get_mut() };
#[allow(static_mut_refs)]
let ct = unsafe { CT.get_mut() };

for entry in ct.iter_mut() {
Expand Down Expand Up @@ -436,6 +440,7 @@ pub extern "efiapi" fn start_image(
let ptr = address as *const ();
let code: extern "efiapi" fn(Handle, *mut efi::SystemTable) -> Status =
unsafe { core::mem::transmute(ptr) };
#[allow(static_mut_refs)]
(code)(image_handle, unsafe { ST.get() })
}

Expand Down Expand Up @@ -521,7 +526,8 @@ pub extern "efiapi" fn open_protocol(
{
unsafe {
if let Some(block_part_id) = (*(handle as *mut file::FileSystemWrapper)).block_part_id {
*out = (&mut (*(BLOCK_WRAPPERS.get_mut().wrappers[block_part_id as usize]))
*out = (&mut (*(#[allow(static_mut_refs)]
BLOCK_WRAPPERS.get_mut().wrappers[block_part_id as usize]))
.controller_path) as *mut _ as *mut c_void;

return Status::SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion src/efi/device_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl DevicePath {
error!("Unexpected end of device path");
return DevicePath::Unsupported;
}
let len = unsafe { core::mem::transmute::<[u8; 2], u16>(dpp.length) };
let len = u16::from_ne_bytes(dpp.length);
dpp = unsafe { &*((dpp as *const _ as u64 + len as u64) as *const _) };
}
}
Expand Down
17 changes: 13 additions & 4 deletions src/efi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ fn new_image_handle(
proto: LoadedImageProtocol {
revision: r_efi::protocols::loaded_image::REVISION,
parent_handle,
#[allow(static_mut_refs)]
system_table: unsafe { ST.get_mut() },
device_handle,
file_path,
Expand Down Expand Up @@ -195,6 +196,7 @@ pub fn efi_exec(
) {
let vendor_data = 0u32;

#[allow(static_mut_refs)]
let ct = unsafe { CT.get_mut() };
let mut ct_index = 0;

Expand Down Expand Up @@ -250,24 +252,31 @@ pub fn efi_exec(

let mut stdin = console::STDIN;
let mut stdout = console::STDOUT;
#[allow(static_mut_refs)]
let st = unsafe { ST.get_mut() };
st.con_in = &mut stdin;
st.con_out = &mut stdout;
st.std_err = &mut stdout;
st.runtime_services = unsafe { RS.get_mut() };
st.boot_services = unsafe { BS.get_mut() };
st.runtime_services = unsafe {
#[allow(static_mut_refs)]
RS.get_mut()
};
st.boot_services = unsafe {
#[allow(static_mut_refs)]
BS.get_mut()
};
st.number_of_table_entries = 1;
st.configuration_table = &mut ct[0];

populate_allocator(info, loaded_address, loaded_size);

#[allow(static_mut_refs)]
let efi_part_id = unsafe { block::populate_block_wrappers(BLOCK_WRAPPERS.get_mut(), block) };

let wrapped_fs = file::FileSystemWrapper::new(fs, efi_part_id);

let mut path = [0u8; 256];
path[0..crate::efi::EFI_BOOT_PATH.as_bytes().len()]
.copy_from_slice(crate::efi::EFI_BOOT_PATH.as_bytes());
path[0..crate::efi::EFI_BOOT_PATH.len()].copy_from_slice(crate::efi::EFI_BOOT_PATH.as_bytes());
let device_path = DevicePath::File(path);
let image = new_image_handle(
device_path.generate(),
Expand Down
2 changes: 2 additions & 0 deletions src/efi/runtime_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ pub static mut RS: SyncUnsafeCell<efi::RuntimeServices> =

#[allow(clippy::missing_transmute_annotations)]
unsafe fn fixup_at_virtual(descriptors: &[MemoryDescriptor]) {
#[allow(static_mut_refs)]
let st = ST.get_mut();
#[allow(static_mut_refs)]
let rs = RS.get_mut();

let ptr = ALLOCATOR
Expand Down
17 changes: 8 additions & 9 deletions src/fat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
mem::MemoryRegion,
};

#[repr(packed)]
#[repr(C, packed)]
struct Header {
_magic: [u8; 3],
_identifier: [u8; 8],
Expand All @@ -24,7 +24,7 @@ struct Header {
sectors: u32,
}

#[repr(packed)]
#[repr(C, packed)]
struct Fat32Header {
_header: Header,
sectors_per_fat: u32,
Expand All @@ -42,7 +42,7 @@ struct Fat32Header {
_id: [u8; 8],
}

#[repr(packed)]
#[repr(C, packed)]
struct FatDirectory {
name: [u8; 11],
flags: u8,
Expand All @@ -53,7 +53,7 @@ struct FatDirectory {
size: u32,
}

#[repr(packed)]
#[repr(C, packed)]
struct FatLongNameEntry {
seq: u8,
name: [u16; 5],
Expand Down Expand Up @@ -608,7 +608,7 @@ fn compare_short_name(name: &str, de: &DirectoryEntry) -> bool {
}

let b = de.name[i];
if a.to_ascii_uppercase() != b.to_ascii_uppercase() {
if !a.eq_ignore_ascii_case(&b) {
return false;
}

Expand All @@ -629,7 +629,7 @@ fn compare_name(name: &str, de: &DirectoryEntry) -> bool {
}

impl<'a> Filesystem<'a> {
pub fn new(device: &'a dyn SectorRead, start: u64, last: u64) -> Filesystem {
pub fn new(device: &'a dyn SectorRead, start: u64, last: u64) -> Filesystem<'a> {
Filesystem {
device,
start,
Expand Down Expand Up @@ -665,8 +665,7 @@ impl<'a> Filesystem<'a> {
self.bytes_per_sector = u32::from(h.bytes_per_sector);
self.fat_count = u32::from(h.fat_count);
self.sectors_per_cluster = u32::from(h.sectors_per_cluster);
self.root_dir_sectors = ((u32::from(h.root_dir_count * 32)) + self.bytes_per_sector - 1)
/ self.bytes_per_sector;
self.root_dir_sectors = (u32::from(h.root_dir_count * 32)).div_ceil(self.bytes_per_sector);

self.sectors_per_fat = if h.legacy_sectors_per_fat == 0 {
let h32 = unsafe { &*(data.as_bytes().as_ptr() as *const Fat32Header) };
Expand Down Expand Up @@ -856,7 +855,7 @@ impl<'a> Filesystem<'a> {
let mut p = [0_u8; 256];
let mut residual = if !is_absolute_path(path) {
p[0] = b'/';
p[1..1 + len].clone_from_slice(path[..len].as_bytes());
p[1..1 + len].clone_from_slice(&path.as_bytes()[..len]);
core::str::from_utf8(&p).unwrap()
} else {
path
Expand Down
Loading