The current segmentation already adds -KERNELBASE. But only when accessing the memory. Don't forget to reload gdt.
--- i386/i386/cpuboot.S | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/i386/i386/cpuboot.S b/i386/i386/cpuboot.S index 7e6c4770..9ac86845 100644 --- a/i386/i386/cpuboot.S +++ b/i386/i386/cpuboot.S @@ -169,12 +169,13 @@ apboot_jmp_offset: movl %ecx,%eax movl $PC_SIZE,%ebx mul %ebx - addl $percpu_array - KERNELBASE, %eax + addl $percpu_array, %eax /* Record our cpu number */ - movl %ecx, (PERCPU_CPU_ID + KERNELBASE)(%eax) + movl %ecx, (PERCPU_CPU_ID)(%eax) /* Set up temporary percpu descriptor */ + addl $(-KERNELBASE), %eax movw %ax, apboot_percpu_low shr $16, %eax movb %al, apboot_percpu_med @@ -184,6 +185,11 @@ apboot_jmp_offset: movw $PERCPU_DS, %ax movw %ax, %gs + /* Reload the gdt because we changed it */ + lgdtl apboot_gdt_descr + ljmpl $KERNEL_CS, $2f +2: + /* Load null Interrupt descriptor table */ mov apboot_idt_ptr, %ebx lidt (%ebx) -- 2.45.2