Print this page
9685 KPTI %cr3 handling needs fixes

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/i86pc/ml/kpti_trampolines.s
          +++ new/usr/src/uts/i86pc/ml/kpti_trampolines.s
↓ open down ↓ 243 lines elided ↑ open up ↑
 244  244  #define INTERRUPT_TRAMPOLINE_NOERR              \
 245  245          INTERRUPT_TRAMPOLINE_P(/**/)
 246  246  
 247  247  #define INTERRUPT_TRAMPOLINE                    \
 248  248          INTERRUPT_TRAMPOLINE_P(pushq KPTI_ERR(%r13))
 249  249  
 250  250  /*
 251  251   * This is used for all interrupts that can plausibly be taken inside another
 252  252   * interrupt and are using a kpti_frame stack (so #BP, #DB, #GP, #PF, #SS).
 253  253   *
      254 + * We also use this for #NP, even though it uses the standard IST: the
      255 + * additional %rsp checks below will catch when we get an exception doing an
      256 + * iret to userspace with a bad %cs/%ss.  This appears as a kernel trap, and
      257 + * only later gets redirected via kern_gpfault().
      258 + *
 254  259   * We check for whether we took the interrupt while in another trampoline, in
 255  260   * which case we need to use the kthread stack.
 256  261   */
 257  262  #define DBG_INTERRUPT_TRAMPOLINE_P(errpush)     \
 258  263          pushq   %r13;                           \
 259  264          pushq   %r14;                           \
 260  265          subq    $KPTI_R14, %rsp;                \
 261  266          /* Check for clobbering */              \
 262  267          cmp     $0, KPTI_FLAG(%rsp);            \
 263  268          je      1f;                             \
↓ open down ↓ 378 lines elided ↑ open up ↑
 642  647  
 643  648  
 644  649          MK_INTR_TRAMPOLINE_NOERR(div0trap)
 645  650          MK_DBG_INTR_TRAMPOLINE_NOERR(dbgtrap)
 646  651          MK_DBG_INTR_TRAMPOLINE_NOERR(brktrap)
 647  652          MK_INTR_TRAMPOLINE_NOERR(ovflotrap)
 648  653          MK_INTR_TRAMPOLINE_NOERR(boundstrap)
 649  654          MK_INTR_TRAMPOLINE_NOERR(invoptrap)
 650  655          MK_INTR_TRAMPOLINE_NOERR(ndptrap)
 651  656          MK_INTR_TRAMPOLINE(invtsstrap)
 652      -        MK_INTR_TRAMPOLINE(segnptrap)
      657 +        MK_DBG_INTR_TRAMPOLINE(segnptrap)
 653  658          MK_DBG_INTR_TRAMPOLINE(stktrap)
 654  659          MK_DBG_INTR_TRAMPOLINE(gptrap)
 655  660          MK_DBG_INTR_TRAMPOLINE(pftrap)
 656  661          MK_INTR_TRAMPOLINE_NOERR(resvtrap)
 657  662          MK_INTR_TRAMPOLINE_NOERR(ndperr)
 658  663          MK_INTR_TRAMPOLINE(achktrap)
 659  664          MK_INTR_TRAMPOLINE_NOERR(xmtrap)
 660  665          MK_INTR_TRAMPOLINE_NOERR(invaltrap)
 661  666          MK_INTR_TRAMPOLINE_NOERR(fasttrap)
 662  667          MK_INTR_TRAMPOLINE_NOERR(dtrace_ret)
↓ open down ↓ 145 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX