Skip to content

Commit 55872f4

Browse files
committed
minor changes to avoid issue 82523
- see also rust-lang/rust#82523
1 parent 5fdd64e commit 55872f4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/arch/x86_64/kernel/acpi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ fn parse_fadt(fadt: AcpiTable<'_>) {
412412

413413
// Map the "Differentiated System Description Table" (DSDT).
414414
// TODO: This must not require "unsafe", see https://github.com/rust-lang/rust/issues/46043#issuecomment-393072398
415-
let x_dsdt_field_address = unsafe { &fadt_table.x_dsdt as *const _ as usize };
415+
let x_dsdt = core::ptr::addr_of!(fadt_table.x_dsdt);
416+
let x_dsdt_field_address = unsafe { x_dsdt.read_unaligned() as usize };
416417
let dsdt_address = if x_dsdt_field_address < fadt.table_end_address() && fadt_table.x_dsdt > 0 {
417418
PhysAddr(fadt_table.x_dsdt)
418419
} else {

src/arch/x86_64/kernel/apic.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,14 @@ fn detect_from_acpi() -> Result<PhysAddr, ()> {
233233
1 => {
234234
// I/O APIC
235235
let ioapic_record = unsafe { &*(current_address as *const IoApicRecord) };
236+
let ioapic_addr = core::ptr::addr_of!(ioapic_record.address);
236237
debug!("Found I/O APIC record: {}", ioapic_record);
237238

238239
unsafe {
239240
IOAPIC_ADDRESS = virtualmem::allocate(BasePageSize::SIZE).unwrap();
240241
debug!(
241242
"Mapping IOAPIC at {:#X} to virtual address {:#X}",
242-
ioapic_record.address, IOAPIC_ADDRESS
243+
ioapic_addr.read_unaligned(), IOAPIC_ADDRESS
243244
);
244245

245246
let mut flags = PageTableEntryFlags::empty();

0 commit comments

Comments
 (0)