mtrr: Fix range overlap check

This commit is contained in:
mintsuki 2021-03-10 04:45:30 +01:00
parent 8bcbaa48c9
commit 7f32fb591b

View File

@ -20,10 +20,10 @@ static bool is_block_in_mtrr_range(struct mtrr *mtrr, uint64_t block_base, uint6
if (!(mtrr->mask & (1 << 11))) if (!(mtrr->mask & (1 << 11)))
return false; return false;
uint64_t base = mtrr->base & ~(0xfff); uint64_t base = mtrr->base & ~((uint64_t)0xfff);
uint64_t mask = mtrr->mask & ~(0xfff); uint64_t mask = mtrr->mask & ~((uint64_t)0xfff);
for (uint64_t i = block_base; i < block_size; i += 4096) { for (uint64_t i = block_base; i < block_base + block_size; i += 4096) {
if ((i & mask) == (base & mask)) if ((i & mask) == (base & mask))
return true; return true;
} }