diff options
author | Andreas Kling <kling@serenityos.org> | 2021-02-14 09:57:19 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-14 10:01:50 +0100 |
commit | 09b1b09c1923c5e82c5500a06c501088ab5ac4ce (patch) | |
tree | f57307d460c8856604dfa21f3ab27b7a449cd4bc /Kernel/PCI/MMIOAccess.cpp | |
parent | 198d64180886e6fad2997513c4c8f68b1338f4e4 (diff) | |
download | serenity-09b1b09c1923c5e82c5500a06c501088ab5ac4ce.zip |
Kernel: Assert if rounding-up-to-page-size would wrap around to 0
If we try to align a number above 0xfffff000 to the next multiple of
the page size (4 KiB), it would wrap around to 0. This is most likely
never what we want, so let's assert if that happens.
Diffstat (limited to 'Kernel/PCI/MMIOAccess.cpp')
-rw-r--r-- | Kernel/PCI/MMIOAccess.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Kernel/PCI/MMIOAccess.cpp b/Kernel/PCI/MMIOAccess.cpp index e848f8c359..8024ffc044 100644 --- a/Kernel/PCI/MMIOAccess.cpp +++ b/Kernel/PCI/MMIOAccess.cpp @@ -51,7 +51,7 @@ private: DeviceConfigurationSpaceMapping::DeviceConfigurationSpaceMapping(Address device_address, const MMIOSegment& mmio_segment) : m_device_address(device_address) - , m_mapped_region(MM.allocate_kernel_region(PAGE_ROUND_UP(PCI_MMIO_CONFIG_SPACE_SIZE), "PCI MMIO Device Access", Region::Access::Read | Region::Access::Write).release_nonnull()) + , m_mapped_region(MM.allocate_kernel_region(page_round_up(PCI_MMIO_CONFIG_SPACE_SIZE), "PCI MMIO Device Access", Region::Access::Read | Region::Access::Write).release_nonnull()) { PhysicalAddress segment_lower_addr = mmio_segment.get_paddr(); PhysicalAddress device_physical_mmio_space = segment_lower_addr.offset( @@ -106,7 +106,7 @@ MMIOAccess::MMIOAccess(PhysicalAddress p_mcfg) klog() << "PCI: MCFG, length - " << length << ", revision " << revision; checkup_region->unmap(); - auto mcfg_region = MM.allocate_kernel_region(p_mcfg.page_base(), PAGE_ROUND_UP(length) + PAGE_SIZE, "PCI Parsing MCFG", Region::Access::Read | Region::Access::Write); + auto mcfg_region = MM.allocate_kernel_region(p_mcfg.page_base(), page_round_up(length) + PAGE_SIZE, "PCI Parsing MCFG", Region::Access::Read | Region::Access::Write); auto& mcfg = *(ACPI::Structures::MCFG*)mcfg_region->vaddr().offset(p_mcfg.offset_in_page()).as_ptr(); dbgln_if(PCI_DEBUG, "PCI: Checking MCFG @ {}, {}", VirtualAddress(&mcfg), PhysicalAddress(p_mcfg.get())); |