Merge tag 'x86_core_for_v5.19_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 24 May 2022 01:42:07 +0000 (18:42 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 24 May 2022 01:42:07 +0000 (18:42 -0700)
Pull core x86 updates from Borislav Petkov:

 - Remove all the code around GS switching on 32-bit now that it is not
   needed anymore

 - Other misc improvements

* tag 'x86_core_for_v5.19_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  bug: Use normal relative pointers in 'struct bug_entry'
  x86/nmi: Make register_nmi_handler() more robust
  x86/asm: Merge load_gs_index()
  x86/32: Remove lazy GS macros
  ELF: Remove elf_core_copy_kernel_regs()
  x86/32: Simplify ELF_CORE_COPY_REGS

1  2 
arch/x86/include/asm/bug.h
arch/x86/kernel/process.c
arch/x86/kernel/process_32.c

index aaf0cb0db4aecfebc103498e1f2f8106f5b52733,76fbe24cccf9de0066a900676007f367fd676827..a3ec87d198ac8398309e2962b5bcc59eeb074692
@@@ -18,7 -18,7 +18,7 @@@
  #ifdef CONFIG_X86_32
  # define __BUG_REL(val)       ".long " __stringify(val)
  #else
- # define __BUG_REL(val)       ".long " __stringify(val) " - 2b"
+ # define __BUG_REL(val)       ".long " __stringify(val) " - ."
  #endif
  
  #ifdef CONFIG_DEBUG_BUGVERBOSE
@@@ -78,9 -78,9 +78,9 @@@ do {                                                          
   */
  #define __WARN_FLAGS(flags)                                   \
  do {                                                          \
 -      __auto_type f = BUGFLAG_WARNING|(flags);                \
 +      __auto_type __flags = BUGFLAG_WARNING|(flags);          \
        instrumentation_begin();                                \
 -      _BUG_FLAGS(ASM_UD2, f, ASM_REACHABLE);                  \
 +      _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE);            \
        instrumentation_end();                                  \
  } while (0)
  
index d5275ecb1e92a3b17feef9e109b7104a988301ff,96a9885b9c3ad53b91e888f6f0d9c14e88122634..cbe6aa3f649d8415cded6748a1eb8a45b4d730e5
@@@ -46,7 -46,6 +46,7 @@@
  #include <asm/proto.h>
  #include <asm/frame.h>
  #include <asm/unwind.h>
 +#include <asm/tdx.h>
  
  #include "process.h"
  
@@@ -161,6 -160,7 +161,7 @@@ int copy_thread(unsigned long clone_fla
        savesegment(ds, p->thread.ds);
  #else
        p->thread.sp0 = (unsigned long) (childregs + 1);
+       savesegment(gs, p->thread.gs);
        /*
         * Clear all status flags including IF and set fixed bit. 64bit
         * does not have this initialization as the frame does not contain
        if (sp)
                childregs->sp = sp;
  
- #ifdef CONFIG_X86_32
-       task_user_gs(p) = get_user_gs(current_pt_regs());
- #endif
        if (unlikely(p->flags & PF_IO_WORKER)) {
                /*
                 * An IO thread is a user space thread, but it doesn't
@@@ -335,7 -331,7 +332,7 @@@ static int get_cpuid_mode(void
        return !test_thread_flag(TIF_NOCPUID);
  }
  
 -static int set_cpuid_mode(struct task_struct *task, unsigned long cpuid_enabled)
 +static int set_cpuid_mode(unsigned long cpuid_enabled)
  {
        if (!boot_cpu_has(X86_FEATURE_CPUID_FAULT))
                return -ENODEV;
@@@ -406,7 -402,7 +403,7 @@@ static void tss_copy_io_bitmap(struct t
  }
  
  /**
 - * tss_update_io_bitmap - Update I/O bitmap before exiting to usermode
 + * native_tss_update_io_bitmap - Update I/O bitmap before exiting to user mode
   */
  void native_tss_update_io_bitmap(void)
  {
@@@ -874,9 -870,6 +871,9 @@@ void select_idle_routine(const struct c
        } else if (prefer_mwait_c1_over_halt(c)) {
                pr_info("using mwait in idle threads\n");
                x86_idle = mwait_idle;
 +      } else if (cpu_feature_enabled(X86_FEATURE_TDX_GUEST)) {
 +              pr_info("using TDX aware idle routine\n");
 +              x86_idle = tdx_safe_halt;
        } else
                x86_idle = default_idle;
  }
@@@ -989,19 -982,20 +986,19 @@@ unsigned long __get_wchan(struct task_s
        return addr;
  }
  
 -long do_arch_prctl_common(struct task_struct *task, int option,
 -                        unsigned long arg2)
 +long do_arch_prctl_common(int option, unsigned long arg2)
  {
        switch (option) {
        case ARCH_GET_CPUID:
                return get_cpuid_mode();
        case ARCH_SET_CPUID:
 -              return set_cpuid_mode(task, arg2);
 +              return set_cpuid_mode(arg2);
        case ARCH_GET_XCOMP_SUPP:
        case ARCH_GET_XCOMP_PERM:
        case ARCH_REQ_XCOMP_PERM:
        case ARCH_GET_XCOMP_GUEST_PERM:
        case ARCH_REQ_XCOMP_GUEST_PERM:
 -              return fpu_xstate_prctl(task, option, arg2);
 +              return fpu_xstate_prctl(option, arg2);
        }
  
        return -EINVAL;
index 0faa5e28dd64eb713a6d99a113e91e205cd2729e,877358f3dba70b405522abb1701cd5ae4ac53c52..2f314b170c9f0737d6ee673ed380d894a6978911
@@@ -63,10 -63,7 +63,7 @@@ void __show_regs(struct pt_regs *regs, 
        unsigned long d0, d1, d2, d3, d6, d7;
        unsigned short gs;
  
-       if (user_mode(regs))
-               gs = get_user_gs(regs);
-       else
-               savesegment(gs, gs);
+       savesegment(gs, gs);
  
        show_ip(regs, log_lvl);
  
@@@ -114,7 -111,7 +111,7 @@@ void release_thread(struct task_struct 
  void
  start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp)
  {
-       set_user_gs(regs, 0);
+       loadsegment(gs, 0);
        regs->fs                = 0;
        regs->ds                = __USER_DS;
        regs->es                = __USER_DS;
@@@ -177,7 -174,7 +174,7 @@@ __switch_to(struct task_struct *prev_p
         * used %fs or %gs (it does not today), or if the kernel is
         * running inside of a hypervisor layer.
         */
-       lazy_save_gs(prev->gs);
+       savesegment(gs, prev->gs);
  
        /*
         * Load the per-thread Thread-Local Storage descriptor.
         * Restore %gs if needed (which is common)
         */
        if (prev->gs | next->gs)
-               lazy_load_gs(next->gs);
+               loadsegment(gs, next->gs);
  
        this_cpu_write(current_task, next_p);
  
  
  SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
  {
 -      return do_arch_prctl_common(current, option, arg2);
 +      return do_arch_prctl_common(option, arg2);
  }