Print this page
104 Bring back lx brand

@@ -626,10 +626,12 @@
 
 /*ARGSUSED*/
 static greg_t
 fix_segreg(greg_t sr, int iscs, model_t datamodel)
 {
+        kthread_t *t = curthread;
+
         switch (sr &= 0xffff) {
 
         case 0:
                 if (iscs == IS_CS)
                         return (0 | SEL_UPL);

@@ -661,10 +663,23 @@
                 return (sr);
         default:
                 break;
         }
 
+        /*
+         * Allow this process's brand to do any necessary segment register
+         * manipulation.
+         */
+        if (PROC_IS_BRANDED(t->t_procp) && BRMOP(t->t_procp)->b_fixsegreg) {
+                greg_t bsr = BRMOP(t->t_procp)->b_fixsegreg(sr, datamodel);
+
+                if (bsr == 0 && iscs == IS_CS)
+                        return (0 | SEL_UPL);
+                else
+                        return (bsr);
+        }
+
         /*
          * Force it into the LDT in ring 3 for 32-bit processes, which by
          * default do not have an LDT, so that any attempt to use an invalid
          * selector will reference the (non-existant) LDT, and cause a #gp
          * fault for the process.