/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* Copyright (c) 2010, Intel Corporation.
* All rights reserved.
*/
/*
* Copyright 2015 Joyent, Inc.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/asm_linkage.h>
#include <vm/seg_kmem.h>
#include <sys/segments.h>
#include <sys/smp_impldefs.h>
#include <sys/x86_archext.h>
#include <sys/machsystm.h>
#include <sys/traptrace.h>
#include <sys/cpc_impl.h>
#include <sys/archsystm.h>
#include <sys/kdi_machimpl.h>
#include <sys/pci_cfgspace.h>
#include <sys/mach_mmu.h>
#include <sys/sysmacros.h>
#if defined(__xpv)
#include <sys/hypervisor.h>
#endif
#include <sys/cpu_module.h>
/*
* Useful for disabling MP bring-up on a MP capable system.
*/
/*
* to be set by a PSM to indicate what cpus
* are sitting around on the system.
*/
/*
* This variable is used by the hat layer to decide whether or not
* critical sections are needed to prevent race conditions. For sun4m,
* this variable is set once enough MP initialization has been done in
* order to allow cross calls.
*/
static void mp_startup_boot(void);
static void mp_startup_hotplug(void);
static void cpu_sep_enable(void);
static void cpu_sep_disable(void);
static void cpu_asysc_enable(void);
static void cpu_asysc_disable(void);
/*
* Init CPU info - get CPU type info for processor_info system call.
*/
void
{
/*
* Get clock-frequency property for the CPU.
*/
/*
* Current frequency in Hz.
*/
/*
* Supported frequencies.
*/
}
if (fpu_exists)
/*
* If called for the BSP, cp is equal to current CPU.
* For non-BSPs, cpuid info of cp is not ready yet, so use cpuid info
* of current CPU as default values for cpu_idstr and cpu_brandstr.
* They will be corrected in mp_startup_common() after cpuid_pass1()
* has been invoked on target CPU.
*/
}
/*
* Configure syscall support on this CPU.
*/
/*ARGSUSED*/
void
{
#if defined(__amd64)
#if !defined(__lint)
/*
* The syscall instruction imposes a certain ordering on
* segment selectors, so we double-check that ordering
* here.
*/
#endif
/*
*/
/*
* Program the magic registers ..
*/
/*
* This list of flags is masked off the incoming
* %rfl when we enter the kernel.
*/
}
#endif
/*
*
* On 64-bit kernels on Nocona machines, the 32-bit syscall
* variant isn't available to 32-bit applications, but sysenter is.
*/
#if !defined(__lint)
/*
* The sysenter instruction imposes a certain ordering on
* segment selectors, so we double-check that ordering
* here. See "sysenter" in Intel document 245471-012, "IA-32
* Intel Architecture Software Developer's Manual Volume 2:
* Instruction Set Reference"
*/
#endif
/*
* resume() sets this value to the base of the threads stack
* via a context handler.
*/
wrmsr(MSR_INTC_SEP_ESP, 0);
}
}
/*
* Multiprocessor initialization.
*
* Allocate and initialize the cpu structure, TRAPTRACE buffer, and the
* startup and idle threads for the specified CPU.
* Parameter boot is true for boot time operations and is false for CPU
* DR operations.
*/
static struct cpu *
{
#if !defined(__xpv)
extern int idle_cpu_prefer_mwait;
extern void cpu_idle_mwait();
#endif
extern void idle();
extern void cpu_idle();
#ifdef TRAPTRACE
#endif
if (cpu_free_list == NULL) {
} else {
cp = cpu_free_list;
}
/* Create per CPU specific threads in the process p0. */
/*
* Initialize the dispatcher first.
*/
/*
* Allocate and initialize the startup thread for this CPU.
* Interrupt and process switch stacks get allocated later
* when the CPU starts running.
*/
/*
* Set state to TS_ONPROC since this thread will start running
* as soon as the CPU comes online.
*
* All the other fields of the thread structure are setup by
* thread_create().
*/
/*
* Setup thread to start in mp_startup_common.
*/
#if defined(__amd64)
#endif
/*
* Setup thread start entry point for boot or hotplug.
*/
if (boot) {
} else {
}
/*
* cpu_base_spl must be set explicitly here to prevent any blocking
* operations in mp_startup_common from causing the spl of the cpu
* to drop to 0 (allowing device interrupts before we're ready) in
* resume().
* cpu_base_spl MUST remain at LOCK_LEVEL until the cpu is CPU_READY.
* As an extra bit of security on DEBUG kernels, this is enforced with
* an assertion in mp_startup_common() -- before cpu_base_spl is set
* to its proper value.
*/
/*
* Now, initialize per-CPU idle thread for this CPU.
*/
/*
* Bootstrap the CPU's PG data
*/
/*
* Perform CPC initialization on the new CPU.
*/
/*
* Allocate virtual addresses for cpu_caddr1 and cpu_caddr2
* for each CPU.
*/
/*
* Allocate page for new GDT and initialize from current GDT.
*/
#if !defined(__lint)
#endif
#if defined(__i386)
/*
* setup kernel %gs.
*/
SEL_KPL, 0, 1);
#endif
/*
* If we have more than one node, each cpu gets a copy of IDT
* local to its node. If this is a Pentium box, we use cpu 0's
* IDT. cpu 0's IDT has been made read-only to workaround the
* cmpxchgl register bug
*/
#if !defined(__lint)
#endif
} else {
}
/*
* alloc space for cpuid info
*/
#if !defined(__xpv)
} else
#endif
/*
* alloc space for ucode_info
*/
#ifdef TRAPTRACE
/*
* If this is a TRAPTRACE kernel, allocate TRAPTRACE buffers
*/
#endif
/*
* Record that we have another CPU.
*/
/*
* Initialize the interrupt threads for this CPU
*/
/*
* Add CPU to list of available CPUs. It'll be on the active list
* after mp_startup_common().
*/
return (cp);
}
/*
* Undo what was done in mp_cpu_configure_common
*/
static void
{
/*
* Remove the CPU from the list of available CPUs.
*/
/*
* The cpu was started, but never *seemed* to run any
* code in the kernel; it's probably off spinning in its
* own private world, though with potential references to
* our kmem-allocated IDTs and GDTs (for example).
*
* Worse still, it may actually wake up some time later,
* so rather than guess what it might or might not do, we
* leave the fundamental data structures intact.
*/
return;
}
/*
* At this point, the only threads bound to this CPU should
* special per-cpu threads: it's idle thread, it's pause threads,
* and it's interrupt threads. Clean these up.
*/
/*
* Free the interrupt stack.
*/
#ifdef TRAPTRACE
/*
* Discard the trap trace buffer
*/
{
}
#endif
/* Free CPU ID string and brand string. */
}
if (cp->cpu_brandstr) {
}
#if !defined(__xpv)
}
#endif
}
cpu_free_list = cp;
}
/*
* Apply workarounds for known errata, and warn about those that are absent.
*
* System vendors occasionally create configurations which contain different
* revisions of the CPUs that are almost but not exactly the same. At the
* time of writing, this meant that their clock rates were the same, their
* feature sets were the same, but the required workaround were -not-
* necessarily the same. So, this routine is invoked on -every- CPU soon
* after starting to make sure that the resulting system contains the most
* pessimal set of workarounds needed to cope with *any* of the CPUs in the
* system.
*
* workaround_errata is invoked early in mlsetup() for CPU 0, and in
* mp_startup_common() for all slave CPUs. Slaves process workaround_errata
* prior to acknowledging their readiness to the master, so this routine will
* never be executed by multiple CPUs in parallel, thus making updates to
* global data safe.
*
* These workarounds are based on Rev 3.57 of the Revision Guide for
* AMD Athlon(tm) 64 and AMD Opteron(tm) Processors, August 2005.
*/
#if defined(OPTERON_ERRATUM_88)
#endif
#if defined(OPTERON_ERRATUM_91)
#endif
#if defined(OPTERON_ERRATUM_93)
#endif
#if defined(OPTERON_ERRATUM_95)
#endif
#if defined(OPTERON_ERRATUM_100)
#endif
#if defined(OPTERON_ERRATUM_108)
#endif
#if defined(OPTERON_ERRATUM_109)
#endif
#if defined(OPTERON_ERRATUM_121)
#endif
#if defined(OPTERON_ERRATUM_122)
#endif
#if defined(OPTERON_ERRATUM_123)
#endif
#if defined(OPTERON_ERRATUM_131)
#endif
#if defined(OPTERON_WORKAROUND_6336786)
#endif
#if defined(OPTERON_WORKAROUND_6323525)
#endif
#if defined(OPTERON_ERRATUM_298)
int opteron_erratum_298;
#endif
#if defined(OPTERON_ERRATUM_721)
int opteron_erratum_721;
#endif
static void
{
}
static void
{
if (erratum > 1000000)
erratum);
else
erratum);
}
static void
{
}
/*
* Determine the number of nodes in a Hammer / Greyhound / Griffin family
* system.
*/
static uint_t
opteron_get_nnodes(void)
{
if (nnodes == 0) {
#ifdef DEBUG
/*
* This routine uses a PCI config space based mechanism
* for retrieving the number of nodes in the system.
* Device 24, function 0, offset 0x60 as used here is not
* AMD processor architectural, and may not work on processor
* families other than those listed below.
*
* Callers of this routine must ensure that we're running on
* a processor which supports this mechanism.
* The assertion below is meant to catch calls on unsupported
* processors.
*/
#endif /* DEBUG */
/*
* Obtain the number of nodes in the system from
* bits [6:4] of the Node ID register on node 0.
*
* The actual node count is NodeID[6:4] + 1
*
* The Node ID register is accessed via function 0,
* offset 0x60. Node 0 is device 24.
*/
}
return (nnodes);
}
{
/*
* L2 Eviction May Occur During Processor Operation To Set
* Accessed or Dirty Bit.
*/
if (osvwrc == -3) {
} else {
/* osvw return codes should be consistent for all cpus */
}
switch (osvwrc) {
case 0: /* erratum is not present: do nothing */
break;
case 1: /* erratum is present: BIOS workaround applied */
/*
* check if workaround is actually in place and issue warning
* if not.
*/
#if defined(OPTERON_ERRATUM_298)
#else
return (1);
#endif
}
break;
case -1: /* cannot determine via osvw: check cpuid */
#if defined(OPTERON_ERRATUM_298)
#else
return (1);
#endif
}
break;
}
return (0);
}
{
/*LINTED*/
/*
* SWAPGS May Fail To Read Correct GS Base
*/
#if defined(OPTERON_ERRATUM_88)
/*
* The workaround is an mfence in the relevant assembler code
*/
#else
missing++;
#endif
}
/*
* Software Prefetches May Report A Page Fault
*/
#if defined(OPTERON_ERRATUM_91)
/*
* fix is in trap.c
*/
#else
missing++;
#endif
}
/*
* RSM Auto-Halt Restart Returns to Incorrect RIP
*/
#if defined(OPTERON_ERRATUM_93)
/*
* fix is in trap.c
*/
#else
missing++;
#endif
}
/*LINTED*/
/*
* RET Instruction May Return to Incorrect EIP
*/
#if defined(OPTERON_ERRATUM_95)
#if defined(_LP64)
/*
* Workaround this by ensuring that 32-bit user code and
* 64-bit kernel code never occupy the same address
* range mod 4G.
*/
if (_userlimit32 > 0xc0000000ul)
/*LINTED*/
#endif /* _LP64 */
#else
missing++;
#endif
}
/*
* Compatibility Mode Branches Transfer to Illegal Address
*/
#if defined(OPTERON_ERRATUM_100)
/*
* fix is in trap.c
*/
#else
missing++;
#endif
}
/*LINTED*/
/*
* CPUID Instruction May Return Incorrect Model Number In
* Some Processors
*/
#if defined(OPTERON_ERRATUM_108)
/*
* (Our cpuid-handling code corrects the model number on
* those processors)
*/
#else
missing++;
#endif
}
/*LINTED*/
/*
* Certain Reverse REP MOVS May Produce Unpredictable Behavior
*/
#if defined(OPTERON_ERRATUM_109)
/*
* The "workaround" is to print a warning to upgrade the BIOS
*/
int err;
missing++;
}
if (value == 0)
#else
missing++;
#endif
/*CONSTANTCONDITION*/
} while (0);
/*LINTED*/
/*
* Sequential Execution Across Non_Canonical Boundary Caused
* Processor Hang
*/
#if defined(OPTERON_ERRATUM_121)
#if defined(_LP64)
/*
* Erratum 121 is only present in long (64 bit) mode.
* Workaround is to include the page immediately before the
* va hole to eliminate the possibility of system hangs due to
* sequential execution across the va hole boundary.
*/
if (opteron_erratum_121)
else {
if (hole_start) {
hole_start -= PAGESIZE;
} else {
/*
* hole_start not yet initialized by
* mmu_init. Initialize hole_start
* with value to be subtracted.
*/
}
}
#endif /* _LP64 */
#else
missing++;
#endif
}
/*LINTED*/
/*
* TLB Flush Filter May Cause Coherency Problem in
* Multiprocessor Systems
*/
#if defined(OPTERON_ERRATUM_122)
int error;
/*
* Erratum 122 is only present in MP configurations (multi-core
* or multi-processor).
*/
#if defined(__xpv)
if (!DOMAIN_IS_INITDOMAIN(xen_info))
break;
break;
#else
break;
#endif
/* disable TLB Flush Filter */
missing++;
} else {
missing++;
}
}
#else
missing++;
#endif
/*CONSTANTCONDITION*/
} while (0);
/*LINTED*/
/*
* Bypassed Reads May Cause Data Corruption of System Hang in
* Dual Core Processors
*/
#if defined(OPTERON_ERRATUM_123)
int err;
/*
* Erratum 123 applies only to multi-core cpus.
*/
break;
#if defined(__xpv)
if (!DOMAIN_IS_INITDOMAIN(xen_info))
break;
#endif
/*
* The "workaround" is to print a warning to upgrade the BIOS
*/
missing++;
}
if (value == 0)
#else
missing++;
#endif
/*CONSTANTCONDITION*/
} while (0);
/*LINTED*/
/*
* Multiprocessor Systems with Four or More Cores May Deadlock
* Waiting for a Probe Response
*/
#if defined(OPTERON_ERRATUM_131)
int error;
/*
* Erratum 131 applies to any system with four or more cores.
*/
if (opteron_erratum_131)
break;
#if defined(__xpv)
if (!DOMAIN_IS_INITDOMAIN(xen_info))
break;
if (xpv_nr_phys_cpus() < 4)
break;
#else
break;
#endif
/*
* Print a warning if neither of the workarounds for
* erratum 131 is present.
*/
missing++;
} else {
/* cannot have both workarounds set */
}
#else
missing++;
#endif
/*CONSTANTCONDITION*/
} while (0);
/*
* This isn't really an erratum, but for convenience the
* detection/workaround code lives here and in cpuid_opteron_erratum.
*/
#if defined(OPTERON_WORKAROUND_6336786)
/*
* Disable C1-Clock ramping on multi-core/multi-processor
* K8 platforms to guard against TSC drift.
*/
if (opteron_workaround_6336786) {
#if defined(__xpv)
} else if ((DOMAIN_IS_INITDOMAIN(xen_info) &&
xpv_nr_phys_cpus() > 1) ||
/*
* XXPV Hmm. We can't walk the Northbridges on
* the hypervisor; so just complain and drive
* on. This probably needs to be fixed in
* the hypervisor itself.
*/
#else /* __xpv */
} else if ((opteron_get_nnodes() *
nnodes = opteron_get_nnodes();
/*
* Clear PMM7[1:0] (function 3, offset 0x87)
* Northbridge device is the node id + 24.
*/
data &= 0xFC;
}
#endif /* __xpv */
}
#else
missing++;
#endif
}
/*LINTED*/
/*
* Mutex primitives don't work as expected.
*/
#if defined(OPTERON_WORKAROUND_6323525)
/*
* This problem only occurs with 2 or more cores. If bit in
* MSR_AMD_BU_CFG set, then not applicable. The workaround
* is to patch the semaphone routines with the lfence
* instruction to provide necessary load memory barrier with
* possible subsequent read-modify-write ops.
*
* It is too early in boot to call the patch routine so
* set erratum variable to be done in startup_end().
*/
if (opteron_workaround_6323525) {
#if defined(__xpv)
if (DOMAIN_IS_INITDOMAIN(xen_info)) {
/*
* XXPV Use dom0_msr here when extended
* operations are supported?
*/
if (xpv_nr_phys_cpus() > 1)
} else {
/*
* We have no way to tell how many physical
* cpus there are, or even if this processor
* has the problem, so enable the workaround
* unconditionally (at some performance cost).
*/
}
#else /* __xpv */
((opteron_get_nnodes() *
#endif /* __xpv */
}
#else
missing++;
#endif
}
#if defined(OPTERON_ERRATUM_721)
no_trap();
#else
missing++;
#endif
}
#ifdef __xpv
return (0);
#else
return (missing);
#endif
}
void
{
#if defined(OPTERON_ERRATUM_88)
if (opteron_erratum_88)
workaround_applied(88);
#endif
#if defined(OPTERON_ERRATUM_91)
if (opteron_erratum_91)
workaround_applied(91);
#endif
#if defined(OPTERON_ERRATUM_93)
if (opteron_erratum_93)
workaround_applied(93);
#endif
#if defined(OPTERON_ERRATUM_95)
if (opteron_erratum_95)
workaround_applied(95);
#endif
#if defined(OPTERON_ERRATUM_100)
if (opteron_erratum_100)
workaround_applied(100);
#endif
#if defined(OPTERON_ERRATUM_108)
if (opteron_erratum_108)
workaround_applied(108);
#endif
#if defined(OPTERON_ERRATUM_109)
if (opteron_erratum_109) {
"BIOS microcode patch for AMD Athlon(tm) 64/Opteron(tm)"
" processor\nerratum 109 was not detected; updating your"
" system's BIOS to a version\ncontaining this"
" microcode patch is HIGHLY recommended or erroneous"
" system\noperation may occur.\n");
}
#endif
#if defined(OPTERON_ERRATUM_121)
if (opteron_erratum_121)
workaround_applied(121);
#endif
#if defined(OPTERON_ERRATUM_122)
if (opteron_erratum_122)
workaround_applied(122);
#endif
#if defined(OPTERON_ERRATUM_123)
if (opteron_erratum_123) {
"BIOS microcode patch for AMD Athlon(tm) 64/Opteron(tm)"
" processor\nerratum 123 was not detected; updating your"
" system's BIOS to a version\ncontaining this"
" microcode patch is HIGHLY recommended or erroneous"
" system\noperation may occur.\n");
}
#endif
#if defined(OPTERON_ERRATUM_131)
if (opteron_erratum_131) {
"BIOS microcode patch for AMD Athlon(tm) 64/Opteron(tm)"
" processor\nerratum 131 was not detected; updating your"
" system's BIOS to a version\ncontaining this"
" microcode patch is HIGHLY recommended or erroneous"
" system\noperation may occur.\n");
}
#endif
#if defined(OPTERON_WORKAROUND_6336786)
workaround_applied(6336786);
#endif
#if defined(OPTERON_WORKAROUND_6323525)
workaround_applied(6323525);
#endif
#if defined(OPTERON_ERRATUM_298)
if (opteron_erratum_298) {
"BIOS microcode patch for AMD 64/Opteron(tm)"
" processor\nerratum 298 was not detected; updating your"
" system's BIOS to a version\ncontaining this"
" microcode patch is HIGHLY recommended or erroneous"
" system\noperation may occur.\n");
}
#endif
#if defined(OPTERON_ERRATUM_721)
if (opteron_erratum_721)
workaround_applied(721);
#endif
}
/*
* The procset_slave and procset_master are used to synchronize
* between the control CPU and the target CPU when starting CPUs.
*/
static void
{
SMT_PAUSE();
}
}
static void
{
SMT_PAUSE();
}
}
int
{
void *ctx;
int delays;
int error = 0;
#ifndef __xpv
extern void cpupm_init(cpu_t *);
#endif
return (EAGAIN);
}
if (error != 0) {
return (error);
}
delays++) {
if (delays == 500) {
/*
* After five seconds, things are probably looking
* a bit bleak - explain the hang.
*/
"but not running in the kernel yet", cpuid);
} else if (delays > 2000) {
/*
* We waited at least 20 seconds, bail ..
*/
return (error);
}
/*
* wait at least 10ms, then check again..
*/
}
#ifndef __xpv
if (tsc_gethrtime_enable)
#endif
if (dtrace_cpu_init != NULL) {
(*dtrace_cpu_init)(cpuid);
}
/*
* During CPU DR operations, the cpu_lock is held by current
* (the control) thread. We can't release the cpu_lock here
* because that will break the CPU DR logic.
* On the other hand, CPUPM and processor group initialization
* routines need to access the cpu_lock. So we invoke those
* routines here on behalf of mp_startup_common().
*
* CPUPM and processor group initialization routines depend
* on the cpuid probing results. Wait for mp_startup_common()
* to signal that cpuid probing is done.
*/
#ifndef __xpv
cpupm_init(cp);
#endif
return (0);
}
/*
* Start a single cpu, assuming that the kernel context is available
* to successfully start another cpu.
*
* (For example, real mode code is mapped into the right place
* in memory and is ready to be run.)
*/
int
{
int error = 0;
/*
* Check if there's at least a Mbyte of kmem available
* before attempting to start the cpu.
*/
/*
* Kick off a reap in case that helps us with
* later attempts ..
*/
kmem_reap();
return (ENOMEM);
}
/*
* First configure cpu.
*/
/*
* Then start cpu.
*/
if (error != 0) {
return (error);
}
drv_usecwait(1);
}
return (0);
}
void
{
/*
* Initialize our own cpu_info.
*/
/*
* Initialize our syscall handlers
*/
/*
* Take the boot cpu out of the mp_cpus set because we know
* it's already running. Add it to the cpu_ready_set for
* precisely the same reason.
*/
/*
* skip the rest of this if
* . only 1 cpu dectected and system isn't hotplug-capable
* . not using MP
*/
use_mp == 0) {
if (use_mp == 0)
goto done;
}
/*
* perform such initialization as is needed
* to be able to take CPUs on- and off-line.
*/
if (mach_cpucontext_init() != 0)
goto done;
/*
* We lock our affinity to the master CPU to ensure that all slave CPUs
* do their TSC syncs with the same CPU.
*/
continue;
}
/* Free the space allocated to hold the microcode file */
done:
"System detected %d cpus, but "
"only %d cpu(s) were enabled during boot.",
"Use \"boot-ncpus\" parameter to enable more CPU(s). "
"See eeprom(1M).");
}
}
int
{
if (use_mp == 0 || plat_dr_support_cpu() == 0) {
return (ENOTSUP);
}
return (EALREADY);
}
/*
* Check if there's at least a Mbyte of kmem available
* before attempting to start the cpu.
*/
/*
* Kick off a reap in case that helps us with
* later attempts ..
*/
kmem_reap();
return (ENOMEM);
}
}
int
{
if (use_mp == 0 || plat_dr_support_cpu() == 0) {
return (ENOTSUP);
return (EINVAL);
}
return (ENODEV);
}
return (0);
}
/*
* Startup function for 'other' CPUs (besides boot cpu).
* Called from real_mode_start.
*
* WARNING: until CPU_READY is set, mp_startup_common and routines called by
* mp_startup_common should not call routines (e.g. kmem_free) that could call
* hat_unload which requires CPU_READY to be set.
*/
static void
{
extern void cpu_event_init_cpu(cpu_t *);
/*
* We need to get TSC on this proc synced (i.e., any delta
* from cpu0 accounted for) as soon as we can, because many
* many things use gethrtime/pc_gethrestime, including
* interrupts, cmn_err, etc. Before we can do that, we want to
* right away.
*/
}
/* Let the control CPU continue into tsc_sync_master() */
#ifndef __xpv
if (tsc_gethrtime_enable)
#endif
/*
* Once this was done from assembly, but it's safer here; if
* it blocks, we need to be able to swtch() to and from, and
* since we get here by calling t_pc, we need to do that call
* before swtch() overwrites it.
*/
(void) (*ap_mlsetup)();
#ifndef __xpv
/*
* Program this cpu's PAT
*/
pat_sync();
#endif
/*
* Set up TSC_AUX to contain the cpuid for this processor
* for the rdtscp instruction.
*/
/*
* Initialize this CPU's syscall handlers
*/
/*
* Enable interrupts with spl set to LOCK_LEVEL. LOCK_LEVEL is the
* highest level at which a routine is permitted to block on
* an adaptive mutex (allows for cpu poke interrupt in case
* the cpu is blocked on a mutex and halts). Setting LOCK_LEVEL blocks
* device interrupts that may end up in the hat layer issuing cross
* calls before CPU_READY is set.
*/
sti();
/*
* Do a sanity check to make sure this new CPU is a sane thing
* to add to the collection of processors running this system.
*
* XXX Clearly this needs to get more sophisticated, if x86
* systems start to get built out of heterogenous CPUs; as is
* likely to happen once the number of processors in a configuration
* gets large enough.
*/
B_FALSE) {
}
/*
* There exists a small subset of systems which expose differing
* the boot CPU, but is found on a later CPU, the system continues to
* operate as if no MWAIT support is available.
*
* The reverse case, where MWAIT is available on the boot CPU but not
* on a subsequently initialized CPU, is not presently allowed and will
* result in a panic.
*/
} else {
panic("unsupported mixed cpu mwait support detected");
}
}
/*
* We could be more sophisticated here, and just mark the CPU
* as "faulted" but at this point we'll opt for the easier
* answer of dying horribly. Provided the boot cpu is ok,
* the system can be recovered by booting with use_mp set to zero.
*/
if (workaround_errata(cp) != 0)
/*
* We can touch cpu_flags here without acquiring the cpu_lock here
* because the cpu_lock is held by the control CPU which is running
* mp_start_cpu_common().
* Need to clear CPU_QUIESCED flag before calling any function which
* may cause thread context switching, such as kmem_alloc() etc.
* The idle thread checks for CPU_QUIESCED flag and loops for ever if
* it's set. So the startup thread may have no chance to switch back
* again if it's switched away with CPU_QUIESCED set.
*/
/*
* Setup this processor for XSAVE.
*/
if (fp_save_mech == FP_XSAVE) {
}
/*
* Correct cpu_idstr and cpu_brandstr on target CPU after
* cpuid_pass1() is done.
*/
/*
* Enable preemption here so that contention for any locks acquired
* later in mp_startup_common may be preempted if the thread owning
* those locks is continuously executing on other CPUs (for example,
* this CPU must be preemptible to allow other CPUs to pause it during
* their startup phases). It's safe to enable preemption here because
* the CPU state is pretty-much fully constructed.
*/
/* The base spl should still be at LOCK LEVEL here */
set_base_spl(); /* Restore the spl to its proper value */
/*
* Delegate initialization tasks, which need to access the cpu_lock,
* to mp_start_cpu_common() because we can't acquire the cpu_lock here
* during CPU DR operations.
*/
if (boot) {
}
/* Enable interrupts */
(void) spl0();
/*
* Fill out cpu_ucode_info. Update microcode if necessary.
*/
#ifndef __xpv
{
/*
* Set up the CPU module for this CPU. This can't be done
* before this CPU is made CPU_READY, because we may (in
* heterogeneous systems) need to go load another CPU module.
* The act of attempting to load a module may trigger a
* cross-call, which will ASSERT unless this cpu is CPU_READY.
*/
}
}
#endif /* __xpv */
kdi_cpu_init();
/*
* Setting the bit in cpu_ready_set must be the last operation in
* processor initialization; the boot CPU will continue to boot once
* it sees this bit set for all active CPUs.
*/
/*
* Now we are done with the startup thread, so free it up.
*/
thread_exit();
panic("mp_startup: cannot return");
/*NOTREACHED*/
}
/*
* Startup function for 'other' CPUs at boot time (besides boot cpu).
*/
static void
mp_startup_boot(void)
{
}
/*
* Startup function for hotplug CPUs at runtime.
*/
void
mp_startup_hotplug(void)
{
}
/*
* Start CPU on user request.
*/
/* ARGSUSED */
int
{
return (0);
}
/*
* Stop CPU on user request.
*/
int
{
extern int cbe_psm_timer_mode;
#ifdef __xpv
/*
* We can't offline vcpu0.
*/
return (EBUSY);
#endif
/*
* If TIMER_PERIODIC mode is used, CPU0 is the one running it;
* can't stop it. (This is true only for machines with no TSC.)
*/
return (EBUSY);
return (0);
}
/*
* Take the specified CPU out of participation in interrupts.
*/
int
{
return (EBUSY);
return (0);
}
/*
* Allow the specified CPU to participate in interrupts.
*/
void
{
}
void
{
#ifdef __xpv
#else
} else {
}
}
#endif
}
void
{
#ifdef __xpv
#else
} else {
}
}
#endif
}
/*
* The following two routines are used as context operators on threads belonging
* to processes with a private LDT (see sysi86). Due to the rarity of such
* processes, these routines are currently written for best code readability and
* organization rather than speed. We could avoid checking x86_featureset at
* every context switch by installing different context ops, depending on
* x86_featureset, at LDT creation time -- one for each combination of fast
* syscall features.
*/
/*ARGSUSED*/
void
{
}
/*ARGSUSED*/
void
{
}
static void
cpu_sep_enable(void)
{
}
static void
cpu_sep_disable(void)
{
/*
* Setting the SYSENTER_CS_MSR register to 0 causes software executing
* the sysenter or sysexit instruction to trigger a #gp fault.
*/
wrmsr(MSR_INTC_SEP_CS, 0);
}
static void
cpu_asysc_enable(void)
{
}
static void
cpu_asysc_disable(void)
{
/*
* Turn off the SCE (syscall enable) bit in the EFER register. Software
* executing syscall or sysret with this bit off will incur a #ud trap.
*/
}