Move the hardware setup for fast syscalls into a common function.
Discussed with: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week
This commit is contained in:
parent
4275e16fa9
commit
0f7c159f6b
@ -1512,6 +1512,22 @@ amd64_kdb_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Set up the fast syscall stuff */
|
||||
void
|
||||
amd64_conf_fast_syscall(void)
|
||||
{
|
||||
uint64_t msr;
|
||||
|
||||
msr = rdmsr(MSR_EFER) | EFER_SCE;
|
||||
wrmsr(MSR_EFER, msr);
|
||||
wrmsr(MSR_LSTAR, (u_int64_t)IDTVEC(fast_syscall));
|
||||
wrmsr(MSR_CSTAR, (u_int64_t)IDTVEC(fast_syscall32));
|
||||
msr = ((u_int64_t)GSEL(GCODE_SEL, SEL_KPL) << 32) |
|
||||
((u_int64_t)GSEL(GUCODE32_SEL, SEL_UPL) << 48);
|
||||
wrmsr(MSR_STAR, msr);
|
||||
wrmsr(MSR_SF_MASK, PSL_NT | PSL_T | PSL_I | PSL_C | PSL_D);
|
||||
}
|
||||
|
||||
u_int64_t
|
||||
hammer_time(u_int64_t modulep, u_int64_t physfree)
|
||||
{
|
||||
@ -1520,7 +1536,6 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
|
||||
struct pcpu *pc;
|
||||
struct nmi_pcpu *np;
|
||||
struct xstate_hdr *xhdr;
|
||||
u_int64_t msr;
|
||||
char *env;
|
||||
size_t kstack0_sz;
|
||||
int late_console;
|
||||
@ -1663,15 +1678,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
|
||||
gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
|
||||
ltr(gsel_tss);
|
||||
|
||||
/* Set up the fast syscall stuff */
|
||||
msr = rdmsr(MSR_EFER) | EFER_SCE;
|
||||
wrmsr(MSR_EFER, msr);
|
||||
wrmsr(MSR_LSTAR, (u_int64_t)IDTVEC(fast_syscall));
|
||||
wrmsr(MSR_CSTAR, (u_int64_t)IDTVEC(fast_syscall32));
|
||||
msr = ((u_int64_t)GSEL(GCODE_SEL, SEL_KPL) << 32) |
|
||||
((u_int64_t)GSEL(GUCODE32_SEL, SEL_UPL) << 48);
|
||||
wrmsr(MSR_STAR, msr);
|
||||
wrmsr(MSR_SF_MASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D);
|
||||
amd64_conf_fast_syscall();
|
||||
|
||||
/*
|
||||
* Temporary forge some valid pointer to PCB, for exception
|
||||
|
@ -89,8 +89,6 @@ extern struct pcpu __pcpu[];
|
||||
char *doublefault_stack;
|
||||
char *nmi_stack;
|
||||
|
||||
extern inthand_t IDTVEC(fast_syscall), IDTVEC(fast_syscall32);
|
||||
|
||||
/*
|
||||
* Local data and functions.
|
||||
*/
|
||||
@ -190,7 +188,7 @@ init_secondary(void)
|
||||
{
|
||||
struct pcpu *pc;
|
||||
struct nmi_pcpu *np;
|
||||
u_int64_t msr, cr0;
|
||||
u_int64_t cr0;
|
||||
int cpu, gsel_tss, x;
|
||||
struct region_descriptor ap_gdt;
|
||||
|
||||
@ -265,15 +263,7 @@ init_secondary(void)
|
||||
cr0 &= ~(CR0_CD | CR0_NW | CR0_EM);
|
||||
load_cr0(cr0);
|
||||
|
||||
/* Set up the fast syscall stuff */
|
||||
msr = rdmsr(MSR_EFER) | EFER_SCE;
|
||||
wrmsr(MSR_EFER, msr);
|
||||
wrmsr(MSR_LSTAR, (u_int64_t)IDTVEC(fast_syscall));
|
||||
wrmsr(MSR_CSTAR, (u_int64_t)IDTVEC(fast_syscall32));
|
||||
msr = ((u_int64_t)GSEL(GCODE_SEL, SEL_KPL) << 32) |
|
||||
((u_int64_t)GSEL(GUCODE32_SEL, SEL_UPL) << 48);
|
||||
wrmsr(MSR_STAR, msr);
|
||||
wrmsr(MSR_SF_MASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D);
|
||||
amd64_conf_fast_syscall();
|
||||
|
||||
/* signal our startup to the BSP. */
|
||||
mp_naps++;
|
||||
|
@ -42,6 +42,7 @@ extern int hw_lower_amd64_sharedpage;
|
||||
struct savefpu;
|
||||
struct sysentvec;
|
||||
|
||||
void amd64_conf_fast_syscall(void);
|
||||
void amd64_db_resume_dbreg(void);
|
||||
void amd64_lower_shared_page(struct sysentvec *);
|
||||
void amd64_syscall(struct thread *td, int traced);
|
||||
|
Loading…
Reference in New Issue
Block a user