Skip to content

Commit b51207d

Browse files
ubizjakKAGA-KOKO
authored andcommitted
x86/boot/64: Strip percpu address space when setting up GDT descriptors
init_per_cpu_var() returns a pointer in the percpu address space while rip_rel_ptr() expects a pointer in the generic address space. When strict address space checks are enabled, GCC's named address space checks fail: asm.h:124:63: error: passing argument 1 of 'rip_rel_ptr' from pointer to non-enclosed address space Add a explicit cast to remove address space of the returned pointer. Fixes: 11e36b0 ("x86/boot/64: Load the final kernel GDT during early boot directly, remove startup_gdt[]") Signed-off-by: Uros Bizjak <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 7678a53 commit b51207d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/kernel/head64.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,11 @@ void early_setup_idt(void)
559559
*/
560560
void __head startup_64_setup_gdt_idt(void)
561561
{
562+
struct desc_struct *gdt = (void *)(__force unsigned long)init_per_cpu_var(gdt_page.gdt);
562563
void *handler = NULL;
563564

564565
struct desc_ptr startup_gdt_descr = {
565-
.address = (unsigned long)&RIP_REL_REF(init_per_cpu_var(gdt_page.gdt)),
566+
.address = (unsigned long)&RIP_REL_REF(*gdt),
566567
.size = GDT_SIZE - 1,
567568
};
568569

0 commit comments

Comments
 (0)