Re: [PATCH] x86/mm: fix lookup_address() to handle physical memory holes in direct mapping

From: Jürgen Groß
Date: Sat Jun 29 2024 - 12:50:20 EST


On 29.06.24 17:16, Tom Lendacky wrote:
On 6/29/24 05:20, Jürgen Groß wrote:
On 28.06.24 22:52, Ashish Kalra wrote:
From: Ashish Kalra <ashish.kalra@xxxxxxx>

lookup_address_in_pgd_attr() at pte level it is simply returning
pte_offset_kernel() and there does not seem to be a check for
returning NULL if pte_none().

Fix lookup_address_in_pgd_attr() to add check for pte_none()
after pte_offset_kernel() and return NULL if it is true.

Please have a look at the comment above lookup_address(). You should not
break the documented behavior without verifying that no caller is relying
on the current behavior. If this is fine, please update the comment.

This brings up a point from my other reply. The comment says that it
returns "the effective NX and RW bits of all page table levels", but in
fact NX and RW are not updated for the PTE. Since the comment says all
page table levels, shouldn't they be updated with the PTE values, too?

Hmm, the comment could need some clarifications.

It returns the effective NX and RW bits of the levels above the PTE. Reason is
that the function is used in case the NX/RW bits of a PTE are updated, so the
PTE settings are not always really important.


Juergen