Print this page


Split Close
Expand all
Collapse all
          --- old/usr/src/uts/i86pc/ml/syscall_asm_amd64.s
          +++ new/usr/src/uts/i86pc/ml/syscall_asm_amd64.s
↓ open down ↓ 20 lines elided ↑ open up ↑
  21   21  /*
  22   22   * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright 2016 Joyent, Inc.
  24   24   */
  25   25  
  26   26  #include <sys/asm_linkage.h>
  27   27  #include <sys/asm_misc.h>
  28   28  #include <sys/regset.h>
  29   29  #include <sys/privregs.h>
  30   30  #include <sys/psw.h>
  31      -#include <sys/machbrand.h>
  32   31  
  33   32  #if defined(__lint)
  34   33  
  35   34  #include <sys/types.h>
  36   35  #include <sys/thread.h>
  37   36  #include <sys/systm.h>
  38   37  
  39   38  #else   /* __lint */
  40   39  
       40 +#include <sys/machbrand.h>
  41   41  #include <sys/segments.h>
  42   42  #include <sys/pcb.h>
  43   43  #include <sys/trap.h>
  44   44  #include <sys/ftrace.h>
  45   45  #include <sys/traptrace.h>
  46   46  #include <sys/clock.h>
  47   47  #include <sys/model.h>
  48   48  #include <sys/panic.h>
  49   49  
  50   50  #if defined(__xpv)
↓ open down ↓ 473 lines elided ↑ open up ↑
 524  524          movq    LWP_BRAND_SYSCALL(%r14), %rdi
 525  525          testq   %rdi, %rdi
 526  526          jz      _syscall_no_brand
 527  527  
 528  528          pushq   %rax
 529  529          subq    $8, %rsp        /* align stack for call to C */
 530  530          call    *%rdi
 531  531          addq    $8, %rsp
 532  532  
 533  533          /*
 534      -         * If the alternate handler returns non-zero, the normal system call
 535      -         * processing is resumed.
      534 +         * If the alternate handler returns 0, we skip straight to the return to
      535 +         * usermode.  Otherwise, we resume regular system call processing.
 536  536           */
 537  537          testl   %eax, %eax
 538  538          popq    %rax
 539      -        jnz     _syscall_no_brand
      539 +        jz      _syscall_after_brand
 540  540  
 541      -        /*
 542      -         * For branded syscalls which were handled in-kernel, shuffle the
 543      -         * register state as would be done by the native handler before jumping
 544      -         * to the post-syscall logic.
 545      -         */
 546      -        movq    REGOFF_RAX(%rsp), %r12
 547      -        movq    REGOFF_RDX(%rsp), %r13
 548      -        jmp     _syscall_after_brand
 549      -
 550  541  _syscall_no_brand:
 551  542          movw    %ax, T_SYSNUM(%r15)
 552  543          movzbl  T_PRE_SYS(%r15), %ebx
 553  544          ORL_SYSCALLTRACE(%ebx)
 554  545          testl   %ebx, %ebx
 555  546          jne     _syscall_pre
 556  547  
 557  548  _syscall_invoke:
 558  549          movq    REGOFF_RDI(%rbp), %rdi
 559  550          movq    REGOFF_RSI(%rbp), %rsi
↓ open down ↓ 273 lines elided ↑ open up ↑
 833  824           * of the regular system call path.
 834  825           */
 835  826          movq    LWP_BRAND_SYSCALL(%r14), %rax
 836  827          testq   %rax, %rax
 837  828          jz      _syscall32_no_brand
 838  829  
 839  830          movb    $LWP_SYS, LWP_STATE(%r14)
 840  831          call    *%rax
 841  832  
 842  833          /*
 843      -         * If the alternate handler returns non-zero, the normal system call
 844      -         * processing is resumed.
      834 +         * If the alternate handler returns 0, we skip straight to the return
      835 +         * to usermode.  Otherwise, we resume regular system call processing.
 845  836           */
 846  837          testl   %eax, %eax
 847      -        jnz     _syscall32_no_brand
      838 +        jz      _syscall32_after_brand
 848  839  
 849      -        /*
 850      -         * For branded syscalls which were handled in-kernel, shuffle the
 851      -         * register state as would be done by the native handler before jumping
 852      -         * to the post-syscall logic.
 853      -         */
 854      -        movl    REGOFF_RAX(%rsp), %r12d
 855      -        movl    REGOFF_RDX(%rsp), %r13d
 856      -        jmp     _syscall32_after_brand
 857      -
 858  840  _syscall32_no_brand:
 859  841          /*
 860  842           * Make some space for MAXSYSARGS (currently 8) 32-bit args placed
 861  843           * into 64-bit (long) arg slots, maintaining 16 byte alignment.  Or
 862  844           * more succinctly:
 863  845           *
 864  846           *      SA(MAXSYSARGS * sizeof (long)) == 64
 865  847           *
 866  848           * Note, this space is used both to copy in the arguments from user
 867  849           * land, but also to as part of the old UNIX style syscall_ap() method.
↓ open down ↓ 380 lines elided ↑ open up ↑
1248 1230   */
1249 1231  void
1250 1232  sys_int80()
1251 1233  {}
1252 1234  
1253 1235  #else   /* __lint */
1254 1236  
1255 1237          ENTRY_NP(brand_sys_int80)
1256 1238          SWAPGS                          /* kernel gsbase */
1257 1239          XPV_TRAP_POP
1258      -        call    smap_enable
1259 1240  
1260 1241          /*
1261 1242           * We first attempt to call the "b_int80" handler from the "struct
1262 1243           * brand_mach_ops" for this brand.  If no handler function is installed
1263 1244           * for this brand, the BRAND_CALLBACK() macro returns here and we
1264 1245           * check the lwp for a "lwp_brand_syscall" handler.
1265 1246           */
1266 1247          BRAND_CALLBACK(BRAND_CB_INT80, BRAND_URET_FROM_INTR_STACK())
1267 1248  
1268 1249          /*
↓ open down ↓ 18 lines elided ↑ open up ↑
1287 1268          ENTRY_NP(sys_int80)
1288 1269          /*
1289 1270           * We hit an int80, but this process isn't of a brand with an int80
1290 1271           * handler.  Bad process!  Make it look as if the INT failed.
1291 1272           * Modify %rip to point before the INT, push the expected error
1292 1273           * code and fake a GP fault. Note on 64-bit hypervisor we need
1293 1274           * to undo the XPV_TRAP_POP and push rcx and r11 back on the stack
1294 1275           * because gptrap will pop them again with its own XPV_TRAP_POP.
1295 1276           */
1296 1277          XPV_TRAP_POP
1297      -        call    smap_enable
1298 1278  nopop_int80:
1299 1279          subq    $2, (%rsp)      /* int insn 2-bytes */
1300 1280          pushq   $_CONST(_MUL(T_INT80, GATE_DESC_SIZE) + 2)
1301 1281  #if defined(__xpv)
1302 1282          push    %r11
1303 1283          push    %rcx
1304 1284  #endif
1305 1285          jmp     gptrap                  / GP fault
1306 1286          SET_SIZE(sys_int80)
1307 1287          SET_SIZE(brand_sys_int80)
↓ open down ↓ 151 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX