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

@@ -18,11 +18,11 @@
  *
  * CDDL HEADER END
  */
 /*
  * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2019 Joyent, Inc.
+ * Copyright 2021 Joyent, Inc.
  */
 
 /*      Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T   */
 /*      All Rights Reserved   */

@@ -761,11 +761,11 @@
         ASSERT(removectx(t, NULL, brand_interpositioning_disable,
             brand_interpositioning_enable, NULL, NULL,
             brand_interpositioning_disable, NULL) == 0);
         installctx(t, NULL, brand_interpositioning_disable,
             brand_interpositioning_enable, NULL, NULL,
-            brand_interpositioning_disable, NULL);
+            brand_interpositioning_disable, NULL, NULL);
 
         if (t == curthread) {
                 kpreempt_disable();
                 brand_interpositioning_enable();
                 kpreempt_enable();

@@ -827,10 +827,11 @@
         void (*restop)(klwp_t *) = lwp_getdatamodel(lwp) == DATAMODEL_NATIVE ?
             lwp_segregs_restore : lwp_segregs_restore32;
 #else
         void (*restop)(klwp_t *) = lwp_segregs_restore;
 #endif
+        struct ctxop *ctx;
 
         /*
          * Install the basic lwp context handlers on each lwp.
          *
          * On the amd64 kernel, the context handlers are responsible for

@@ -842,14 +843,18 @@
          * On the i386 kernel, the context handlers are responsible for
          * virtualizing %gs/%fs to the lwp by updating the per-cpu GDTs
          */
         ASSERT(removectx(t, lwp, lwp_segregs_save, restop,
             NULL, NULL, NULL, NULL) == 0);
-        if (thisthread)
+        if (thisthread) {
+                ctx = installctx_preallocate();
                 kpreempt_disable();
+        } else {
+                ctx = NULL;
+        }
         installctx(t, lwp, lwp_segregs_save, restop,
-            NULL, NULL, NULL, NULL);
+            NULL, NULL, NULL, NULL, ctx);
         if (thisthread) {
                 /*
                  * Since we're the right thread, set the values in the GDT
                  */
                 restop(lwp);

@@ -872,14 +877,18 @@
                     SA(sizeof (struct regs) + MINFRAME);
 #endif
                 ASSERT(removectx(t, kstktop,
                     sep_save, sep_restore, NULL, NULL, NULL, NULL) == 0);
 
-                if (thisthread)
+                if (thisthread) {
+                        ctx = installctx_preallocate();
                         kpreempt_disable();
+                } else {
+                        ctx = NULL;
+                }
                 installctx(t, kstktop,
-                    sep_save, sep_restore, NULL, NULL, NULL, NULL);
+                    sep_save, sep_restore, NULL, NULL, NULL, NULL, ctx);
                 if (thisthread) {
                         /*
                          * We're the right thread, so set the stack pointer
                          * for the first sysenter instruction to use
                          */