mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
Kernel/ACPI: Map two pages when reading the FADT
On some cases, the FADT could be on the end of a page, so if we don't have two pages being mapped, we could easily read from a non-mapped virtual address, which will trigger the UB sanitizer. Also, we need to treat the FADT structure as volatile and const, as it may change at any time, but we should not touch (write) it anyhow.
This commit is contained in:
@@ -71,11 +71,13 @@ UNMAP_AFTER_INIT void Parser::init_fadt()
|
||||
m_fadt = find_table("FACP");
|
||||
VERIFY(!m_fadt.is_null());
|
||||
|
||||
auto sdt = map_typed<Structures::FADT>(m_fadt);
|
||||
// FIXME: We need at least two pages for mapping, since we can be on the "edge" of one page...
|
||||
auto sdt = map_typed<const volatile Structures::FADT>(m_fadt, PAGE_SIZE * 2);
|
||||
|
||||
dbgln_if(ACPI_DEBUG, "ACPI: FADT @ V{}, {}", &sdt, m_fadt);
|
||||
|
||||
dmesgln("ACPI: Fixed ACPI data, Revision {}, length: {} bytes", sdt->h.revision, sdt->h.length);
|
||||
auto* header = &sdt.ptr()->h;
|
||||
dmesgln("ACPI: Fixed ACPI data, Revision {}, length: {} bytes", (size_t)header->revision, (size_t)header->length);
|
||||
dmesgln("ACPI: DSDT {}", PhysicalAddress(sdt->dsdt_ptr));
|
||||
m_x86_specific_flags.cmos_rtc_not_present = (sdt->ia_pc_boot_arch_flags & (u8)FADTFlags::IA_PC_Flags::CMOS_RTC_Not_Present);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user