linux-coco.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/mm: fix lookup_address() to handle physical memory holes in direct mapping
@ 2024-06-28 20:52 Ashish Kalra
  2024-06-28 20:58 ` Edgecombe, Rick P
  2024-06-29 10:20 ` Jürgen Groß
  0 siblings, 2 replies; 15+ messages in thread
From: Ashish Kalra @ 2024-06-28 20:52 UTC (permalink / raw)
  To: dave.hansen, luto, peterz, tglx, mingo, bp
  Cc: x86, hpa, kirill.shutemov, rick.p.edgecombe, mhklinux, peterx,
	jgross, linux-kernel, thomas.lendacky, linux-coco, jroedel

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.

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;
 }
 
 /*
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-07-02  5:29 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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ß

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).