Skip to content

Commit

Permalink
x86: Compare physical instead of virtual PGD addresses
Browse files Browse the repository at this point in the history
This is a preparatory patch for when pointers have tags in their
upper address bits. But it's a harmless change on its own.

The mm->pgd virtual address may be tagged because it came out of
the allocator at some point. The __va(read_cr3_pa()) address will
never be tagged (the tag bits are all 1's). A direct pointer value
comparison would fail if one is tagged and the other is not.

To fix this, just compare the physical addresses which are never
affected by tagging.

[ dhansen: subject and changelog munging ]

Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lore.kernel.org/all/fde443d0e67f76a51e7ab4e96647705840f53ddb.1738686764.git.maciej.wieczor-retman%40intel.com
  • Loading branch information
Maciej Wieczor-Retman authored and Dave Hansen committed Feb 6, 2025
1 parent 3ef938c commit 63887c9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/x86/mm/tlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ bool nmi_uaccess_okay(void)
if (loaded_mm != current_mm)
return false;

VM_WARN_ON_ONCE(current_mm->pgd != __va(read_cr3_pa()));
VM_WARN_ON_ONCE(__pa(current_mm->pgd) != read_cr3_pa());

return true;
}
Expand Down

0 comments on commit 63887c9

Please sign in to comment.