All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: "Jürgen Groß" <jgross@suse.com>,
	"Ashish Kalra" <Ashish.Kalra@amd.com>,
	dave.hansen@linux.intel.com, luto@kernel.org,
	peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com,
	bp@alien8.de
Cc: x86@kernel.org, hpa@zytor.com, kirill.shutemov@linux.intel.com,
	rick.p.edgecombe@intel.com, mhklinux@outlook.com,
	peterx@redhat.com, linux-kernel@vger.kernel.org,
	linux-coco@lists.linux.dev, jroedel@suse.de
Subject: Re: [PATCH] x86/mm: fix lookup_address() to handle physical memory holes in direct mapping
Date: Sat, 29 Jun 2024 10:16:26 -0500	[thread overview]
Message-ID: <76d96581-202c-80ce-eb26-8f906660c8e0@amd.com> (raw)
In-Reply-To: <2982a4f2-ea8f-4fa4-81ea-d73c00fc2ad0@suse.com>

On 6/29/24 05:20, Jürgen Groß wrote:
> On 28.06.24 22:52, Ashish Kalra wrote:
>> From: Ashish Kalra <ashish.kalra@amd.com>
>>
>> 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?

Thanks,
Tom

> 
> 
> Juergen
> 
>>
>> Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
>> ---
>>   arch/x86/mm/pat/set_memory.c | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
>> index 443a97e515c0..be8b5bf3bc3f 100644
>> --- a/arch/x86/mm/pat/set_memory.c
>> +++ b/arch/x86/mm/pat/set_memory.c
>> @@ -672,6 +672,7 @@ pte_t *lookup_address_in_pgd_attr(pgd_t *pgd,
>> unsigned long address,
>>       p4d_t *p4d;
>>       pud_t *pud;
>>       pmd_t *pmd;
>> +    pte_t *pte;
>>         *level = PG_LEVEL_256T;
>>       *nx = false;
>> @@ -717,7 +718,11 @@ pte_t *lookup_address_in_pgd_attr(pgd_t *pgd,
>> unsigned long address,
>>       *nx |= pmd_flags(*pmd) & _PAGE_NX;
>>       *rw &= pmd_flags(*pmd) & _PAGE_RW;
>>   -    return pte_offset_kernel(pmd, address);
>> +    pte = pte_offset_kernel(pmd, address);
>> +    if (pte_none(*pte))
>> +        return NULL;
>> +
>> +    return pte;
>>   }
>>     /*
> 

  reply	other threads:[~2024-06-29 15:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-28 20:52 [PATCH] x86/mm: fix lookup_address() to handle physical memory holes in direct mapping Ashish Kalra
2024-06-28 20:58 ` Edgecombe, Rick P
2024-06-28 21:22   ` Kalra, Ashish
2024-06-28 21:33     ` Edgecombe, Rick P
2024-06-28 21:36       ` Tom Lendacky
2024-06-28 21:31   ` Tom Lendacky
2024-06-29 10:20 ` Jürgen Groß
2024-06-29 15:16   ` Tom Lendacky [this message]
2024-06-29 16:50     ` Jürgen Groß
2024-07-01 17:57   ` Kalra, Ashish
2024-07-01 18:38     ` Jürgen Groß
2024-07-01 18:59       ` Kalra, Ashish
2024-07-01 19:13         ` Edgecombe, Rick P
2024-07-01 19:39           ` Kalra, Ashish
2024-07-02  5:29             ` Jürgen Groß

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=76d96581-202c-80ce-eb26-8f906660c8e0@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=Ashish.Kalra@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=jroedel@suse.de \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=mingo@redhat.com \
    --cc=peterx@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rick.p.edgecombe@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.