Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/amd64/machdep.c
Show First 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | |||||
* couple of scratch registers, as well as the trapframe left behind after an | * couple of scratch registers, as well as the trapframe left behind after an | ||||
* iret fault. | * iret fault. | ||||
*/ | */ | ||||
CTASSERT(PC_PTI_STACK_SZ * sizeof(register_t) >= 2 * sizeof(struct pti_frame) - | CTASSERT(PC_PTI_STACK_SZ * sizeof(register_t) >= 2 * sizeof(struct pti_frame) - | ||||
offsetof(struct pti_frame, pti_rip)); | offsetof(struct pti_frame, pti_rip)); | ||||
extern u_int64_t hammer_time(u_int64_t, u_int64_t); | extern u_int64_t hammer_time(u_int64_t, u_int64_t); | ||||
#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) | |||||
#define EFL_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) | |||||
static void cpu_startup(void *); | static void cpu_startup(void *); | ||||
static void get_fpcontext(struct thread *td, mcontext_t *mcp, | static void get_fpcontext(struct thread *td, mcontext_t *mcp, | ||||
char *xfpusave, size_t xfpusave_len); | char *xfpusave, size_t xfpusave_len); | ||||
static int set_fpcontext(struct thread *td, mcontext_t *mcp, | static int set_fpcontext(struct thread *td, mcontext_t *mcp, | ||||
char *xfpustate, size_t xfpustate_len); | char *xfpustate, size_t xfpustate_len); | ||||
SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); | SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); | ||||
/* Preload data parse function */ | /* Preload data parse function */ | ||||
▲ Show 20 Lines • Show All 1,725 Lines • ▼ Show 20 Lines | #endif | ||||
thread0.td_pcb->pcb_save = get_pcb_user_save_td(&thread0); | thread0.td_pcb->pcb_save = get_pcb_user_save_td(&thread0); | ||||
bzero(thread0.td_pcb->pcb_save, cpu_max_ext_state_size); | bzero(thread0.td_pcb->pcb_save, cpu_max_ext_state_size); | ||||
if (use_xsave) { | if (use_xsave) { | ||||
xhdr = (struct xstate_hdr *)(get_pcb_user_save_td(&thread0) + | xhdr = (struct xstate_hdr *)(get_pcb_user_save_td(&thread0) + | ||||
1); | 1); | ||||
xhdr->xstate_bv = xsave_mask; | xhdr->xstate_bv = xsave_mask; | ||||
} | } | ||||
/* make an initial tss so cpu can get interrupt stack on syscall! */ | /* make an initial tss so cpu can get interrupt stack on syscall! */ | ||||
rsp0 = thread0.td_md.md_stack_base; | rsp0 = thread0.td_md.md_stack_base; | ||||
markj: Aren't we relying on the set_top_of_stack_td() call here? | |||||
Done Inline ActionsYes, it is done at line 1503 above. kib: Yes, it is done at line 1503 above. | |||||
/* Ensure the stack is aligned to 16 bytes */ | /* Ensure the stack is aligned to 16 bytes */ | ||||
rsp0 &= ~0xFul; | rsp0 &= ~0xFul; | ||||
PCPU_PTR(common_tss)->tss_rsp0 = rsp0; | PCPU_PTR(common_tss)->tss_rsp0 = rsp0; | ||||
amd64_bsp_pcpu_init2(rsp0); | amd64_bsp_pcpu_init2(rsp0); | ||||
/* transfer to user mode */ | /* transfer to user mode */ | ||||
_ucodesel = GSEL(GUCODE_SEL, SEL_UPL); | _ucodesel = GSEL(GUCODE_SEL, SEL_UPL); | ||||
Show All 37 Lines | cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) | ||||
pcpu->pc_acpi_id = 0xffffffff; | pcpu->pc_acpi_id = 0xffffffff; | ||||
} | } | ||||
static int | static int | ||||
smap_sysctl_handler(SYSCTL_HANDLER_ARGS) | smap_sysctl_handler(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
struct bios_smap *smapbase; | struct bios_smap *smapbase; | ||||
struct bios_smap_xattr smap; | struct bios_smap_xattr smap; | ||||
caddr_t kmdp; | caddr_t kmdp; | ||||
Done Inline ActionsWhy do we zero the entire save area for thread0 but not for other threads? markj: Why do we zero the entire save area for thread0 but not for other threads? | |||||
Done Inline ActionsThis is just historic. I removed thread0_init_fpu_state() so this question should become not important. kib: This is just historic. I removed thread0_init_fpu_state() so this question should become not… | |||||
uint32_t *smapattr; | uint32_t *smapattr; | ||||
int count, error, i; | int count, error, i; | ||||
/* Retrieve the system memory map from the loader. */ | /* Retrieve the system memory map from the loader. */ | ||||
kmdp = preload_search_by_type("elf kernel"); | kmdp = preload_search_by_type("elf kernel"); | ||||
if (kmdp == NULL) | if (kmdp == NULL) | ||||
kmdp = preload_search_by_type("elf64 kernel"); | kmdp = preload_search_by_type("elf64 kernel"); | ||||
smapbase = (struct bios_smap *)preload_search_info(kmdp, | smapbase = (struct bios_smap *)preload_search_info(kmdp, | ||||
▲ Show 20 Lines • Show All 860 Lines • Show Last 20 Lines |
Aren't we relying on the set_top_of_stack_td() call here?