Skip to content

Commit

Permalink
x86/mm/ident_map: Check for errors from ident_pud_init()
Browse files Browse the repository at this point in the history
[ Upstream commit 1fcd009 ]

Commit

  ea3b5e6 ("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.

 [ bp: Space out statements for better readability. ]

Fixes: ea3b5e6 ("x86/mm/ident_map: Add 5-level paging support")
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Joerg Roedel <jroedel@suse.de>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Link: https://lkml.kernel.org/r/20201027230648.1885111-1-nivedita@alum.mit.edu
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
nivedita76 authored and gregkh committed Dec 30, 2020
1 parent 965f559 commit 9c79c9e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions arch/x86/mm/ident_map.c
Expand Up @@ -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);
Expand All @@ -73,13 +74,20 @@ 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));
}

Expand Down

0 comments on commit 9c79c9e

Please sign in to comment.