Print this page
13902 Fix for 13717 may break 8-disk raidz2
13915 installctx() blocking allocate causes problems
Portions contributed by: Jerry Jelinek <gjelinek@gmail.com>
Change-Id: I934d69946cec42630fc541fa8c7385b862b69ca2

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/ia32/os/sysi86.c
          +++ new/usr/src/uts/intel/ia32/os/sysi86.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  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   * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
  23      - * Copyright 2018 Joyent, Inc.
       23 + * Copyright 2021 Joyent, Inc.
  24   24   */
  25   25  
  26   26  /*      Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
  27   27  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T   */
  28      -/*        All Rights Reserved   */
       28 +/*        All Rights Reserved   */
  29   29  
  30   30  /*      Copyright (c) 1987, 1988 Microsoft Corporation  */
  31   31  /*        All Rights Reserved   */
  32   32  
  33   33  #include <sys/param.h>
  34   34  #include <sys/types.h>
  35   35  #include <sys/sysmacros.h>
  36   36  #include <sys/systm.h>
  37   37  #include <sys/signal.h>
  38   38  #include <sys/errno.h>
↓ open down ↓ 47 lines elided ↑ open up ↑
  86   86          proc_t *pp = curproc;
  87   87  
  88   88          switch (cmd) {
  89   89  
  90   90          /*
  91   91           * The SI86V86 subsystem call of the SYSI86 system call
  92   92           * supports only one subcode -- V86SC_IOPL.
  93   93           */
  94   94          case SI86V86:
  95   95                  if (arg1 == V86SC_IOPL) {
       96 +#if defined(__xpv)
       97 +                        struct ctxop *ctx;
       98 +#endif
  96   99                          struct regs *rp = lwptoregs(ttolwp(curthread));
  97  100                          greg_t oldpl = rp->r_ps & PS_IOPL;
  98  101                          greg_t newpl = arg2 & PS_IOPL;
  99  102  
 100  103                          /*
 101  104                           * Must be privileged to run this system call
 102  105                           * if giving more io privilege.
 103  106                           */
 104  107                          if (newpl > oldpl && (error =
 105  108                              secpolicy_sys_config(CRED(), B_FALSE)) != 0)
 106  109                                  return (set_errno(error));
 107  110  #if defined(__xpv)
      111 +                        ctx = installctx_preallocate();
 108  112                          kpreempt_disable();
 109  113                          installctx(curthread, NULL, xen_disable_user_iopl,
 110  114                              xen_enable_user_iopl, NULL, NULL,
 111      -                            xen_disable_user_iopl, NULL);
      115 +                            xen_disable_user_iopl, NULL, ctx);
 112  116                          xen_enable_user_iopl();
 113  117                          kpreempt_enable();
 114  118  #else
 115  119                          rp->r_ps ^= oldpl ^ newpl;
 116  120  #endif
 117  121                  } else
 118  122                          error = EINVAL;
 119  123                  break;
 120  124  
 121  125          /*
↓ open down ↓ 269 lines elided ↑ open up ↑
 391  395  {
 392  396          ASSERT(p->p_ldt != NULL);
 393  397          ASSERT(p == curproc);
 394  398  
 395  399  #if defined(__amd64)
 396  400          /*
 397  401           * The 64-bit kernel must be sure to clear any stale ldt
 398  402           * selectors when context switching away from a process that
 399  403           * has a private ldt. Consider the following example:
 400  404           *
 401      -         *      Wine creats a ldt descriptor and points a segment register
 402      -         *      to it.
      405 +         *      Wine creats a ldt descriptor and points a segment register
      406 +         *      to it.
 403  407           *
 404  408           *      We then context switch away from wine lwp to kernel
 405  409           *      thread and hit breakpoint in kernel with kmdb
 406  410           *
 407  411           *      When we continue and resume from kmdb we will #gp
 408      -         *      fault since kmdb will have saved the stale ldt selector
      412 +         *      fault since kmdb will have saved the stale ldt selector
 409  413           *      from wine and will try to restore it but we are no longer in
 410  414           *      the context of the wine process and do not have our
 411  415           *      ldtr register pointing to the private ldt.
 412  416           */
 413  417          reset_sregs();
 414  418  #endif
 415  419  
 416  420          ldt_unload();
 417  421          cpu_fast_syscall_enable();
 418  422  }
↓ open down ↓ 468 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX