x86/boot/64: Fix missed fixup_pointer() for next_early_pgt access
PATCH 1/1 x86/boot/64: Fix missed fixup_pointer() for next_early_pgt access
__startup_64() uses fixup_pointer() to access global variables in a position-independent fashion. Access to next_early_pgt was wrapped into the helper, but one of the instance in 5-level paging branch was missed.
GCC generates a R_X86_64_PC32 PC-relative relocation for the access which doesn't trigger the issue, but Clang emmits a R_X86_64_32S which leads to an invalid memory and system reboot.
--- arch/x86/kernel/head64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/head64.c +1 -1
@@ -184,7 +184,7 @@ unsigned long __head __startup_64(unsigned long physaddr, pgtable_flags = _KERNPG_TABLE_NOENC +sme_get_me_mask ();if (la57) { - p4d =fixup_pointer (early_dynamic_pgts[next_early_pgt++], physaddr); + p4d =fixup_pointer (early_dynamic_pgts[(*next_pgt_ptr)++], physaddr); i = (physaddr >>PGDIR_SHIFT ) %PTRS_PER_PGD ; pgd[i +0 ] = (pgdval_t )p4d + pgtable_flags;
Signature · 1 line
2.21.0
tip-bot for Kirill A. Shutemov
merge bot[tip:x86/urgent] x86/boot/64: Add missing fixup_pointer() for next_early_pgt access
x86/boot/64: Add missing fixup_pointer() for next_early_pgt access
Commit-ID: c1887159eb48ba40e775584cfb2a443962cf1a05 Gitweb: https://git.kernel.org/tip/c1887159eb48ba40e775584cfb2a443962cf1a05 Author: Kirill A. Shutemov <[email protected]> AuthorDate: Thu, 20 Jun 2019 14:24:22 +0300 Committer: Thomas Gleixner <[email protected]> CommitDate: Wed, 26 Jun 2019 07:25:09 +0200
x86/boot/64: Add missing fixup_pointer() for next_early_pgt access
__startup_64() uses fixup_pointer() to access global variables in a position-independent fashion. Access to next_early_pgt was wrapped into the helper, but one instance in the 5-level paging branch was missed.
GCC generates a R_X86_64_PC32 PC-relative relocation for the access which doesn't trigger the issue, but Clang emmits a R_X86_64_32S which leads to an invalid memory access and system reboot.
--- arch/x86/kernel/head64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/head64.c +2 -1
@@ -184,7 +184,8 @@ unsigned long __head __startup_64(unsigned long physaddr, pgtable_flags = _KERNPG_TABLE_NOENC +sme_get_me_mask ();if (la57) { - p4d =fixup_pointer (early_dynamic_pgts[next_early_pgt++], physaddr); + p4d =fixup_pointer (early_dynamic_pgts[(*next_pgt_ptr)++], + physaddr); i = (physaddr >>PGDIR_SHIFT ) %PTRS_PER_PGD ; pgd[i +0 ] = (pgdval_t )p4d + pgtable_flags;