17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
5ee88d2bkchow * Common Development and Distribution License (the "License").
6ee88d2bkchow * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
21ae115bcmrj
227c478bdstevel@tonic-gate/*
237417cfdKuriakose Kuruvilla * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
24549e8c9Marcel Telka * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
25bf16b11Matthew Ahrens * Copyright (c) 2014 by Delphix. All rights reserved.
26a9cc46cRobert Mustacchi * Copyright 2019 Joyent, Inc.
277c478bdstevel@tonic-gate */
287c478bdstevel@tonic-gate
297c478bdstevel@tonic-gate/*
307c478bdstevel@tonic-gate *  Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.
317c478bdstevel@tonic-gate *  Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T
327c478bdstevel@tonic-gate *    All Rights Reserved
337c478bdstevel@tonic-gate */
347c478bdstevel@tonic-gate
357c478bdstevel@tonic-gate/*
367af88acKuriakose Kuruvilla * Copyright (c) 2009, Intel Corporation.
377af88acKuriakose Kuruvilla * All rights reserved.
387af88acKuriakose Kuruvilla */
397af88acKuriakose Kuruvilla
407af88acKuriakose Kuruvilla/*
417c478bdstevel@tonic-gate * General assembly language routines.
427c478bdstevel@tonic-gate * It is the intent of this file to contain routines that are
437c478bdstevel@tonic-gate * independent of the specific kernel architecture, and those that are
447c478bdstevel@tonic-gate * common across kernel architectures.
457c478bdstevel@tonic-gate * As architectures diverge, and implementations of specific
467c478bdstevel@tonic-gate * architecture-dependent routines change, the routines should be moved
477c478bdstevel@tonic-gate * from this file into the respective ../`arch -k`/subr.s file.
487c478bdstevel@tonic-gate */
497c478bdstevel@tonic-gate
507c478bdstevel@tonic-gate#include <sys/asm_linkage.h>
517c478bdstevel@tonic-gate#include <sys/asm_misc.h>
527c478bdstevel@tonic-gate#include <sys/panic.h>
537c478bdstevel@tonic-gate#include <sys/ontrap.h>
547c478bdstevel@tonic-gate#include <sys/regset.h>
557c478bdstevel@tonic-gate#include <sys/privregs.h>
567c478bdstevel@tonic-gate#include <sys/reboot.h>
577c478bdstevel@tonic-gate#include <sys/psw.h>
587c478bdstevel@tonic-gate#include <sys/x86_archext.h>
597c478bdstevel@tonic-gate
607c478bdstevel@tonic-gate#if defined(__lint)
617c478bdstevel@tonic-gate#include <sys/types.h>
627c478bdstevel@tonic-gate#include <sys/systm.h>
637c478bdstevel@tonic-gate#include <sys/thread.h>
647c478bdstevel@tonic-gate#include <sys/archsystm.h>
657c478bdstevel@tonic-gate#include <sys/byteorder.h>
667c478bdstevel@tonic-gate#include <sys/dtrace.h>
674df4bd6bs#include <sys/ftrace.h>
687c478bdstevel@tonic-gate#else	/* __lint */
697c478bdstevel@tonic-gate#include "assym.h"
707c478bdstevel@tonic-gate#endif	/* __lint */
717c478bdstevel@tonic-gate#include <sys/dditypes.h>
727c478bdstevel@tonic-gate
737c478bdstevel@tonic-gate/*
747c478bdstevel@tonic-gate * on_fault()
753ce2fcdRobert Mustacchi *
767c478bdstevel@tonic-gate * Catch lofault faults. Like setjmp except it returns one
777c478bdstevel@tonic-gate * if code following causes uncorrectable fault. Turned off
783ce2fcdRobert Mustacchi * by calling no_fault(). Note that while under on_fault(),
793ce2fcdRobert Mustacchi * SMAP is disabled. For more information see
803ce2fcdRobert Mustacchi * uts/intel/ia32/ml/copy.s.
817c478bdstevel@tonic-gate */
827c478bdstevel@tonic-gate
837c478bdstevel@tonic-gate#if defined(__lint)
847c478bdstevel@tonic-gate
857c478bdstevel@tonic-gate/* ARGSUSED */
867c478bdstevel@tonic-gateint
877c478bdstevel@tonic-gateon_fault(label_t *ljb)
887c478bdstevel@tonic-gate{ return (0); }
897c478bdstevel@tonic-gate
907c478bdstevel@tonic-gatevoid
917c478bdstevel@tonic-gateno_fault(void)
927c478bdstevel@tonic-gate{}
937c478bdstevel@tonic-gate
947c478bdstevel@tonic-gate#else	/* __lint */
957c478bdstevel@tonic-gate
967c478bdstevel@tonic-gate#if defined(__amd64)
977c478bdstevel@tonic-gate
987c478bdstevel@tonic-gate	ENTRY(on_fault)
997c478bdstevel@tonic-gate	movq	%gs:CPU_THREAD, %rsi
1007c478bdstevel@tonic-gate	leaq	catch_fault(%rip), %rdx
1017c478bdstevel@tonic-gate	movq	%rdi, T_ONFAULT(%rsi)		/* jumpbuf in t_onfault */
1027c478bdstevel@tonic-gate	movq	%rdx, T_LOFAULT(%rsi)		/* catch_fault in t_lofault */
1033ce2fcdRobert Mustacchi	call	smap_disable			/* allow user accesses */
1047c478bdstevel@tonic-gate	jmp	setjmp				/* let setjmp do the rest */
1057c478bdstevel@tonic-gate
1067c478bdstevel@tonic-gatecatch_fault:
1077c478bdstevel@tonic-gate	movq	%gs:CPU_THREAD, %rsi
1087c478bdstevel@tonic-gate	movq	T_ONFAULT(%rsi), %rdi		/* address of save area */
1097c478bdstevel@tonic-gate	xorl	%eax, %eax
1107c478bdstevel@tonic-gate	movq	%rax, T_ONFAULT(%rsi)		/* turn off onfault */
1117c478bdstevel@tonic-gate	movq	%rax, T_LOFAULT(%rsi)		/* turn off lofault */
1123ce2fcdRobert Mustacchi	call	smap_enable			/* disallow user accesses */
1137c478bdstevel@tonic-gate	jmp	longjmp				/* let longjmp do the rest */
1147c478bdstevel@tonic-gate	SET_SIZE(on_fault)
1157c478bdstevel@tonic-gate
1167c478bdstevel@tonic-gate	ENTRY(no_fault)
1177c478bdstevel@tonic-gate	movq	%gs:CPU_THREAD, %rsi
1187c478bdstevel@tonic-gate	xorl	%eax, %eax
1197c478bdstevel@tonic-gate	movq	%rax, T_ONFAULT(%rsi)		/* turn off onfault */
1207c478bdstevel@tonic-gate	movq	%rax, T_LOFAULT(%rsi)		/* turn off lofault */
1213ce2fcdRobert Mustacchi	call	smap_enable			/* disallow user accesses */
1227c478bdstevel@tonic-gate	ret
1237c478bdstevel@tonic-gate	SET_SIZE(no_fault)
1247c478bdstevel@tonic-gate
1257c478bdstevel@tonic-gate#elif defined(__i386)
1264b56a00Daniel Anderson
1277c478bdstevel@tonic-gate	ENTRY(on_fault)
1287c478bdstevel@tonic-gate	movl	%gs:CPU_THREAD, %edx
1297c478bdstevel@tonic-gate	movl	4(%esp), %eax			/* jumpbuf address */
1307c478bdstevel@tonic-gate	leal	catch_fault, %ecx
1317c478bdstevel@tonic-gate	movl	%eax, T_ONFAULT(%edx)		/* jumpbuf in t_onfault */
1327c478bdstevel@tonic-gate	movl	%ecx, T_LOFAULT(%edx)		/* catch_fault in t_lofault */
1337c478bdstevel@tonic-gate	jmp	setjmp				/* let setjmp do the rest */
1347c478bdstevel@tonic-gate
1357c478bdstevel@tonic-gatecatch_fault:
1367c478bdstevel@tonic-gate	movl	%gs:CPU_THREAD, %edx
1377c478bdstevel@tonic-gate	xorl	%eax, %eax
1387c478bdstevel@tonic-gate	movl	T_ONFAULT(%edx), %ecx		/* address of save area */
1397c478bdstevel@tonic-gate	movl	%eax, T_ONFAULT(%edx)		/* turn off onfault */
1407c478bdstevel@tonic-gate	movl	%eax, T_LOFAULT(%edx)		/* turn off lofault */
1417c478bdstevel@tonic-gate	pushl	%ecx
1427c478bdstevel@tonic-gate	call	longjmp				/* let longjmp do the rest */
1437c478bdstevel@tonic-gate	SET_SIZE(on_fault)
1447c478bdstevel@tonic-gate
1457c478bdstevel@tonic-gate	ENTRY(no_fault)
1467c478bdstevel@tonic-gate	movl	%gs:CPU_THREAD, %edx
1477c478bdstevel@tonic-gate	xorl	%eax, %eax
1487c478bdstevel@tonic-gate	movl	%eax, T_ONFAULT(%edx)		/* turn off onfault */
1497c478bdstevel@tonic-gate	movl	%eax, T_LOFAULT(%edx)		/* turn off lofault */
1507c478bdstevel@tonic-gate	ret
1517c478bdstevel@tonic-gate	SET_SIZE(no_fault)
1527c478bdstevel@tonic-gate
1537c478bdstevel@tonic-gate#endif	/* __i386 */
1547c478bdstevel@tonic-gate#endif	/* __lint */
1557c478bdstevel@tonic-gate
1567c478bdstevel@tonic-gate/*
1577c478bdstevel@tonic-gate * Default trampoline code for on_trap() (see <sys/ontrap.h>).  We just
1587c478bdstevel@tonic-gate * do a longjmp(&curthread->t_ontrap->ot_jmpbuf) if this is ever called.
1597c478bdstevel@tonic-gate */
1607c478bdstevel@tonic-gate
1617c478bdstevel@tonic-gate#if defined(lint)
1627c478bdstevel@tonic-gate
1637c478bdstevel@tonic-gatevoid
1647c478bdstevel@tonic-gateon_trap_trampoline(void)
1657c478bdstevel@tonic-gate{}
1667c478bdstevel@tonic-gate
1677c478bdstevel@tonic-gate#else	/* __lint */
1687c478bdstevel@tonic-gate
1697c478bdstevel@tonic-gate#if defined(__amd64)
1707c478bdstevel@tonic-gate
1717c478bdstevel@tonic-gate	ENTRY(on_trap_trampoline)
1727c478bdstevel@tonic-gate	movq	%gs:CPU_THREAD, %rsi
1737c478bdstevel@tonic-gate	movq	T_ONTRAP(%rsi), %rdi
1747c478bdstevel@tonic-gate	addq	$OT_JMPBUF, %rdi
1757c478bdstevel@tonic-gate	jmp	longjmp
1767c478bdstevel@tonic-gate	SET_SIZE(on_trap_trampoline)
1777c478bdstevel@tonic-gate
1787c478bdstevel@tonic-gate#elif defined(__i386)
1797c478bdstevel@tonic-gate
1807c478bdstevel@tonic-gate	ENTRY(on_trap_trampoline)
1817c478bdstevel@tonic-gate	movl	%gs:CPU_THREAD, %eax
1827c478bdstevel@tonic-gate	movl	T_ONTRAP(%eax), %eax
1837c478bdstevel@tonic-gate	addl	$OT_JMPBUF, %eax
1847c478bdstevel@tonic-gate	pushl	%eax
1857c478bdstevel@tonic-gate	call	longjmp
1867c478bdstevel@tonic-gate	SET_SIZE(on_trap_trampoline)
1877c478bdstevel@tonic-gate
1887c478bdstevel@tonic-gate#endif	/* __i386 */
1897c478bdstevel@tonic-gate#endif	/* __lint */
1907c478bdstevel@tonic-gate
1917c478bdstevel@tonic-gate/*
1927c478bdstevel@tonic-gate * Push a new element on to the t_ontrap stack.  Refer to <sys/ontrap.h> for
1937c478bdstevel@tonic-gate * more information about the on_trap() mechanism.  If the on_trap_data is the
1947c478bdstevel@tonic-gate * same as the topmost stack element, we just modify that element.
1957c478bdstevel@tonic-gate */
1967c478bdstevel@tonic-gate#if defined(lint)
1977c478bdstevel@tonic-gate
1987c478bdstevel@tonic-gate/*ARGSUSED*/
1997c478bdstevel@tonic-gateint
2007c478bdstevel@tonic-gateon_trap(on_trap_data_t *otp, uint_t prot)
2017c478bdstevel@tonic-gate{ return (0); }
2027c478bdstevel@tonic-gate
2037c478bdstevel@tonic-gate#else	/* __lint */
2047c478bdstevel@tonic-gate
2057c478bdstevel@tonic-gate#if defined(__amd64)
2067c478bdstevel@tonic-gate
2077c478bdstevel@tonic-gate	ENTRY(on_trap)
2087c478bdstevel@tonic-gate	movw	%si, OT_PROT(%rdi)		/* ot_prot = prot */
2097c478bdstevel@tonic-gate	movw	$0, OT_TRAP(%rdi)		/* ot_trap = 0 */
2107c478bdstevel@tonic-gate	leaq	on_trap_trampoline(%rip), %rdx	/* rdx = &on_trap_trampoline */
2117c478bdstevel@tonic-gate	movq	%rdx, OT_TRAMPOLINE(%rdi)	/* ot_trampoline = rdx */
2127c478bdstevel@tonic-gate	xorl	%ecx, %ecx
2137c478bdstevel@tonic-gate	movq	%rcx, OT_HANDLE(%rdi)		/* ot_handle = NULL */
2147c478bdstevel@tonic-gate	movq	%rcx, OT_PAD1(%rdi)		/* ot_pad1 = NULL */
2157c478bdstevel@tonic-gate	movq	%gs:CPU_THREAD, %rdx		/* rdx = curthread */
2167c478bdstevel@tonic-gate	movq	T_ONTRAP(%rdx), %rcx		/* rcx = curthread->t_ontrap */
2177c478bdstevel@tonic-gate	cmpq	%rdi, %rcx			/* if (otp == %rcx)	*/
2187c478bdstevel@tonic-gate	je	0f				/*	don't modify t_ontrap */
2197c478bdstevel@tonic-gate
2207c478bdstevel@tonic-gate	movq	%rcx, OT_PREV(%rdi)		/* ot_prev = t_ontrap */
2217c478bdstevel@tonic-gate	movq	%rdi, T_ONTRAP(%rdx)		/* curthread->t_ontrap = otp */
2227c478bdstevel@tonic-gate
2237c478bdstevel@tonic-gate0:	addq	$OT_JMPBUF, %rdi		/* &ot_jmpbuf */
2247c478bdstevel@tonic-gate	jmp	setjmp
2257c478bdstevel@tonic-gate	SET_SIZE(on_trap)
2267c478bdstevel@tonic-gate
2277c478bdstevel@tonic-gate#elif defined(__i386)
2287c478bdstevel@tonic-gate
2297c478bdstevel@tonic-gate	ENTRY(on_trap)
2307c478bdstevel@tonic-gate	movl	4(%esp), %eax			/* %eax = otp */
2317c478bdstevel@tonic-gate	movl	8(%esp), %edx			/* %edx = prot */
2327c478bdstevel@tonic-gate
2337c478bdstevel@tonic-gate	movw	%dx, OT_PROT(%eax)		/* ot_prot = prot */
2347c478bdstevel@tonic-gate	movw	$0, OT_TRAP(%eax)		/* ot_trap = 0 */
2357c478bdstevel@tonic-gate	leal	on_trap_trampoline, %edx	/* %edx = &on_trap_trampoline */
2367c478bdstevel@tonic-gate	movl	%edx, OT_TRAMPOLINE(%eax)	/* ot_trampoline = %edx */
2377c478bdstevel@tonic-gate	movl	$0, OT_HANDLE(%eax)		/* ot_handle = NULL */
2387c478bdstevel@tonic-gate	movl	$0, OT_PAD1(%eax)		/* ot_pad1 = NULL */
2397c478bdstevel@tonic-gate	movl	%gs:CPU_THREAD, %edx		/* %edx = curthread */
2407c478bdstevel@tonic-gate	movl	T_ONTRAP(%edx), %ecx		/* %ecx = curthread->t_ontrap */
2417c478bdstevel@tonic-gate	cmpl	%eax, %ecx			/* if (otp == %ecx) */
2427c478bdstevel@tonic-gate	je	0f				/*    don't modify t_ontrap */
2437c478bdstevel@tonic-gate
2447c478bdstevel@tonic-gate	movl	%ecx, OT_PREV(%eax)		/* ot_prev = t_ontrap */
2457c478bdstevel@tonic-gate	movl	%eax, T_ONTRAP(%edx)		/* curthread->t_ontrap = otp */
2467c478bdstevel@tonic-gate
2477c478bdstevel@tonic-gate0:	addl	$OT_JMPBUF, %eax		/* %eax = &ot_jmpbuf */
2487c478bdstevel@tonic-gate	movl	%eax, 4(%esp)			/* put %eax back on the stack */
2497c478bdstevel@tonic-gate	jmp	setjmp				/* let setjmp do the rest */
2507c478bdstevel@tonic-gate	SET_SIZE(on_trap)
2517c478bdstevel@tonic-gate
2527c478bdstevel@tonic-gate#endif	/* __i386 */
2537c478bdstevel@tonic-gate#endif	/* __lint */
2547c478bdstevel@tonic-gate
2557c478bdstevel@tonic-gate/*
2567c478bdstevel@tonic-gate * Setjmp and longjmp implement non-local gotos using state vectors
2577c478bdstevel@tonic-gate * type label_t.
2587c478bdstevel@tonic-gate */
2597c478bdstevel@tonic-gate
2607c478bdstevel@tonic-gate#if defined(__lint)
2617c478bdstevel@tonic-gate
2627c478bdstevel@tonic-gate/* ARGSUSED */
2637c478bdstevel@tonic-gateint
2647c478bdstevel@tonic-gatesetjmp(label_t *lp)
2657c478bdstevel@tonic-gate{ return (0); }
2667c478bdstevel@tonic-gate
2677c478bdstevel@tonic-gate/* ARGSUSED */
2687c478bdstevel@tonic-gatevoid
2697c478bdstevel@tonic-gatelongjmp(label_t *lp)
2707c478bdstevel@tonic-gate{}
2717c478bdstevel@tonic-gate
2727c478bdstevel@tonic-gate#else	/* __lint */
2737c478bdstevel@tonic-gate
2747c478bdstevel@tonic-gate#if LABEL_PC != 0
2757c478bdstevel@tonic-gate#error LABEL_PC MUST be defined as 0 for setjmp/longjmp to work as coded
2767c478bdstevel@tonic-gate#endif	/* LABEL_PC != 0 */
2777c478bdstevel@tonic-gate
2787c478bdstevel@tonic-gate#if defined(__amd64)
2797c478bdstevel@tonic-gate
2807c478bdstevel@tonic-gate	ENTRY(setjmp)
2817c478bdstevel@tonic-gate	movq	%rsp, LABEL_SP(%rdi)
2827c478bdstevel@tonic-gate	movq	%rbp, LABEL_RBP(%rdi)
2837c478bdstevel@tonic-gate	movq	%rbx, LABEL_RBX(%rdi)
2847c478bdstevel@tonic-gate	movq	%r12, LABEL_R12(%rdi)
2857c478bdstevel@tonic-gate	movq	%r13, LABEL_R13(%rdi)
2867c478bdstevel@tonic-gate	movq	%r14, LABEL_R14(%rdi)
2877c478bdstevel@tonic-gate	movq	%r15, LABEL_R15(%rdi)
2887c478bdstevel@tonic-gate	movq	(%rsp), %rdx		/* return address */
2897c478bdstevel@tonic-gate	movq	%rdx, (%rdi)		/* LABEL_PC is 0 */
2907c478bdstevel@tonic-gate	xorl	%eax, %eax		/* return 0 */
2917c478bdstevel@tonic-gate	ret
2927c478bdstevel@tonic-gate	SET_SIZE(setjmp)
2937c478bdstevel@tonic-gate
2947c478bdstevel@tonic-gate	ENTRY(longjmp)
2957c478bdstevel@tonic-gate	movq	LABEL_SP(%rdi), %rsp
2967c478bdstevel@tonic-gate	movq	LABEL_RBP(%rdi), %rbp
2977c478bdstevel@tonic-gate	movq	LABEL_RBX(%rdi), %rbx
2987c478bdstevel@tonic-gate	movq	LABEL_R12(%rdi), %r12
2997c478bdstevel@tonic-gate	movq	LABEL_R13(%rdi), %r13
3007c478bdstevel@tonic-gate	movq	LABEL_R14(%rdi), %r14
3017c478bdstevel@tonic-gate	movq	LABEL_R15(%rdi), %r15
3027c478bdstevel@tonic-gate	movq	(%rdi), %rdx		/* return address; LABEL_PC is 0 */
3037c478bdstevel@tonic-gate	movq	%rdx, (%rsp)
3047c478bdstevel@tonic-gate	xorl	%eax, %eax
3057c478bdstevel@tonic-gate	incl	%eax			/* return 1 */
3067c478bdstevel@tonic-gate	ret
3077c478bdstevel@tonic-gate	SET_SIZE(longjmp)
3087c478bdstevel@tonic-gate
3097c478bdstevel@tonic-gate#elif defined(__i386)
3107c478bdstevel@tonic-gate
3117c478bdstevel@tonic-gate	ENTRY(setjmp)
3127c478bdstevel@tonic-gate	movl	4(%esp), %edx		/* address of save area */
3137c478bdstevel@tonic-gate	movl	%ebp, LABEL_EBP(%edx)
3147c478bdstevel@tonic-gate	movl	%ebx, LABEL_EBX(%edx)
3157c478bdstevel@tonic-gate	movl	%esi, LABEL_ESI(%edx)
3167c478bdstevel@tonic-gate	movl	%edi, LABEL_EDI(%edx)
3177c478bdstevel@tonic-gate	movl	%esp, 4(%edx)
3187c478bdstevel@tonic-gate	movl	(%esp), %ecx		/* %eip (return address) */
3197c478bdstevel@tonic-gate	movl	%ecx, (%edx)		/* LABEL_PC is 0 */
3207c478bdstevel@tonic-gate	subl	%eax, %eax		/* return 0 */
3217c478bdstevel@tonic-gate	ret
3227c478bdstevel@tonic-gate	SET_SIZE(setjmp)
3237c478bdstevel@tonic-gate
3247c478bdstevel@tonic-gate	ENTRY(longjmp)
3257c478bdstevel@tonic-gate	movl	4(%esp), %edx		/* address of save area */
3267c478bdstevel@tonic-gate	movl	LABEL_EBP(%edx), %ebp
3277c478bdstevel@tonic-gate	movl	LABEL_EBX(%edx), %ebx
3287c478bdstevel@tonic-gate	movl	LABEL_ESI(%edx), %esi
3297c478bdstevel@tonic-gate	movl	LABEL_EDI(%edx), %edi
3307c478bdstevel@tonic-gate	movl	4(%edx), %esp
3317c478bdstevel@tonic-gate	movl	(%edx), %ecx		/* %eip (return addr); LABEL_PC is 0 */
3327c478bdstevel@tonic-gate	movl	$1, %eax
3337c478bdstevel@tonic-gate	addl	$4, %esp		/* pop ret adr */
3347c478bdstevel@tonic-gate	jmp	*%ecx			/* indirect */
3357c478bdstevel@tonic-gate	SET_SIZE(longjmp)
3367c478bdstevel@tonic-gate
3377c478bdstevel@tonic-gate#endif	/* __i386 */
3387c478bdstevel@tonic-gate#endif	/* __lint */
3397c478bdstevel@tonic-gate
3407c478bdstevel@tonic-gate/*
3417c478bdstevel@tonic-gate * if a() calls b() calls caller(),
3427c478bdstevel@tonic-gate * caller() returns return address in a().
3437c478bdstevel@tonic-gate * (Note: We assume a() and b() are C routines which do the normal entry/exit
3447c478bdstevel@tonic-gate *  sequence.)
3457c478bdstevel@tonic-gate */
3467c478bdstevel@tonic-gate
3477c478bdstevel@tonic-gate#if defined(__lint)
3487c478bdstevel@tonic-gate
3497c478bdstevel@tonic-gatecaddr_t
3507c478bdstevel@tonic-gatecaller(void)
3517c478bdstevel@tonic-gate{ return (0); }
3527c478bdstevel@tonic-gate
3537c478bdstevel@tonic-gate#else	/* __lint */
3547c478bdstevel@tonic-gate
3557c478bdstevel@tonic-gate#if defined(__amd64)
3567c478bdstevel@tonic-gate
3577c478bdstevel@tonic-gate	ENTRY(caller)
3587c478bdstevel@tonic-gate	movq	8(%rbp), %rax		/* b()'s return pc, in a() */
3597c478bdstevel@tonic-gate	ret
3607c478bdstevel@tonic-gate	SET_SIZE(caller)
3617c478bdstevel@tonic-gate
3627c478bdstevel@tonic-gate#elif defined(__i386)
3637c478bdstevel@tonic-gate
3647c478bdstevel@tonic-gate	ENTRY(caller)
3657c478bdstevel@tonic-gate	movl	4(%ebp), %eax		/* b()'s return pc, in a() */
3667c478bdstevel@tonic-gate	ret
3677c478bdstevel@tonic-gate	SET_SIZE(caller)
3687c478bdstevel@tonic-gate
3697c478bdstevel@tonic-gate#endif	/* __i386 */
3707c478bdstevel@tonic-gate#endif	/* __lint */
3717c478bdstevel@tonic-gate
3727c478bdstevel@tonic-gate/*
3737c478bdstevel@tonic-gate * if a() calls callee(), callee() returns the
3747c478bdstevel@tonic-gate * return address in a();
3757c478bdstevel@tonic-gate */
3767c478bdstevel@tonic-gate
3777c478bdstevel@tonic-gate#if defined(__lint)
3787c478bdstevel@tonic-gate
3797c478bdstevel@tonic-gatecaddr_t
3807c478bdstevel@tonic-gatecallee(void)
3817c478bdstevel@tonic-gate{ return (0); }
3827c478bdstevel@tonic-gate
3837c478bdstevel@tonic-gate#else	/* __lint */
3847c478bdstevel@tonic-gate
3857c478bdstevel@tonic-gate#if defined(__amd64)
3867c478bdstevel@tonic-gate
3877c478bdstevel@tonic-gate	ENTRY(callee)
3887c478bdstevel@tonic-gate	movq	(%rsp), %rax		/* callee()'s return pc, in a() */
3897c478bdstevel@tonic-gate	ret
3907c478bdstevel@tonic-gate	SET_SIZE(callee)
3917c478bdstevel@tonic-gate
3927c478bdstevel@tonic-gate#elif defined(__i386)
3937c478bdstevel@tonic-gate
3947c478bdstevel@tonic-gate	ENTRY(callee)
3957c478bdstevel@tonic-gate	movl	(%esp), %eax		/* callee()'s return pc, in a() */
3967c478bdstevel@tonic-gate	ret
3977c478bdstevel@tonic-gate	SET_SIZE(callee)
3987c478bdstevel@tonic-gate
3997c478bdstevel@tonic-gate#endif	/* __i386 */
4007c478bdstevel@tonic-gate#endif	/* __lint */
4017c478bdstevel@tonic-gate
4027c478bdstevel@tonic-gate/*
4037c478bdstevel@tonic-gate * return the current frame pointer
4047c478bdstevel@tonic-gate */
4057c478bdstevel@tonic-gate
4067c478bdstevel@tonic-gate#if defined(__lint)
4077c478bdstevel@tonic-gate
4087c478bdstevel@tonic-gategreg_t
4097c478bdstevel@tonic-gategetfp(void)
4107c478bdstevel@tonic-gate{ return (0); }
4117c478bdstevel@tonic-gate
4127c478bdstevel@tonic-gate#else	/* __lint */
4137c478bdstevel@tonic-gate
4147c478bdstevel@tonic-gate#if defined(__amd64)
4157c478bdstevel@tonic-gate
4167c478bdstevel@tonic-gate	ENTRY(getfp)
4177c478bdstevel@tonic-gate	movq	%rbp, %rax
4187c478bdstevel@tonic-gate	ret
4197c478bdstevel@tonic-gate	SET_SIZE(getfp)
4207c478bdstevel@tonic-gate
4217c478bdstevel@tonic-gate#elif defined(__i386)
4227c478bdstevel@tonic-gate
4237c478bdstevel@tonic-gate	ENTRY(getfp)
4247c478bdstevel@tonic-gate	movl	%ebp, %eax
4257c478bdstevel@tonic-gate	ret
4267c478bdstevel@tonic-gate	SET_SIZE(getfp)
4277c478bdstevel@tonic-gate
4287c478bdstevel@tonic-gate#endif	/* __i386 */
4297c478bdstevel@tonic-gate#endif	/* __lint */
4307c478bdstevel@tonic-gate
4317c478bdstevel@tonic-gate/*
4327c478bdstevel@tonic-gate * Invalidate a single page table entry in the TLB
4337c478bdstevel@tonic-gate */
4347c478bdstevel@tonic-gate
4357c478bdstevel@tonic-gate#if defined(__lint)
4367c478bdstevel@tonic-gate
4377c478bdstevel@tonic-gate/* ARGSUSED */
4387c478bdstevel@tonic-gatevoid
43974ecdb5John Levonmmu_invlpg(caddr_t m)
4407c478bdstevel@tonic-gate{}
4417c478bdstevel@tonic-gate
4427c478bdstevel@tonic-gate#else	/* __lint */
4437c478bdstevel@tonic-gate
44474ecdb5John Levon	ENTRY(mmu_invlpg)
4457c478bdstevel@tonic-gate	invlpg	(%rdi)
4467c478bdstevel@tonic-gate	ret
44774ecdb5John Levon	SET_SIZE(mmu_invlpg)
4487c478bdstevel@tonic-gate
4497c478bdstevel@tonic-gate#endif	/* __lint */
4507c478bdstevel@tonic-gate
4517c478bdstevel@tonic-gate
4527c478bdstevel@tonic-gate/*
4537c478bdstevel@tonic-gate * Get/Set the value of various control registers
4547c478bdstevel@tonic-gate */
4557c478bdstevel@tonic-gate
4567c478bdstevel@tonic-gate#if defined(__lint)
4577c478bdstevel@tonic-gate
4587c478bdstevel@tonic-gateulong_t
4597c478bdstevel@tonic-gategetcr0(void)
4607c478bdstevel@tonic-gate{ return (0); }
4617c478bdstevel@tonic-gate
4627c478bdstevel@tonic-gate/* ARGSUSED */
4637c478bdstevel@tonic-gatevoid
4647c478bdstevel@tonic-gatesetcr0(ulong_t value)
4657c478bdstevel@tonic-gate{}
4667c478bdstevel@tonic-gate
4677c478bdstevel@tonic-gateulong_t
4687c478bdstevel@tonic-gategetcr2(void)
4697c478bdstevel@tonic-gate{ return (0); }
4707c478bdstevel@tonic-gate
4717c478bdstevel@tonic-gateulong_t
4727c478bdstevel@tonic-gategetcr3(void)
4737c478bdstevel@tonic-gate{ return (0); }
4747c478bdstevel@tonic-gate
475843e198johnlev#if !defined(__xpv)
4767c478bdstevel@tonic-gate/* ARGSUSED */
4777c478bdstevel@tonic-gatevoid
4787c478bdstevel@tonic-gatesetcr3(ulong_t val)
4797c478bdstevel@tonic-gate{}
4807c478bdstevel@tonic-gate
4817c478bdstevel@tonic-gatevoid
4827c478bdstevel@tonic-gatereload_cr3(void)
4837c478bdstevel@tonic-gate{}
484843e198johnlev#endif
4857c478bdstevel@tonic-gate
4867c478bdstevel@tonic-gateulong_t
4877c478bdstevel@tonic-gategetcr4(void)
4887c478bdstevel@tonic-gate{ return (0); }
4897c478bdstevel@tonic-gate
4907c478bdstevel@tonic-gate/* ARGSUSED */
4917c478bdstevel@tonic-gatevoid
4927c478bdstevel@tonic-gatesetcr4(ulong_t val)
4937c478bdstevel@tonic-gate{}
4947c478bdstevel@tonic-gate
4957c478bdstevel@tonic-gate#if defined(__amd64)
4967c478bdstevel@tonic-gate
4977c478bdstevel@tonic-gateulong_t
4987c478bdstevel@tonic-gategetcr8(void)
4997c478bdstevel@tonic-gate{ return (0); }
5007c478bdstevel@tonic-gate
5017c478bdstevel@tonic-gate/* ARGSUSED */
5027c478bdstevel@tonic-gatevoid
5037c478bdstevel@tonic-gatesetcr8(ulong_t val)
5047c478bdstevel@tonic-gate{}
5057c478bdstevel@tonic-gate
5067c478bdstevel@tonic-gate#endif	/* __amd64 */
5077c478bdstevel@tonic-gate
5087c478bdstevel@tonic-gate#else	/* __lint */
5097c478bdstevel@tonic-gate
5107c478bdstevel@tonic-gate#if defined(__amd64)
5117c478bdstevel@tonic-gate
5127c478bdstevel@tonic-gate	ENTRY(getcr0)
5137c478bdstevel@tonic-gate	movq	%cr0, %rax
5147c478bdstevel@tonic-gate	ret
5157c478bdstevel@tonic-gate	SET_SIZE(getcr0)
5167c478bdstevel@tonic-gate
5177c478bdstevel@tonic-gate	ENTRY(setcr0)
5187c478bdstevel@tonic-gate	movq	%rdi, %cr0
5197c478bdstevel@tonic-gate	ret
5207c478bdstevel@tonic-gate	SET_SIZE(setcr0)
5217c478bdstevel@tonic-gate
522ae115bcmrj        ENTRY(getcr2)
523843e198johnlev#if defined(__xpv)
524843e198johnlev	movq	%gs:CPU_VCPU_INFO, %rax
525843e198johnlev	movq	VCPU_INFO_ARCH_CR2(%rax), %rax
526843e198johnlev#else
527ae115bcmrj        movq    %cr2, %rax
528843e198johnlev#endif
529ae115bcmrj        ret
5307c478bdstevel@tonic-gate	SET_SIZE(getcr2)
5317c478bdstevel@tonic-gate
5327c478bdstevel@tonic-gate	ENTRY(getcr3)
533ae115bcmrj	movq    %cr3, %rax
5347c478bdstevel@tonic-gate	ret
5357c478bdstevel@tonic-gate	SET_SIZE(getcr3)
5367c478bdstevel@tonic-gate
537843e198johnlev#if !defined(__xpv)
538843e198johnlev
539ae115bcmrj        ENTRY(setcr3)
540ae115bcmrj        movq    %rdi, %cr3
541ae115bcmrj        ret
5427c478bdstevel@tonic-gate	SET_SIZE(setcr3)
5437c478bdstevel@tonic-gate
5447c478bdstevel@tonic-gate	ENTRY(reload_cr3)
5457c478bdstevel@tonic-gate	movq	%cr3, %rdi
5467c478bdstevel@tonic-gate	movq	%rdi, %cr3
5477c478bdstevel@tonic-gate	ret
5487c478bdstevel@tonic-gate	SET_SIZE(reload_cr3)
5497c478bdstevel@tonic-gate
550843e198johnlev#endif	/* __xpv */
551843e198johnlev
5527c478bdstevel@tonic-gate	ENTRY(getcr4)
5537c478bdstevel@tonic-gate	movq	%cr4, %rax
5547c478bdstevel@tonic-gate	ret
5557c478bdstevel@tonic-gate	SET_SIZE(getcr4)
5567c478bdstevel@tonic-gate
5577c478bdstevel@tonic-gate	ENTRY(setcr4)
5587c478bdstevel@tonic-gate	movq	%rdi, %cr4
5597c478bdstevel@tonic-gate	ret
5607c478bdstevel@tonic-gate	SET_SIZE(setcr4)
5617c478bdstevel@tonic-gate
5627c478bdstevel@tonic-gate	ENTRY(getcr8)
5637c478bdstevel@tonic-gate	movq	%cr8, %rax
5647c478bdstevel@tonic-gate	ret
5657c478bdstevel@tonic-gate	SET_SIZE(getcr8)
5667c478bdstevel@tonic-gate
5677c478bdstevel@tonic-gate	ENTRY(setcr8)
5687c478bdstevel@tonic-gate	movq	%rdi, %cr8
5697c478bdstevel@tonic-gate	ret
5707c478bdstevel@tonic-gate	SET_SIZE(setcr8)
5717c478bdstevel@tonic-gate
5727c478bdstevel@tonic-gate#elif defined(__i386)
5737c478bdstevel@tonic-gate
5747c478bdstevel@tonic-gate        ENTRY(getcr0)
5757c478bdstevel@tonic-gate        movl    %cr0, %eax
5767c478bdstevel@tonic-gate        ret
5777c478bdstevel@tonic-gate	SET_SIZE(getcr0)
5787c478bdstevel@tonic-gate
5797c478bdstevel@tonic-gate        ENTRY(setcr0)
5807c478bdstevel@tonic-gate        movl    4(%esp), %eax
5817c478bdstevel@tonic-gate        movl    %eax, %cr0
5827c478bdstevel@tonic-gate        ret
5837c478bdstevel@tonic-gate	SET_SIZE(setcr0)
5847c478bdstevel@tonic-gate
5852ef50f0Joe Bonasera	/*
5862ef50f0Joe Bonasera	 * "lock mov %cr0" is used on processors which indicate it is
5872ef50f0Joe Bonasera	 * supported via CPUID. Normally the 32 bit TPR is accessed via
5882ef50f0Joe Bonasera	 * the local APIC.
5892ef50f0Joe Bonasera	 */
5902ef50f0Joe Bonasera	ENTRY(getcr8)
5912ef50f0Joe Bonasera	lock
5922ef50f0Joe Bonasera	movl	%cr0, %eax
5932ef50f0Joe Bonasera	ret
5942ef50f0Joe Bonasera	SET_SIZE(getcr8)
5952ef50f0Joe Bonasera
5962ef50f0Joe Bonasera	ENTRY(setcr8)
5972ef50f0Joe Bonasera        movl    4(%esp), %eax
5982ef50f0Joe Bonasera	lock
5992ef50f0Joe Bonasera        movl    %eax, %cr0
6002ef50f0Joe Bonasera	ret
6012ef50f0Joe Bonasera	SET_SIZE(setcr8)
6022ef50f0Joe Bonasera
6037c478bdstevel@tonic-gate        ENTRY(getcr2)
604843e198johnlev#if defined(__xpv)
605843e198johnlev	movl	%gs:CPU_VCPU_INFO, %eax
606843e198johnlev	movl	VCPU_INFO_ARCH_CR2(%eax), %eax
607843e198johnlev#else
6087c478bdstevel@tonic-gate        movl    %cr2, %eax
609843e198johnlev#endif
6107c478bdstevel@tonic-gate        ret
6117c478bdstevel@tonic-gate	SET_SIZE(getcr2)
6127c478bdstevel@tonic-gate
6137c478bdstevel@tonic-gate	ENTRY(getcr3)
6147c478bdstevel@tonic-gate	movl    %cr3, %eax
6157c478bdstevel@tonic-gate	ret
6167c478bdstevel@tonic-gate	SET_SIZE(getcr3)
6177c478bdstevel@tonic-gate
618843e198johnlev#if !defined(__xpv)
619843e198johnlev
6207c478bdstevel@tonic-gate        ENTRY(setcr3)
6217c478bdstevel@tonic-gate        movl    4(%esp), %eax
6227c478bdstevel@tonic-gate        movl    %eax, %cr3
6237c478bdstevel@tonic-gate        ret
6247c478bdstevel@tonic-gate	SET_SIZE(setcr3)
6257c478bdstevel@tonic-gate
6267c478bdstevel@tonic-gate	ENTRY(reload_cr3)
6277c478bdstevel@tonic-gate	movl    %cr3, %eax
6287c478bdstevel@tonic-gate	movl    %eax, %cr3
6297c478bdstevel@tonic-gate	ret
6307c478bdstevel@tonic-gate	SET_SIZE(reload_cr3)
6317c478bdstevel@tonic-gate
632843e198johnlev#endif	/* __xpv */
633843e198johnlev
6347c478bdstevel@tonic-gate	ENTRY(getcr4)
6357c478bdstevel@tonic-gate	movl    %cr4, %eax
6367c478bdstevel@tonic-gate	ret
6377c478bdstevel@tonic-gate	SET_SIZE(getcr4)
6387c478bdstevel@tonic-gate
6397c478bdstevel@tonic-gate        ENTRY(setcr4)
6407c478bdstevel@tonic-gate        movl    4(%esp), %eax
6417c478bdstevel@tonic-gate        movl    %eax, %cr4
6427c478bdstevel@tonic-gate        ret
6437c478bdstevel@tonic-gate	SET_SIZE(setcr4)
6447c478bdstevel@tonic-gate
6457c478bdstevel@tonic-gate#endif	/* __i386 */
6467c478bdstevel@tonic-gate#endif	/* __lint */
6477c478bdstevel@tonic-gate
6487c478bdstevel@tonic-gate#if defined(__lint)
6497c478bdstevel@tonic-gate
6507c478bdstevel@tonic-gate/*ARGSUSED*/
6517c478bdstevel@tonic-gateuint32_t
6528949bcdandrei__cpuid_insn(struct cpuid_regs *regs)
6537c478bdstevel@tonic-gate{ return (0); }
6547c478bdstevel@tonic-gate
6557c478bdstevel@tonic-gate#else	/* __lint */
6567c478bdstevel@tonic-gate
6577c478bdstevel@tonic-gate#if defined(__amd64)
6587c478bdstevel@tonic-gate
6597c478bdstevel@tonic-gate	ENTRY(__cpuid_insn)
6608949bcdandrei	movq	%rbx, %r8
6618949bcdandrei	movq	%rcx, %r9
6628949bcdandrei	movq	%rdx, %r11
6638949bcdandrei	movl	(%rdi), %eax		/* %eax = regs->cp_eax */
6648949bcdandrei	movl	0x4(%rdi), %ebx		/* %ebx = regs->cp_ebx */
6658949bcdandrei	movl	0x8(%rdi), %ecx		/* %ecx = regs->cp_ecx */
6668949bcdandrei	movl	0xc(%rdi), %edx		/* %edx = regs->cp_edx */
6677c478bdstevel@tonic-gate	cpuid
6688949bcdandrei	movl	%eax, (%rdi)		/* regs->cp_eax = %eax */
6698949bcdandrei	movl	%ebx, 0x4(%rdi)		/* regs->cp_ebx = %ebx */
6708949bcdandrei	movl	%ecx, 0x8(%rdi)		/* regs->cp_ecx = %ecx */
6718949bcdandrei	movl	%edx, 0xc(%rdi)		/* regs->cp_edx = %edx */
6728949bcdandrei	movq	%r8, %rbx
6738949bcdandrei	movq	%r9, %rcx
6748949bcdandrei	movq	%r11, %rdx
6757c478bdstevel@tonic-gate	ret
6767c478bdstevel@tonic-gate	SET_SIZE(__cpuid_insn)
6777c478bdstevel@tonic-gate
6787c478bdstevel@tonic-gate#elif defined(__i386)
6797c478bdstevel@tonic-gate
6807c478bdstevel@tonic-gate        ENTRY(__cpuid_insn)
6817c478bdstevel@tonic-gate	pushl	%ebp
6828949bcdandrei	movl	0x8(%esp), %ebp		/* %ebp = regs */
6837c478bdstevel@tonic-gate	pushl	%ebx
6848949bcdandrei	pushl	%ecx
6858949bcdandrei	pushl	%edx
6868949bcdandrei	movl	(%ebp), %eax		/* %eax = regs->cp_eax */
6878949bcdandrei	movl	0x4(%ebp), %ebx		/* %ebx = regs->cp_ebx */
6888949bcdandrei	movl	0x8(%ebp), %ecx		/* %ecx = regs->cp_ecx */
6898949bcdandrei	movl	0xc(%ebp), %edx		/* %edx = regs->cp_edx */
6907c478bdstevel@tonic-gate	cpuid
6918949bcdandrei	movl	%eax, (%ebp)		/* regs->cp_eax = %eax */
6928949bcdandrei	movl	%ebx, 0x4(%ebp)		/* regs->cp_ebx = %ebx */
6938949bcdandrei	movl	%ecx, 0x8(%ebp)		/* regs->cp_ecx = %ecx */
6948949bcdandrei	movl	%edx, 0xc(%ebp)		/* regs->cp_edx = %edx */
6958949bcdandrei	popl	%edx
6968949bcdandrei	popl	%ecx
6977c478bdstevel@tonic-gate	popl	%ebx
6987c478bdstevel@tonic-gate	popl	%ebp
6997c478bdstevel@tonic-gate	ret
7007c478bdstevel@tonic-gate	SET_SIZE(__cpuid_insn)
7017c478bdstevel@tonic-gate
7027c478bdstevel@tonic-gate#endif	/* __i386 */
7037c478bdstevel@tonic-gate#endif	/* __lint */
7047c478bdstevel@tonic-gate
705f98fbcebholler#if defined(__lint)
706f98fbcebholler
707f98fbcebholler/*ARGSUSED*/
708f98fbcebhollervoid
709f98fbcebholleri86_monitor(volatile uint32_t *addr, uint32_t extensions, uint32_t hints)
710f34a717Joe Bonasera{}
711f98fbcebholler
712f98fbcebholler#else   /* __lint */
713f98fbcebholler
714f98fbcebholler#if defined(__amd64)
715f98fbcebholler
716f98fbcebholler	ENTRY_NP(i86_monitor)
717f98fbcebholler	pushq	%rbp
718f98fbcebholler	movq	%rsp, %rbp
719f98fbcebholler	movq	%rdi, %rax		/* addr */
720f98fbcebholler	movq	%rsi, %rcx		/* extensions */
721f98fbcebholler	/* rdx contains input arg3: hints */
7221d1a394Bill Holler	clflush	(%rax)
723f98fbcebholler	.byte	0x0f, 0x01, 0xc8	/* monitor */
724f98fbcebholler	leave
725f98fbcebholler	ret
726f98fbcebholler	SET_SIZE(i86_monitor)
727f98fbcebholler
728f98fbcebholler#elif defined(__i386)
729f98fbcebholler
730f98fbcebhollerENTRY_NP(i86_monitor)
731f98fbcebholler	pushl	%ebp
732f98fbcebholler	movl	%esp, %ebp
733e406c1abholler	movl	0x8(%ebp),%eax		/* addr */
734e406c1abholler	movl	0xc(%ebp),%ecx		/* extensions */
735e406c1abholler	movl	0x10(%ebp),%edx		/* hints */
7361d1a394Bill Holler	clflush	(%eax)
737f98fbcebholler	.byte	0x0f, 0x01, 0xc8	/* monitor */
738f98fbcebholler	leave
739f98fbcebholler	ret
740f98fbcebholler	SET_SIZE(i86_monitor)
741f98fbcebholler
742f98fbcebholler#endif	/* __i386 */
743f98fbcebholler#endif	/* __lint */
744f98fbcebholler
745f98fbcebholler#if defined(__lint)
746f98fbcebholler
747f98fbcebholler/*ARGSUSED*/
748f98fbcebhollervoid
749f98fbcebholleri86_mwait(uint32_t data, uint32_t extensions)
750f34a717Joe Bonasera{}
751f98fbcebholler
752f98fbcebholler#else	/* __lint */
753f98fbcebholler
754f98fbcebholler#if defined(__amd64)
755f98fbcebholler
756f98fbcebholler	ENTRY_NP(i86_mwait)
757f98fbcebholler	pushq	%rbp
75865f2042Robert Mustacchi	call	x86_md_clear
759f98fbcebholler	movq	%rsp, %rbp
760f98fbcebholler	movq	%rdi, %rax		/* data */
761f98fbcebholler	movq	%rsi, %rcx		/* extensions */
762f98fbcebholler	.byte	0x0f, 0x01, 0xc9	/* mwait */
763f98fbcebholler	leave
764f98fbcebholler	ret
765f98fbcebholler	SET_SIZE(i86_mwait)
766f98fbcebholler
767f98fbcebholler#elif defined(__i386)
768f98fbcebholler
769f98fbcebholler	ENTRY_NP(i86_mwait)
770f98fbcebholler	pushl	%ebp
771f98fbcebholler	movl	%esp, %ebp
772e406c1abholler	movl	0x8(%ebp),%eax		/* data */
773e406c1abholler	movl	0xc(%ebp),%ecx		/* extensions */
774f98fbcebholler	.byte	0x0f, 0x01, 0xc9	/* mwait */
775f98fbcebholler	leave
776f98fbcebholler	ret
777f98fbcebholler	SET_SIZE(i86_mwait)
778f98fbcebholler
779f98fbcebholler#endif	/* __i386 */
780f98fbcebholler#endif	/* __lint */
781ae115bcmrj
782f34a717Joe Bonasera#if defined(__xpv)
783f34a717Joe Bonasera	/*
784f34a717Joe Bonasera	 * Defined in C
785f34a717Joe Bonasera	 */
786f34a717Joe Bonasera#else
787f34a717Joe Bonasera
788ae115bcmrj#if defined(__lint)
789