• Joerg Roedel's avatar
    x86/head/64: Install a CPU bringup IDT · f5963ba7
    Joerg Roedel authored
    Add a separate bringup IDT for the CPU bringup code that will be used
    until the kernel switches to the idt_table. There are two reasons for a
    separate IDT:
    
    	1) When the idt_table is set up and the secondary CPUs are
    	   booted, it contains entries (e.g. IST entries) which
    	   require certain CPU state to be set up. This includes a
    	   working TSS (for IST), MSR_GS_BASE (for stack protector) or
    	   CR4.FSGSBASE (for paranoid_entry) path. By using a
    	   dedicated IDT for early boot this state need not to be set
    	   up early.
    
    	2) The idt_table is static to idt.c, so any function
    	   using/modifying must be in idt.c too. That means that all
    	   compiler driven instrumentation like tracing or KASAN is
    	   also active in this code. But during early CPU bringup the
    	   environment is not set up for this instrumentation to work
    	   correctly.
    
    To avoid all of these hassles and make early exception handling robust,
    use a dedicated bringup IDT.
    
    The IDT is loaded two times, first on the boot CPU while the kernel is
    still running on direct mapped addresses, and again later after the
    switch to kernel addresses has happened. The second IDT load happens on
    the boot and secondary CPUs.
    Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
    Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
    Link: https://lkml.kernel.org/r/20200907131613.12703-34-joro@8bytes.org
    f5963ba7
head64.c 16.1 KB