diff --git a/Cargo.lock b/Cargo.lock index 632880e8..cbdac28a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,7 +136,7 @@ dependencies = [ "rsdp", "serde-json-core", "usize_conversions", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -154,7 +154,7 @@ dependencies = [ "spinning_top", "uart_16550", "usize_conversions", - "x86_64", + "x86_64 0.15.2", "xmas-elf", ] @@ -168,7 +168,7 @@ dependencies = [ "log", "serde-json-core", "uefi", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -734,7 +734,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -743,7 +743,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -752,7 +752,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -761,7 +761,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -770,7 +770,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -779,7 +779,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -788,7 +788,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -797,7 +797,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -806,7 +806,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -837,7 +837,7 @@ checksum = "b074eb9300ad949edd74c529c0e8d451625af71bb948e6b65fe69f72dc1363d9" dependencies = [ "bitflags 1.3.2", "rustversion", - "x86_64", + "x86_64 0.14.13", ] [[package]] @@ -1020,6 +1020,18 @@ dependencies = [ "volatile", ] +[[package]] +name = "x86_64" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f042214de98141e9c8706e8192b73f56494087cc55ebec28ce10f26c5c364ae" +dependencies = [ + "bit_field", + "bitflags 2.3.3", + "rustversion", + "volatile", +] + [[package]] name = "xmas-elf" version = "0.8.0" diff --git a/bios/stage-4/Cargo.toml b/bios/stage-4/Cargo.toml index 769ca657..2afb8654 100644 --- a/bios/stage-4/Cargo.toml +++ b/bios/stage-4/Cargo.toml @@ -14,7 +14,7 @@ bootloader-x86_64-common = { workspace = true } bootloader-x86_64-bios-common = { workspace = true } bootloader-boot-config = { workspace = true } log = "0.4.14" -x86_64 = "0.14.8" +x86_64 = "0.15.2" rsdp = "2.0.0" usize_conversions = "0.2.0" serde-json-core = "0.5.0" diff --git a/common/Cargo.toml b/common/Cargo.toml index afc8ed7d..7375b940 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -14,7 +14,7 @@ bootloader-boot-config = { workspace = true } conquer-once = { version = "0.3.2", default-features = false } spinning_top = "0.2.4" usize_conversions = "0.2.0" -x86_64 = { version = "0.14.8" } +x86_64 = { version = "0.15.2" } xmas-elf = "0.8.0" raw-cpuid = "10.2.0" rand = { version = "0.8.4", default-features = false } diff --git a/common/src/gdt.rs b/common/src/gdt.rs index 9ac45ade..5ba16c5b 100644 --- a/common/src/gdt.rs +++ b/common/src/gdt.rs @@ -15,8 +15,8 @@ pub fn create_and_load(frame: PhysFrame) { let ptr: *mut GlobalDescriptorTable = virt_addr.as_mut_ptr(); let mut gdt = GlobalDescriptorTable::new(); - let code_selector = gdt.add_entry(Descriptor::kernel_code_segment()); - let data_selector = gdt.add_entry(Descriptor::kernel_data_segment()); + let code_selector = gdt.append(Descriptor::kernel_code_segment()); + let data_selector = gdt.append(Descriptor::kernel_data_segment()); let gdt = unsafe { ptr.write(gdt); &*ptr diff --git a/common/src/level_4_entries.rs b/common/src/level_4_entries.rs index c894d0b5..9757374f 100644 --- a/common/src/level_4_entries.rs +++ b/common/src/level_4_entries.rs @@ -48,7 +48,10 @@ impl UsedLevel4Entries { // The bootload needs to access the frame buffer. if let Some(frame_buffer) = framebuffer { - used.mark_range_as_used(frame_buffer.addr.as_u64(), frame_buffer.info.byte_len); + used.mark_range_as_used( + frame_buffer.addr.as_u64(), + frame_buffer.info.byte_len as u64, + ); } // Mark the statically configured ranges from the config as used. @@ -56,7 +59,7 @@ impl UsedLevel4Entries { if let Some(config::Mapping::FixedAddress(physical_memory_offset)) = config.mappings.physical_memory { - used.mark_range_as_used(physical_memory_offset, max_phys_addr.as_u64().into_usize()); + used.mark_range_as_used(physical_memory_offset, max_phys_addr.as_u64()); } if let Some(config::Mapping::FixedAddress(recursive_address)) = @@ -76,12 +79,12 @@ impl UsedLevel4Entries { let memory_regions_layout = Layout::array::(regions).unwrap(); let (combined, _) = boot_info_layout.extend(memory_regions_layout).unwrap(); - used.mark_range_as_used(boot_info_address, combined.size()); + used.mark_range_as_used(boot_info_address, combined.size() as u64); } if let config::Mapping::FixedAddress(framebuffer_address) = config.mappings.framebuffer { if let Some(framebuffer) = framebuffer { - used.mark_range_as_used(framebuffer_address, framebuffer.info.byte_len); + used.mark_range_as_used(framebuffer_address, framebuffer.info.byte_len as u64); } } @@ -111,14 +114,9 @@ impl UsedLevel4Entries { } /// Marks all p4 entries in the range `[address..address+size)` as used. - /// - /// `size` can be a `u64` or `usize`. - fn mark_range_as_used(&mut self, address: u64, size: S) - where - VirtAddr: core::ops::Add, - { + fn mark_range_as_used(&mut self, address: u64, size: u64) { let start = VirtAddr::new(address); - let end_inclusive = (start + size) - 1usize; + let end_inclusive = (start + size) - 1; let start_page = Page::::containing_address(start); let end_page_inclusive = Page::::containing_address(end_inclusive); diff --git a/common/src/lib.rs b/common/src/lib.rs index 1c8b1efe..475ab22e 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -285,8 +285,9 @@ where log::info!("Map framebuffer"); let framebuffer_start_frame: PhysFrame = PhysFrame::containing_address(framebuffer.addr); - let framebuffer_end_frame = - PhysFrame::containing_address(framebuffer.addr + framebuffer.info.byte_len - 1u64); + let framebuffer_end_frame = PhysFrame::containing_address( + framebuffer.addr + framebuffer.info.byte_len as u64 - 1u64, + ); let start_page = mapping_addr_page_aligned( config.mappings.framebuffer, u64::from_usize(framebuffer.info.byte_len), @@ -394,7 +395,7 @@ where } }; - let entry = &mut kernel_page_table.level_4_table()[index]; + let entry = &mut kernel_page_table.level_4_table_mut()[index]; if !entry.is_unused() { panic!( "Could not set up recursive mapping: index {} already in use", @@ -496,8 +497,8 @@ where ) .expect("boot info addr is not properly aligned"); - let memory_map_regions_addr = boot_info_addr + memory_regions_offset; - let memory_map_regions_end = boot_info_addr + combined.size(); + let memory_map_regions_addr = boot_info_addr + memory_regions_offset as u64; + let memory_map_regions_end = boot_info_addr + combined.size() as u64; let start_page = Page::containing_address(boot_info_addr); let end_page = Page::containing_address(memory_map_regions_end - 1u64); diff --git a/common/src/load_kernel.rs b/common/src/load_kernel.rs index 0eab3a24..b1c35560 100644 --- a/common/src/load_kernel.rs +++ b/common/src/load_kernel.rs @@ -342,8 +342,8 @@ where let end_inclusive_copy_address = cmp::min(end_inclusive_addr, page_end_inclusive); // These are the offsets into the frame we want to copy from. - let start_offset_in_frame = (start_copy_address - page_start) as usize; - let end_inclusive_offset_in_frame = (end_inclusive_copy_address - page_start) as usize; + let start_offset_in_frame = start_copy_address - page_start; + let end_inclusive_offset_in_frame = end_inclusive_copy_address - page_start; // Calculate how many bytes we want to copy from this frame. let copy_len = end_inclusive_offset_in_frame - start_offset_in_frame + 1; @@ -362,11 +362,11 @@ where // SAFETY: We know that this memory is valid because we got it // as a result from a translation. There are not other // references to it. - &*core::ptr::slice_from_raw_parts(src_ptr, copy_len) + &*core::ptr::slice_from_raw_parts(src_ptr, copy_len as usize) }; // Calculate the destination pointer. - let dest = &mut buf[start_offset_in_buf..][..copy_len]; + let dest = &mut buf[start_offset_in_buf..][..copy_len as usize]; // Do the actual copy. dest.copy_from_slice(src); @@ -409,8 +409,8 @@ where let end_inclusive_copy_address = cmp::min(end_inclusive_addr, page_end_inclusive); // These are the offsets into the frame we want to copy from. - let start_offset_in_frame = (start_copy_address - page_start) as usize; - let end_inclusive_offset_in_frame = (end_inclusive_copy_address - page_start) as usize; + let start_offset_in_frame = start_copy_address - page_start; + let end_inclusive_offset_in_frame = end_inclusive_copy_address - page_start; // Calculate how many bytes we want to copy from this frame. let copy_len = end_inclusive_offset_in_frame - start_offset_in_frame + 1; @@ -429,11 +429,11 @@ where // SAFETY: We know that this memory is valid because we got it // as a result from a translation. There are not other // references to it. - &mut *core::ptr::slice_from_raw_parts_mut(dest_ptr, copy_len) + &mut *core::ptr::slice_from_raw_parts_mut(dest_ptr, copy_len as usize) }; // Calculate the destination pointer. - let src = &buf[start_offset_in_buf..][..copy_len]; + let src = &buf[start_offset_in_buf..][..copy_len as usize]; // Do the actual copy. dest.copy_from_slice(src); diff --git a/tests/test_kernels/Cargo.lock b/tests/test_kernels/Cargo.lock index 408c7bb2..00964519 100644 --- a/tests/test_kernels/Cargo.lock +++ b/tests/test_kernels/Cargo.lock @@ -36,7 +36,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -45,7 +45,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -54,7 +54,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -63,7 +63,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -72,7 +72,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -81,7 +81,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -90,7 +90,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -99,7 +99,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -108,7 +108,7 @@ version = "0.1.0" dependencies = [ "bootloader_api", "uart_16550", - "x86_64", + "x86_64 0.15.2", ] [[package]] @@ -119,7 +119,7 @@ checksum = "614ff2a87880d4bd4374722268598a970bbad05ced8bf630439417347254ab2e" dependencies = [ "bitflags 1.3.2", "rustversion", - "x86_64", + "x86_64 0.14.13", ] [[package]] @@ -139,3 +139,15 @@ dependencies = [ "rustversion", "volatile", ] + +[[package]] +name = "x86_64" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f042214de98141e9c8706e8192b73f56494087cc55ebec28ce10f26c5c364ae" +dependencies = [ + "bit_field", + "bitflags 2.8.0", + "rustversion", + "volatile", +] diff --git a/tests/test_kernels/config_file/Cargo.toml b/tests/test_kernels/config_file/Cargo.toml index 990b9508..86a90cf7 100644 --- a/tests/test_kernels/config_file/Cargo.toml +++ b/tests/test_kernels/config_file/Cargo.toml @@ -6,8 +6,7 @@ edition = "2021" [dependencies] bootloader_api = { path = "../../../api" } -x86_64 = { version = "0.14.7", default-features = false, features = [ +x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", - "inline_asm", ] } uart_16550 = "0.2.10" diff --git a/tests/test_kernels/default_settings/Cargo.toml b/tests/test_kernels/default_settings/Cargo.toml index 81e1be2f..8d643cdd 100644 --- a/tests/test_kernels/default_settings/Cargo.toml +++ b/tests/test_kernels/default_settings/Cargo.toml @@ -6,8 +6,7 @@ edition = "2021" [dependencies] bootloader_api = { path = "../../../api" } -x86_64 = { version = "0.14.7", default-features = false, features = [ +x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", - "inline_asm", ] } uart_16550 = "0.2.10" diff --git a/tests/test_kernels/higher_half/Cargo.toml b/tests/test_kernels/higher_half/Cargo.toml index aedecae0..b7d7f2c7 100644 --- a/tests/test_kernels/higher_half/Cargo.toml +++ b/tests/test_kernels/higher_half/Cargo.toml @@ -8,9 +8,8 @@ edition = "2021" [dependencies] bootloader_api = { path = "../../../api" } -x86_64 = { version = "0.14.7", default-features = false, features = [ +x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", - "inline_asm", ] } uart_16550 = "0.2.10" diff --git a/tests/test_kernels/lower_memory_free/Cargo.toml b/tests/test_kernels/lower_memory_free/Cargo.toml index 65b06da2..be0249c7 100644 --- a/tests/test_kernels/lower_memory_free/Cargo.toml +++ b/tests/test_kernels/lower_memory_free/Cargo.toml @@ -5,8 +5,7 @@ edition = "2021" [dependencies] bootloader_api = { path = "../../../api" } -x86_64 = { version = "0.14.7", default-features = false, features = [ +x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", - "inline_asm", ] } uart_16550 = "0.2.10" diff --git a/tests/test_kernels/lto/Cargo.toml b/tests/test_kernels/lto/Cargo.toml index 030625c1..0f8e4e3c 100644 --- a/tests/test_kernels/lto/Cargo.toml +++ b/tests/test_kernels/lto/Cargo.toml @@ -6,8 +6,7 @@ edition = "2018" [dependencies] bootloader_api = { path = "../../../api" } -x86_64 = { version = "0.14.7", default-features = false, features = [ +x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", - "inline_asm", ] } uart_16550 = "0.2.10" diff --git a/tests/test_kernels/map_phys_mem/Cargo.toml b/tests/test_kernels/map_phys_mem/Cargo.toml index 51233f1c..5dcb5b16 100644 --- a/tests/test_kernels/map_phys_mem/Cargo.toml +++ b/tests/test_kernels/map_phys_mem/Cargo.toml @@ -6,8 +6,7 @@ edition = "2021" [target.'cfg(target_arch = "x86_64")'.dependencies] bootloader_api = { path = "../../../api" } -x86_64 = { version = "0.14.7", default-features = false, features = [ +x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", - "inline_asm", ] } uart_16550 = "0.2.10" diff --git a/tests/test_kernels/min_stack/Cargo.toml b/tests/test_kernels/min_stack/Cargo.toml index afc7c2d6..82aae6d3 100644 --- a/tests/test_kernels/min_stack/Cargo.toml +++ b/tests/test_kernels/min_stack/Cargo.toml @@ -6,8 +6,7 @@ edition = "2021" [dependencies] bootloader_api = { path = "../../../api" } -x86_64 = { version = "0.14.7", default-features = false, features = [ +x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", - "inline_asm", ] } uart_16550 = "0.2.10" diff --git a/tests/test_kernels/pie/Cargo.toml b/tests/test_kernels/pie/Cargo.toml index c6ee298a..93f71abd 100644 --- a/tests/test_kernels/pie/Cargo.toml +++ b/tests/test_kernels/pie/Cargo.toml @@ -6,8 +6,7 @@ edition = "2018" [dependencies] bootloader_api = { path = "../../../api" } -x86_64 = { version = "0.14.7", default-features = false, features = [ +x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", - "inline_asm", ] } uart_16550 = "0.2.10" diff --git a/tests/test_kernels/ramdisk/Cargo.toml b/tests/test_kernels/ramdisk/Cargo.toml index 4258b0a5..0ca537e7 100644 --- a/tests/test_kernels/ramdisk/Cargo.toml +++ b/tests/test_kernels/ramdisk/Cargo.toml @@ -6,8 +6,7 @@ edition = "2021" [dependencies] bootloader_api = { path = "../../../api" } -x86_64 = { version = "0.14.7", default-features = false, features = [ +x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", - "inline_asm", ] } uart_16550 = "0.2.10" diff --git a/tests/test_kernels/write_usable_memory/Cargo.toml b/tests/test_kernels/write_usable_memory/Cargo.toml index 88cf640f..200abc9d 100644 --- a/tests/test_kernels/write_usable_memory/Cargo.toml +++ b/tests/test_kernels/write_usable_memory/Cargo.toml @@ -5,8 +5,7 @@ edition = "2021" [dependencies] bootloader_api = { path = "../../../api" } -x86_64 = { version = "0.14.7", default-features = false, features = [ +x86_64 = { version = "0.15.2", default-features = false, features = [ "instructions", - "inline_asm", ] } uart_16550 = "0.2.10" diff --git a/uefi/Cargo.toml b/uefi/Cargo.toml index 80168be5..9e96ce64 100644 --- a/uefi/Cargo.toml +++ b/uefi/Cargo.toml @@ -13,6 +13,6 @@ bootloader_api = { workspace = true } bootloader-x86_64-common = { workspace = true } bootloader-boot-config = { workspace = true } log = "0.4.14" -x86_64 = "0.14.8" +x86_64 = "0.15.2" serde-json-core = "0.5.0" uefi = "0.20.0" diff --git a/uefi/src/main.rs b/uefi/src/main.rs index 0ad26557..1ee17c0d 100644 --- a/uefi/src/main.rs +++ b/uefi/src/main.rs @@ -423,7 +423,7 @@ fn create_page_tables( // necessarily part of the identity mapping). if let Some(frame_buffer) = frame_buffer { let start_addr = VirtAddr::new(frame_buffer.addr.as_u64()); - let end_addr = start_addr + frame_buffer.info.byte_len; + let end_addr = start_addr + frame_buffer.info.byte_len as u64; for p4 in usize::from(start_addr.p4_index())..=usize::from(end_addr.p4_index()) { new_table[p4] = old_table[p4].clone(); }