1a9643ea8Slogwang /*- 2*22ce4affSfengbojiang * SPDX-License-Identifier: BSD-3-Clause 3*22ce4affSfengbojiang * 4a9643ea8Slogwang * Copyright (c) 1991 Regents of the University of California. 5a9643ea8Slogwang * All rights reserved. 6a9643ea8Slogwang * 7a9643ea8Slogwang * Redistribution and use in source and binary forms, with or without 8a9643ea8Slogwang * modification, are permitted provided that the following conditions 9a9643ea8Slogwang * are met: 10a9643ea8Slogwang * 1. Redistributions of source code must retain the above copyright 11a9643ea8Slogwang * notice, this list of conditions and the following disclaimer. 12a9643ea8Slogwang * 2. Redistributions in binary form must reproduce the above copyright 13a9643ea8Slogwang * notice, this list of conditions and the following disclaimer in the 14a9643ea8Slogwang * documentation and/or other materials provided with the distribution. 15*22ce4affSfengbojiang * 3. Neither the name of the University nor the names of its contributors 16a9643ea8Slogwang * may be used to endorse or promote products derived from this software 17a9643ea8Slogwang * without specific prior written permission. 18a9643ea8Slogwang * 19a9643ea8Slogwang * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20a9643ea8Slogwang * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21a9643ea8Slogwang * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22a9643ea8Slogwang * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23a9643ea8Slogwang * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24a9643ea8Slogwang * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25a9643ea8Slogwang * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26a9643ea8Slogwang * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27a9643ea8Slogwang * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28a9643ea8Slogwang * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29a9643ea8Slogwang * SUCH DAMAGE. 30a9643ea8Slogwang * 31a9643ea8Slogwang * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 32a9643ea8Slogwang * $FreeBSD$ 33a9643ea8Slogwang */ 34a9643ea8Slogwang 35a9643ea8Slogwang #ifndef _MACHINE_PROC_H_ 36a9643ea8Slogwang #define _MACHINE_PROC_H_ 37a9643ea8Slogwang 38a9643ea8Slogwang #include <sys/queue.h> 39*22ce4affSfengbojiang #include <machine/pcb.h> 40a9643ea8Slogwang #include <machine/segments.h> 41a9643ea8Slogwang 42a9643ea8Slogwang /* 43a9643ea8Slogwang * List of locks 44*22ce4affSfengbojiang * c - proc lock 45a9643ea8Slogwang * k - only accessed by curthread 46a9643ea8Slogwang * pp - pmap.c:invl_gen_mtx 47a9643ea8Slogwang */ 48a9643ea8Slogwang 49a9643ea8Slogwang struct proc_ldt { 50a9643ea8Slogwang caddr_t ldt_base; 51a9643ea8Slogwang int ldt_refcnt; 52a9643ea8Slogwang }; 53a9643ea8Slogwang 54*22ce4affSfengbojiang #define PMAP_INVL_GEN_NEXT_INVALID 0x1ULL 55a9643ea8Slogwang struct pmap_invl_gen { 56a9643ea8Slogwang u_long gen; /* (k) */ 57*22ce4affSfengbojiang union { 58a9643ea8Slogwang LIST_ENTRY(pmap_invl_gen) link; /* (pp) */ 59*22ce4affSfengbojiang struct { 60*22ce4affSfengbojiang struct pmap_invl_gen *next; 61*22ce4affSfengbojiang u_char saved_pri; 62a9643ea8Slogwang }; 63*22ce4affSfengbojiang }; 64*22ce4affSfengbojiang } __aligned(16); 65a9643ea8Slogwang 66a9643ea8Slogwang /* 67a9643ea8Slogwang * Machine-dependent part of the proc structure for AMD64. 68a9643ea8Slogwang */ 69a9643ea8Slogwang struct mdthread { 70a9643ea8Slogwang int md_spinlock_count; /* (k) */ 71a9643ea8Slogwang register_t md_saved_flags; /* (k) */ 72a9643ea8Slogwang register_t md_spurflt_addr; /* (k) Spurious page fault address. */ 73a9643ea8Slogwang struct pmap_invl_gen md_invl_gen; 74*22ce4affSfengbojiang register_t md_efirt_tmp; /* (k) */ 75*22ce4affSfengbojiang int md_efirt_dis_pf; /* (k) */ 76*22ce4affSfengbojiang struct pcb md_pcb; 77*22ce4affSfengbojiang vm_offset_t md_stack_base; 78a9643ea8Slogwang }; 79a9643ea8Slogwang 80a9643ea8Slogwang struct mdproc { 81a9643ea8Slogwang struct proc_ldt *md_ldt; /* (t) per-process ldt */ 82a9643ea8Slogwang struct system_segment_descriptor md_ldt_sd; 83*22ce4affSfengbojiang u_int md_flags; /* (c) md process flags P_MD */ 84a9643ea8Slogwang }; 85a9643ea8Slogwang 86*22ce4affSfengbojiang #define P_MD_KPTI 0x00000001 /* Enable KPTI on exec */ 87*22ce4affSfengbojiang #define P_MD_LA48 0x00000002 /* Request LA48 after exec */ 88*22ce4affSfengbojiang #define P_MD_LA57 0x00000004 /* Request LA57 after exec */ 89*22ce4affSfengbojiang 90a9643ea8Slogwang #define KINFO_PROC_SIZE 1088 91a9643ea8Slogwang #define KINFO_PROC32_SIZE 768 92a9643ea8Slogwang 93*22ce4affSfengbojiang struct syscall_args { 94*22ce4affSfengbojiang u_int code; 95*22ce4affSfengbojiang struct sysent *callp; 96*22ce4affSfengbojiang register_t args[8]; 97*22ce4affSfengbojiang }; 98*22ce4affSfengbojiang 99a9643ea8Slogwang #ifdef _KERNEL 100a9643ea8Slogwang 101a9643ea8Slogwang /* Get the current kernel thread stack usage. */ 102a9643ea8Slogwang #define GET_STACK_USAGE(total, used) do { \ 103a9643ea8Slogwang struct thread *td = curthread; \ 104a9643ea8Slogwang (total) = td->td_kstack_pages * PAGE_SIZE; \ 105a9643ea8Slogwang (used) = (char *)td->td_kstack + \ 106a9643ea8Slogwang td->td_kstack_pages * PAGE_SIZE - \ 107a9643ea8Slogwang (char *)&td; \ 108a9643ea8Slogwang } while (0) 109a9643ea8Slogwang 110a9643ea8Slogwang struct proc_ldt *user_ldt_alloc(struct proc *, int); 111a9643ea8Slogwang void user_ldt_free(struct thread *); 112a9643ea8Slogwang struct sysarch_args; 113a9643ea8Slogwang int sysarch_ldt(struct thread *td, struct sysarch_args *uap, int uap_space); 114a9643ea8Slogwang int amd64_set_ldt_data(struct thread *td, int start, int num, 115a9643ea8Slogwang struct user_segment_descriptor *descs); 116a9643ea8Slogwang 117a9643ea8Slogwang extern struct mtx dt_lock; 118a9643ea8Slogwang extern int max_ldt_segment; 119a9643ea8Slogwang 120*22ce4affSfengbojiang #define NARGREGS 6 121*22ce4affSfengbojiang 122a9643ea8Slogwang #endif /* _KERNEL */ 123a9643ea8Slogwang 124a9643ea8Slogwang #endif /* !_MACHINE_PROC_H_ */ 125