]> Git Repo - J-linux.git/commitdiff
Merge branch 'linus' into x86/boot, to resolve conflict
authorIngo Molnar <[email protected]>
Tue, 12 Mar 2024 08:49:52 +0000 (09:49 +0100)
committerIngo Molnar <[email protected]>
Tue, 12 Mar 2024 08:55:57 +0000 (09:55 +0100)
There's a new conflict with Linus's upstream tree, because
in the following merge conflict resolution in <asm/coco.h>:

  38b334fc767e Merge tag 'x86_sev_for_v6.9_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Linus has resolved the conflicting placement of 'cc_mask' better
than the original commit:

  1c811d403afd x86/sev: Fix position dependent variable references in startup code

... which was also done by an internal merge resolution:

  2e5fc4786b7a Merge branch 'x86/sev' into x86/boot, to resolve conflicts and to pick up dependent tree

But Linus is right in 38b334fc767e, the 'cc_mask' declaration is sufficient
within the #ifdef CONFIG_ARCH_HAS_CC_PLATFORM block.

So instead of forcing Linus to do the same resolution again, merge in Linus's
tree and follow his conflict resolution.

 Conflicts:
arch/x86/include/asm/coco.h

Signed-off-by: Ingo Molnar <[email protected]>
1  2 
arch/x86/Kconfig
arch/x86/boot/compressed/ident_map_64.c
arch/x86/boot/compressed/sev.c
arch/x86/include/asm/desc.h
arch/x86/include/asm/sev.h
arch/x86/include/uapi/asm/bootparam.h
arch/x86/kernel/head_64.S
arch/x86/kernel/sev-shared.c
arch/x86/kernel/sev.c
arch/x86/lib/Makefile

diff --combined arch/x86/Kconfig
index 63535c8c8b2a7aecaf818cec3a2f26b864debfd1,8f7271d9f1d7808393437ccfbef4c03989e5e41d..720b963881914498e31db02c335634781744dccf
@@@ -147,6 -147,7 +147,7 @@@ config X8
        select EDAC_ATOMIC_SCRUB
        select EDAC_SUPPORT
        select GENERIC_CLOCKEVENTS_BROADCAST    if X86_64 || (X86_32 && X86_LOCAL_APIC)
+       select GENERIC_CLOCKEVENTS_BROADCAST_IDLE       if GENERIC_CLOCKEVENTS_BROADCAST
        select GENERIC_CLOCKEVENTS_MIN_ADJUST
        select GENERIC_CMOS_UPDATE
        select GENERIC_CPU_AUTOPROBE
@@@ -496,6 -497,15 +497,15 @@@ config X86_CPU_RESCTR
  
          Say N if unsure.
  
+ config X86_FRED
+       bool "Flexible Return and Event Delivery"
+       depends on X86_64
+       help
+         When enabled, try to use Flexible Return and Event Delivery
+         instead of the legacy SYSCALL/SYSENTER/IDT architecture for
+         ring transitions and exception/interrupt handling if the
+         system supports.
  if X86_32
  config X86_BIGSMP
        bool "Support for big SMP systems with more than 8 CPUs"
@@@ -2101,11 -2111,11 +2111,11 @@@ config PHYSICAL_STAR
        help
          This gives the physical address where the kernel is loaded.
  
 -        If kernel is a not relocatable (CONFIG_RELOCATABLE=n) then
 -        bzImage will decompress itself to above physical address and
 -        run from there. Otherwise, bzImage will run from the address where
 -        it has been loaded by the boot loader and will ignore above physical
 -        address.
 +        If the kernel is not relocatable (CONFIG_RELOCATABLE=n) then bzImage
 +        will decompress itself to above physical address and run from there.
 +        Otherwise, bzImage will run from the address where it has been loaded
 +        by the boot loader. The only exception is if it is loaded below the
 +        above physical address, in which case it will relocate itself there.
  
          In normal kdump cases one does not have to set/change this option
          as now bzImage can be compiled as a completely relocatable image
@@@ -2421,6 -2431,18 +2431,18 @@@ source "kernel/livepatch/Kconfig
  
  endmenu
  
+ config CC_HAS_NAMED_AS
+       def_bool CC_IS_GCC && GCC_VERSION >= 120100
+ config USE_X86_SEG_SUPPORT
+       def_bool y
+       depends on CC_HAS_NAMED_AS
+       #
+       # -fsanitize=kernel-address (KASAN) is at the moment incompatible
+       # with named address spaces - see GCC PR sanitizer/111736.
+       #
+       depends on !KASAN
  config CC_HAS_SLS
        def_bool $(cc-option,-mharden-sls=all)
  
@@@ -2452,12 -2474,12 +2474,12 @@@ config CALL_PADDIN
  
  config FINEIBT
        def_bool y
-       depends on X86_KERNEL_IBT && CFI_CLANG && RETPOLINE
+       depends on X86_KERNEL_IBT && CFI_CLANG && MITIGATION_RETPOLINE
        select CALL_PADDING
  
  config HAVE_CALL_THUNKS
        def_bool y
-       depends on CC_HAS_ENTRY_PADDING && RETHUNK && OBJTOOL
+       depends on CC_HAS_ENTRY_PADDING && MITIGATION_RETHUNK && OBJTOOL
  
  config CALL_THUNKS
        def_bool n
@@@ -2479,7 -2501,7 +2501,7 @@@ menuconfig SPECULATION_MITIGATION
  
  if SPECULATION_MITIGATIONS
  
- config PAGE_TABLE_ISOLATION
+ config MITIGATION_PAGE_TABLE_ISOLATION
        bool "Remove the kernel mapping in user mode"
        default y
        depends on (X86_64 || X86_PAE)
  
          See Documentation/arch/x86/pti.rst for more details.
  
- config RETPOLINE
+ config MITIGATION_RETPOLINE
        bool "Avoid speculative indirect branches in kernel"
        select OBJTOOL if HAVE_OBJTOOL
        default y
          branches. Requires a compiler with -mindirect-branch=thunk-extern
          support for full protection. The kernel may run slower.
  
- config RETHUNK
+ config MITIGATION_RETHUNK
        bool "Enable return-thunks"
-       depends on RETPOLINE && CC_HAS_RETURN_THUNK
+       depends on MITIGATION_RETPOLINE && CC_HAS_RETURN_THUNK
        select OBJTOOL if HAVE_OBJTOOL
        default y if X86_64
        help
          Requires a compiler with -mfunction-return=thunk-extern
          support for full protection. The kernel may run slower.
  
- config CPU_UNRET_ENTRY
+ config MITIGATION_UNRET_ENTRY
        bool "Enable UNRET on kernel entry"
-       depends on CPU_SUP_AMD && RETHUNK && X86_64
+       depends on CPU_SUP_AMD && MITIGATION_RETHUNK && X86_64
        default y
        help
          Compile the kernel with support for the retbleed=unret mitigation.
  
- config CALL_DEPTH_TRACKING
+ config MITIGATION_CALL_DEPTH_TRACKING
        bool "Mitigate RSB underflow with call depth tracking"
        depends on CPU_SUP_INTEL && HAVE_CALL_THUNKS
        select HAVE_DYNAMIC_FTRACE_NO_PATCHABLE
  
  config CALL_THUNKS_DEBUG
        bool "Enable call thunks and call depth tracking debugging"
-       depends on CALL_DEPTH_TRACKING
+       depends on MITIGATION_CALL_DEPTH_TRACKING
        select FUNCTION_ALIGNMENT_32B
        default n
        help
          Only enable this when you are debugging call thunks as this
          creates a noticeable runtime overhead. If unsure say N.
  
- config CPU_IBPB_ENTRY
+ config MITIGATION_IBPB_ENTRY
        bool "Enable IBPB on kernel entry"
        depends on CPU_SUP_AMD && X86_64
        default y
        help
          Compile the kernel with support for the retbleed=ibpb mitigation.
  
- config CPU_IBRS_ENTRY
+ config MITIGATION_IBRS_ENTRY
        bool "Enable IBRS on kernel entry"
        depends on CPU_SUP_INTEL && X86_64
        default y
          This mitigates both spectre_v2 and retbleed at great cost to
          performance.
  
- config CPU_SRSO
+ config MITIGATION_SRSO
        bool "Mitigate speculative RAS overflow on AMD"
-       depends on CPU_SUP_AMD && X86_64 && RETHUNK
+       depends on CPU_SUP_AMD && X86_64 && MITIGATION_RETHUNK
        default y
        help
          Enable the SRSO mitigation needed on AMD Zen1-4 machines.
  
- config SLS
+ config MITIGATION_SLS
        bool "Mitigate Straight-Line-Speculation"
        depends on CC_HAS_SLS && X86_64
        select OBJTOOL if HAVE_OBJTOOL
          against straight line speculation. The kernel image might be slightly
          larger.
  
- config GDS_FORCE_MITIGATION
+ config MITIGATION_GDS_FORCE
        bool "Force GDS Mitigation"
        depends on CPU_SUP_INTEL
        default n
index 4a029baa5147748e19cd3699e9a6d67778396b29,ff09ca6dbb87eeda39878ad8badb875e74a07934..909f2a35b60c5da423868732ee9b2c3aa2e45ccd
@@@ -8,8 -8,8 +8,8 @@@
   * Copyright (C)      2016  Kees Cook
   */
  
- /* No PAGE_TABLE_ISOLATION support needed either: */
- #undef CONFIG_PAGE_TABLE_ISOLATION
+ /* No MITIGATION_PAGE_TABLE_ISOLATION support needed either: */
+ #undef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
  
  #include "error.h"
  #include "misc.h"
@@@ -389,5 -389,5 +389,5 @@@ void do_boot_page_fault(struct pt_regs 
  
  void do_boot_nmi_trap(struct pt_regs *regs, unsigned long error_code)
  {
 -      /* Empty handler to ignore NMI during early boot */
 +      spurious_nmi_count++;
  }
index bea0719d70f2d2ea08e4e2a4e80d9c684481a2cf,97561eabfbef12f3324d411150dbb2af3c73897a..ec71846d28c9ed1230fc910954974aca73e51fcf
@@@ -12,6 -12,7 +12,7 @@@
   */
  #include "misc.h"
  
+ #include <asm/bootparam.h>
  #include <asm/pgtable_types.h>
  #include <asm/sev.h>
  #include <asm/trapnr.h>
@@@ -116,9 -117,6 +117,9 @@@ static bool fault_in_kernel_space(unsig
  #undef __init
  #define __init
  
 +#undef __head
 +#define __head
 +
  #define __BOOT_COMPRESSED
  
  /* Basic instruction decoding support needed */
@@@ -372,7 -370,7 +373,7 @@@ static void enforce_vmpl0(void
                                 MSR_AMD64_SNP_VMPL_SSS |               \
                                 MSR_AMD64_SNP_SECURE_TSC |             \
                                 MSR_AMD64_SNP_VMGEXIT_PARAM |          \
-                                MSR_AMD64_SNP_VMSA_REG_PROTECTION |    \
+                                MSR_AMD64_SNP_VMSA_REG_PROT |          \
                                 MSR_AMD64_SNP_RESERVED_BIT13 |         \
                                 MSR_AMD64_SNP_RESERVED_BIT15 |         \
                                 MSR_AMD64_SNP_RESERVED_MASK)
index 52c0150179907f8b506ed9f9230301bdae31d2bc,ec95fe44fa3a03a1708bc0d8474595258db6027f..62dc9f59ea768c2022cd4673d5b0e74d2c3d4ce6
@@@ -46,7 -46,6 +46,7 @@@ struct gdt_page 
  } __attribute__((aligned(PAGE_SIZE)));
  
  DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
 +DECLARE_INIT_PER_CPU(gdt_page);
  
  /* Provide the original GDT */
  static inline struct desc_struct *get_cpu_gdt_rw(unsigned int cpu)
@@@ -403,8 -402,6 +403,6 @@@ static inline void set_desc_limit(struc
        desc->limit1 = (limit >> 16) & 0xf;
  }
  
- void alloc_intr_gate(unsigned int n, const void *addr);
  static inline void init_idt_data(struct idt_data *data, unsigned int n,
                                 const void *addr)
  {
index cf671138feef489a5e0ce2e0b98f131da70cabe9,10f9f1b259c322848641dbcba83a770b9275dd4c..9477b4053bce2ccb9d6c1c0113fd6ee44bd34d50
@@@ -13,7 -13,6 +13,6 @@@
  
  #include <asm/insn.h>
  #include <asm/sev-common.h>
- #include <asm/bootparam.h>
  #include <asm/coco.h>
  
  #define GHCB_PROTOCOL_MIN     1ULL
@@@ -22,6 -21,8 +21,8 @@@
  
  #define       VMGEXIT()                       { asm volatile("rep; vmmcall\n\r"); }
  
+ struct boot_params;
  enum es_result {
        ES_OK,                  /* All good */
        ES_UNSUPPORTED,         /* Requested operation not supported */
@@@ -213,21 -214,22 +214,22 @@@ static inline int pvalidate(unsigned lo
  struct snp_guest_request_ioctl;
  
  void setup_ghcb(void);
 -void __init early_snp_set_memory_private(unsigned long vaddr, unsigned long paddr,
 -                                       unsigned long npages);
 -void __init early_snp_set_memory_shared(unsigned long vaddr, unsigned long paddr,
 -                                      unsigned long npages);
 +void early_snp_set_memory_private(unsigned long vaddr, unsigned long paddr,
 +                                unsigned long npages);
 +void early_snp_set_memory_shared(unsigned long vaddr, unsigned long paddr,
 +                               unsigned long npages);
  void __init snp_prep_memory(unsigned long paddr, unsigned int sz, enum psc_op op);
  void snp_set_memory_shared(unsigned long vaddr, unsigned long npages);
  void snp_set_memory_private(unsigned long vaddr, unsigned long npages);
  void snp_set_wakeup_secondary_cpu(void);
  bool snp_init(struct boot_params *bp);
 -void __init __noreturn snp_abort(void);
 +void __noreturn snp_abort(void);
  int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, struct snp_guest_request_ioctl *rio);
  void snp_accept_memory(phys_addr_t start, phys_addr_t end);
  u64 snp_get_unsupported_features(u64 status);
  u64 sev_get_status(void);
  void kdump_sev_callback(void);
+ void sev_show_status(void);
  #else
  static inline void sev_es_ist_enter(struct pt_regs *regs) { }
  static inline void sev_es_ist_exit(void) { }
@@@ -257,6 -259,7 +259,7 @@@ static inline void snp_accept_memory(ph
  static inline u64 snp_get_unsupported_features(u64 status) { return 0; }
  static inline u64 sev_get_status(void) { return 0; }
  static inline void kdump_sev_callback(void) { }
+ static inline void sev_show_status(void) { }
  #endif
  
  #ifdef CONFIG_KVM_AMD_SEV
index eeea058cf6028ec15cd7a0524b1eca7824775e4f,4a38e7917756fa29b479c3b58eb19259a5b0eaf3..9b82eebd7add55e918d50a1e3a47e5300f29c222
@@@ -2,21 -2,7 +2,7 @@@
  #ifndef _ASM_X86_BOOTPARAM_H
  #define _ASM_X86_BOOTPARAM_H
  
- /* setup_data/setup_indirect types */
- #define SETUP_NONE                    0
- #define SETUP_E820_EXT                        1
- #define SETUP_DTB                     2
- #define SETUP_PCI                     3
- #define SETUP_EFI                     4
- #define SETUP_APPLE_PROPERTIES                5
- #define SETUP_JAILHOUSE                       6
- #define SETUP_CC_BLOB                 7
- #define SETUP_IMA                     8
- #define SETUP_RNG_SEED                        9
- #define SETUP_ENUM_MAX                        SETUP_RNG_SEED
- #define SETUP_INDIRECT                        (1<<31)
- #define SETUP_TYPE_MAX                        (SETUP_ENUM_MAX | SETUP_INDIRECT)
+ #include <asm/setup_data.h>
  
  /* ram_size flags */
  #define RAMDISK_IMAGE_START_MASK      0x07FF
@@@ -38,7 -24,6 +24,7 @@@
  #define XLF_EFI_KEXEC                 (1<<4)
  #define XLF_5LEVEL                    (1<<5)
  #define XLF_5LEVEL_ENABLED            (1<<6)
 +#define XLF_MEM_ENCRYPTION            (1<<7)
  
  #ifndef __ASSEMBLY__
  
  #include <asm/ist.h>
  #include <video/edid.h>
  
- /* extensible setup data list node */
- struct setup_data {
-       __u64 next;
-       __u32 type;
-       __u32 len;
-       __u8 data[];
- };
- /* extensible setup indirect data node */
- struct setup_indirect {
-       __u32 type;
-       __u32 reserved;  /* Reserved, must be set to zero. */
-       __u64 len;
-       __u64 addr;
- };
  struct setup_header {
        __u8    setup_sects;
        __u16   root_flags;
@@@ -137,51 -106,11 +107,11 @@@ struct efi_info 
   */
  #define E820_MAX_ENTRIES_ZEROPAGE 128
  
- /*
-  * The E820 memory region entry of the boot protocol ABI:
-  */
- struct boot_e820_entry {
-       __u64 addr;
-       __u64 size;
-       __u32 type;
- } __attribute__((packed));
  /*
   * Smallest compatible version of jailhouse_setup_data required by this kernel.
   */
  #define JAILHOUSE_SETUP_REQUIRED_VERSION      1
  
- /*
-  * The boot loader is passing platform information via this Jailhouse-specific
-  * setup data structure.
-  */
- struct jailhouse_setup_data {
-       struct {
-               __u16   version;
-               __u16   compatible_version;
-       } __attribute__((packed)) hdr;
-       struct {
-               __u16   pm_timer_address;
-               __u16   num_cpus;
-               __u64   pci_mmconfig_base;
-               __u32   tsc_khz;
-               __u32   apic_khz;
-               __u8    standard_ioapic;
-               __u8    cpu_ids[255];
-       } __attribute__((packed)) v1;
-       struct {
-               __u32   flags;
-       } __attribute__((packed)) v2;
- } __attribute__((packed));
- /*
-  * IMA buffer setup data information from the previous kernel during kexec
-  */
- struct ima_setup_data {
-       __u64 addr;
-       __u64 size;
- } __attribute__((packed));
  /* The so-called "zeropage" */
  struct boot_params {
        struct screen_info screen_info;                 /* 0x000 */
index 79f7c342e3da0a4f35c87eb3a1b92238cd25822f,3dbd05f938599381b4bdffc3e7696916ee78571d..d8198fbd70e54ea9da8355614b7b05963acb6cdf
@@@ -26,6 -26,7 +26,7 @@@
  #include <asm/apicdef.h>
  #include <asm/fixmap.h>
  #include <asm/smp.h>
+ #include <asm/thread_info.h>
  
  /*
   * We are not able to switch in one step to the final KERNEL ADDRESS SPACE
@@@ -39,6 -40,7 +40,6 @@@ L4_START_KERNEL = l4_index(__START_KERN
  
  L3_START_KERNEL = pud_index(__START_KERNEL_map)
  
 -      .text
        __HEAD
        .code64
  SYM_CODE_START_NOALIGN(startup_64)
        mov     %rsi, %r15
  
        /* Set up the stack for verify_cpu() */
-       leaq    (__end_init_task - PTREGS_SIZE)(%rip), %rsp
+       leaq    (__end_init_task - TOP_OF_KERNEL_STACK_PADDING - PTREGS_SIZE)(%rip), %rsp
  
 -      leaq    _text(%rip), %rdi
 -
        /* Setup GSBASE to allow stack canary access for C code */
        movl    $MSR_GS_BASE, %ecx
        leaq    INIT_PER_CPU_VAR(fixed_percpu_data)(%rip), %rdx
@@@ -74,7 -78,7 +75,7 @@@
        shrq    $32,  %rdx
        wrmsr
  
 -      call    startup_64_setup_env
 +      call    startup_64_setup_gdt_idt
  
        /* Now switch to __KERNEL_CS so IRET works reliably */
        pushq   $__KERNEL_CS
        call    __startup_64
  
        /* Form the CR3 value being sure to include the CR3 modifier */
 -      addq    $(early_top_pgt - __START_KERNEL_map), %rax
 +      leaq    early_top_pgt(%rip), %rcx
 +      addq    %rcx, %rax
  
  #ifdef CONFIG_AMD_MEM_ENCRYPT
        mov     %rax, %rdi
 -      mov     %rax, %r14
 -
 -      addq    phys_base(%rip), %rdi
  
        /*
         * For SEV guests: Verify that the C-bit is correct. A malicious
         * the next RET instruction.
         */
        call    sev_verify_cbit
 +#endif
  
        /*
 -       * Restore CR3 value without the phys_base which will be added
 -       * below, before writing %cr3.
 +       * Switch to early_top_pgt which still has the identity mappings
 +       * present.
         */
 -       mov    %r14, %rax
 -#endif
 +      movq    %rax, %cr3
  
 -      jmp 1f
 +      /* Branch to the common startup code at its kernel virtual address */
 +      ANNOTATE_RETPOLINE_SAFE
 +      jmp     *0f(%rip)
  SYM_CODE_END(startup_64)
  
 +      __INITRODATA
 +0:    .quad   common_startup_64
 +
 +      .text
  SYM_CODE_START(secondary_startup_64)
        UNWIND_HINT_END_OF_STACK
        ANNOTATE_NOENDBR
@@@ -172,39 -172,22 +173,39 @@@ SYM_INNER_LABEL(secondary_startup_64_no
        ANNOTATE_NOENDBR
  
        /* Clear %R15 which holds the boot_params pointer on the boot CPU */
 -      xorq    %r15, %r15
 +      xorl    %r15d, %r15d
 +
 +      /* Derive the runtime physical address of init_top_pgt[] */
 +      movq    phys_base(%rip), %rax
 +      addq    $(init_top_pgt - __START_KERNEL_map), %rax
  
        /*
         * Retrieve the modifier (SME encryption mask if SME is active) to be
         * added to the initial pgdir entry that will be programmed into CR3.
         */
  #ifdef CONFIG_AMD_MEM_ENCRYPT
 -      movq    sme_me_mask, %rax
 -#else
 -      xorq    %rax, %rax
 +      addq    sme_me_mask(%rip), %rax
  #endif
 +      /*
 +       * Switch to the init_top_pgt here, away from the trampoline_pgd and
 +       * unmap the identity mapped ranges.
 +       */
 +      movq    %rax, %cr3
  
 -      /* Form the CR3 value being sure to include the CR3 modifier */
 -      addq    $(init_top_pgt - __START_KERNEL_map), %rax
 -1:
 +SYM_INNER_LABEL(common_startup_64, SYM_L_LOCAL)
 +      UNWIND_HINT_END_OF_STACK
 +      ANNOTATE_NOENDBR
  
 +      /*
 +       * Create a mask of CR4 bits to preserve. Omit PGE in order to flush
 +       * global 1:1 translations from the TLBs.
 +       *
 +       * From the SDM:
 +       * "If CR4.PGE is changing from 0 to 1, there were no global TLB
 +       *  entries before the execution; if CR4.PGE is changing from 1 to 0,
 +       *  there will be no global TLB entries after the execution."
 +       */
 +      movl    $(X86_CR4_PAE | X86_CR4_LA57), %edx
  #ifdef CONFIG_X86_MCE
        /*
         * Preserve CR4.MCE if the kernel will enable #MC support.
         * configured will crash the system regardless of the CR4.MCE value set
         * here.
         */
 -      movq    %cr4, %rcx
 -      andl    $X86_CR4_MCE, %ecx
 -#else
 -      movl    $0, %ecx
 +      orl     $X86_CR4_MCE, %edx
  #endif
 +      movq    %cr4, %rcx
 +      andl    %edx, %ecx
  
 -      /* Enable PAE mode, PSE, PGE and LA57 */
 -      orl     $(X86_CR4_PAE | X86_CR4_PSE | X86_CR4_PGE), %ecx
 -#ifdef CONFIG_X86_5LEVEL
 -      testb   $1, __pgtable_l5_enabled(%rip)
 -      jz      1f
 -      orl     $X86_CR4_LA57, %ecx
 -1:
 -#endif
 +      /* Even if ignored in long mode, set PSE uniformly on all logical CPUs. */
 +      btsl    $X86_CR4_PSE_BIT, %ecx
        movq    %rcx, %cr4
  
 -      /* Setup early boot stage 4-/5-level pagetables. */
 -      addq    phys_base(%rip), %rax
 -
        /*
 -       * Switch to new page-table
 -       *
 -       * For the boot CPU this switches to early_top_pgt which still has the
 -       * identity mappings present. The secondary CPUs will switch to the
 -       * init_top_pgt here, away from the trampoline_pgd and unmap the
 -       * identity mapped ranges.
 -       */
 -      movq    %rax, %cr3
 -
 -      /*
 -       * Do a global TLB flush after the CR3 switch to make sure the TLB
 -       * entries from the identity mapping are flushed.
 +       * Set CR4.PGE to re-enable global translations.
         */
 -      movq    %cr4, %rcx
 -      movq    %rcx, %rax
 -      xorq    $X86_CR4_PGE, %rcx
 +      btsl    $X86_CR4_PGE_BIT, %ecx
        movq    %rcx, %cr4
 -      movq    %rax, %cr4
 -
 -      /* Ensure I am executing from virtual addresses */
 -      movq    $1f, %rax
 -      ANNOTATE_RETPOLINE_SAFE
 -      jmp     *%rax
 -1:
 -      UNWIND_HINT_END_OF_STACK
 -      ANNOTATE_NOENDBR // above
  
  #ifdef CONFIG_SMP
        /*
  
  .Llookup_AP:
        /* EAX contains the APIC ID of the current CPU */
 -      xorq    %rcx, %rcx
 +      xorl    %ecx, %ecx
        leaq    cpuid_to_apicid(%rip), %rbx
  
  .Lfind_cpunr:
        movq    %r15, %rdi
  
  .Ljump_to_C_code:
 -      /*
 -       * Jump to run C code and to be on a real kernel address.
 -       * Since we are running on identity-mapped space we have to jump
 -       * to the full 64bit address, this is only possible as indirect
 -       * jump.  In addition we need to ensure %cs is set so we make this
 -       * a far return.
 -       *
 -       * Note: do not change to far jump indirect with 64bit offset.
 -       *
 -       * AMD does not support far jump indirect with 64bit offset.
 -       * AMD64 Architecture Programmer's Manual, Volume 3: states only
 -       *      JMP FAR mem16:16 FF /5 Far jump indirect,
 -       *              with the target specified by a far pointer in memory.
 -       *      JMP FAR mem16:32 FF /5 Far jump indirect,
 -       *              with the target specified by a far pointer in memory.
 -       *
 -       * Intel64 does support 64bit offset.
 -       * Software Developer Manual Vol 2: states:
 -       *      FF /5 JMP m16:16 Jump far, absolute indirect,
 -       *              address given in m16:16
 -       *      FF /5 JMP m16:32 Jump far, absolute indirect,
 -       *              address given in m16:32.
 -       *      REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
 -       *              address given in m16:64.
 -       */
 -      pushq   $.Lafter_lret   # put return address on stack for unwinder
        xorl    %ebp, %ebp      # clear frame pointer
 -      movq    initial_code(%rip), %rax
 -      pushq   $__KERNEL_CS    # set correct cs
 -      pushq   %rax            # target address in negative space
 -      lretq
 -.Lafter_lret:
 -      ANNOTATE_NOENDBR
 +      ANNOTATE_RETPOLINE_SAFE
 +      callq   *initial_code(%rip)
 +      ud2
  SYM_CODE_END(secondary_startup_64)
  
  #include "verify_cpu.S"
@@@ -434,7 -478,7 +435,7 @@@ SYM_CODE_START(soft_restart_cpu
        UNWIND_HINT_END_OF_STACK
  
        /* Find the idle task stack */
-       movq    PER_CPU_VAR(pcpu_hot) + X86_current_task, %rcx
+       movq    PER_CPU_VAR(pcpu_hot + X86_current_task), %rcx
        movq    TASK_threadsp(%rcx), %rsp
  
        jmp     .Ljump_to_C_code
@@@ -579,7 -623,7 +580,7 @@@ SYM_CODE_END(vc_no_ghcb
  #define SYM_DATA_START_PAGE_ALIGNED(name)                     \
        SYM_START(name, SYM_L_GLOBAL, .balign PAGE_SIZE)
  
- #ifdef CONFIG_PAGE_TABLE_ISOLATION
+ #ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
  /*
   * Each PGD needs to be 8k long and 8k aligned.  We do not
   * ever go out to userspace with these, so we do not
        .balign 4
  
  SYM_DATA_START_PTI_ALIGNED(early_top_pgt)
 -      .fill   512,8,0
 +      .fill   511,8,0
 +      .quad   level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC
        .fill   PTI_USER_PGD_FILL,8,0
  SYM_DATA_END(early_top_pgt)
  
index 0bd7ccbe87324a3851e913be4c4fd4631f979c26,a200bd72fadc555c1f8468cece4dec569f629b6e..8b04958da5e7d6c4bd096cffdaa4874e73433846
@@@ -9,6 -9,8 +9,8 @@@
   * and is included directly into both code-bases.
   */
  
+ #include <asm/setup_data.h>
  #ifndef __BOOT_COMPRESSED
  #define error(v)                      pr_err(v)
  #define has_cpuflag(f)                        boot_cpu_has(f)
@@@ -93,8 -95,7 +95,8 @@@ static bool __init sev_es_check_cpu_fea
        return true;
  }
  
 -static void __noreturn sev_es_terminate(unsigned int set, unsigned int reason)
 +static void __head __noreturn
 +sev_es_terminate(unsigned int set, unsigned int reason)
  {
        u64 val = GHCB_MSR_TERM_REQ;
  
@@@ -331,7 -332,13 +333,7 @@@ static int sev_cpuid_hv(struct ghcb *gh
   */
  static const struct snp_cpuid_table *snp_cpuid_get_table(void)
  {
 -      void *ptr;
 -
 -      asm ("lea cpuid_table_copy(%%rip), %0"
 -           : "=r" (ptr)
 -           : "p" (&cpuid_table_copy));
 -
 -      return ptr;
 +      return &RIP_REL_REF(cpuid_table_copy);
  }
  
  /*
@@@ -390,7 -397,7 +392,7 @@@ static u32 snp_cpuid_calc_xsave_size(u6
        return xsave_size;
  }
  
 -static bool
 +static bool __head
  snp_cpuid_get_validated_func(struct cpuid_leaf *leaf)
  {
        const struct snp_cpuid_table *cpuid_table = snp_cpuid_get_table();
@@@ -527,8 -534,7 +529,8 @@@ static int snp_cpuid_postprocess(struc
   * Returns -EOPNOTSUPP if feature not enabled. Any other non-zero return value
   * should be treated as fatal by caller.
   */
 -static int snp_cpuid(struct ghcb *ghcb, struct es_em_ctxt *ctxt, struct cpuid_leaf *leaf)
 +static int __head
 +snp_cpuid(struct ghcb *ghcb, struct es_em_ctxt *ctxt, struct cpuid_leaf *leaf)
  {
        const struct snp_cpuid_table *cpuid_table = snp_cpuid_get_table();
  
   * page yet, so it only supports the MSR based communication with the
   * hypervisor and only the CPUID exit-code.
   */
 -void __init do_vc_no_ghcb(struct pt_regs *regs, unsigned long exit_code)
 +void __head do_vc_no_ghcb(struct pt_regs *regs, unsigned long exit_code)
  {
        unsigned int subfn = lower_bits(regs->cx, 32);
        unsigned int fn = lower_bits(regs->ax, 32);
@@@ -1021,8 -1027,7 +1023,8 @@@ struct cc_setup_data 
   * Search for a Confidential Computing blob passed in as a setup_data entry
   * via the Linux Boot Protocol.
   */
 -static struct cc_blob_sev_info *find_cc_blob_setup_data(struct boot_params *bp)
 +static __head
 +struct cc_blob_sev_info *find_cc_blob_setup_data(struct boot_params *bp)
  {
        struct cc_setup_data *sd = NULL;
        struct setup_data *hdr;
   * mapping needs to be updated in sync with all the changes to virtual memory
   * layout and related mapping facilities throughout the boot process.
   */
 -static void __init setup_cpuid_table(const struct cc_blob_sev_info *cc_info)
 +static void __head setup_cpuid_table(const struct cc_blob_sev_info *cc_info)
  {
        const struct snp_cpuid_table *cpuid_table_fw, *cpuid_table;
        int i;
diff --combined arch/x86/kernel/sev.c
index 33c14aa1f06c9c2be22feb1e238cceef410238d4,7d242898852f5ea0c5d76fcb9b926274ae29c009..b59b09c2f28406fc286066a2517eb178f36ad6ae
@@@ -25,7 -25,6 +25,7 @@@
  #include <linux/psp-sev.h>
  #include <uapi/linux/sev-guest.h>
  
 +#include <asm/init.h>
  #include <asm/cpu_entry_area.h>
  #include <asm/stacktrace.h>
  #include <asm/sev.h>
  #define AP_INIT_CR0_DEFAULT           0x60000010
  #define AP_INIT_MXCSR_DEFAULT         0x1f80
  
+ static const char * const sev_status_feat_names[] = {
+       [MSR_AMD64_SEV_ENABLED_BIT]             = "SEV",
+       [MSR_AMD64_SEV_ES_ENABLED_BIT]          = "SEV-ES",
+       [MSR_AMD64_SEV_SNP_ENABLED_BIT]         = "SEV-SNP",
+       [MSR_AMD64_SNP_VTOM_BIT]                = "vTom",
+       [MSR_AMD64_SNP_REFLECT_VC_BIT]          = "ReflectVC",
+       [MSR_AMD64_SNP_RESTRICTED_INJ_BIT]      = "RI",
+       [MSR_AMD64_SNP_ALT_INJ_BIT]             = "AI",
+       [MSR_AMD64_SNP_DEBUG_SWAP_BIT]          = "DebugSwap",
+       [MSR_AMD64_SNP_PREVENT_HOST_IBS_BIT]    = "NoHostIBS",
+       [MSR_AMD64_SNP_BTB_ISOLATION_BIT]       = "BTBIsol",
+       [MSR_AMD64_SNP_VMPL_SSS_BIT]            = "VmplSSS",
+       [MSR_AMD64_SNP_SECURE_TSC_BIT]          = "SecureTSC",
+       [MSR_AMD64_SNP_VMGEXIT_PARAM_BIT]       = "VMGExitParam",
+       [MSR_AMD64_SNP_IBS_VIRT_BIT]            = "IBSVirt",
+       [MSR_AMD64_SNP_VMSA_REG_PROT_BIT]       = "VMSARegProt",
+       [MSR_AMD64_SNP_SMT_PROT_BIT]            = "SMTProt",
+ };
  /* For early boot hypervisor communication in SEV-ES enabled guests */
  static struct ghcb boot_ghcb_page __bss_decrypted __aligned(PAGE_SIZE);
  
@@@ -683,9 -701,8 +702,9 @@@ static u64 __init get_jump_table_addr(v
        return ret;
  }
  
 -static void early_set_pages_state(unsigned long vaddr, unsigned long paddr,
 -                                unsigned long npages, enum psc_op op)
 +static void __head
 +early_set_pages_state(unsigned long vaddr, unsigned long paddr,
 +                    unsigned long npages, enum psc_op op)
  {
        unsigned long paddr_end;
        u64 val;
@@@ -741,7 -758,7 +760,7 @@@ e_term
        sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_PSC);
  }
  
 -void __init early_snp_set_memory_private(unsigned long vaddr, unsigned long paddr,
 +void __head early_snp_set_memory_private(unsigned long vaddr, unsigned long paddr,
                                         unsigned long npages)
  {
        /*
@@@ -2064,7 -2081,7 +2083,7 @@@ fail
   *
   * Scan for the blob in that order.
   */
 -static __init struct cc_blob_sev_info *find_cc_blob(struct boot_params *bp)
 +static __head struct cc_blob_sev_info *find_cc_blob(struct boot_params *bp)
  {
        struct cc_blob_sev_info *cc_info;
  
@@@ -2090,7 -2107,7 +2109,7 @@@ found_cc_info
        return cc_info;
  }
  
 -bool __init snp_init(struct boot_params *bp)
 +bool __head snp_init(struct boot_params *bp)
  {
        struct cc_blob_sev_info *cc_info;
  
        return true;
  }
  
 -void __init __noreturn snp_abort(void)
 +void __head __noreturn snp_abort(void)
  {
        sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SNP_UNSUPPORTED);
  }
@@@ -2277,3 -2294,19 +2296,19 @@@ void kdump_sev_callback(void
        if (cpu_feature_enabled(X86_FEATURE_SEV_SNP))
                wbinvd();
  }
+ void sev_show_status(void)
+ {
+       int i;
+       pr_info("Status: ");
+       for (i = 0; i < MSR_AMD64_SNP_RESV_BIT; i++) {
+               if (sev_status & BIT_ULL(i)) {
+                       if (!sev_status_feat_names[i])
+                               continue;
+                       pr_cont("%s ", sev_status_feat_names[i]);
+               }
+       }
+       pr_cont("\n");
+ }
diff --combined arch/x86/lib/Makefile
index f0dae4fb6d071627842fae7321e0eaea10cf558f,72cc9c90e9f307fa0ec2d9f225c4b43548c041bc..6da73513f02668ab5c178b3f5a01668691b79403
@@@ -14,6 -14,19 +14,6 @@@ ifdef CONFIG_KCSA
  CFLAGS_REMOVE_delay.o = $(CC_FLAGS_FTRACE)
  endif
  
 -# Early boot use of cmdline; don't instrument it
 -ifdef CONFIG_AMD_MEM_ENCRYPT
 -KCOV_INSTRUMENT_cmdline.o := n
 -KASAN_SANITIZE_cmdline.o  := n
 -KCSAN_SANITIZE_cmdline.o  := n
 -
 -ifdef CONFIG_FUNCTION_TRACER
 -CFLAGS_REMOVE_cmdline.o = -pg
 -endif
 -
 -CFLAGS_cmdline.o := -fno-stack-protector -fno-jump-tables
 -endif
 -
  inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
  inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
  quiet_cmd_inat_tables = GEN     $@
@@@ -36,7 -49,7 +36,7 @@@ lib-$(CONFIG_ARCH_HAS_COPY_MC) += copy_
  lib-$(CONFIG_INSTRUCTION_DECODER) += insn.o inat.o insn-eval.o
  lib-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
  lib-$(CONFIG_FUNCTION_ERROR_INJECTION)        += error-inject.o
- lib-$(CONFIG_RETPOLINE) += retpoline.o
+ lib-$(CONFIG_MITIGATION_RETPOLINE) += retpoline.o
  
  obj-y += msr.o msr-reg.o msr-reg-export.o hweight.o
  obj-y += iomem.o
This page took 0.110858 seconds and 4 git commands to generate.