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/intel/ia32/ml/hypersubr.s
          +++ new/usr/src/uts/intel/ia32/ml/hypersubr.s
↓ open down ↓ 16 lines elided ↑ open up ↑
  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 2009 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
       27 +/*
       28 + * Copyright 2019 Joyent, Inc.
       29 + */
       30 +
  27   31  #include <sys/asm_linkage.h>
  28   32  #ifndef __xpv
  29   33  #include <sys/xpv_support.h>
  30   34  #endif
  31   35  #include <sys/hypervisor.h>
  32   36  
  33   37  /*
  34   38   * Hypervisor "system calls"
  35   39   *
  36   40   * i386
  37      - *      %eax == call number
  38      - *      args in registers (%ebx, %ecx, %edx, %esi, %edi)
       41 + *      %eax == call number
       42 + *      args in registers (%ebx, %ecx, %edx, %esi, %edi)
  39   43   *
  40   44   * amd64
  41      - *      %rax == call number
  42      - *      args in registers (%rdi, %rsi, %rdx, %r10, %r8, %r9)
       45 + *      %rax == call number
       46 + *      args in registers (%rdi, %rsi, %rdx, %r10, %r8, %r9)
  43   47   *
  44   48   * Note that for amd64 we use %r10 instead of %rcx for passing 4th argument
  45   49   * as in C calling convention since the "syscall" instruction clobbers %rcx.
  46   50   *
  47   51   * (These calls can be done more efficiently as gcc-style inlines, but
  48   52   * for simplicity and help with initial debugging, we use these primitives
  49   53   * to build the hypervisor calls up from C wrappers.)
  50   54   */
  51   55  
  52   56  #if defined(__lint)
↓ open down ↓ 104 lines elided ↑ open up ↑
 157  161          .align  HYPERCALL_PAGESIZE
 158  162          .globl  hypercall_page
 159  163          .type   hypercall_page, @function
 160  164  hypercall_page:
 161  165          .skip   HYPERCALL_PAGESIZE
 162  166          .size   hypercall_page, HYPERCALL_PAGESIZE
 163  167  #if defined(__amd64)
 164  168  #define TRAP_INSTR                      \
 165  169          shll    $5, %eax;               \
 166  170          addq    $hypercall_page, %rax;  \
 167      -        jmp     *%rax
      171 +        INDIRECT_JMP_REG(rax);
 168  172  #else
 169  173  #define TRAP_INSTR                      \
 170  174          shll    $5, %eax;               \
 171  175          addl    $hypercall_page, %eax;  \
 172  176          call    *%eax
 173  177  #endif
 174  178  
 175  179  #else /* !_xpv */
 176  180  
 177  181  #if defined(__amd64)
 178  182  #define TRAP_INSTR      syscall
 179  183  #elif defined(__i386)
 180  184  #define TRAP_INSTR      int $0x82
 181  185  #endif
 182  186  #endif /* !__xpv */
 183  187  
 184  188  
 185      -#if defined(__amd64) 
      189 +#if defined(__amd64)
 186  190  
 187  191          ENTRY_NP(__hypercall0)
 188  192          ALTENTRY(__hypercall0_int)
 189  193          movl    %edi, %eax
 190  194          TRAP_INSTR
 191  195          ret
 192  196          SET_SIZE(__hypercall0)
 193  197  
 194  198          ENTRY_NP(__hypercall1)
 195  199          ALTENTRY(__hypercall1_int)
↓ open down ↓ 126 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX