diff options
Diffstat (limited to 'usr/src/uts/intel')
35 files changed, 2210 insertions, 89 deletions
diff --git a/usr/src/uts/intel/Makefile b/usr/src/uts/intel/Makefile index 5ddfbe5117..adaa4d6158 100644 --- a/usr/src/uts/intel/Makefile +++ b/usr/src/uts/intel/Makefile @@ -85,13 +85,13 @@ install_h := TARGET= install_h .PARALLEL: $(KMODS) $(CLOSED_KMODS) $(SVVS) $(XMODS) $(CLOSED_XMODS) \ config $(LINT_DEPS) -def all install clean clobber modlist: $(KMODS) $(CLOSED_KMODS) \ - $(SVVS) $(XMODS) $(CLOSED_XMODS) config +def all install clean clobber modlist: genassym $(KMODS) $(CLOSED_KMODS) \ + $(SVVS) $(XMODS) $(CLOSED_XMODS) config modlintlib clean.lint: $(LINT_KMODS) $(CLOSED_LINT_KMODS) $(SVVS) \ $(XMODS) $(CLOSED_XMODS) -$(KMODS) $(SUBDIRS) config: FRC +genassym $(KMODS) $(SUBDIRS) config: FRC @cd $@; pwd; $(MAKE) $(NO_STATE) $(TARGET) $(CLOSED_KMODS): FRC diff --git a/usr/src/uts/intel/Makefile.files b/usr/src/uts/intel/Makefile.files index 45484afa4c..d2ab9a3290 100644 --- a/usr/src/uts/intel/Makefile.files +++ b/usr/src/uts/intel/Makefile.files @@ -18,6 +18,7 @@ # # CDDL HEADER END # + # # uts/intel/Makefile.files # @@ -107,6 +108,14 @@ XMEMFS_OBJS += \ xmem_vfsops.o \ xmem_vnops.o +LX_PROC_OBJS += \ + lx_prsubr.o \ + lx_prvfsops.o \ + lx_prvnops.o + +LX_AUTOFS_OBJS += \ + lx_autofs.o + # # Driver modules # @@ -178,6 +187,29 @@ AAC_OBJS = aac.o aac_ioctl.o AMR_OBJS = amr.o # +# Brand modules +# +SN1_BRAND_OBJS = sn1_brand.o sn1_brand_asm.o + +LX_BRAND_OBJS = \ + lx_brand.o \ + lx_brand_asm.o \ + lx_brk.o \ + lx_clone.o \ + lx_futex.o \ + lx_getpid.o \ + lx_id.o \ + lx_kill.o \ + lx_misc.o \ + lx_modify_ldt.o \ + lx_pid.o \ + lx_sched.o \ + lx_signum.o \ + lx_syscall.o \ + lx_sysinfo.o \ + lx_thread_area.o + +# # special files # MODSTUB_OBJ += \ diff --git a/usr/src/uts/intel/Makefile.intel.shared b/usr/src/uts/intel/Makefile.intel.shared index 7636718bd9..2367e343c3 100644 --- a/usr/src/uts/intel/Makefile.intel.shared +++ b/usr/src/uts/intel/Makefile.intel.shared @@ -25,9 +25,11 @@ # # ident "%Z%%M% %I% %E% SMI" # + # # This makefile contains the common definitions for all intel # implementation architecture independent modules. +# # # Machine type (implementation architecture): @@ -44,6 +46,7 @@ PLATFORM = i86pc # UNIX_DIR = $(UTSBASE)/i86pc/unix GENLIB_DIR = $(UTSBASE)/intel/genunix +GENASSYM_DIR = $(UTSBASE)/intel/genassym IPDRV_DIR = $(UTSBASE)/intel/ip MODSTUBS_DIR = $(UNIX_DIR) DSF_DIR = $(UTSBASE)/$(PLATFORM)/genassym @@ -135,6 +138,7 @@ ASFLAGS_XARCH_64 = $(amd64_ASFLAGS) ASFLAGS_XARCH = $(ASFLAGS_XARCH_$(CLASS)) ASFLAGS += $(ASFLAGS_XARCH) +AS_INC_PATH += -I$(GENASSYM_DIR)/$(OBJS_DIR) # # Define the base directory for installation. @@ -403,6 +407,13 @@ MISC_KMODS += md_stripe md_hotspares md_mirror md_raid md_trans md_notify MISC_KMODS += md_sp # +# Brand modules +# +MISC_KMODS += sn1_brand lx_brand +DRV_KMODS += lx_systrace lx_ptm lx_audio +STRMOD_KMODS += ldlinux + +# # Exec Class Modules (/kernel/exec): # EXEC_KMODS += elfexec intpexec javaexec @@ -416,7 +427,7 @@ SCHED_KMODS += IA RT TS RT_DPTBL TS_DPTBL FSS FX FX_DPTBL # File System Modules (/kernel/fs): # FS_KMODS += autofs cachefs ctfs dev devfs fdfs fifofs hsfs lofs -FS_KMODS += mntfs namefs nfs objfs zfs +FS_KMODS += lx_afs lx_proc mntfs namefs nfs objfs zfs FS_KMODS += pcfs procfs sockfs specfs tmpfs udfs ufs xmemfs # diff --git a/usr/src/uts/intel/Makefile.rules b/usr/src/uts/intel/Makefile.rules index 467289ca7f..50de973acd 100644 --- a/usr/src/uts/intel/Makefile.rules +++ b/usr/src/uts/intel/Makefile.rules @@ -2,9 +2,8 @@ # CDDL HEADER START # # The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. +# 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 # or http://www.opensolaris.org/os/licensing. @@ -47,6 +46,9 @@ $(OBJS_DIR)/%.o: $(SRC)/common/fs/%.c $(OBJS_DIR)/%.o: $(SRC)/common/util/i386/%.s $(COMPILE.s) -o $@ $< +$(OBJS_DIR)/%.o: $(UTSBASE)/intel/brand/sn1/%.s + $(COMPILE.s) -o $@ $< + $(OBJS_DIR)/%.o: $(UTSBASE)/intel/dtrace/%.c $(COMPILE.c) -o $@ $< $(CTFCONVERT_O) @@ -150,6 +152,9 @@ $(LINTS_DIR)/%.ln: $(SRC)/common/fs/%.c $(LINTS_DIR)/%.ln: $(SRC)/common/util/i386/%.s @($(LHEAD) $(LINT.s) $< $(LTAIL)) +$(LINTS_DIR)/%.ln: $(UTSBASE)/intel/brand/sn1/%.s + @($(LHEAD) $(LINT.s) $< $(LTAIL)) + $(LINTS_DIR)/%.ln: $(UTSBASE)/intel/dtrace/%.c @($(LHEAD) $(LINT.c) $< $(LTAIL)) diff --git a/usr/src/uts/intel/brand/lx/lx_brand_asm.s b/usr/src/uts/intel/brand/lx/lx_brand_asm.s new file mode 100644 index 0000000000..7e51a6e487 --- /dev/null +++ b/usr/src/uts/intel/brand/lx/lx_brand_asm.s @@ -0,0 +1,205 @@ +/* + * 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 + * or http://www.opensolaris.org/os/licensing. + * 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 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#if defined(__lint) + +#include <sys/systm.h> + +#else /* __lint */ + +#include <sys/asm_linkage.h> +#include <sys/privregs.h> +#include <sys/segments.h> +#include "genassym.h" + +#endif /* __lint */ + +#ifdef __lint + +void +lx_brand_int80_callback(void) +{ +} + +#else /* __lint */ + +#if defined(__amd64) + /* + * lx brand callback for the int $0x80 trap handler. + * + * We're running on the user's %gs. + * + * We return directly to userland, bypassing the _update_sregs logic, so + * this routine must NOT do anything that could cause a context switch. + * + * %rax - syscall number + * + * When called, all general registers and %gs are as they were when + * the user process made the system call. The stack looks like + * this: + * -------------------------------------- + * 32 | saved stack pointer | + * | 24 | lwp brand data | + * | 16 | proc brand data | + * v 8 | user return address (*) | + * 0 | caller's return addr (sys_int80) | + * ------------------------------------- + */ + ENTRY(lx_brand_int80_callback) + movq 24(%rsp), %r15 /* grab the lwp brand data */ + movl %gs, BR_UGS(%r15) /* save user %gs */ + + movq 16(%rsp), %r15 /* grab the proc brand data */ + +.lx_brand_int80_patch_point: + jmp .lx_brand_int80_notrace + +.lx_brand_int80_notrace: + movq L_HANDLER(%r15), %r15 /* load the base address */ + +0: + /* + * Rather than returning to the instruction after the int 80, we + * transfer control into the brand library's handler table at + * table_addr + (16 * syscall_num) thus encoding the system + * call number in the instruction pointer. The original return address + * is passed in %eax. + */ + shlq $4, %rax + addq %r15, %rax + movq 32(%rsp), %rsp /* restore user stack pointer */ + xchgq (%rsp), %rax /* swap %rax and return addr */ + iretq + +.lx_brand_int80_trace: + /* + * If tracing is active, we vector to an alternate trace-enabling + * handler table instead. + */ + movq L_TRACEHANDLER(%r15), %r15 /* load trace handler address */ + jmp 0b + SET_SIZE(lx_brand_int80_callback) + + +#define PATCH_POINT _CONST(.lx_brand_int80_patch_point + 1) +#define PATCH_VAL _CONST(.lx_brand_int80_trace - .lx_brand_int80_notrace) + + ENTRY(lx_brand_int80_enable) + movl $1, lx_systrace_brand_enabled(%rip) + movq $PATCH_POINT, %r8 + movb $PATCH_VAL, (%r8) + ret + SET_SIZE(lx_brand_int80_enable) + + ENTRY(lx_brand_int80_disable) + movq $PATCH_POINT, %r8 + movb $0, (%r8) + movl $0, lx_systrace_brand_enabled(%rip) + ret + SET_SIZE(lx_brand_int80_disable) + + +#else + /* + * %eax - syscall number + * + * When called, all general registers and %gs are as they were when + * the user process made the system call. The stack looks like + * this: + * + * -------------------------------------- + * | 48 | user's %ss | + * | 44 | user's %esp | + * | 40 | EFLAGS register | + * | 36 | user's %cs | + * | 32 | user's %eip | + * | 28 | 'scatch space' | + * | 24 | user's %ebx | + * | 20 | user's %gs selector | + * | 16 | kernel's %gs selector | + * | 12 | lwp brand data | + * | 8 | proc brand data | + * v 4 | user return address | + * 0 | callback wrapper return addr | + * ------------------------------------- + */ + ENTRY(lx_brand_int80_callback) + pushl %ebx /* save for use as scratch */ + movl 16(%esp), %ebx /* grab the lwp brand data */ + movw %gs, BR_UGS(%ebx) /* save user %gs */ + + movl 12(%esp), %ebx /* grab the proc brand data */ + +.lx_brand_int80_patch_point: + jmp .lx_brand_int80_notrace + +.lx_brand_int80_notrace: + movl L_HANDLER(%ebx), %ebx /* load the base address */ + +0: + /* + * See the corresponding comment in the amd64 version above. + */ + shll $4, %eax + addl %ebx, %eax + popl %ebx /* restore %ebx */ + addl $32, %esp + xchgl (%esp), %eax /* swap %eax and return addr */ + iret + +.lx_brand_int80_trace: + movl L_TRACEHANDLER(%ebx), %ebx /* load trace handler address */ + jmp 0b + SET_SIZE(lx_brand_int80_callback) + + +#define PATCH_POINT _CONST(.lx_brand_int80_patch_point + 1) +#define PATCH_VAL _CONST(.lx_brand_int80_trace - .lx_brand_int80_notrace) + + ENTRY(lx_brand_int80_enable) + pushl %ebx + pushl %eax + movl $1, lx_systrace_brand_enabled + movl $PATCH_POINT, %ebx + movl $PATCH_VAL, %eax + movb %al, (%ebx) + popl %eax + popl %ebx + ret + SET_SIZE(lx_brand_int80_enable) + + ENTRY(lx_brand_int80_disable) + pushl %ebx + movl $PATCH_POINT, %ebx + movb $0, (%ebx) + movl $0, lx_systrace_brand_enabled + popl %ebx + ret + SET_SIZE(lx_brand_int80_disable) + +#endif /* __amd64 */ +#endif /* __lint */ diff --git a/usr/src/uts/intel/brand/sn1/sn1_brand_asm.s b/usr/src/uts/intel/brand/sn1/sn1_brand_asm.s new file mode 100644 index 0000000000..fd793b2098 --- /dev/null +++ b/usr/src/uts/intel/brand/sn1/sn1_brand_asm.s @@ -0,0 +1,340 @@ +/* + * 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 + * or http://www.opensolaris.org/os/licensing. + * 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 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#if defined(lint) + +#include <sys/systm.h> + +#else /* lint */ + +#include <sys/asm_linkage.h> +#include <sys/privregs.h> +#include <sys/segments.h> + +#endif /* lint */ + +#ifdef lint + +void +sn1_brand_sysenter_callback(void) +{ +} + +void +sn1_brand_syscall_callback(void) +{ +} + +#if defined(__amd64) +void +sn1_brand_syscall32_callback(void) +{ +} +#endif /* amd64 */ + +void +sn1_brand_int91_callback(void) +{ +} + +#else /* lint */ + +/* + * Each of the following macros returns to the standard syscall codepath if + * it detects that this process is not able, or intended, to emulate this + * system call. They all assume that the routine provides a 'bail-out' + * label of '9'. + */ + +/* + * See if this process has a user-space handler registered for it. For the + * sn1 brand, the per-process brand data holds the address of the handler. + * As shown in the stack diagrams below, the callback code leaves that data + * at these offsets. + */ +#if defined(__amd64) +#define CHECK_FOR_HANDLER \ + cmpq $0, 24(%rsp) ;\ + je 9f +#else +#define CHECK_FOR_HANDLER \ + cmpl $0, 12(%esp) ;\ + je 9f +#endif /* __amd64 */ + +/* + * If the system call number is >= 1024, then it is coming from the + * emulation support library. As such we should handle it natively instead + * of sending it back to the emulation library. + */ +#define CHECK_FOR_NATIVE(reg) \ + cmp $1024, reg ;\ + jl 1f ;\ + sub $1024, reg ;\ + jmp 9f ;\ +1: + +/* + * Check to see if we want to interpose on this system call. If not, we + * jump back into the normal syscall path and pretend nothing happened. + */ +#define CHECK_FOR_INTERPOSITION(sysr, scr, scr_low) \ + lea sn1_emulation_table, scr ;\ + mov (scr), scr ;\ + add sysr, scr ;\ + movb (scr), scr_low ;\ + cmpb $0, scr_low ;\ + je 9f ;\ + +#define CALLBACK_PROLOGUE(call, scr, scr_low) ;\ + push scr /* Save scratch register */ ;\ + CHECK_FOR_HANDLER ;\ + CHECK_FOR_NATIVE(call) ;\ + CHECK_FOR_INTERPOSITION(call, scr, scr_low) + +/* + * The callback routines: + */ + +#if defined(__amd64) + /* + * When we get into any of these callback routines, the stack + * looks like this: + * -------------------------------------- + * 32 | saved stack pointer | + * | 24 | lwp brand data | + * | 16 | proc brand data | + * v 8 | user return address (*) | + * 0 | BRAND_CALLBACK()'s return addr | + * -------------------------------------- + * (*) This is actually just the bottom value from the user's + * stack. syscall puts this in %rcx instead of the stack, + * so it's just garbage for that entry point. + */ + + /* + * syscall handler for 32-bit user processes: + * + * %ecx contains the address of the instruction after the syscall + */ + ENTRY(sn1_brand_syscall32_callback) + + CALLBACK_PROLOGUE(%rax, %r15, %r15b) + + movq %rsp, %r15 /* save our stack pointer */ + + /* + * Adjust the user's stack so that the 'ret' from our userspace + * handler takes us to the post-syscall instruction instead of to + * the routine that called the system call. + */ + movq 40(%rsp), %rsp /* restore user's stack pointer */ + subq $4, %rsp /* save room for the post-syscall addr */ + movl %ecx, (%rsp) /* Save post-syscall addr on stack */ + + /* + * To 'return' to our user-space handler, we just need to copy + * its address into %ecx. + */ + movq 24(%r15), %rcx /* user-space handler == proc_data for sn1 */ + movq (%r15), %r15 /* Restore scratch register */ + sysret +9: + popq %r15 + retq + SET_SIZE(sn1_brand_syscall32_callback) + + /* + * syscall handler for 64-bit user processes: + * %rax - syscall number + * %rcx - user space %rip + */ + ENTRY(sn1_brand_syscall_callback) + + CALLBACK_PROLOGUE(%rax, %r15, %r15b) + + movq %rsp, %r15 /* save our stack pointer */ + + movq 40(%rsp), %rsp /* restore user's stack pointer */ + subq $8, %rsp /* save room for the post-syscall addr */ + movq %rcx, (%rsp) /* Save post-syscall addr on stack */ + + /* + * To 'return' to our user-space handler, we just need to copy + * its address into %ecx. + */ + movq 24(%r15), %rcx /* user-space handler == proc_data for sn1 */ + movq (%r15), %r15 /* Restore scratch register */ + sysretq +9: + popq %r15 + retq + + SET_SIZE(sn1_brand_syscall_callback) + + /* + * %rax - syscall number + * %rcx - user space %esp + * %rdx - user space return address + * + * XXX: not tested yet. Need a Nocona machine first. + */ + ENTRY(sn1_brand_sysenter_callback) + + CALLBACK_PROLOGUE(%rax, %r15, %r15b) + + subq $4, %rcx /* Save room for user ret addr */ + movq %rdx, (%rcx) /* Save current return addr */ + movq 24(%rsp), %rdx /* user-space handler == proc_data for sn1 */ + popq %r15 + sysexit +9: + popq %r15 + ret + SET_SIZE(sn1_brand_sysenter_callback) + + /* + * The saved stack pointer points at the state saved when we took + * the interrupt: + * -------------------------------------- + * | 32 | user's %ss | + * | 24 | user's %esp | + * | 16 | EFLAGS register | + * v 8 | user's %cs | + * 0 | user's %eip | + * -------------------------------------- + */ + ENTRY(sn1_brand_int91_callback) + + CALLBACK_PROLOGUE(%rax, %r15, %r15b) + + movq 24(%rsp), %r15 /* user-space handler == proc_data for sn1 */ + pushq %rax /* Save scratch register */ + movq 48(%rsp), %rax /* Get saved %esp */ + movq %r15, (%rax) /* replace iret target address with hdlr */ + + /* + * Adjust the caller's stack so we return to the instruction after + * the syscall on the next 'ret' in userspace - not to the parent + * routine. + */ + movq 24(%rax), %r15 /* Get user's %esp */ + subq $4, %r15 /* Make room for new ret addr */ + movq %r15, 24(%rax) /* Replace current with updated %esp */ + movl 24(%rsp), %eax /* Get post-syscall address */ + movl %eax, (%r15) /* Put it on the user's stack */ + + popq %rax /* Restore scratch register */ + popq %r15 /* Restore scratch register */ + movq 32(%rsp), %rsp /* Remove all callback stuff from stack */ + iretq +9: + popq %r15 + retq + SET_SIZE(sn1_brand_int91_callback) + +#else /* __amd64 */ + + /* + * When we get into any of these callback routines, the stack + * looks like this: + * -------------------------------------- + * | 28 | 'scatch space' | + * | 24 | user's %ebx | + * | 20 | user's %gs selector | + * | 16 | kernel's %gs selector | + * | 12 | lwp brand data | + * | 8 | proc brand data | + * v 4 | user return address | + * 0 | callback wrapper return addr | + * -------------------------------------- + */ + + /* + * lcall handler for 32-bit OS + * %eax - syscall number + * + * Above the stack contents common to all callbacks is the + * int/lcall-specific state: + * -------------------------------------- + * | 48 | user's %ss | + * | 44 | user's %esp | + * | 40 | EFLAGS register | + * v 36 | user's %cs | + * 32 | user's %eip | + * -------------------------------------- + */ + ENTRY(sn1_brand_syscall_callback) + + CALLBACK_PROLOGUE(%eax, %ebx, %bl) + + movl 12(%esp), %ebx /* user-space handler == proc_data for sn1 */ + movl %ebx, 36(%esp) /* replace iret target address with hdlr */ + + /* + * Adjust the caller's stack so we return to the instruction after + * the syscall on the next 'ret' in userspace - not to the parent + * routine. + */ + pushl %eax /* Save scratch register */ + movl 52(%esp), %eax /* Get current %esp */ + subl $4, %eax /* Make room for new ret addr */ + movl %eax, 52(%esp) /* Replace current with updated %esp */ + movl 12(%esp), %ebx /* Get post-syscall address */ + movl %ebx, (%eax) /* Put it on the user's stack */ + popl %eax /* Restore scratch register */ + + popl %ebx /* Restore scratch register */ + addl $32, %esp /* Remove all callback stuff from stack */ + iret +9: + popl %ebx + ret + SET_SIZE(sn1_brand_syscall_callback) + + /* + * %eax - syscall number + * %ecx - user space %esp + * %edx - user space return address + */ + ENTRY(sn1_brand_sysenter_callback) + + CALLBACK_PROLOGUE(%eax, %ebx, %bl) + + subl $4, %ecx /* Save room for user ret addr */ + movl %edx, (%ecx) /* Save current return addr */ + movl 12(%esp), %edx /* Return to user-space handler */ + popl %ebx /* Restore scratch register */ + sysexit +9: + popl %ebx + ret + SET_SIZE(sn1_brand_sysenter_callback) + +#endif /* __amd64 */ +#endif /* lint */ + diff --git a/usr/src/uts/intel/dtrace/fasttrap_isa.c b/usr/src/uts/intel/dtrace/fasttrap_isa.c index b64be9243f..5b0c0a9383 100644 --- a/usr/src/uts/intel/dtrace/fasttrap_isa.c +++ b/usr/src/uts/intel/dtrace/fasttrap_isa.c @@ -36,6 +36,7 @@ #include <sys/segments.h> #include <sys/sysmacros.h> #include <sys/trap.h> +#include <sys/archsystm.h> /* * Lossless User-Land Tracing on x86 @@ -230,7 +231,7 @@ fasttrap_tracepoint_init(proc_t *p, fasttrap_tracepoint_t *tp, uintptr_t pc, size_t first = MIN(len, PAGESIZE - (pc & PAGEOFFSET)); uint_t start = 0; int rmindex; - uint8_t rex = 0; + uint8_t seg, rex = 0; /* * Read the instruction at the given address out of the process's @@ -269,23 +270,49 @@ fasttrap_tracepoint_init(proc_t *p, fasttrap_tracepoint_t *tp, uintptr_t pc, if (tp->ftt_size > len) return (-1); + tp->ftt_segment = FASTTRAP_SEG_NONE; + /* * Find the start of the instruction's opcode by processing any * legacy prefixes. */ for (;;) { + seg = 0; switch (instr[start]) { + case FASTTRAP_PREFIX_SS: + seg++; + /*FALLTHRU*/ + case FASTTRAP_PREFIX_GS: + seg++; + /*FALLTHRU*/ + case FASTTRAP_PREFIX_FS: + seg++; + /*FALLTHRU*/ + case FASTTRAP_PREFIX_ES: + seg++; + /*FALLTHRU*/ + case FASTTRAP_PREFIX_DS: + seg++; + /*FALLTHRU*/ + case FASTTRAP_PREFIX_CS: + seg++; + /*FALLTHRU*/ case FASTTRAP_PREFIX_OPERAND: case FASTTRAP_PREFIX_ADDRESS: - case FASTTRAP_PREFIX_CS: - case FASTTRAP_PREFIX_DS: - case FASTTRAP_PREFIX_ES: - case FASTTRAP_PREFIX_FS: - case FASTTRAP_PREFIX_GS: - case FASTTRAP_PREFIX_SS: case FASTTRAP_PREFIX_LOCK: case FASTTRAP_PREFIX_REP: case FASTTRAP_PREFIX_REPNE: + if (seg != 0) { + /* + * It's illegal for an instruction to specify + * two segment prefixes -- give up on this + * illegal instruction. + */ + if (tp->ftt_segment != FASTTRAP_SEG_NONE) + return (-1); + + tp->ftt_segment = seg; + } start++; continue; } @@ -483,6 +510,19 @@ fasttrap_tracepoint_init(proc_t *p, fasttrap_tracepoint_t *tp, uintptr_t pc, */ ASSERT(instr[start] == FASTTRAP_INSTR); return (-1); + + case FASTTRAP_INT: + /* + * Interrupts seem like they could be traced with + * no negative implications, but it's possible that + * a thread could be redirected by the trap handling + * code which would eventually return to the + * instruction after the interrupt. If the interrupt + * were in our scratch space, the subsequent + * instruction might be overwritten before we return. + * Accordingly we refuse to instrument any interrupt. + */ + return (-1); } } @@ -696,6 +736,119 @@ fasttrap_usdt_args32(fasttrap_probe_t *probe, struct regs *rp, int argc, } } +static int +fasttrap_do_seg(fasttrap_tracepoint_t *tp, struct regs *rp, uintptr_t *addr) +{ + proc_t *p = curproc; + user_desc_t *desc; + uint16_t sel, ndx, type; + uintptr_t limit; + + switch (tp->ftt_segment) { + case FASTTRAP_SEG_CS: + sel = rp->r_cs; + break; + case FASTTRAP_SEG_DS: + sel = rp->r_ds; + break; + case FASTTRAP_SEG_ES: + sel = rp->r_es; + break; + case FASTTRAP_SEG_FS: + sel = rp->r_fs; + break; + case FASTTRAP_SEG_GS: + sel = rp->r_gs; + break; + case FASTTRAP_SEG_SS: + sel = rp->r_ss; + break; + } + + /* + * Make sure the given segment register specifies a user priority + * selector rather than a kernel selector. + */ + if (!SELISUPL(sel)) + return (-1); + + ndx = SELTOIDX(sel); + + /* + * Check the bounds and grab the descriptor out of the specified + * descriptor table. + */ + if (SELISLDT(sel)) { + if (ndx > p->p_ldtlimit) + return (-1); + + desc = p->p_ldt + ndx; + + } else { + if (ndx >= NGDT) + return (-1); + + desc = cpu_get_gdt() + ndx; + } + + /* + * The descriptor must have user privilege level and it must be + * present in memory. + */ + if (desc->usd_dpl != SEL_UPL || desc->usd_p != 1) + return (-1); + + type = desc->usd_type; + + /* + * If the S bit in the type field is not set, this descriptor can + * only be used in system context. + */ + if ((type & 0x10) != 0x10) + return (-1); + + limit = USEGD_GETLIMIT(desc) * (desc->usd_gran ? PAGESIZE : 1); + + if (tp->ftt_segment == FASTTRAP_SEG_CS) { + /* + * The code/data bit and readable bit must both be set. + */ + if ((type & 0xa) != 0xa) + return (-1); + + if (*addr > limit) + return (-1); + } else { + /* + * The code/data bit must be clear. + */ + if ((type & 0x8) != 0) + return (-1); + + /* + * If the expand-down bit is clear, we just check the limit as + * it would naturally be applied. Otherwise, we need to check + * that the address is the range [limit + 1 .. 0xffff] or + * [limit + 1 ... 0xffffffff] depending on if the default + * operand size bit is set. + */ + if ((type & 0x4) == 0) { + if (*addr > limit) + return (-1); + } else if (desc->usd_def32) { + if (*addr < limit + 1 || 0xffff < *addr) + return (-1); + } else { + if (*addr < limit + 1 || 0xffffffff < *addr) + return (-1); + } + } + + *addr += USEGD_GETBASE(desc); + + return (0); +} + int fasttrap_pid_probe(struct regs *rp) { @@ -1105,7 +1258,7 @@ fasttrap_pid_probe(struct regs *rp) if (tp->ftt_code == 0) { new_pc = tp->ftt_dest; } else { - uintptr_t addr = tp->ftt_dest; + uintptr_t value, addr = tp->ftt_dest; if (tp->ftt_base != FASTTRAP_NOREG) addr += fasttrap_getreg(rp, tp->ftt_base); @@ -1114,10 +1267,22 @@ fasttrap_pid_probe(struct regs *rp) tp->ftt_scale; if (tp->ftt_code == 1) { + /* + * If there's a segment prefix for this + * instruction, we'll need to check permissions + * and bounds on the given selector, and adjust + * the address accordingly. + */ + if (tp->ftt_segment != FASTTRAP_SEG_NONE && + fasttrap_do_seg(tp, rp, &addr) != 0) { + fasttrap_sigsegv(p, curthread, addr); + new_pc = pc; + break; + } + #ifdef __amd64 if (p->p_model == DATAMODEL_NATIVE) { #endif - uintptr_t value; if (fasttrap_fulword((void *)addr, &value) == -1) { fasttrap_sigsegv(p, curthread, @@ -1128,15 +1293,16 @@ fasttrap_pid_probe(struct regs *rp) new_pc = value; #ifdef __amd64 } else { - uint32_t value; + uint32_t value32; + addr = (uintptr_t)(uint32_t)addr; if (fasttrap_fuword32((void *)addr, - &value) == -1) { + &value32) == -1) { fasttrap_sigsegv(p, curthread, addr); new_pc = pc; break; } - new_pc = value; + new_pc = value32; } #endif } else { diff --git a/usr/src/uts/intel/genassym/Makefile b/usr/src/uts/intel/genassym/Makefile new file mode 100644 index 0000000000..ce01dc8610 --- /dev/null +++ b/usr/src/uts/intel/genassym/Makefile @@ -0,0 +1,85 @@ +# +# 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 +# or http://www.opensolaris.org/os/licensing. +# 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 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This makefile drives the production of genassym.h through +# compile time intialized data. +# +# intel architecture dependent +# + +# +# Path to the base of the uts directory tree (usually /usr/src/uts). +# +UTSBASE = ../.. + +GENASSYM_H = $(GENASSYM_DIR)/$(OBJS_DIR)/genassym.h +OFFSETS_SRC = $(GENASSYM_DIR)/offsets.in + +# +# Include common rules. +# +include $(UTSBASE)/intel/Makefile.intel + +# +# Define targets +# +ALL_TARGET = $(GENASSYM_H) + +INC_PATH += -I$(UTSBASE)/common/brand/lx + +# +# Overrides +# +CLEANFILES = Nothing_to_remove +CLOBBERFILES = $(GENASSYM_H) Nothing_to_remove + +# +# Default build targets. +# +.KEEP_STATE: + +def: $(DEF_DEPS) + +all: $(ALL_DEPS) + +clean: $(CLEAN_DEPS) + +clobber: $(CLOBBER_DEPS) + +clean.lint: + +install: def + +# +# Create genassym.h +# +$(GENASSYM_H): $(OFFSETS_SRC) + $(OFFSETS_CREATE) <$(OFFSETS_SRC) >$@ + +# +# Include common targets. +# +include $(UTSBASE)/intel/Makefile.targ diff --git a/usr/src/uts/intel/genassym/offsets.in b/usr/src/uts/intel/genassym/offsets.in new file mode 100644 index 0000000000..21dfcd01aa --- /dev/null +++ b/usr/src/uts/intel/genassym/offsets.in @@ -0,0 +1,45 @@ +\ +\ 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 +\ or http://www.opensolaris.org/os/licensing. +\ 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 2006 Sun Microsystems, Inc. All rights reserved. +\ Use is subject to license terms. +\ + +#pragma ident "%Z%%M% %I% %E% SMI" + +\ +\ offsets.in: input file to produce the architecture-dependent genassym.h +\ using the ctfstabs program +\ + +#ifndef _GENASSYM +#define _GENASSYM +#endif + +#include <sys/lx_brand.h> + +lx_lwp_data + br_ugs + +lx_proc_data + l_handler + l_tracehandler + l_traceflag diff --git a/usr/src/uts/intel/ia32/ml/copy.s b/usr/src/uts/intel/ia32/ml/copy.s index 98951b8164..f30b864a46 100644 --- a/usr/src/uts/intel/ia32/ml/copy.s +++ b/usr/src/uts/intel/ia32/ml/copy.s @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * 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 * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -2044,6 +2043,15 @@ void ucopy(const void *ufrom, void *uto, size_t ulength) {} +/* + * copy a string in user space + */ + +/* ARGSUSED */ +void +ucopystr(const char *ufrom, char *uto, size_t umaxlength, size_t *lencopied) +{} + #else /* __lint */ #if defined(__amd64) @@ -2089,15 +2097,24 @@ ucopy(const void *ufrom, void *uto, size_t ulength) ENTRY(ucopy) movq kernelbase(%rip), %rax cmpq %rax, %rdi - jb 1f - movq %rax, %rdi -1: + cmovaeq %rax, %rdi /* force fault at kernelbase */ cmpq %rax, %rsi - jb do_copy - movq %rax, %rsi + cmovaeq %rax, %rsi /* force fault at kernelbase */ jmp do_copy SET_SIZE(ucopy) + ENTRY(ucopystr) + movq kernelbase(%rip), %rax + cmpq %rax, %rdi + cmovaeq %rax, %rdi /* force fault at kernelbase */ + cmpq %rax, %rsi + cmovaeq %rax, %rsi /* force fault at kernelbase */ + /* do_copystr expects lofault address in %r8 */ + movq %gs:CPU_THREAD, %r8 + movq T_LOFAULT(%r8), %r8 + jmp do_copystr + SET_SIZE(ucopystr) + #elif defined(__i386) ENTRY(copyin_noerr) @@ -2150,6 +2167,22 @@ ucopy(const void *ufrom, void *uto, size_t ulength) jmp do_copy SET_SIZE(ucopy) + ENTRY(ucopystr) + movl kernelbase, %eax + cmpl %eax, 4(%esp) + jb 1f + movl %eax, 4(%esp) /* force fault at kernelbase */ +1: + cmpl %eax, 8(%esp) + jb 2f + movl %eax, 8(%esp) /* force fault at kernelbase */ +2: + /* do_copystr expects the lofault address in %eax */ + movl %gs:CPU_THREAD, %eax + movl T_LOFAULT(%eax), %eax + jmp do_copystr + SET_SIZE(ucopystr) + #endif /* __i386 */ #ifdef DEBUG diff --git a/usr/src/uts/intel/ia32/os/archdep.c b/usr/src/uts/intel/ia32/os/archdep.c index 5a94720495..c3f0688965 100644 --- a/usr/src/uts/intel/ia32/os/archdep.c +++ b/usr/src/uts/intel/ia32/os/archdep.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * 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 * or http://www.opensolaris.org/os/licensing. @@ -65,6 +64,8 @@ #include <sys/auxv.h> #include <sys/auxv_386.h> #include <sys/dtrace.h> +#include <sys/brand.h> +#include <sys/machbrand.h> extern const struct fnsave_state x87_initial; extern const struct fxsave_state sse_initial; @@ -604,6 +605,8 @@ getuserpc() static greg_t fix_segreg(greg_t sr, model_t datamodel) { + kthread_t *t = curthread; + switch (sr &= 0xffff) { #if defined(__amd64) /* @@ -633,6 +636,13 @@ fix_segreg(greg_t sr, model_t datamodel) } /* + * Allow this process's brand to do any necessary segment register + * manipulation. + */ + if (PROC_IS_BRANDED(t->t_procp) && BRMOP(t->t_procp)->b_fixsegreg) + return (BRMOP(t->t_procp)->b_fixsegreg(sr, datamodel)); + + /* * Force it into the LDT in ring 3 for 32-bit processes, which by * default do not have an LDT, so that any attempt to use an invalid * selector will reference the (non-existant) LDT, and cause a #gp fault diff --git a/usr/src/uts/intel/ia32/os/desctbls.c b/usr/src/uts/intel/ia32/os/desctbls.c index f53563eae3..ed31db4a2d 100644 --- a/usr/src/uts/intel/ia32/os/desctbls.c +++ b/usr/src/uts/intel/ia32/os/desctbls.c @@ -57,6 +57,7 @@ #include <sys/reboot.h> #include <sys/kdi.h> #include <sys/systm.h> +#include <sys/controlregs.h> extern void syscall_int(void); @@ -104,6 +105,22 @@ void (*(fasttable[]))(void) = { }; /* + * Structure containing pre-computed descriptors to allow us to temporarily + * interpose on a standard handler. + */ +struct interposing_handler { + int ih_inum; + gate_desc_t ih_interp_desc; + gate_desc_t ih_default_desc; +}; + +/* + * The brand infrastructure interposes on two handlers, and we use one as a + * NULL signpost. + */ +static struct interposing_handler brand_tbl[3]; + +/* * software prototypes for default local descriptor table */ @@ -279,6 +296,7 @@ init_gdt(void) desctbr_t r_bgdt, r_gdt; user_desc_t *bgdt; size_t alen = 0xfffff; /* entire 32-bit address space */ + int i; /* * Copy in from boot's gdt to our gdt entries 1 - 4. @@ -358,6 +376,14 @@ init_gdt(void) SEL_UPL, SDP_PAGES, SDP_OP32); /* + * Initialize the descriptors set aside for brand usage. + * Only attributes and limits are initialized. + */ + for (i = GDT_BRANDMIN; i <= GDT_BRANDMAX; i++) + set_usegd(&gdt0[i], SDP_SHORT, NULL, alen, SDT_MEMRWA, + SEL_UPL, SDP_PAGES, SDP_OP32); + + /* * Install our new GDT */ r_gdt.dtr_limit = sizeof (gdt0) - 1; @@ -382,6 +408,7 @@ init_gdt(void) { desctbr_t r_bgdt, r_gdt; user_desc_t *bgdt; + int i; /* * Copy in from boot's gdt to our gdt entries 1 - 4. @@ -455,6 +482,14 @@ init_gdt(void) SDP_PAGES, SDP_OP32); /* + * Initialize the descriptors set aside for brand usage. + * Only attributes and limits are initialized. + */ + for (i = GDT_BRANDMIN; i <= GDT_BRANDMAX; i++) + set_usegd(&gdt0[i], NULL, (size_t)-1, SDT_MEMRWA, SEL_UPL, + SDP_PAGES, SDP_OP32); + + /* * Install our new GDT */ r_gdt.dtr_limit = sizeof (gdt0) - 1; @@ -580,6 +615,12 @@ init_idt(void) } /* + * install "int80" handler at, well, 0x80. + */ + set_gatesegd(&idt0[T_INT80], &sys_int80, KCS_SEL, 0, SDT_SYSIGT, + SEL_UPL); + + /* * install fast trap handler at 210. */ set_gatesegd(&idt0[T_FASTTRAP], &fasttrap, KCS_SEL, 0, @@ -608,6 +649,23 @@ init_idt(void) idt0_default_r.dtr_limit = sizeof (idt0) - 1; idt0_default_r.dtr_base = (uintptr_t)idt0; wr_idtr(&idt0_default_r); + + /* + * Prepare interposing descriptors for the branded "int80" + * and syscall handlers and cache copies of the default + * descriptors. + */ + brand_tbl[0].ih_inum = T_INT80; + brand_tbl[0].ih_default_desc = idt0[T_INT80]; + set_gatesegd(&(brand_tbl[0].ih_interp_desc), &brand_sys_int80, KCS_SEL, + 0, SDT_SYSIGT, SEL_UPL); + + brand_tbl[1].ih_inum = T_SYSCALLINT; + brand_tbl[1].ih_default_desc = idt0[T_SYSCALLINT]; + set_gatesegd(&(brand_tbl[1].ih_interp_desc), &brand_sys_syscall_int, + KCS_SEL, 0, SDT_SYSIGT, SEL_UPL); + + brand_tbl[2].ih_inum = 0; } #elif defined(__i386) @@ -705,6 +763,12 @@ init_idt(void) } /* + * install "int80" handler at, well, 0x80. + */ + set_gatesegd(&idt0[T_INT80], &sys_int80, KCS_SEL, 0, SDT_SYSIGT, + SEL_UPL); + + /* * install fast trap handler at 210. */ set_gatesegd(&idt0[T_FASTTRAP], &fasttrap, KCS_SEL, 0, @@ -734,6 +798,23 @@ init_idt(void) idt0_default_r.dtr_limit = sizeof (idt0) - 1; idt0_default_r.dtr_base = (uintptr_t)idt0; wr_idtr(&idt0_default_r); + + /* + * Prepare interposing descriptors for the branded "int80" + * and syscall handlers and cache copies of the default + * descriptors. + */ + brand_tbl[0].ih_inum = T_INT80; + brand_tbl[0].ih_default_desc = idt0[T_INT80]; + set_gatesegd(&(brand_tbl[0].ih_interp_desc), &brand_sys_int80, KCS_SEL, + 0, SDT_SYSIGT, SEL_UPL); + + brand_tbl[1].ih_inum = T_SYSCALLINT; + brand_tbl[1].ih_default_desc = idt0[T_SYSCALLINT]; + set_gatesegd(&(brand_tbl[1].ih_interp_desc), &brand_sys_call, + KCS_SEL, 0, SDT_SYSIGT, SEL_UPL); + + brand_tbl[2].ih_inum = 0; } #endif /* __i386 */ @@ -835,3 +916,49 @@ init_tables(void) init_idt(); init_ldt(); } + +/* + * Enable interpositioning on the system call path by rewriting the + * sys{call|enter} MSRs and the syscall-related entries in the IDT to use + * the branded entry points. + */ +void +brand_interpositioning_enable(void) +{ + int i; + + for (i = 0; brand_tbl[i].ih_inum; i++) + CPU->cpu_idt[brand_tbl[i].ih_inum] = + brand_tbl[i].ih_interp_desc; + +#if defined(__amd64) + wrmsr(MSR_AMD_LSTAR, (uintptr_t)brand_sys_syscall); + wrmsr(MSR_AMD_CSTAR, (uintptr_t)brand_sys_syscall32); +#endif + + if (x86_feature & X86_SEP) + wrmsr(MSR_INTC_SEP_EIP, (uintptr_t)brand_sys_sysenter); +} + +/* + * Disable interpositioning on the system call path by rewriting the + * sys{call|enter} MSRs and the syscall-related entries in the IDT to use + * the standard entry points, which bypass the interpositioning hooks. + */ +void +brand_interpositioning_disable(void) +{ + int i; + + for (i = 0; brand_tbl[i].ih_inum; i++) + CPU->cpu_idt[brand_tbl[i].ih_inum] = + brand_tbl[i].ih_default_desc; + +#if defined(__amd64) + wrmsr(MSR_AMD_LSTAR, (uintptr_t)sys_syscall); + wrmsr(MSR_AMD_CSTAR, (uintptr_t)sys_syscall32); +#endif + + if (x86_feature & X86_SEP) + wrmsr(MSR_INTC_SEP_EIP, (uintptr_t)sys_sysenter); +} diff --git a/usr/src/uts/intel/ia32/os/sundep.c b/usr/src/uts/intel/ia32/os/sundep.c index b0372798ee..1fe1e7e72d 100644 --- a/usr/src/uts/intel/ia32/os/sundep.c +++ b/usr/src/uts/intel/ia32/os/sundep.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * 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 * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -81,6 +80,7 @@ #include <sys/tuneable.h> #include <c2/audit.h> #include <sys/bootconf.h> +#include <sys/brand.h> #include <sys/dumphdr.h> #include <sys/promif.h> #include <sys/systeminfo.h> @@ -345,9 +345,20 @@ void lwp_forkregs(klwp_t *lwp, klwp_t *clwp) { #if defined(__amd64) - clwp->lwp_pcb.pcb_flags |= RUPDATE_PENDING; - lwptot(clwp)->t_post_sys = 1; + struct pcb *pcb = &clwp->lwp_pcb; + struct regs *rp = lwptoregs(lwp); + + if ((pcb->pcb_flags & RUPDATE_PENDING) == 0) { + pcb->pcb_ds = rp->r_ds; + pcb->pcb_es = rp->r_es; + pcb->pcb_fs = rp->r_fs; + pcb->pcb_gs = rp->r_gs; + pcb->pcb_flags |= RUPDATE_PENDING; + lwptot(clwp)->t_post_sys = 1; + } + ASSERT(lwptot(clwp)->t_post_sys); #endif + bcopy(lwp->lwp_regs, clwp->lwp_regs, sizeof (struct regs)); } @@ -484,6 +495,32 @@ lwp_segregs_restore32(klwp_t *lwp) #endif /* _SYSCALL32_IMPL */ /* + * If this is a process in a branded zone, then we want it to use the brand + * syscall entry points instead of the standard Solaris entry points. This + * routine must be called when a new lwp is created within a branded zone + * or when an existing lwp moves into a branded zone via a zone_enter() + * operation. + */ +void +lwp_attach_brand_hdlrs(klwp_t *lwp) +{ + kthread_t *t = lwptot(lwp); + + ASSERT(PROC_IS_BRANDED(lwptoproc(lwp))); + ASSERT(removectx(t, NULL, brand_interpositioning_disable, + brand_interpositioning_enable, NULL, NULL, NULL, NULL) == 0); + + installctx(t, NULL, brand_interpositioning_disable, + brand_interpositioning_enable, NULL, NULL, NULL, NULL); + + if (t == curthread) { + kpreempt_disable(); + brand_interpositioning_enable(); + kpreempt_enable(); + } +} + +/* * Add any lwp-associated context handlers to the lwp at the beginning * of the lwp's useful life. * @@ -571,6 +608,9 @@ lwp_installctx(klwp_t *lwp) kpreempt_enable(); } } + + if (PROC_IS_BRANDED(ttoproc(t))) + lwp_attach_brand_hdlrs(lwp); } /* @@ -701,6 +741,13 @@ setregs(uarg_t *args) lwp_installctx(lwp); } +user_desc_t * +cpu_get_gdt(void) +{ + return (CPU->cpu_gdt); +} + + #if !defined(lwp_getdatamodel) /* diff --git a/usr/src/uts/intel/ia32/os/syscall.c b/usr/src/uts/intel/ia32/os/syscall.c index 00fc0b6ba9..965fc07c1d 100644 --- a/usr/src/uts/intel/ia32/os/syscall.c +++ b/usr/src/uts/intel/ia32/os/syscall.c @@ -850,20 +850,17 @@ deferred_singlestep_trap(caddr_t pc) /* * If both NORMAL_STEP and WATCH_STEP are in - * effect, give precedence to NORMAL_STEP. + * effect, give precedence to WATCH_STEP. * If neither is set, user must have set the * PS_T bit in %efl; treat this as NORMAL_STEP. */ - if ((pcb->pcb_flags & NORMAL_STEP) || - !(pcb->pcb_flags & WATCH_STEP)) { + if ((fault = undo_watch_step(&siginfo)) == 0 && + ((pcb->pcb_flags & NORMAL_STEP) || + !(pcb->pcb_flags & WATCH_STEP))) { siginfo.si_signo = SIGTRAP; siginfo.si_code = TRAP_TRACE; siginfo.si_addr = pc; fault = FLTTRACE; - if (pcb->pcb_flags & WATCH_STEP) - (void) undo_watch_step(NULL); - } else { - fault = undo_watch_step(&siginfo); } pcb->pcb_flags &= ~(DEBUG_PENDING|NORMAL_STEP|WATCH_STEP); diff --git a/usr/src/uts/intel/ia32/os/sysi86.c b/usr/src/uts/intel/ia32/os/sysi86.c index 08b48234f7..8b56b01002 100644 --- a/usr/src/uts/intel/ia32/os/sysi86.c +++ b/usr/src/uts/intel/ia32/os/sysi86.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * 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 * or http://www.opensolaris.org/os/licensing. @@ -63,7 +62,6 @@ #include <sys/fp.h> #include <sys/cmn_err.h> -static int setdscr(caddr_t ap); static void setup_ldt(proc_t *pp); static void *ldt_map(proc_t *pp, uint_t seli); static void ldt_free(proc_t *pp); @@ -80,6 +78,7 @@ extern void sgmtl(long); int sysi86(short cmd, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3) { + struct ssd ssd; int error = 0; int c; proc_t *pp = curproc; @@ -121,7 +120,19 @@ sysi86(short cmd, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3) error = EINTR; break; } - error = setdscr((caddr_t)arg1); + + if (get_udatamodel() == DATAMODEL_LP64) { + error = EINVAL; + break; + } + + if (copyin((caddr_t)arg1, &ssd, sizeof (ssd)) < 0) { + error = EFAULT; + break; + } + + error = setdscr(&ssd); + mutex_enter(&pp->p_lock); if (curthread != pp->p_agenttp) continuelwps(pp); @@ -440,30 +451,23 @@ ldt_installctx(proc_t *p, proc_t *cp) mutex_exit(&targ->p_lock); } -static int -setdscr(caddr_t ap) +int +setdscr(struct ssd *ssd) { - struct ssd ssd; /* request structure buffer */ ushort_t seli; /* selector index */ user_desc_t *dscrp; /* descriptor pointer */ proc_t *pp = ttoproc(curthread); - if (get_udatamodel() == DATAMODEL_LP64) - return (EINVAL); - - if (copyin(ap, &ssd, sizeof (ssd)) < 0) - return (EFAULT); - /* * LDT segments: executable and data at DPL 3 only. */ - if (!SELISLDT(ssd.sel) || !SELISUPL(ssd.sel)) + if (!SELISLDT(ssd->sel) || !SELISUPL(ssd->sel)) return (EINVAL); /* * check the selector index. */ - seli = SELTOIDX(ssd.sel); + seli = SELTOIDX(ssd->sel); if (seli >= MAXNLDT || seli < LDT_UDBASE) return (EINVAL); @@ -541,7 +545,7 @@ setdscr(caddr_t ap) * a lot better failure mode than SIGKILL and a core file * from kern_gpfault() too.) */ - if (SI86SSD_PRES(&ssd) == 0) { + if (SI86SSD_PRES(ssd) == 0) { kthread_t *t; int bad = 0; @@ -563,27 +567,27 @@ setdscr(caddr_t ap) pcb_t *pcb = &lwp->lwp_pcb; #endif - if (ssd.sel == rp->r_cs || ssd.sel == rp->r_ss) { + if (ssd->sel == rp->r_cs || ssd->sel == rp->r_ss) { bad = 1; break; } #if defined(__amd64) if (pcb->pcb_flags & RUPDATE_PENDING) { - if (ssd.sel == pcb->pcb_ds || - ssd.sel == pcb->pcb_es || - ssd.sel == pcb->pcb_fs || - ssd.sel == pcb->pcb_gs) { + if (ssd->sel == pcb->pcb_ds || + ssd->sel == pcb->pcb_es || + ssd->sel == pcb->pcb_fs || + ssd->sel == pcb->pcb_gs) { bad = 1; break; } } else #endif { - if (ssd.sel == rp->r_ds || - ssd.sel == rp->r_es || - ssd.sel == rp->r_fs || - ssd.sel == rp->r_gs) { + if (ssd->sel == rp->r_ds || + ssd->sel == rp->r_es || + ssd->sel == rp->r_fs || + ssd->sel == rp->r_gs) { bad = 1; break; } @@ -601,7 +605,7 @@ setdscr(caddr_t ap) /* * If acc1 is zero, clear the descriptor (including the 'present' bit) */ - if (ssd.acc1 == 0) { + if (ssd->acc1 == 0) { bzero(dscrp, sizeof (*dscrp)); mutex_exit(&pp->p_ldtlock); return (0); @@ -611,17 +615,18 @@ setdscr(caddr_t ap) * Check segment type, allow segment not present and * only user DPL (3). */ - if (SI86SSD_DPL(&ssd) != SEL_UPL) { + if (SI86SSD_DPL(ssd) != SEL_UPL) { mutex_exit(&pp->p_ldtlock); return (EINVAL); } #if defined(__amd64) /* - * Do not allow 32-bit applications to create 64-bit mode code segments. + * Do not allow 32-bit applications to create 64-bit mode code + * segments. */ - if (SI86SSD_ISUSEG(&ssd) && ((SI86SSD_TYPE(&ssd) >> 3) & 1) == 1 && - SI86SSD_ISLONG(&ssd)) { + if (SI86SSD_ISUSEG(ssd) && ((SI86SSD_TYPE(ssd) >> 3) & 1) == 1 && + SI86SSD_ISLONG(ssd)) { mutex_exit(&pp->p_ldtlock); return (EINVAL); } @@ -630,8 +635,8 @@ setdscr(caddr_t ap) /* * Set up a code or data user segment descriptor. */ - if (SI86SSD_ISUSEG(&ssd)) { - ssd_to_usd(&ssd, dscrp); + if (SI86SSD_ISUSEG(ssd)) { + ssd_to_usd(ssd, dscrp); mutex_exit(&pp->p_ldtlock); return (0); } @@ -639,8 +644,8 @@ setdscr(caddr_t ap) /* * Allow a call gate only if the destination is in the LDT. */ - if (SI86SSD_TYPE(&ssd) == SDT_SYSCGT && SELISLDT(ssd.ls)) { - ssd_to_sgd(&ssd, (gate_desc_t *)dscrp); + if (SI86SSD_TYPE(ssd) == SDT_SYSCGT && SELISLDT(ssd->ls)) { + ssd_to_sgd(ssd, (gate_desc_t *)dscrp); mutex_exit(&pp->p_ldtlock); return (0); } @@ -653,7 +658,7 @@ setdscr(caddr_t ap) * Allocate a private LDT for this process and initialize it with the * default entries. */ -void +static void setup_ldt(proc_t *pp) { user_desc_t *ldtp; /* descriptor pointer */ diff --git a/usr/src/uts/intel/ia32/sys/trap.h b/usr/src/uts/intel/ia32/sys/trap.h index b03f947fe8..fcd8739775 100644 --- a/usr/src/uts/intel/ia32/sys/trap.h +++ b/usr/src/uts/intel/ia32/sys/trap.h @@ -65,6 +65,7 @@ extern "C" { #define T_FASTTRAP 0xd2 /* fast system call */ #define T_SYSCALLINT 0x91 /* general system call */ #define T_DTRACE_RET 0x7f /* DTrace pid return */ +#define T_INT80 0x80 /* int80 handler for linux emulation */ #define T_SOFTINT 0x50fd /* pseudo softint trap type */ /* diff --git a/usr/src/uts/intel/ldlinux/Makefile b/usr/src/uts/intel/ldlinux/Makefile new file mode 100644 index 0000000000..6a842e41f4 --- /dev/null +++ b/usr/src/uts/intel/ldlinux/Makefile @@ -0,0 +1,98 @@ +# +# 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 +# or http://www.opensolaris.org/os/licensing. +# 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 +# +# +# uts/intel/ldlinux/Makefile +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# This makefile drives the production of the ldlinux streams kernel +# module. +# +# intel architecture dependent +# + +# +# Path to the base of the uts directory tree (usually /usr/src/uts). +# +UTSBASE = ../.. + +# +# Define the module and object file sets. +# +MODULE = ldlinux +OBJECTS = $(LDLINUX_OBJS:%=$(OBJS_DIR)/%) +LINTS = $(LDLINUX_OBJS:%.o=$(LINTS_DIR)/%.ln) +ROOTMODULE = $(ROOT_STRMOD_DIR)/$(MODULE) + +# +# Include common rules. +# +include $(UTSBASE)/intel/Makefile.intel + +# +# Define targets +# +ALL_TARGET = $(BINARY) +LINT_TARGET = $(MODULE).lint +INSTALL_TARGET = $(BINARY) $(ROOTMODULE) + +CPPFLAGS += -I$(UTSBASE)/common/brand/lx + +# +# Overrides. +# +CFLAGS += $(CCVERBOSE) + +# +# Default build targets. +# +.KEEP_STATE: + +def: $(DEF_DEPS) + +all: $(ALL_DEPS) + +clean: $(CLEAN_DEPS) + +clobber: $(CLOBBER_DEPS) + +lint: $(LINT_DEPS) + +modlintlib: $(MODLINTLIB_DEPS) + +clean.lint: $(CLEAN_LINT_DEPS) + +install: $(INSTALL_DEPS) + +# +# Include common targets. +# +include $(UTSBASE)/intel/Makefile.targ + +$(OBJS_DIR)/%.o: $(UTSBASE)/common/brand/lx/io/%.c + $(COMPILE.c) -o $@ $< + $(CTFCONVERT_O) + +$(LINTS_DIR)/%.ln: $(UTSBASE)/common/brand/lx/io/%.c + @($(LHEAD) $(LINT.c) $< $(LTAIL)) diff --git a/usr/src/uts/intel/lx_afs/Makefile b/usr/src/uts/intel/lx_afs/Makefile new file mode 100644 index 0000000000..3656a6dc2c --- /dev/null +++ b/usr/src/uts/intel/lx_afs/Makefile @@ -0,0 +1,103 @@ +# +# 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 +# or http://www.opensolaris.org/os/licensing. +# 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 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +# +# This makefile drives the production of the lxproc file system +# kernel module. +# +# i86 architecture dependent +# + +# +# Path to the base of the uts directory tree (usually /usr/src/uts). +# +UTSBASE = ../.. + +# +# Define the module and object file sets. +# +# Note that the name of the actual filesystem is lx_afs and +# not lx_autofs. This is becase filesystem names are stupidly +# limited to 8 characters. +# +MODULE = lx_afs +OBJECTS = $(LX_AUTOFS_OBJS:%=$(OBJS_DIR)/%) +LINTS = $(LX_AUTOFS_OBJS:%.o=$(LINTS_DIR)/%.ln) +ROOTMODULE = $(ROOT_FS_DIR)/$(MODULE) + +INC_PATH += -I$(UTSBASE)/common/brand/lx + +# +# Include common rules. +# +include $(UTSBASE)/intel/Makefile.intel + +# +# Define targets +# +ALL_TARGET = $(BINARY) +LINT_TARGET = $(MODULE).lint +INSTALL_TARGET = $(BINARY) $(ROOTMODULE) + +# +# Overrides. +# +CFLAGS += $(CCVERBOSE) +LDFLAGS += -dy + +# +# Default build targets. +# +.KEEP_STATE: + +def: $(DEF_DEPS) + +all: $(ALL_DEPS) + +clean: $(CLEAN_DEPS) + +clobber: $(CLOBBER_DEPS) + +lint: $(LINT_DEPS) + +modlintlib: $(MODLINTLIB_DEPS) + +clean.lint: $(CLEAN_LINT_DEPS) + +install: $(INSTALL_DEPS) + +# +# Include common targets. +# +include $(UTSBASE)/intel/Makefile.targ + +# +# Include brand-specific rules +# + +include $(UTSBASE)/intel/lx_afs/Makefile.rules diff --git a/usr/src/uts/intel/lx_afs/Makefile.rules b/usr/src/uts/intel/lx_afs/Makefile.rules new file mode 100644 index 0000000000..2793fedaa4 --- /dev/null +++ b/usr/src/uts/intel/lx_afs/Makefile.rules @@ -0,0 +1,40 @@ +# +# 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 +# or http://www.opensolaris.org/os/licensing. +# 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 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +# +# Section 1a: C object build rules +# +$(OBJS_DIR)/%.o: $(UTSBASE)/common/brand/lx/autofs/%.c + $(COMPILE.c) -o $@ $< + $(CTFCONVERT_O) + +# +# Section 1b: Lint `object' build rules. +# +$(LINTS_DIR)/%.ln: $(UTSBASE)/common/brand/lx/autofs/%.c + @($(LHEAD) $(LINT.c) $< $(LTAIL)) diff --git a/usr/src/uts/intel/lx_audio/Makefile b/usr/src/uts/intel/lx_audio/Makefile new file mode 100644 index 0000000000..89b828bd3e --- /dev/null +++ b/usr/src/uts/intel/lx_audio/Makefile @@ -0,0 +1,93 @@ +# +# 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 +# or http://www.opensolaris.org/os/licensing. +# 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 +# +# +# uts/intel/lx_audio/Makefile +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# This makefile drives the production of the lx_audio driver +# +# intel architecture dependent +# + +# +# Path to the base of the uts directory tree (usually /usr/src/uts). +# +UTSBASE = ../.. + +# +# Define the module and object file sets. +# +MODULE = lx_audio +OBJECTS = $(LX_AUDIO_OBJS:%=$(OBJS_DIR)/%) +LINTS = $(LX_AUDIO_OBJS:%.o=$(LINTS_DIR)/%.ln) +ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) +CONF_SRCDIR = $(UTSBASE)/common/brand/lx/io + +# +# Include common rules. +# +include $(UTSBASE)/intel/Makefile.intel + +# +# Define targets +# +ALL_TARGET = $(BINARY) $(SRC_CONFILE) +LINT_TARGET = $(MODULE).lint +INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) + +CPPFLAGS += -I$(UTSBASE)/common/brand/lx + +# +# Default build targets. +# +.KEEP_STATE: + +def: $(DEF_DEPS) + +all: $(ALL_DEPS) + +clean: $(CLEAN_DEPS) + +clobber: $(CLOBBER_DEPS) + +lint: $(LINT_DEPS) + +modlintlib: $(MODLINTLIB_DEPS) + +clean.lint: $(CLEAN_LINT_DEPS) + +install: $(INSTALL_DEPS) + +# +# Include common targets. +# +include $(UTSBASE)/intel/Makefile.targ + +$(OBJS_DIR)/%.o: $(UTSBASE)/common/brand/lx/io/%.c + $(COMPILE.c) -o $@ $< + $(CTFCONVERT_O) + +$(LINTS_DIR)/%.ln: $(UTSBASE)/common/brand/lx/io/%.c + @($(LHEAD) $(LINT.c) $< $(LTAIL)) diff --git a/usr/src/uts/intel/lx_brand/Makefile b/usr/src/uts/intel/lx_brand/Makefile new file mode 100644 index 0000000000..0ad69fefce --- /dev/null +++ b/usr/src/uts/intel/lx_brand/Makefile @@ -0,0 +1,100 @@ +# +# 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 +# or http://www.opensolaris.org/os/licensing. +# 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 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" +# +# This makefile drives the production of the kernel component of +# the lx brand +# + +# +# Path to the base of the uts directory tree (usually /usr/src/uts). +# +UTSBASE = ../.. + +# +# Path to where brand common sources live +# +LX_CMN = $(SRC)/common/brand/lx + +# +# Define the module and object file sets. +# +MODULE = lx_brand +OBJECTS = $(LX_BRAND_OBJS:%=$(OBJS_DIR)/%) +LINTS = $(LX_BRAND_OBJS:%.o=$(LINTS_DIR)/%.ln) +ROOTMODULE = $(ROOT_BRAND_DIR)/$(MODULE) + +# +# Include common rules. +# +include $(UTSBASE)/intel/Makefile.intel + +# +# Define targets +# +ALL_TARGET = $(BINARY) +LINT_TARGET = $(MODULE).lint +INSTALL_TARGET = $(BINARY) $(ROOTMODULE) + +INC_PATH += -I$(UTSBASE)/common/brand/lx -I$(LX_CMN) + +# +# lint pass one enforcement +# +CFLAGS += $(CCVERBOSE) + +LDFLAGS += -dy -Nexec/elfexec + +# +# Default build targets. +# +.KEEP_STATE: + +def: $(DEF_DEPS) + +all: $(ALL_DEPS) + +clean: $(CLEAN_DEPS) + +clobber: $(CLOBBER_DEPS) + +lint: $(LINT_DEPS) + +modlintlib: $(MODLINTLIB_DEPS) + +clean.lint: $(CLEAN_LINT_DEPS) + +install: $(INSTALL_DEPS) + +# +# Include common targets. +# +include $(UTSBASE)/intel/Makefile.targ + +# +# Include brand-specific rules +# + +include $(UTSBASE)/intel/lx_brand/Makefile.rules diff --git a/usr/src/uts/intel/lx_brand/Makefile.rules b/usr/src/uts/intel/lx_brand/Makefile.rules new file mode 100644 index 0000000000..0862baef84 --- /dev/null +++ b/usr/src/uts/intel/lx_brand/Makefile.rules @@ -0,0 +1,85 @@ +# +# 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 +# or http://www.opensolaris.org/os/licensing. +# 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 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" +# + +# +# Section 1a: C object build rules +# +$(OBJS_DIR_OBJ64)/%.o: $(UTSBASE)/common/brand/lx/os/%.c + $(COMPILE.c) -D_ELF32_COMPAT -o $@ $< + $(CTFCONVERT_O) + +$(OBJS_DIR_DBG64)/%.o: $(UTSBASE)/common/brand/lx/os/%.c + $(COMPILE.c) -D_ELF32_COMPAT -o $@ $< + $(CTFCONVERT_O) + +$(OBJS_DIR_OBJ64)/%.o: $(UTSBASE)/common/brand/lx/syscall/%.c + $(COMPILE.c) -D_ELF32_COMPAT -o $@ $< + $(CTFCONVERT_O) + +$(OBJS_DIR_DBG64)/%.o: $(UTSBASE)/common/brand/lx/syscall/%.c + $(COMPILE.c) -D_ELF32_COMPAT -o $@ $< + $(CTFCONVERT_O) + +$(OBJS_DIR_OBJ64)/%.o: $(UTSBASE)/intel/brand/lx/%.s + $(COMPILE.s) -D_ELF32_COMPAT -o $@ $< + +$(OBJS_DIR_OBJ64)/%.o: $(LX_CMN)/%.c + $(COMPILE.c) -o $@ $< + $(CTFCONVERT_O) + +$(OBJS_DIR_DBG64)/%.o: $(UTSBASE)/intel/brand/lx/%.s + $(COMPILE.s) -D_ELF32_COMPAT -o $@ $< + +$(OBJS_DIR)/%.o: $(UTSBASE)/common/brand/lx/os/%.c + $(COMPILE.c) -o $@ $< + $(CTFCONVERT_O) + +$(OBJS_DIR)/%.o: $(UTSBASE)/common/brand/lx/syscall/%.c + $(COMPILE.c) -o $@ $< + $(CTFCONVERT_O) + +$(OBJS_DIR)/%.o: $(LX_CMN)/%.c + $(COMPILE.c) -o $@ $< + $(CTFCONVERT_O) + +$(OBJS_DIR)/%.o: $(UTSBASE)/intel/brand/lx/%.s + $(COMPILE.s) -o $@ $< + +# +# Section 1b: Lint `object' build rules. +# +$(LINTS_DIR)/%.ln: $(UTSBASE)/common/brand/lx/os/%.c + @($(LHEAD) $(LINT.c) $< $(LTAIL)) + +$(LINTS_DIR)/%.ln: $(UTSBASE)/common/brand/lx/syscall/%.c + @($(LHEAD) $(LINT.c) $< $(LTAIL)) + +$(LINTS_DIR)/%.ln: $(LX_CMN)/%.c + @($(LHEAD) $(LINT.c) $< $(LTAIL)) + +$(LINTS_DIR)/%.ln: $(UTSBASE)/intel/brand/lx/%.s + @($(LHEAD) $(LINT.s) $< $(LTAIL)) diff --git a/usr/src/uts/intel/lx_proc/Makefile b/usr/src/uts/intel/lx_proc/Makefile new file mode 100644 index 0000000000..91c032f9fe --- /dev/null +++ b/usr/src/uts/intel/lx_proc/Makefile @@ -0,0 +1,107 @@ +# +# 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 +# or http://www.opensolaris.org/os/licensing. +# 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 +# +# +# uts/intel/lx_proc/Makefile +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" +# +# This makefile drives the production of the lxproc file system +# kernel module. +# +# i86 architecture dependent +# + +# +# Path to the base of the uts directory tree (usually /usr/src/uts). +# +UTSBASE = ../.. + +# +# Path to where brand common sources live +# +LX_CMN = $(SRC)/common/brand/lx + +# +# Define the module and object file sets. +# +MODULE = lx_proc +OBJECTS = $(LX_PROC_OBJS:%=$(OBJS_DIR)/%) +LINTS = $(LX_PROC_OBJS:%.o=$(LINTS_DIR)/%.ln) +ROOTMODULE = $(ROOT_FS_DIR)/$(MODULE) + +INC_PATH += -I$(UTSBASE)/common/brand/lx -I$(LX_CMN) + +# +# Include common rules. +# +include $(UTSBASE)/intel/Makefile.intel + +# +# Define targets +# +ALL_TARGET = $(BINARY) +LINT_TARGET = $(MODULE).lint +INSTALL_TARGET = $(BINARY) $(ROOTMODULE) + +# +# Overrides. +# +CFLAGS += $(CCVERBOSE) + +# +# Depends on procfs and lx_brand +# +LDFLAGS += -dy -Nfs/procfs -Nbrand/lx_brand + +# +# Default build targets. +# +.KEEP_STATE: + +def: $(DEF_DEPS) + +all: $(ALL_DEPS) + +clean: $(CLEAN_DEPS) + +clobber: $(CLOBBER_DEPS) + +lint: $(LINT_DEPS) + +modlintlib: $(MODLINTLIB_DEPS) + +clean.lint: $(CLEAN_LINT_DEPS) + +install: $(INSTALL_DEPS) + +# +# Include common targets. +# +include $(UTSBASE)/intel/Makefile.targ + +# +# Include brand-specific rules +# + +include $(UTSBASE)/intel/lx_proc/Makefile.rules diff --git a/usr/src/uts/intel/lx_proc/Makefile.rules b/usr/src/uts/intel/lx_proc/Makefile.rules new file mode 100644 index 0000000000..b8592d2fdd --- /dev/null +++ b/usr/src/uts/intel/lx_proc/Makefile.rules @@ -0,0 +1,38 @@ +# +# 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 +# or http://www.opensolaris.org/os/licensing. +# 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 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +# +# Section 1a: C object build rules +# +$(OBJS_DIR)/%.o: $(UTSBASE)/common/brand/lx/procfs/%.c + $(COMPILE.c) -o $@ $< + $(CTFCONVERT_O) + +# +# Section 1b: Lint `object' build rules. +# +$(LINTS_DIR)/%.ln: $(UTSBASE)/common/brand/lx/procfs/%.c + @($(LHEAD) $(LINT.c) $< $(LTAIL)) diff --git a/usr/src/uts/intel/lx_ptm/Makefile b/usr/src/uts/intel/lx_ptm/Makefile new file mode 100644 index 0000000000..9a7d26597e --- /dev/null +++ b/usr/src/uts/intel/lx_ptm/Makefile @@ -0,0 +1,93 @@ +# +# 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 +# or http://www.opensolaris.org/os/licensing. +# 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 +# +# +# uts/intel/lx_ptm/Makefile +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#pragma ident "%Z%%M% %I% %E% SMI" +# +# This makefile drives the production of the lx_ptm driver +# +# intel architecture dependent +# + +# +# Path to the base of the uts directory tree (usually /usr/src/uts). +# +UTSBASE = ../.. + +# +# Define the module and object file sets. +# +MODULE = lx_ptm +OBJECTS = $(LX_PTM_OBJS:%=$(OBJS_DIR)/%) +LINTS = $(LX_PTM_OBJS:%.o=$(LINTS_DIR)/%.ln) +ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) +CONF_SRCDIR = $(UTSBASE)/common/brand/lx/io + +# +# Include common rules. +# +include $(UTSBASE)/intel/Makefile.intel + +# +# Define targets +# +ALL_TARGET = $(BINARY) $(SRC_CONFILE) +LINT_TARGET = $(MODULE).lint +INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) + +CPPFLAGS += -I$(UTSBASE)/common/brand/lx + +# +# Default build targets. +# +.KEEP_STATE: + +def: $(DEF_DEPS) + +all: $(ALL_DEPS) + +clean: $(CLEAN_DEPS) + +clobber: $(CLOBBER_DEPS) + +lint: $(LINT_DEPS) + +modlintlib: $(MODLINTLIB_DEPS) + +clean.lint: $(CLEAN_LINT_DEPS) + +install: $(INSTALL_DEPS) + +# +# Include common targets. +# +include $(UTSBASE)/intel/Makefile.targ + +$(OBJS_DIR)/%.o: $(UTSBASE)/common/brand/lx/io/%.c + $(COMPILE.c) -o $@ $< + $(CTFCONVERT_O) + +$(LINTS_DIR)/%.ln: $(UTSBASE)/common/brand/lx/io/%.c + @($(LHEAD) $(LINT.c) $< $(LTAIL)) diff --git a/usr/src/uts/intel/lx_systrace/Makefile b/usr/src/uts/intel/lx_systrace/Makefile new file mode 100644 index 0000000000..25872ff3dd --- /dev/null +++ b/usr/src/uts/intel/lx_systrace/Makefile @@ -0,0 +1,74 @@ +# +# 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 +# or http://www.opensolaris.org/os/licensing. +# 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 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +UTSBASE = ../.. + +MODULE = lx_systrace +OBJECTS = $(LX_SYSTRACE_OBJS:%=$(OBJS_DIR)/%) +LINTS = $(LX_SYSTRACE_OBJS:%.o=$(LINTS_DIR)/%.ln) +ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) +ROOTLINK = $(ROOT_DTRACE_DIR)/$(MODULE) +CONF_SRCDIR = $(UTSBASE)/common/brand/lx/dtrace + +include $(UTSBASE)/intel/Makefile.intel + +ALL_TARGET = $(BINARY) $(SRC_CONFILE) +LINT_TARGET = $(MODULE).lint +INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOTLINK) $(ROOT_CONFFILE) + +CPPFLAGS += -I$(UTSBASE)/common/brand/lx + +LDFLAGS += -dy -Ndrv/dtrace -Nbrand/lx_brand + +.KEEP_STATE: + +def: $(DEF_DEPS) + +all: $(ALL_DEPS) + +clean: $(CLEAN_DEPS) + +clobber: $(CLOBBER_DEPS) + +lint: $(LINT_DEPS) + +modlintlib: $(MODLINTLIB_DEPS) + +clean.lint: $(CLEAN_LINT_DEPS) + +install: $(INSTALL_DEPS) + +$(ROOTLINK): $(ROOT_DTRACE_DIR) $(ROOTMODULE) + -$(RM) $@; ln $(ROOTMODULE) $@ + +include $(UTSBASE)/intel/Makefile.targ + +$(OBJS_DIR)/%.o: $(UTSBASE)/common/brand/lx/dtrace/%.c + $(COMPILE.c) -o $@ $< + $(CTFCONVERT_O) + +$(LINTS_DIR)/%.ln: $(UTSBASE)/common/brand/lx/dtrace/%.c + @($(LHEAD) $(LINT.c) $< $(LTAIL)) diff --git a/usr/src/uts/intel/os/minor_perm b/usr/src/uts/intel/os/minor_perm index 2bff059569..3929c6f960 100644 --- a/usr/src/uts/intel/os/minor_perm +++ b/usr/src/uts/intel/os/minor_perm @@ -121,3 +121,5 @@ zfs:* 0600 root sys zfs:zfs 0666 root sys scsi_vhci:* 0666 root sys kssl:* 0666 root sys +lx_ptm:lx_ptmajor 0666 root sys +lx_systrace:* 0644 root sys diff --git a/usr/src/uts/intel/os/name_to_major b/usr/src/uts/intel/os/name_to_major index 1e4d010253..551c165a18 100644 --- a/usr/src/uts/intel/os/name_to_major +++ b/usr/src/uts/intel/os/name_to_major @@ -122,3 +122,6 @@ kssl 185 mc-amd 186 tzmon 187 did 239 +lx_ptm 240 +lx_systrace 241 +lx_audio 242 diff --git a/usr/src/uts/intel/os/name_to_sysnum b/usr/src/uts/intel/os/name_to_sysnum index 61fcfca712..aebf29f2f2 100644 --- a/usr/src/uts/intel/os/name_to_sysnum +++ b/usr/src/uts/intel/os/name_to_sysnum @@ -38,6 +38,7 @@ syssync 36 kill 37 fstatfs 38 setpgrp 39 +uucopystr 40 dup 41 pipe 42 times 43 @@ -157,6 +158,7 @@ pread 173 pwrite 174 llseek 175 inst_sync 176 +brandsys 177 kaio 178 cpc 179 meminfosys 180 @@ -232,4 +234,5 @@ lwp_mutex_unlock 250 lwp_mutex_trylock 251 lwp_mutex_init 252 cladm 253 +uucopy 254 umount2 255 diff --git a/usr/src/uts/intel/sn1_brand/Makefile b/usr/src/uts/intel/sn1_brand/Makefile new file mode 100644 index 0000000000..403819001b --- /dev/null +++ b/usr/src/uts/intel/sn1_brand/Makefile @@ -0,0 +1,82 @@ +# +# 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 +# or http://www.opensolaris.org/os/licensing. +# 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 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" +# +# This makefile drives the production of the kernel component of +# the N-1 Solaris brand +# + +# +# Path to the base of the uts directory tree (usually /usr/src/uts). +# +UTSBASE = ../.. + +# +# Define the module and object file sets. +# +MODULE = sn1_brand +OBJECTS = $(SN1_BRAND_OBJS:%=$(OBJS_DIR)/%) +LINTS = $(SN1_BRAND_OBJS:%.o=$(LINTS_DIR)/%.ln) +ROOTMODULE = $(ROOT_BRAND_DIR)/$(MODULE) + +# +# Include common rules. +# +include $(UTSBASE)/intel/Makefile.intel + +# +# Define targets +# +ALL_TARGET = $(BINARY) +LINT_TARGET = $(MODULE).lint +INSTALL_TARGET = $(BINARY) $(ROOTMODULE) + +INC_PATH += -I$(UTSBASE)/common/brand/sn1 + +# +# Default build targets. +# +.KEEP_STATE: + +def: $(DEF_DEPS) + +all: $(ALL_DEPS) + +clean: $(CLEAN_DEPS) + +clobber: $(CLOBBER_DEPS) + +lint: $(LINT_DEPS) + +modlintlib: $(MODLINTLIB_DEPS) + +clean.lint: $(CLEAN_LINT_DEPS) + +install: $(INSTALL_DEPS) + +# +# Include common targets. +# +include $(UTSBASE)/intel/Makefile.targ diff --git a/usr/src/uts/intel/sys/archsystm.h b/usr/src/uts/intel/sys/archsystm.h index 5ed70f0cb2..07adccd582 100644 --- a/usr/src/uts/intel/sys/archsystm.h +++ b/usr/src/uts/intel/sys/archsystm.h @@ -69,11 +69,17 @@ extern void sys_syscall(); extern void sys_syscall32(); extern void sys_lcall32(); extern void sys_syscall_int(); +extern void brand_sys_syscall(); +extern void brand_sys_syscall32(); +extern void brand_sys_syscall_int(); #elif defined(__i386) extern void sys_call(); +extern void brand_sys_call(); #endif extern void sys_sysenter(); extern void _sys_sysenter_post_swapgs(); +extern void brand_sys_sysenter(); +extern void _brand_sys_sysenter_post_swapgs(); extern void dosyscall(void); @@ -112,6 +118,9 @@ extern int fpu_pentium_fdivbug; extern void sep_save(void *); extern void sep_restore(void *); +extern void brand_interpositioning_enable(void); +extern void brand_interpositioning_disable(void); + struct regs; extern int instr_size(struct regs *, caddr_t *, enum seg_rw); @@ -136,6 +145,8 @@ extern void setup_mca(void); extern void setup_mtrr(void); extern void patch_tsc(void); +extern user_desc_t *cpu_get_gdt(void); + /* * Warning: these routines do -not- use normal calling conventions! */ diff --git a/usr/src/uts/intel/sys/fasttrap_isa.h b/usr/src/uts/intel/sys/fasttrap_isa.h index 89e2cf30ed..2406791710 100644 --- a/usr/src/uts/intel/sys/fasttrap_isa.h +++ b/usr/src/uts/intel/sys/fasttrap_isa.h @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * 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 * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -55,6 +54,7 @@ typedef struct fasttrap_machtp { uint8_t ftmt_base; /* branch base */ uint8_t ftmt_index; /* branch index */ uint8_t ftmt_scale; /* branch scale */ + uint8_t ftmt_segment; /* segment for memory accesses */ uintptr_t ftmt_dest; /* destination of control flow */ } fasttrap_machtp_t; @@ -69,6 +69,7 @@ typedef struct fasttrap_machtp { #define ftt_base ftt_mtp.ftmt_base #define ftt_index ftt_mtp.ftmt_index #define ftt_scale ftt_mtp.ftmt_scale +#define ftt_segment ftt_mtp.ftmt_segment #define ftt_dest ftt_mtp.ftmt_dest #define FASTTRAP_T_COMMON 0x00 /* common case -- no emulation */ @@ -89,6 +90,17 @@ typedef struct fasttrap_machtp { #define FASTTRAP_RIP_2 0x2 #define FASTTRAP_RIP_X 0x4 +/* + * Segment values. + */ +#define FASTTRAP_SEG_NONE 0 +#define FASTTRAP_SEG_CS 1 +#define FASTTRAP_SEG_DS 2 +#define FASTTRAP_SEG_ES 3 +#define FASTTRAP_SEG_FS 4 +#define FASTTRAP_SEG_GS 5 +#define FASTTRAP_SEG_SS 6 + #define FASTTRAP_AFRAMES 3 #define FASTTRAP_RETURN_AFRAMES 4 #define FASTTRAP_ENTRY_AFRAMES 3 diff --git a/usr/src/uts/intel/sys/machbrand.h b/usr/src/uts/intel/sys/machbrand.h new file mode 100644 index 0000000000..e4b90473a6 --- /dev/null +++ b/usr/src/uts/intel/sys/machbrand.h @@ -0,0 +1,60 @@ +/* + * 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 + * or http://www.opensolaris.org/os/licensing. + * 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 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SYS_MACHBRAND_H +#define _SYS_MACHBRAND_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ASM + +#include <sys/model.h> + +struct brand_mach_ops { + void (*b_sysenter)(void); + void (*b_int80)(void); + void (*b_int91)(void); + void (*b_syscall)(void); + void (*b_syscall32)(void); + greg_t (*b_fixsegreg)(greg_t, model_t); +}; + +#endif /* _ASM */ + +#define BRAND_CB_SYSENTER 0 +#define BRAND_CB_INT80 1 +#define BRAND_CB_INT91 2 +#define BRAND_CB_SYSCALL 3 +#define BRAND_CB_SYSCALL32 4 + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MACHBRAND_H */ diff --git a/usr/src/uts/intel/sys/segments.h b/usr/src/uts/intel/sys/segments.h index b17b300cd6..fe65db8575 100644 --- a/usr/src/uts/intel/sys/segments.h +++ b/usr/src/uts/intel/sys/segments.h @@ -453,7 +453,9 @@ void set_syssegd(system_desc_t *, void *, size_t, uint_t, uint_t); #define GDT_GS GDT_NULL /* kernel %gs segment selector */ #define GDT_LWPFS 55 /* lwp private %fs segment selector */ #define GDT_LWPGS 56 /* lwp private %gs segment selector */ -#define NGDT 58 /* number of entries in GDT */ +#define GDT_BRANDMIN 57 /* first entry in GDT for brand usage */ +#define GDT_BRANDMAX 61 /* last entry in GDT for brand usage */ +#define NGDT 62 /* number of entries in GDT */ /* * This selector is only used in the temporary GDT used to bring additional @@ -479,6 +481,8 @@ void set_syssegd(system_desc_t *, void *, size_t, uint_t, uint_t); #define GDT_GS 54 /* kernel %gs segment selector */ #define GDT_LWPFS 55 /* lwp private %fs segment selector */ #define GDT_LWPGS 56 /* lwp private %gs segment selector */ +#define GDT_BRANDMIN 57 /* first entry in GDT for brand usage */ +#define GDT_BRANDMAX 61 /* last entry in GDT for brand usage */ #define NGDT 90 /* number of entries in GDT */ #endif /* __i386 */ @@ -501,6 +505,8 @@ void set_syssegd(system_desc_t *, void *, size_t, uint_t, uint_t); #define KGS_SEL SEL_GDT(GDT_GS, SEL_KPL) #define LWPFS_SEL SEL_GDT(GDT_LWPFS, SEL_UPL) #define LWPGS_SEL SEL_GDT(GDT_LWPGS, SEL_UPL) +#define BRANDMIN_SEL SEL_GDT(GDT_BRANDMIN, SEL_UPL) +#define BRANDMAX_SEL SEL_GDT(GDT_BRANDMAX, SEL_UPL) #if defined(__amd64) #define B64CODE_SEL SEL_GDT(GDT_B64CODE, SEL_KPL) #else @@ -551,6 +557,8 @@ extern void _start(), cmnint(); extern void achktrap(), mcetrap(); extern void xmtrap(); extern void fasttrap(); +extern void sys_int80(); +extern void brand_sys_int80(); extern void dtrace_ret(); #if !defined(__amd64) diff --git a/usr/src/uts/intel/sys/sysi86.h b/usr/src/uts/intel/sys/sysi86.h index 4c3c4182ff..54e9f905a0 100644 --- a/usr/src/uts/intel/sys/sysi86.h +++ b/usr/src/uts/intel/sys/sysi86.h @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * 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 * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -144,6 +143,7 @@ struct ssd { #ifdef _KERNEL extern void usd_to_ssd(user_desc_t *, struct ssd *, selector_t); +extern int setdscr(struct ssd *); #endif /* _KERNEL */ /* |