Print this page
11859 need swapgs mitigation
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@fingolfin.org>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/kdi/kdi_asm.s
          +++ new/usr/src/uts/intel/kdi/kdi_asm.s
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   *
  26      - * Copyright 2018 Joyent, Inc.
       26 + * Copyright 2019 Joyent, Inc.
  27   27   */
  28   28  
  29   29  /*
  30   30   * Debugger entry and exit for both master and slave CPUs. kdi_idthdl.s contains
  31   31   * the IDT stubs that drop into here (mainly via kdi_cmnint).
  32   32   */
  33   33  
  34   34  #if defined(__lint)
  35   35  #include <sys/types.h>
  36   36  #else
↓ open down ↓ 227 lines elided ↑ open up ↑
 264  264  
 265  265  #if !defined(__xpv)
 266  266          /*
 267  267           * Switch to the kernel's GSBASE.  Neither GSBASE nor the ill-named
 268  268           * KGSBASE can be trusted, as the kernel may or may not have already
 269  269           * done a swapgs.  All is not lost, as the kernel can divine the correct
 270  270           * value for us.  Note that the previous GSBASE is saved in the
 271  271           * KDI_SAVE_REGS macro to prevent a usermode process's GSBASE from being
 272  272           * blown away.  On the hypervisor, we don't need to do this, since it's
 273  273           * ensured we're on our requested kernel GSBASE already.
      274 +         *
      275 +         * No need to worry about swapgs speculation here as it's unconditional
      276 +         * and via wrmsr anyway.
 274  277           */
 275  278          subq    $10, %rsp
 276  279          sgdt    (%rsp)
 277  280          movq    2(%rsp), %rdi   /* gdt base now in %rdi */
 278  281          addq    $10, %rsp
 279  282          call    kdi_gdt2gsbase  /* returns kernel's GSBASE in %rax */
 280  283  
 281  284          movq    %rax, %rdx
 282  285          shrq    $32, %rdx
 283  286          movl    $MSR_AMD_GSBASE, %ecx
↓ open down ↓ 433 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX