From: Hang SU <darcysail@xxxxxxxxx> Add assembly check in desc.h, to replace segment selector magic number with macro definition. Signed-off-by: Hang SU <darcy.sh@xxxxxxxxxxxx> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx> --- lib/x86/desc.h | 7 ++++++- x86/cstart64.S | 8 ++++---- x86/trampolines.S | 8 +++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/x86/desc.h b/lib/x86/desc.h index aa6213d1..5634de94 100644 --- a/lib/x86/desc.h +++ b/lib/x86/desc.h @@ -69,6 +69,8 @@ #define __ASM_SEL(a,b) __ASM_FORM(b) #endif +#ifndef __ASSEMBLER__ + #include <setjmp.h> void setup_idt(void); @@ -338,4 +340,7 @@ do { \ #define asm_safe_report_ex __asm_safe_report -#endif + +#endif /* __ASSEMBLER__ */ + +#endif /* _X86_DESC_H_ */ diff --git a/x86/cstart64.S b/x86/cstart64.S index 4dff1102..2b14c076 100644 --- a/x86/cstart64.S +++ b/x86/cstart64.S @@ -1,5 +1,5 @@ - #include "apic-defs.h" +#include "desc.h" ipi_vector = 0x20 @@ -66,7 +66,7 @@ start: mov $stacktop, %esp setup_percpu_area call prepare_64 - jmpl $8, $start64 + jmpl $KERNEL_CS, $start64 switch_to_5level: /* Disable CR4.PCIDE */ @@ -86,11 +86,11 @@ switch_to_5level: bts $12, %eax mov %eax, %cr4 - mov $0x10, %ax + mov $KERNEL_DS, %ax mov %ax, %ss call enter_long_mode - jmpl $8, $lvl5 + jmpl $KERNEL_CS, $lvl5 smp_stacktop: .long stacktop - 4096 diff --git a/x86/trampolines.S b/x86/trampolines.S index 6a3df9c1..f0b05ab5 100644 --- a/x86/trampolines.S +++ b/x86/trampolines.S @@ -3,6 +3,8 @@ * transition from 32-bit to 64-bit code (x86-64 only) */ +#include "desc.h" + /* EFI provides it's own SIPI sequence to handle relocation. */ #ifndef CONFIG_EFI .code16 @@ -15,7 +17,7 @@ sipi_entry: or $1, %eax mov %eax, %cr0 lgdtl ap_rm_gdt_descr - sipi_entry - ljmpl $8, $ap_start32 + ljmpl $KERNEL_CS32, $ap_start32 sipi_end: .globl ap_rm_gdt_descr @@ -66,7 +68,7 @@ MSR_GS_BASE = 0xc0000101 mov $MSR_GS_BASE, %ecx rdmsr - mov $0x10, %bx + mov $KERNEL_DS, %bx mov %bx, %ds mov %bx, %es mov %bx, %fs @@ -123,7 +125,7 @@ ap_start32: call prepare_64 load_absolute_addr $ap_start64, %edx - pushl $0x08 + pushl $KERNEL_CS pushl %edx lretl #endif -- 2.48.1.601.g30ceb7b040-goog