Print this page
OS-7125 Need mitigation of L1TF (CVE-2018-3646)
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>


   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 /*
  23  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2012 by Delphix. All rights reserved.
  25  * Copyright 2014 Igor Kozhukhov <ikozhukhov@gmail.com>.

  26  * Copyright 2017 RackTop Systems.
  27  */
  28 
  29 #ifndef _SYS_CPUVAR_H
  30 #define _SYS_CPUVAR_H
  31 
  32 #include <sys/thread.h>
  33 #include <sys/sysinfo.h>  /* has cpu_stat_t definition */
  34 #include <sys/disp.h>
  35 #include <sys/processor.h>
  36 #include <sys/kcpc.h>             /* has kcpc_ctx_t definition */
  37 
  38 #include <sys/loadavg.h>
  39 #if (defined(_KERNEL) || defined(_KMEMUSER)) && defined(_MACHDEP)
  40 #include <sys/machcpuvar.h>
  41 #endif
  42 
  43 #include <sys/types.h>
  44 #include <sys/file.h>
  45 #include <sys/bitmap.h>


 555 extern cpu_t            *cpu_list;      /* list of CPUs */
 556 extern cpu_t            *cpu_active;    /* list of active CPUs */
 557 extern int              ncpus;          /* number of CPUs present */
 558 extern int              ncpus_online;   /* number of CPUs not quiesced */
 559 extern int              max_ncpus;      /* max present before ncpus is known */
 560 extern int              boot_max_ncpus; /* like max_ncpus but for real */
 561 extern int              boot_ncpus;     /* # cpus present @ boot */
 562 extern processorid_t    max_cpuid;      /* maximum CPU number */
 563 extern struct cpu       *cpu_inmotion;  /* offline or partition move target */
 564 extern cpu_t            *clock_cpu_list;
 565 extern processorid_t    max_cpu_seqid_ever;     /* maximum seqid ever given */
 566 
 567 #if defined(__i386) || defined(__amd64)
 568 extern struct cpu *curcpup(void);
 569 #define CPU             (curcpup())     /* Pointer to current CPU */
 570 #else
 571 #define CPU             (curthread->t_cpu)   /* Pointer to current CPU */
 572 #endif
 573 
 574 /*
 575  * CPU_CURRENT indicates to thread_affinity_set to use CPU->cpu_id
 576  * as the target and to grab cpu_lock instead of requiring the caller
 577  * to grab it.
 578  */
 579 #define CPU_CURRENT     -3
 580 
 581 /*







 582  * Per-CPU statistics
 583  *
 584  * cpu_stats_t contains numerous system and VM-related statistics, in the form
 585  * of gauges or monotonically-increasing event occurrence counts.
 586  */
 587 
 588 #define CPU_STATS_ENTER_K()     kpreempt_disable()
 589 #define CPU_STATS_EXIT_K()      kpreempt_enable()
 590 
 591 #define CPU_STATS_ADD_K(class, stat, amount) \
 592         {       kpreempt_disable(); /* keep from switching CPUs */\
 593                 CPU_STATS_ADDQ(CPU, class, stat, amount); \
 594                 kpreempt_enable(); \
 595         }
 596 
 597 #define CPU_STATS_ADDQ(cp, class, stat, amount) {                       \
 598         extern void __dtrace_probe___cpu_##class##info_##stat(uint_t,   \
 599             uint64_t *, cpu_t *);                                       \
 600         uint64_t *stataddr = &((cp)->cpu_stats.class.stat);              \
 601         __dtrace_probe___cpu_##class##info_##stat((amount),             \




   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 /*
  23  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2012 by Delphix. All rights reserved.
  25  * Copyright 2014 Igor Kozhukhov <ikozhukhov@gmail.com>.
  26  * Copyright 2018 Joyent, Inc.
  27  * Copyright 2017 RackTop Systems.
  28  */
  29 
  30 #ifndef _SYS_CPUVAR_H
  31 #define _SYS_CPUVAR_H
  32 
  33 #include <sys/thread.h>
  34 #include <sys/sysinfo.h>  /* has cpu_stat_t definition */
  35 #include <sys/disp.h>
  36 #include <sys/processor.h>
  37 #include <sys/kcpc.h>             /* has kcpc_ctx_t definition */
  38 
  39 #include <sys/loadavg.h>
  40 #if (defined(_KERNEL) || defined(_KMEMUSER)) && defined(_MACHDEP)
  41 #include <sys/machcpuvar.h>
  42 #endif
  43 
  44 #include <sys/types.h>
  45 #include <sys/file.h>
  46 #include <sys/bitmap.h>


 556 extern cpu_t            *cpu_list;      /* list of CPUs */
 557 extern cpu_t            *cpu_active;    /* list of active CPUs */
 558 extern int              ncpus;          /* number of CPUs present */
 559 extern int              ncpus_online;   /* number of CPUs not quiesced */
 560 extern int              max_ncpus;      /* max present before ncpus is known */
 561 extern int              boot_max_ncpus; /* like max_ncpus but for real */
 562 extern int              boot_ncpus;     /* # cpus present @ boot */
 563 extern processorid_t    max_cpuid;      /* maximum CPU number */
 564 extern struct cpu       *cpu_inmotion;  /* offline or partition move target */
 565 extern cpu_t            *clock_cpu_list;
 566 extern processorid_t    max_cpu_seqid_ever;     /* maximum seqid ever given */
 567 
 568 #if defined(__i386) || defined(__amd64)
 569 extern struct cpu *curcpup(void);
 570 #define CPU             (curcpup())     /* Pointer to current CPU */
 571 #else
 572 #define CPU             (curthread->t_cpu)   /* Pointer to current CPU */
 573 #endif
 574 
 575 /*
 576  * CPU_CURRENT indicates to thread_affinity_set() to use whatever curthread's
 577  * current CPU is; holding cpu_lock is not required.

 578  */
 579 #define CPU_CURRENT     -3
 580 
 581 /*
 582  * CPU_BEST can be used by thread_affinity_set() callers to set affinity to a
 583  * good CPU (in particular, an ht_acquire()-friendly choice); holding cpu_lock
 584  * is not required.
 585  */
 586 #define CPU_BEST        -4
 587 
 588 /*
 589  * Per-CPU statistics
 590  *
 591  * cpu_stats_t contains numerous system and VM-related statistics, in the form
 592  * of gauges or monotonically-increasing event occurrence counts.
 593  */
 594 
 595 #define CPU_STATS_ENTER_K()     kpreempt_disable()
 596 #define CPU_STATS_EXIT_K()      kpreempt_enable()
 597 
 598 #define CPU_STATS_ADD_K(class, stat, amount) \
 599         {       kpreempt_disable(); /* keep from switching CPUs */\
 600                 CPU_STATS_ADDQ(CPU, class, stat, amount); \
 601                 kpreempt_enable(); \
 602         }
 603 
 604 #define CPU_STATS_ADDQ(cp, class, stat, amount) {                       \
 605         extern void __dtrace_probe___cpu_##class##info_##stat(uint_t,   \
 606             uint64_t *, cpu_t *);                                       \
 607         uint64_t *stataddr = &((cp)->cpu_stats.class.stat);              \
 608         __dtrace_probe___cpu_##class##info_##stat((amount),             \