1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26/* 27 * Copyright 2019 Joyent, Inc. 28 * Copyright 2022 Oxide Computer Company 29 */ 30 31#include <sys/asm_linkage.h> 32#include <sys/asm_misc.h> 33#include <sys/regset.h> 34#include <sys/panic.h> 35#include <sys/ontrap.h> 36#include <sys/privregs.h> 37#include <sys/segments.h> 38#include <sys/trap.h> 39 40#include "assym.h" 41 42 ENTRY_NP(rd_idtr) 43 sidt (%rdi) 44 ret 45 SET_SIZE(rd_idtr) 46 47 ENTRY_NP(wr_idtr) 48 lidt (%rdi) 49 ret 50 SET_SIZE(wr_idtr) 51 52 ENTRY_NP(rd_gdtr) 53 pushq %rbp 54 movq %rsp, %rbp 55 sgdt (%rdi) 56 leave 57 ret 58 SET_SIZE(rd_gdtr) 59 60 ENTRY_NP(wr_gdtr) 61 pushq %rbp 62 movq %rsp, %rbp 63 lgdt (%rdi) 64 leave 65 ret 66 SET_SIZE(wr_gdtr) 67 68 /* 69 * loads zero selector for ds and es. 70 */ 71 ENTRY_NP(load_segment_registers) 72 pushq %rbp 73 movq %rsp, %rbp 74 pushq %rdi 75 pushq $.newcs 76 lretq 77.newcs: 78 /* 79 * zero %ds and %es - they're ignored anyway 80 */ 81 xorl %eax, %eax 82 movw %ax, %ds 83 movw %ax, %es 84 movl %esi, %eax 85 movw %ax, %fs 86 movl %edx, %eax 87 movw %ax, %gs 88 movl %ecx, %eax 89 movw %ax, %ss 90 leave 91 ret 92 SET_SIZE(load_segment_registers) 93 94 ENTRY_NP(get_cs_register) 95 movq %cs, %rax 96 ret 97 SET_SIZE(get_cs_register) 98 99 ENTRY_NP(wr_ldtr) 100 movq %rdi, %rax 101 lldt %ax 102 ret 103 SET_SIZE(wr_ldtr) 104 105 ENTRY_NP(rd_ldtr) 106 xorl %eax, %eax 107 sldt %ax 108 ret 109 SET_SIZE(rd_ldtr) 110 111 ENTRY_NP(wr_tsr) 112 movq %rdi, %rax 113 ltr %ax 114 ret 115 SET_SIZE(wr_tsr) 116 117