Print this page
10924 Need mitigation of L1TF (CVE-2018-3646)
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Peter Tribble <peter.tribble@gmail.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/disp/cpupart.c
          +++ new/usr/src/uts/common/disp/cpupart.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) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
       23 + *
       24 + * Copyright 2018 Joyent, Inc.
  23   25   * Copyright (c) 2017 by Delphix. All rights reserved.
  24   26   */
  25   27  
  26   28  #include <sys/types.h>
  27   29  #include <sys/systm.h>
  28   30  #include <sys/cmn_err.h>
  29   31  #include <sys/cpuvar.h>
  30   32  #include <sys/thread.h>
  31   33  #include <sys/disp.h>
  32   34  #include <sys/kmem.h>
↓ open down ↓ 285 lines elided ↑ open up ↑
 318  320  
 319  321  
 320  322  static int
 321  323  cpupart_move_cpu(cpu_t *cp, cpupart_t *newpp, int forced)
 322  324  {
 323  325          cpupart_t *oldpp;
 324  326          cpu_t   *ncp, *newlist;
 325  327          kthread_t *t;
 326  328          int     move_threads = 1;
 327  329          lgrp_id_t lgrpid;
 328      -        proc_t  *p;
      330 +        proc_t  *p;
 329  331          int lgrp_diff_lpl;
 330  332          lpl_t   *cpu_lpl;
 331  333          int     ret;
 332  334          boolean_t unbind_all_threads = (forced != 0);
 333  335  
 334  336          ASSERT(MUTEX_HELD(&cpu_lock));
 335  337          ASSERT(newpp != NULL);
 336  338  
 337  339          oldpp = cp->cpu_part;
 338  340          ASSERT(oldpp != NULL);
↓ open down ↓ 224 lines elided ↑ open up ↑
 563  565                                   */
 564  566                                  ASSERT(t->t_lpl >= t->t_cpupart->cp_lgrploads &&
 565  567                                      (t->t_lpl < t->t_cpupart->cp_lgrploads +
 566  568                                      t->t_cpupart->cp_nlgrploads));
 567  569  
 568  570                                  ASSERT(t->t_lpl->lpl_ncpu > 0);
 569  571  
 570  572                                  /* Update CPU last ran on if it was this CPU */
 571  573                                  if (t->t_cpu == cp && t->t_cpupart == oldpp &&
 572  574                                      t->t_bound_cpu != cp) {
 573      -                                        t->t_cpu = disp_lowpri_cpu(ncp,
 574      -                                            t->t_lpl, t->t_pri, NULL);
      575 +                                        t->t_cpu = disp_lowpri_cpu(ncp, t,
      576 +                                            t->t_pri);
 575  577                                  }
 576  578                                  t = t->t_forw;
 577  579                          } while (t != p->p_tlist);
 578  580  
 579  581                          /*
 580  582                           * Didn't find any threads in the same lgroup as this
 581  583                           * CPU with a different lpl, so remove the lgroup from
 582  584                           * the process lgroup bitmask.
 583  585                           */
 584  586  
↓ open down ↓ 31 lines elided ↑ open up ↑
 616  618                          /* make sure lpl points to our own partition */
 617  619                          ASSERT((t->t_lpl >= t->t_cpupart->cp_lgrploads) &&
 618  620                              (t->t_lpl < t->t_cpupart->cp_lgrploads +
 619  621                              t->t_cpupart->cp_nlgrploads));
 620  622  
 621  623                          ASSERT(t->t_lpl->lpl_ncpu > 0);
 622  624  
 623  625                          /* Update CPU last ran on if it was this CPU */
 624  626                          if (t->t_cpu == cp && t->t_cpupart == oldpp &&
 625  627                              t->t_bound_cpu != cp) {
 626      -                                t->t_cpu = disp_lowpri_cpu(ncp, t->t_lpl,
 627      -                                    t->t_pri, NULL);
      628 +                                t->t_cpu = disp_lowpri_cpu(ncp, t,
      629 +                                    t->t_pri);
 628  630                          }
 629  631  
 630  632                          t = t->t_next;
 631  633                  } while (t != curthread);
 632  634  
 633  635                  /*
 634  636                   * Clear off the CPU's run queue, and the kp queue if the
 635  637                   * partition is now empty.
 636  638                   */
 637  639                  disp_cpu_inactive(cp);
↓ open down ↓ 234 lines elided ↑ open up ↑
 872  874          return (0);
 873  875  }
 874  876  
 875  877  /*
 876  878   * Move threads from specified partition to cp_default. If `force' is specified,
 877  879   * move all threads, otherwise move only soft-bound threads.
 878  880   */
 879  881  static int
 880  882  cpupart_unbind_threads(cpupart_t *pp, boolean_t unbind_all)
 881  883  {
 882      -        void    *projbuf, *zonebuf;
      884 +        void    *projbuf, *zonebuf;
 883  885          kthread_t *t;
 884  886          proc_t  *p;
 885  887          int     err = 0;
 886  888          psetid_t psid = pp->cp_id;
 887  889  
 888  890          ASSERT(pool_lock_held());
 889  891          ASSERT(MUTEX_HELD(&cpu_lock));
 890  892  
 891  893          if (pp == NULL || pp == &cp_default) {
 892  894                  return (EINVAL);
↓ open down ↓ 335 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX