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/sundep.c
          +++ new/usr/src/uts/intel/ia32/os/sundep.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 2019 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   28  /*      All Rights Reserved   */
  29   29  
  30   30  #include <sys/types.h>
  31   31  #include <sys/param.h>
  32   32  #include <sys/sysmacros.h>
  33   33  #include <sys/signal.h>
↓ open down ↓ 722 lines elided ↑ open up ↑
 756  756  {
 757  757          kthread_t *t = lwptot(lwp);
 758  758  
 759  759          ASSERT(PROC_IS_BRANDED(lwptoproc(lwp)));
 760  760  
 761  761          ASSERT(removectx(t, NULL, brand_interpositioning_disable,
 762  762              brand_interpositioning_enable, NULL, NULL,
 763  763              brand_interpositioning_disable, NULL) == 0);
 764  764          installctx(t, NULL, brand_interpositioning_disable,
 765  765              brand_interpositioning_enable, NULL, NULL,
 766      -            brand_interpositioning_disable, NULL);
      766 +            brand_interpositioning_disable, NULL, NULL);
 767  767  
 768  768          if (t == curthread) {
 769  769                  kpreempt_disable();
 770  770                  brand_interpositioning_enable();
 771  771                  kpreempt_enable();
 772  772          }
 773  773  }
 774  774  
 775  775  /*
 776  776   * If this is a process in a branded zone, then we want it to disable the
↓ open down ↓ 45 lines elided ↑ open up ↑
 822  822  lwp_installctx(klwp_t *lwp)
 823  823  {
 824  824          kthread_t *t = lwptot(lwp);
 825  825          int thisthread = t == curthread;
 826  826  #ifdef _SYSCALL32_IMPL
 827  827          void (*restop)(klwp_t *) = lwp_getdatamodel(lwp) == DATAMODEL_NATIVE ?
 828  828              lwp_segregs_restore : lwp_segregs_restore32;
 829  829  #else
 830  830          void (*restop)(klwp_t *) = lwp_segregs_restore;
 831  831  #endif
      832 +        struct ctxop *ctx;
 832  833  
 833  834          /*
 834  835           * Install the basic lwp context handlers on each lwp.
 835  836           *
 836  837           * On the amd64 kernel, the context handlers are responsible for
 837  838           * virtualizing %ds, %es, %fs, and %gs to the lwp.  The register
 838  839           * values are only ever changed via sys_rtt when the
 839  840           * PCB_UPDATE_SEGS bit (1) is set in pcb->pcb_rupdate. Only
 840  841           * sys_rtt gets to clear the bit.
 841  842           *
 842  843           * On the i386 kernel, the context handlers are responsible for
 843  844           * virtualizing %gs/%fs to the lwp by updating the per-cpu GDTs
 844  845           */
 845  846          ASSERT(removectx(t, lwp, lwp_segregs_save, restop,
 846  847              NULL, NULL, NULL, NULL) == 0);
 847      -        if (thisthread)
      848 +        if (thisthread) {
      849 +                ctx = installctx_preallocate();
 848  850                  kpreempt_disable();
      851 +        } else {
      852 +                ctx = NULL;
      853 +        }
 849  854          installctx(t, lwp, lwp_segregs_save, restop,
 850      -            NULL, NULL, NULL, NULL);
      855 +            NULL, NULL, NULL, NULL, ctx);
 851  856          if (thisthread) {
 852  857                  /*
 853  858                   * Since we're the right thread, set the values in the GDT
 854  859                   */
 855  860                  restop(lwp);
 856  861                  kpreempt_enable();
 857  862          }
 858  863  
 859  864          /*
 860  865           * If we have sysenter/sysexit instructions enabled, we need
↓ open down ↓ 6 lines elided ↑ open up ↑
 867  872          if (is_x86_feature(x86_featureset, X86FSET_SEP)) {
 868  873  #if defined(__amd64)
 869  874                  caddr_t kstktop = (caddr_t)lwp->lwp_regs;
 870  875  #elif defined(__i386)
 871  876                  caddr_t kstktop = ((caddr_t)lwp->lwp_regs - MINFRAME) +
 872  877                      SA(sizeof (struct regs) + MINFRAME);
 873  878  #endif
 874  879                  ASSERT(removectx(t, kstktop,
 875  880                      sep_save, sep_restore, NULL, NULL, NULL, NULL) == 0);
 876  881  
 877      -                if (thisthread)
      882 +                if (thisthread) {
      883 +                        ctx = installctx_preallocate();
 878  884                          kpreempt_disable();
      885 +                } else {
      886 +                        ctx = NULL;
      887 +                }
 879  888                  installctx(t, kstktop,
 880      -                    sep_save, sep_restore, NULL, NULL, NULL, NULL);
      889 +                    sep_save, sep_restore, NULL, NULL, NULL, NULL, ctx);
 881  890                  if (thisthread) {
 882  891                          /*
 883  892                           * We're the right thread, so set the stack pointer
 884  893                           * for the first sysenter instruction to use
 885  894                           */
 886  895                          sep_restore(kstktop);
 887  896                          kpreempt_enable();
 888  897                  }
 889  898          }
 890  899  
↓ open down ↓ 148 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX