Skip to content

Commit d9ec115

Browse files
ardbiesheuvelIngo Molnar
authored andcommitted
x86/boot/64: Use RIP_REL_REF() to assign 'phys_base'
'phys_base' is assigned from code that executes from a 1:1 mapping so it cannot use a plain access from C. Replace the use of fixup_pointer() with RIP_REL_REF(), which is better and simpler. While at it, move the assignment to before the addition of the SME mask so there is no need to subtract it again, and drop the unnecessary addition ('phys_base' is statically initialized to 0x0) Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20240221113506.2565718-20-ardb+git@google.com
1 parent 5da7936 commit d9ec115

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

arch/x86/kernel/head64.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ unsigned long __head __startup_64(unsigned long physaddr,
192192
* and the address I am actually running at.
193193
*/
194194
load_delta = physaddr - (unsigned long)(_text - __START_KERNEL_map);
195+
RIP_REL_REF(phys_base) = load_delta;
195196

196197
/* Is the address not 2M aligned? */
197198
if (load_delta & ~PMD_MASK)
@@ -301,12 +302,6 @@ unsigned long __head __startup_64(unsigned long physaddr,
301302
for (; i < PTRS_PER_PMD; i++)
302303
pmd[i] &= ~_PAGE_PRESENT;
303304

304-
/*
305-
* Fixup phys_base - remove the memory encryption mask to obtain
306-
* the true physical address.
307-
*/
308-
*fixup_long(&phys_base, physaddr) += load_delta - sme_get_me_mask();
309-
310305
return sme_postprocess_startup(bp, pmd);
311306
}
312307

0 commit comments

Comments
 (0)