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>


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.


  23  * Copyright (c) 2017 by Delphix. All rights reserved.
  24  */
  25 
  26 #include <sys/types.h>
  27 #include <sys/systm.h>
  28 #include <sys/cmn_err.h>
  29 #include <sys/cpuvar.h>
  30 #include <sys/thread.h>
  31 #include <sys/disp.h>
  32 #include <sys/kmem.h>
  33 #include <sys/debug.h>
  34 #include <sys/cpupart.h>
  35 #include <sys/pset.h>
  36 #include <sys/var.h>
  37 #include <sys/cyclic.h>
  38 #include <sys/lgrp.h>
  39 #include <sys/pghw.h>
  40 #include <sys/loadavg.h>
  41 #include <sys/class.h>
  42 #include <sys/fss.h>


 553                                  */
 554 
 555                                 if (!LGRP_CPUS_IN_PART(t->t_lpl->lpl_lgrpid,
 556                                     t->t_cpupart)) {
 557                                         lgrp_move_thread(t,
 558                                             lgrp_choose(t, t->t_cpupart), 0);
 559                                 }
 560 
 561                                 /*
 562                                  * make sure lpl points to our own partition
 563                                  */
 564                                 ASSERT(t->t_lpl >= t->t_cpupart->cp_lgrploads &&
 565                                     (t->t_lpl < t->t_cpupart->cp_lgrploads +
 566                                     t->t_cpupart->cp_nlgrploads));
 567 
 568                                 ASSERT(t->t_lpl->lpl_ncpu > 0);
 569 
 570                                 /* Update CPU last ran on if it was this CPU */
 571                                 if (t->t_cpu == cp && t->t_cpupart == oldpp &&
 572                                     t->t_bound_cpu != cp) {
 573                                         t->t_cpu = disp_lowpri_cpu(ncp,
 574                                             t->t_lpl, t->t_pri, NULL);
 575                                 }
 576                                 t = t->t_forw;
 577                         } while (t != p->p_tlist);
 578 
 579                         /*
 580                          * Didn't find any threads in the same lgroup as this
 581                          * CPU with a different lpl, so remove the lgroup from
 582                          * the process lgroup bitmask.
 583                          */
 584 
 585                         if (lgrp_diff_lpl)
 586                                 klgrpset_del(p->p_lgrpset, lgrpid);
 587                 }
 588 
 589                 /*
 590                  * Walk thread list looking for threads that need to be
 591                  * rehomed, since there are some threads that are not in
 592                  * their process's p_tlist.
 593                  */
 594 


 606                          * since there may be an lgroup with more
 607                          * affinity available after moving CPUs
 608                          * around.
 609                          */
 610                         if (!LGRP_CPUS_IN_PART(t->t_lpl->lpl_lgrpid,
 611                             t->t_cpupart) || t->t_lgrp_affinity) {
 612                                 lgrp_move_thread(t,
 613                                     lgrp_choose(t, t->t_cpupart), 1);
 614                         }
 615 
 616                         /* make sure lpl points to our own partition */
 617                         ASSERT((t->t_lpl >= t->t_cpupart->cp_lgrploads) &&
 618                             (t->t_lpl < t->t_cpupart->cp_lgrploads +
 619                             t->t_cpupart->cp_nlgrploads));
 620 
 621                         ASSERT(t->t_lpl->lpl_ncpu > 0);
 622 
 623                         /* Update CPU last ran on if it was this CPU */
 624                         if (t->t_cpu == cp && t->t_cpupart == oldpp &&
 625                             t->t_bound_cpu != cp) {
 626                                 t->t_cpu = disp_lowpri_cpu(ncp, t->t_lpl,
 627                                     t->t_pri, NULL);
 628                         }
 629 
 630                         t = t->t_next;
 631                 } while (t != curthread);
 632 
 633                 /*
 634                  * Clear off the CPU's run queue, and the kp queue if the
 635                  * partition is now empty.
 636                  */
 637                 disp_cpu_inactive(cp);
 638 
 639                 /*
 640                  * Make cp switch to a thread from the new partition.
 641                  */
 642                 cp->cpu_runrun = 1;
 643                 cp->cpu_kprunrun = 1;
 644         }
 645 
 646         cpu_inmotion = NULL;
 647         start_cpus();




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
  23  *
  24  * Copyright 2018 Joyent, Inc.
  25  * Copyright (c) 2017 by Delphix. All rights reserved.
  26  */
  27 
  28 #include <sys/types.h>
  29 #include <sys/systm.h>
  30 #include <sys/cmn_err.h>
  31 #include <sys/cpuvar.h>
  32 #include <sys/thread.h>
  33 #include <sys/disp.h>
  34 #include <sys/kmem.h>
  35 #include <sys/debug.h>
  36 #include <sys/cpupart.h>
  37 #include <sys/pset.h>
  38 #include <sys/var.h>
  39 #include <sys/cyclic.h>
  40 #include <sys/lgrp.h>
  41 #include <sys/pghw.h>
  42 #include <sys/loadavg.h>
  43 #include <sys/class.h>
  44 #include <sys/fss.h>


 555                                  */
 556 
 557                                 if (!LGRP_CPUS_IN_PART(t->t_lpl->lpl_lgrpid,
 558                                     t->t_cpupart)) {
 559                                         lgrp_move_thread(t,
 560                                             lgrp_choose(t, t->t_cpupart), 0);
 561                                 }
 562 
 563                                 /*
 564                                  * make sure lpl points to our own partition
 565                                  */
 566                                 ASSERT(t->t_lpl >= t->t_cpupart->cp_lgrploads &&
 567                                     (t->t_lpl < t->t_cpupart->cp_lgrploads +
 568                                     t->t_cpupart->cp_nlgrploads));
 569 
 570                                 ASSERT(t->t_lpl->lpl_ncpu > 0);
 571 
 572                                 /* Update CPU last ran on if it was this CPU */
 573                                 if (t->t_cpu == cp && t->t_cpupart == oldpp &&
 574                                     t->t_bound_cpu != cp) {
 575                                         t->t_cpu = disp_lowpri_cpu(ncp, t,
 576                                             t->t_pri);
 577                                 }
 578                                 t = t->t_forw;
 579                         } while (t != p->p_tlist);
 580 
 581                         /*
 582                          * Didn't find any threads in the same lgroup as this
 583                          * CPU with a different lpl, so remove the lgroup from
 584                          * the process lgroup bitmask.
 585                          */
 586 
 587                         if (lgrp_diff_lpl)
 588                                 klgrpset_del(p->p_lgrpset, lgrpid);
 589                 }
 590 
 591                 /*
 592                  * Walk thread list looking for threads that need to be
 593                  * rehomed, since there are some threads that are not in
 594                  * their process's p_tlist.
 595                  */
 596 


 608                          * since there may be an lgroup with more
 609                          * affinity available after moving CPUs
 610                          * around.
 611                          */
 612                         if (!LGRP_CPUS_IN_PART(t->t_lpl->lpl_lgrpid,
 613                             t->t_cpupart) || t->t_lgrp_affinity) {
 614                                 lgrp_move_thread(t,
 615                                     lgrp_choose(t, t->t_cpupart), 1);
 616                         }
 617 
 618                         /* make sure lpl points to our own partition */
 619                         ASSERT((t->t_lpl >= t->t_cpupart->cp_lgrploads) &&
 620                             (t->t_lpl < t->t_cpupart->cp_lgrploads +
 621                             t->t_cpupart->cp_nlgrploads));
 622 
 623                         ASSERT(t->t_lpl->lpl_ncpu > 0);
 624 
 625                         /* Update CPU last ran on if it was this CPU */
 626                         if (t->t_cpu == cp && t->t_cpupart == oldpp &&
 627                             t->t_bound_cpu != cp) {
 628                                 t->t_cpu = disp_lowpri_cpu(ncp, t,
 629                                     t->t_pri);
 630                         }
 631 
 632                         t = t->t_next;
 633                 } while (t != curthread);
 634 
 635                 /*
 636                  * Clear off the CPU's run queue, and the kp queue if the
 637                  * partition is now empty.
 638                  */
 639                 disp_cpu_inactive(cp);
 640 
 641                 /*
 642                  * Make cp switch to a thread from the new partition.
 643                  */
 644                 cp->cpu_runrun = 1;
 645                 cp->cpu_kprunrun = 1;
 646         }
 647 
 648         cpu_inmotion = NULL;
 649         start_cpus();