Print this page
11787 Kernel needs to be built with retpolines
11788 Kernel needs to generally use RSB stuffing
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: John Levon <john.levon@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/i86pc/ml/md_clear.s
          +++ new/usr/src/uts/i86pc/ml/md_clear.s
↓ open down ↓ 34 lines elided ↑ open up ↑
  35   35   *
  36   36   *  o %cr3 is on the kernel-side and therefore we still have access to kernel
  37   37   *    text. In other words, we haven't switched back to the user page table.
  38   38   *
  39   39   *  o It is up to the caller to insure that a sufficient serializing instruction
  40   40   *    has been executed after this to make sure any pending speculations are
  41   41   *    captured. In general, this should be handled by the fact that callers of
  42   42   *    this are either going to change privilege levels or halt, which makes
  43   43   *    these operations safer.
  44   44   */
  45      -        ENTRY_NP(x86_md_clear_noop)
  46      -        ret
  47      -        SET_SIZE(x86_md_clear_noop)
  48   45  
  49   46          /*
  50      -         * This uses the microcode based means of flushing state. VERW will
  51      -         * clobber flags.
       47 +         * By default, x86_md_clear is disabled until the system determines that
       48 +         * it both needs MDS related mitigations and we have microcode that
       49 +         * provides the needed functionality.
       50 +         *
       51 +         * The VERW instruction clobbers flags which is why it's important that
       52 +         * we save and restore them here.
  52   53           */
  53      -        ENTRY_NP(x86_md_clear_verw)
       54 +        ENTRY_NP(x86_md_clear)
       55 +        ret
  54   56          pushfq
  55   57          subq    $8, %rsp
  56   58          mov     %ds, (%rsp)
  57   59          verw    (%rsp)
  58   60          addq    $8, %rsp
  59   61          popfq
  60   62          ret
  61      -        SET_SIZE(x86_md_clear_verw)
       63 +        SET_SIZE(x86_md_clear)
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX