#include <sys/types.h>
#include <sys/t_lock.h>
#include <sys/param.h>
#include <sys/segments.h>
#include <sys/sysmacros.h>
#include <sys/signal.h>
#include <sys/systm.h>
#include <sys/user.h>
#include <sys/mman.h>
#include <sys/vm.h>
#include <sys/disp.h>
#include <sys/class.h>
#include <sys/proc.h>
#include <sys/buf.h>
#include <sys/kmem.h>
#include <sys/reboot.h>
#include <sys/uadmin.h>
#include <sys/callb.h>
#include <sys/cred.h>
#include <sys/vnode.h>
#include <sys/file.h>
#include <sys/procfs.h>
#include <sys/acct.h>
#include <sys/vfs.h>
#include <sys/dnlc.h>
#include <sys/var.h>
#include <sys/cmn_err.h>
#include <sys/utsname.h>
#include <sys/debug.h>
#include <sys/dumphdr.h>
#include <sys/bootconf.h>
#include <sys/varargs.h>
#include <sys/promif.h>
#include <sys/modctl.h>
#include <sys/consdev.h>
#include <sys/frame.h>
#include <sys/sunddi.h>
#include <sys/ddidmareq.h>
#include <sys/psw.h>
#include <sys/regset.h>
#include <sys/privregs.h>
#include <sys/clock.h>
#include <sys/tss.h>
#include <sys/cpu.h>
#include <sys/stack.h>
#include <sys/trap.h>
#include <sys/pic.h>
#include <vm/hat.h>
#include <vm/anon.h>
#include <vm/as.h>
#include <vm/page.h>
#include <vm/seg.h>
#include <vm/seg_kmem.h>
#include <vm/seg_map.h>
#include <vm/seg_vn.h>
#include <vm/seg_kp.h>
#include <vm/hat_i86.h>
#include <sys/swap.h>
#include <sys/thread.h>
#include <sys/sysconf.h>
#include <sys/vm_machparam.h>
#include <sys/archsystm.h>
#include <sys/machsystm.h>
#include <sys/machlock.h>
#include <sys/x_call.h>
#include <sys/instance.h>
#include <sys/time.h>
#include <sys/smp_impldefs.h>
#include <sys/psm_types.h>
#include <sys/atomic.h>
#include <sys/panic.h>
#include <sys/cpuvar.h>
#include <sys/dtrace.h>
#include <sys/bl.h>
#include <sys/nvpair.h>
#include <sys/x86_archext.h>
#include <sys/pool_pset.h>
#include <sys/autoconf.h>
#include <sys/mem.h>
#include <sys/dumphdr.h>
#include <sys/compress.h>
#include <sys/cpu_module.h>
#if defined(__xpv)
#include <sys/hypervisor.h>
#include <sys/xpv_panic.h>
#endif
#include <sys/fastboot.h>
#include <sys/machelf.h>
#include <sys/kobj.h>
#include <sys/multiboot.h>
#ifdef TRAPTRACE
#include <sys/traptrace.h>
#endif
#include <c2/audit.h>
#include <sys/clock_impl.h>
extern void audit_enterprom(int);
extern void audit_exitprom(int);
int apix_enable = 1;
int apic_nvidia_io_max = 0;
int force_shutdown_method = AD_UNKNOWN;
char panicbuf[PANICBUFSIZE];
uint64_t plat_dr_options;
uint64_t plat_dr_physmax;
int maxphys = 56 * 1024;
int klustsize = 56 * 1024;
caddr_t p0_va;
int vac;
void debug_enter(char *);
extern void pm_cfb_check_and_powerup(void);
extern void pm_cfb_rele(void);
extern fastboot_info_t newkernel;
static const uint8_t clac_instr[3] = { 0x0f, 0x01, 0xca };
static const uint8_t stac_instr[3] = { 0x0f, 0x01, 0xcb };
void
mdboot(int cmd, int fcn, char *mdep, boolean_t invoke_cb)
{
processorid_t bootcpuid = 0;
static int is_first_quiesce = 1;
static int is_first_reset = 1;
int reset_status = 0;
static char fallback_str[] = "Falling back to regular reboot.\n";
if (fcn == AD_FASTREBOOT && !newkernel.fi_valid)
fcn = AD_BOOT;
if (!panicstr) {
kpreempt_disable();
if (fcn == AD_FASTREBOOT) {
mutex_enter(&cpu_lock);
if (CPU_ACTIVE(cpu_get(bootcpuid))) {
affinity_set(bootcpuid);
}
mutex_exit(&cpu_lock);
} else {
affinity_set(CPU_CURRENT);
}
}
if (force_shutdown_method != AD_UNKNOWN)
fcn = force_shutdown_method;
rconsvp = NULL;
if (!(fcn == AD_HALT || fcn == AD_POWEROFF))
prom_printf("rebooting...\n");
if (IN_XPV_PANIC())
reset();
pm_cfb_check_and_powerup();
devtree_freeze();
if (invoke_cb)
(void) callb_execute_class(CB_CL_MDBOOT, 0);
page_retire_mdboot();
#if defined(__xpv)
if (panicstr && proc_init == NULL)
(void) HYPERVISOR_shutdown(SHUTDOWN_poweroff);
#endif
(void) spl6();
if (!panicstr) {
mutex_enter(&cpu_lock);
pause_cpus(NULL, NULL);
mutex_exit(&cpu_lock);
}
if (fcn == AD_BOOT && panicstr && newkernel.fi_valid &&
fastreboot_onpanic &&
(panic_lbolt - lbolt_at_boot) > fastreboot_onpanic_uptime) {
fcn = AD_FASTREBOOT;
}
if (is_first_quiesce) {
is_first_quiesce = 0;
quiesce_active = 1;
quiesce_devices(ddi_root_node(), &reset_status);
if (reset_status == -1) {
if (fcn == AD_FASTREBOOT && !force_fastreboot) {
prom_printf("Driver(s) not capable of fast "
"reboot.\n");
prom_printf(fallback_str);
fastreboot_capable = 0;
fcn = AD_BOOT;
} else if (fcn != AD_FASTREBOOT)
fastreboot_capable = 0;
}
quiesce_active = 0;
}
if (is_first_reset && (!fastreboot_capable || quiesce_active)) {
is_first_reset = 0;
reset_leaves();
}
if (fastreboot_capable && fcn == AD_FASTREBOOT &&
fastboot_cksum_verify(&newkernel) != 0) {
fastreboot_capable = 0;
prom_printf("Fast reboot: checksum failed for the new "
"kernel.\n");
prom_printf(fallback_str);
}
(void) spl8();
if (fastreboot_capable && fcn == AD_FASTREBOOT) {
fast_reboot();
} else {
(*psm_shutdownf)(cmd, fcn);
if (fcn == AD_HALT || fcn == AD_POWEROFF)
halt((char *)NULL);
else
prom_reboot("");
}
}
void
mdpreboot(int cmd, int fcn, char *mdep)
{
if (fcn == AD_FASTREBOOT && !fastreboot_capable) {
fcn = AD_BOOT;
#ifdef __xpv
cmn_err(CE_WARN, "Fast reboot is not supported on xVM");
#else
cmn_err(CE_WARN,
"Fast reboot is not supported on this platform%s",
fastreboot_nosup_message());
#endif
}
if (fcn == AD_FASTREBOOT) {
fastboot_load_kernel(mdep);
if (!newkernel.fi_valid)
fcn = AD_BOOT;
}
(*psm_preshutdownf)(cmd, fcn);
}
static void
stop_other_cpus(void)
{
ulong_t s = clear_int_flag();
cpuset_t xcset;
CPUSET_ALL_BUT(xcset, CPU->cpu_id);
xc_priority(0, 0, 0, CPUSET2BV(xcset), mach_cpu_halt);
restore_int_flag(s);
}
void
abort_sequence_enter(char *msg)
{
if (abort_enable == 0) {
if (AU_ZONE_AUDITING(GET_KCTX_GZ))
audit_enterprom(0);
return;
}
if (AU_ZONE_AUDITING(GET_KCTX_GZ))
audit_enterprom(1);
debug_enter(msg);
if (AU_ZONE_AUDITING(GET_KCTX_GZ))
audit_exitprom(1);
}
void
debug_enter(char *msg)
{
if (dtrace_debugger_init != NULL)
(*dtrace_debugger_init)();
if (msg != NULL || (boothowto & RB_DEBUG))
prom_printf("\n");
if (msg != NULL)
prom_printf("%s\n", msg);
if (boothowto & RB_DEBUG)
kmdb_enter();
if (dtrace_debugger_fini != NULL)
(*dtrace_debugger_fini)();
}
void
reset(void)
{
extern void acpi_reset_system();
#if !defined(__xpv)
ushort_t *bios_memchk;
if (khat_running) {
bios_memchk = (ushort_t *)psm_map_phys(0x472,
sizeof (ushort_t), PROT_READ | PROT_WRITE);
if (bios_memchk)
*bios_memchk = 0x1234;
if (options_dip != NULL &&
ddi_prop_exists(DDI_DEV_T_ANY, ddi_root_node(), 0,
"efi-systab")) {
if (bootops == NULL)
acpi_reset_system();
efi_reset();
}
if (bootops == NULL)
acpi_reset_system();
}
pc_reset();
#else
if (IN_XPV_PANIC()) {
if (khat_running && bootops == NULL) {
acpi_reset_system();
}
pc_reset();
}
(void) HYPERVISOR_shutdown(SHUTDOWN_reboot);
panic("HYPERVISOR_shutdown() failed");
#endif
}
void
halt(char *s)
{
stop_other_cpus();
if (s)
prom_printf("(%s) \n", s);
prom_exit_to_mon();
}
void
i_ddi_intr_redist_all_cpus()
{
}
pfn_t
impl_obmem_pfnum(pfn_t pf)
{
return (pf);
}
#ifdef NM_DEBUG
int nmi_test = 0;
int nmtest = -1;
nmfunc1(int arg, struct regs *rp)
{
printf("nmi called with arg = %x, regs = %x\n", arg, rp);
nmtest += 50;
if (arg == nmtest) {
printf("ip = %x\n", rp->r_pc);
return (1);
}
return (0);
}
#endif
#include <sys/bootsvcs.h>
int
sysp_getchar()
{
int i;
ulong_t s;
if (cons_polledio == NULL) {
prom_printf("getchar called with no console\n");
for (;;)
;
}
s = clear_int_flag();
i = cons_polledio->cons_polledio_getchar(
cons_polledio->cons_polledio_argument);
restore_int_flag(s);
return (i);
}
void
sysp_putchar(int c)
{
ulong_t s;
if (cons_polledio == NULL ||
cons_polledio->cons_polledio_putchar == NULL)
return;
s = clear_int_flag();
cons_polledio->cons_polledio_putchar(
cons_polledio->cons_polledio_argument, c);
restore_int_flag(s);
}
int
sysp_ischar()
{
int i;
ulong_t s;
if (cons_polledio == NULL ||
cons_polledio->cons_polledio_ischar == NULL)
return (0);
s = clear_int_flag();
i = cons_polledio->cons_polledio_ischar(
cons_polledio->cons_polledio_argument);
restore_int_flag(s);
return (i);
}
int
goany(void)
{
prom_printf("Type any key to continue ");
(void) prom_getchar();
prom_printf("\n");
return (1);
}
static struct boot_syscalls kern_sysp = {
sysp_getchar,
sysp_putchar,
sysp_ischar,
};
#if defined(__xpv)
int using_kern_polledio;
#endif
void
prom_io_use_kernel()
{
sysp = &kern_sysp;
#if defined(__xpv)
using_kern_polledio = 1;
#endif
}
int
poll_port(ushort_t port, ushort_t mask, ushort_t onbits, ushort_t offbits)
{
int i;
ushort_t maskval;
for (i = 500000; i; i--) {
maskval = inb(port) & mask;
if (((maskval & onbits) == onbits) &&
((maskval & offbits) == 0))
return (0);
drv_usecwait(10);
}
return (1);
}
static uint_t last_idle_cpu;
void
set_idle_cpu(int cpun)
{
last_idle_cpu = cpun;
(*psm_set_idle_cpuf)(cpun);
}
void
unset_idle_cpu(int cpun)
{
(*psm_unset_idle_cpuf)(cpun);
}
void
pc_gethrestime(timestruc_t *tp)
{
int lock_prev;
timestruc_t now;
int nslt;
int adj;
loop:
lock_prev = hres_lock;
now = hrestime;
nslt = (int)(gethrtime() - hres_last_tick);
if (nslt < 0) {
goto loop;
}
now.tv_nsec += nslt;
if (hrestime_adj != 0) {
if (hrestime_adj > 0) {
adj = (nslt >> ADJ_SHIFT);
if (adj > hrestime_adj)
adj = (int)hrestime_adj;
} else {
adj = -(nslt >> ADJ_SHIFT);
if (adj < hrestime_adj)
adj = (int)hrestime_adj;
}
now.tv_nsec += adj;
}
while ((unsigned long)now.tv_nsec >= NANOSEC) {
now.tv_nsec -= NANOSEC;
now.tv_sec++;
}
if ((hres_lock & ~1) != lock_prev)
goto loop;
*tp = now;
}
void
gethrestime_lasttick(timespec_t *tp)
{
int s;
s = hr_clock_lock();
*tp = hrestime;
hr_clock_unlock(s);
}
time_t
gethrestime_sec(void)
{
timestruc_t now;
gethrestime(&now);
return (now.tv_sec);
}
caddr_t
thread_stk_init(caddr_t stk)
{
ASSERT(((uintptr_t)stk & (STACK_ALIGN - 1)) == 0);
return (stk - SA(MINFRAME));
}
#ifdef TRAPTRACE
#endif
caddr_t
lwp_stk_init(klwp_t *lwp, caddr_t stk)
{
caddr_t oldstk;
struct pcb *pcb = &lwp->lwp_pcb;
oldstk = stk;
stk -= SA(sizeof (struct regs) + SA(MINFRAME));
#ifdef TRAPTRACE
stk -= 2 * sizeof (greg_t);
#endif
stk = (caddr_t)((uintptr_t)stk & ~(STACK_ALIGN - 1ul));
bzero(stk, oldstk - stk);
lwp->lwp_regs = (void *)(stk + SA(MINFRAME));
if (lwp_getdatamodel(lwp) == DATAMODEL_NATIVE)
pcb->pcb_fsdesc = pcb->pcb_gsdesc = zero_udesc;
else
pcb->pcb_fsdesc = pcb->pcb_gsdesc = zero_u32desc;
lwp_installctx(lwp);
return (stk);
}
void
lwp_stk_fini(klwp_t *lwp)
{
fp_lwp_cleanup(lwp);
}
void
lwp_fp_init(klwp_t *lwp)
{
fp_lwp_init(lwp);
}
void
panic_idle(void)
{
splx(ipltospl(CLOCK_LEVEL));
(void) setjmp(&curthread->t_pcb);
dumpsys_helper();
#ifndef __xpv
for (;;)
i86_halt();
#else
for (;;)
;
#endif
}
void
panic_stopcpus(cpu_t *cp, kthread_t *t, int spl)
{
processorid_t i;
cpuset_t xcset;
if (!IN_XPV_PANIC()) {
(void) splzs();
CPUSET_ALL_BUT(xcset, cp->cpu_id);
xc_priority(0, 0, 0, CPUSET2BV(xcset), (xc_func_t)panic_idle);
}
for (i = 0; i < NCPU; i++) {
if (i != cp->cpu_id && cpu[i] != NULL &&
(cpu[i]->cpu_flags & CPU_EXISTS))
cpu[i]->cpu_flags |= CPU_QUIESCED;
}
}
void
panic_enter_hw(int spl)
{
}
void
panic_quiesce_hw(panic_data_t *pdp)
{
psm_notifyf(PSM_PANIC_ENTER);
cmi_panic_callback();
#ifdef TRAPTRACE
TRAPTRACE_FREEZE;
#endif
}
void
panic_dump_hw(int spl)
{
}
void *
plat_traceback(void *fpreg)
{
#ifdef __xpv
if (IN_XPV_PANIC())
return (xpv_traceback(fpreg));
#endif
return (fpreg);
}
void
plat_tod_fault(enum tod_fault_type tod_bad)
{}
int
blacklist(int cmd, const char *scheme, nvlist_t *fmri, const char *class)
{
return (ENOTSUP);
}
int
console_enter(int busy)
{
return (splzs());
}
void
console_exit(int busy, int spl)
{
splx(spl);
}
void *
boot_virt_alloc(void *addr, size_t size)
{
return (addr);
}
void
tenmicrosec(void)
{
extern int gethrtime_hires;
if (gethrtime_hires) {
hrtime_t start, end;
start = end = gethrtime();
while ((end - start) < (10 * (NANOSEC / MICROSEC))) {
SMT_PAUSE();
end = gethrtime();
}
} else {
#if defined(__xpv)
hrtime_t newtime;
newtime = xpv_gethrtime() + 10000;
while (xpv_gethrtime() < newtime)
SMT_PAUSE();
#else
panic("TSC was not calibrated!");
#endif
}
}
void
get_cpu_mstate(cpu_t *cpu, hrtime_t *times)
{
int i;
hrtime_t now, start;
uint16_t gen;
uint16_t state;
hrtime_t intracct[NCMSTATES];
now = gethrtime_unscaled();
gen = cpu->cpu_mstate_gen;
membar_consumer();
start = cpu->cpu_mstate_start;
state = cpu->cpu_mstate;
for (i = 0; i < NCMSTATES; i++) {
intracct[i] = cpu->cpu_intracct[i];
times[i] = cpu->cpu_acct[i];
}
membar_consumer();
if (gen != 0 && gen == cpu->cpu_mstate_gen && now > start)
times[state] += now - start;
for (i = 0; i < NCMSTATES; i++) {
if (i == CMS_SYSTEM)
continue;
times[i] -= intracct[i];
if (times[i] < 0) {
intracct[i] += times[i];
times[i] = 0;
}
times[CMS_SYSTEM] += intracct[i];
scalehrtime(×[i]);
}
scalehrtime(×[CMS_SYSTEM]);
}
int
checked_rdmsr(uint_t msr, uint64_t *value)
{
if (!is_x86_feature(x86_featureset, X86FSET_MSR))
return (ENOTSUP);
*value = rdmsr(msr);
return (0);
}
int
checked_wrmsr(uint_t msr, uint64_t value)
{
if (!is_x86_feature(x86_featureset, X86FSET_MSR))
return (ENOTSUP);
wrmsr(msr, value);
return (0);
}
void
wrmsr_and_test(uint_t msr, const uint64_t v)
{
wrmsr(msr, v);
#ifdef DEBUG
uint64_t rv = rdmsr(msr);
if (rv != v) {
cmn_err(CE_PANIC, "MSR 0x%x written with value 0x%lx "
"has value 0x%lx\n", msr, v, rv);
}
#endif
}
int
plat_mem_do_mmio(struct uio *uio, enum uio_rw rw)
{
#if defined(__xpv)
void *va = (void *)(uintptr_t)uio->uio_loffset;
off_t pageoff = uio->uio_loffset & PAGEOFFSET;
size_t nbytes = MIN((size_t)(PAGESIZE - pageoff),
(size_t)uio->uio_iov->iov_len);
if ((rw == UIO_READ &&
(va == HYPERVISOR_shared_info || va == xen_info)) ||
(pfn_is_foreign(hat_getpfnum(kas.a_hat, va))))
return (uiomove(va, nbytes, rw, uio));
#endif
return (ENOTSUP);
}
pgcnt_t
num_phys_pages()
{
pgcnt_t npages = 0;
struct memlist *mp;
#if defined(__xpv)
if (DOMAIN_IS_INITDOMAIN(xen_info))
return (xpv_nr_phys_pages());
#endif
for (mp = phys_install; mp != NULL; mp = mp->ml_next)
npages += mp->ml_size >> PAGESHIFT;
return (npages);
}
#ifdef _LP64
uint_t dump_plat_mincpu_default = DUMP_PLAT_X86_64_MINCPU;
#else
uint_t dump_plat_mincpu_default = DUMP_PLAT_X86_32_MINCPU;
#endif
int
dump_plat_addr()
{
#ifdef __xpv
pfn_t pfn = mmu_btop(xen_info->shared_info) | PFN_IS_FOREIGN_MFN;
mem_vtop_t mem_vtop;
int cnt;
if (!IN_XPV_PANIC()) {
mem_vtop.m_as = &kas;
mem_vtop.m_va = HYPERVISOR_shared_info;
mem_vtop.m_pfn = pfn;
dumpvp_write(&mem_vtop, sizeof (mem_vtop_t));
cnt = 1;
} else {
cnt = dump_xpv_addr();
}
return (cnt);
#else
return (0);
#endif
}
void
dump_plat_pfn()
{
#ifdef __xpv
pfn_t pfn = mmu_btop(xen_info->shared_info) | PFN_IS_FOREIGN_MFN;
if (!IN_XPV_PANIC())
dumpvp_write(&pfn, sizeof (pfn));
else
dump_xpv_pfn();
#endif
}
int
dump_plat_data(void *dump_cbuf)
{
#ifdef __xpv
uint32_t csize;
int cnt;
if (!IN_XPV_PANIC()) {
csize = (uint32_t)compress(HYPERVISOR_shared_info, dump_cbuf,
PAGESIZE);
dumpvp_write(&csize, sizeof (uint32_t));
dumpvp_write(dump_cbuf, csize);
cnt = 1;
} else {
cnt = dump_xpv_data(dump_cbuf);
}
return (cnt);
#else
return (0);
#endif
}
int
linear_pc(struct regs *rp, proc_t *p, caddr_t *linearp)
{
user_desc_t *descrp;
caddr_t baseaddr;
uint16_t idx = SELTOIDX(rp->r_cs);
ASSERT(rp->r_cs <= 0xFFFF);
ASSERT(MUTEX_HELD(&p->p_ldtlock));
if (SELISLDT(rp->r_cs)) {
ASSERT(p->p_model != DATAMODEL_LP64);
if (p->p_ldt == NULL)
return (-1);
descrp = &p->p_ldt[idx];
baseaddr = (caddr_t)(uintptr_t)USEGD_GETBASE(descrp);
*linearp = (caddr_t)(uintptr_t)(uint32_t)((uintptr_t)baseaddr +
rp->r_pc);
} else {
#ifdef DEBUG
descrp = &CPU->cpu_gdt[idx];
baseaddr = (caddr_t)(uintptr_t)USEGD_GETBASE(descrp);
ASSERT(baseaddr == 0);
#endif
*linearp = (caddr_t)(uintptr_t)rp->r_pc;
}
return (0);
}
int
dtrace_linear_pc(struct regs *rp, proc_t *p, caddr_t *linearp)
{
user_desc_t *descrp;
caddr_t baseaddr;
uint16_t idx = SELTOIDX(rp->r_cs);
ASSERT(rp->r_cs <= 0xFFFF);
if (SELISLDT(rp->r_cs)) {
ASSERT(p->p_model != DATAMODEL_LP64);
mutex_enter(&p->p_ldtlock);
if (p->p_ldt == NULL) {
mutex_exit(&p->p_ldtlock);
return (-1);
}
descrp = &p->p_ldt[idx];
baseaddr = (caddr_t)(uintptr_t)USEGD_GETBASE(descrp);
mutex_exit(&p->p_ldtlock);
*linearp = (caddr_t)(uintptr_t)(uint32_t)((uintptr_t)baseaddr +
rp->r_pc);
} else {
#ifdef DEBUG
descrp = &CPU->cpu_gdt[idx];
baseaddr = (caddr_t)(uintptr_t)USEGD_GETBASE(descrp);
ASSERT(baseaddr == 0);
#endif
*linearp = (caddr_t)(uintptr_t)rp->r_pc;
}
return (0);
}
static ddi_softint_hdl_impl_t lbolt_softint_hdl =
{0, 0, NULL, NULL, 0, NULL, NULL, NULL};
void
lbolt_softint_add(void)
{
(void) add_avsoftintr((void *)&lbolt_softint_hdl, LOCK_LEVEL,
(avfunc)lbolt_ev_to_cyclic, "lbolt_ev_to_cyclic", NULL, NULL);
}
void
lbolt_softint_post(void)
{
(*setsoftint)(CBE_LOCK_PIL, lbolt_softint_hdl.ih_pending);
}
boolean_t
plat_dr_check_capability(uint64_t features)
{
return ((plat_dr_options & features) == features);
}
boolean_t
plat_dr_support_cpu(void)
{
return (plat_dr_options & PLAT_DR_FEATURE_CPU);
}
boolean_t
plat_dr_support_memory(void)
{
return (plat_dr_options & PLAT_DR_FEATURE_MEMORY);
}
void
plat_dr_enable_capability(uint64_t features)
{
atomic_or_64(&plat_dr_options, features);
}
void
plat_dr_disable_capability(uint64_t features)
{
atomic_and_64(&plat_dr_options, ~features);
}
void
hotinline_smap(hotinline_desc_t *hid)
{
if (is_x86_feature(x86_featureset, X86FSET_SMAP) == B_FALSE)
return;
if (strcmp(hid->hid_symname, "smap_enable") == 0) {
bcopy(clac_instr, (void *)hid->hid_instr_offset,
sizeof (clac_instr));
} else if (strcmp(hid->hid_symname, "smap_disable") == 0) {
bcopy(stac_instr, (void *)hid->hid_instr_offset,
sizeof (stac_instr));
}
}
void
do_hotinlines(struct module *mp)
{
for (hotinline_desc_t *hid = mp->hi_calls; hid != NULL;
hid = hid->hid_next) {
#if !defined(__xpv)
hotinline_smap(hid);
#endif
}
}