public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/mm/ident_map: Check for errors from ident_pud_init()
@ 2020-10-27 23:06 Arvind Sankar
  2020-10-28 13:29 ` Joerg Roedel
  2020-10-28 13:56 ` [tip: x86/mm] " tip-bot2 for Arvind Sankar
  0 siblings, 2 replies; 3+ messages in thread
From: Arvind Sankar @ 2020-10-27 23:06 UTC (permalink / raw)
  To: Dave Hansen, Andy Lutomirski, Peter Zijlstra, x86
  Cc: Kirill A. Shutemov, Joerg Roedel, linux-kernel

Commit
  ea3b5e60ce80 ("x86/mm/ident_map: Add 5-level paging support")
added ident_p4d_init() to support 5-level paging, but this function
doesn't check and return errors from ident_pud_init().

For example, the decompressor stub uses this code to create an identity
mapping. If it runs out of pages while trying to allocate a PMD
pagetable, the error will be currently ignored.

Fix this to propagate errors.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Fixes: ea3b5e60ce80 ("x86/mm/ident_map: Add 5-level paging support")
---
 arch/x86/mm/ident_map.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/ident_map.c b/arch/x86/mm/ident_map.c
index fe7a12599d8e..5ecb0883cc88 100644
--- a/arch/x86/mm/ident_map.c
+++ b/arch/x86/mm/ident_map.c
@@ -62,6 +62,7 @@ static int ident_p4d_init(struct x86_mapping_info *info, p4d_t *p4d_page,
 			  unsigned long addr, unsigned long end)
 {
 	unsigned long next;
+	int result;
 
 	for (; addr < end; addr = next) {
 		p4d_t *p4d = p4d_page + p4d_index(addr);
@@ -73,13 +74,17 @@ static int ident_p4d_init(struct x86_mapping_info *info, p4d_t *p4d_page,
 
 		if (p4d_present(*p4d)) {
 			pud = pud_offset(p4d, 0);
-			ident_pud_init(info, pud, addr, next);
+			result = ident_pud_init(info, pud, addr, next);
+			if (result)
+				return result;
 			continue;
 		}
 		pud = (pud_t *)info->alloc_pgt_page(info->context);
 		if (!pud)
 			return -ENOMEM;
-		ident_pud_init(info, pud, addr, next);
+		result = ident_pud_init(info, pud, addr, next);
+		if (result)
+			return result;
 		set_p4d(p4d, __p4d(__pa(pud) | info->kernpg_flag));
 	}
 
-- 
2.26.2


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

end of thread, other threads:[~2020-10-28 22:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-27 23:06 [PATCH] x86/mm/ident_map: Check for errors from ident_pud_init() Arvind Sankar
2020-10-28 13:29 ` Joerg Roedel
2020-10-28 13:56 ` [tip: x86/mm] " tip-bot2 for Arvind Sankar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox