Skip to content

Commit 5574b36

Browse files
ashkalrabp3tk0v
authored andcommitted
x86/mm: Do not zap page table entries mapping unaccepted memory table during kdump
During crashkernel boot only pre-allocated crash memory is presented as E820_TYPE_RAM. This can cause page table entries mapping unaccepted memory table to be zapped during phys_pte_init(), phys_pmd_init(), phys_pud_init() and phys_p4d_init() as SNP/TDX guest use E820_TYPE_ACPI to store the unaccepted memory table and pass it between the kernels on kexec/kdump. E820_TYPE_ACPI covers not only ACPI data, but also EFI tables and might be required by kernel to function properly. The problem was discovered during debugging kdump for SNP guest. The unaccepted memory table stored with E820_TYPE_ACPI and passed between the kernels on kdump was getting zapped as the PMD entry mapping this is above the E820_TYPE_RAM range for the reserved crashkernel memory. Signed-off-by: Ashish Kalra <[email protected]> Signed-off-by: Kirill A. Shutemov <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 06fa48d commit 5574b36

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

arch/x86/mm/init_64.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,9 @@ phys_pte_init(pte_t *pte_page, unsigned long paddr, unsigned long paddr_end,
469469
!e820__mapped_any(paddr & PAGE_MASK, paddr_next,
470470
E820_TYPE_RAM) &&
471471
!e820__mapped_any(paddr & PAGE_MASK, paddr_next,
472-
E820_TYPE_RESERVED_KERN))
472+
E820_TYPE_RESERVED_KERN) &&
473+
!e820__mapped_any(paddr & PAGE_MASK, paddr_next,
474+
E820_TYPE_ACPI))
473475
set_pte_init(pte, __pte(0), init);
474476
continue;
475477
}
@@ -524,7 +526,9 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long paddr, unsigned long paddr_end,
524526
!e820__mapped_any(paddr & PMD_MASK, paddr_next,
525527
E820_TYPE_RAM) &&
526528
!e820__mapped_any(paddr & PMD_MASK, paddr_next,
527-
E820_TYPE_RESERVED_KERN))
529+
E820_TYPE_RESERVED_KERN) &&
530+
!e820__mapped_any(paddr & PMD_MASK, paddr_next,
531+
E820_TYPE_ACPI))
528532
set_pmd_init(pmd, __pmd(0), init);
529533
continue;
530534
}
@@ -611,7 +615,9 @@ phys_pud_init(pud_t *pud_page, unsigned long paddr, unsigned long paddr_end,
611615
!e820__mapped_any(paddr & PUD_MASK, paddr_next,
612616
E820_TYPE_RAM) &&
613617
!e820__mapped_any(paddr & PUD_MASK, paddr_next,
614-
E820_TYPE_RESERVED_KERN))
618+
E820_TYPE_RESERVED_KERN) &&
619+
!e820__mapped_any(paddr & PUD_MASK, paddr_next,
620+
E820_TYPE_ACPI))
615621
set_pud_init(pud, __pud(0), init);
616622
continue;
617623
}
@@ -698,7 +704,9 @@ phys_p4d_init(p4d_t *p4d_page, unsigned long paddr, unsigned long paddr_end,
698704
!e820__mapped_any(paddr & P4D_MASK, paddr_next,
699705
E820_TYPE_RAM) &&
700706
!e820__mapped_any(paddr & P4D_MASK, paddr_next,
701-
E820_TYPE_RESERVED_KERN))
707+
E820_TYPE_RESERVED_KERN) &&
708+
!e820__mapped_any(paddr & P4D_MASK, paddr_next,
709+
E820_TYPE_ACPI))
702710
set_p4d_init(p4d, __p4d(0), init);
703711
continue;
704712
}

0 commit comments

Comments
 (0)