Kernel: Fix page round wrap detection for 64-bit

We were assuming 32-bit pointers, which will not always be the case
Also fixed an incorrect comment about wrapping
This commit is contained in:
Hendiadyoin1 2021-06-28 18:58:23 +02:00 committed by Andreas Kling
parent 65566d6868
commit 10728cd421
Notes: sideshowbarker 2024-07-18 11:23:43 +09:00

View file

@ -22,13 +22,13 @@ namespace Kernel {
constexpr bool page_round_up_would_wrap(FlatPtr x)
{
return x > 0xfffff000u;
return x > (explode_byte(0xFF) & ~0xFFF);
}
constexpr FlatPtr page_round_up(FlatPtr x)
{
FlatPtr rounded = (((FlatPtr)(x)) + PAGE_SIZE - 1) & (~(PAGE_SIZE - 1));
// Rounding up >0xffff0000 wraps back to 0. That's never what we want.
// Rounding up >0xfffff000 wraps back to 0. That's never what we want.
VERIFY(x == 0 || rounded != 0);
return rounded;
}