From 6683b30c03598c49bbdeb6df6c99e69a239fa057 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Tue, 22 Aug 2017 13:16:14 +0000 Subject: [PATCH] Move the l0 pagetable address to struct mdproc. It is a property of the whole process so should live there. Sponsored by: DARPA, AFRL --- sys/arm64/arm64/genassym.c | 5 ++++- sys/arm64/arm64/pmap.c | 5 +++-- sys/arm64/arm64/swtch.S | 12 ++++++++++-- sys/arm64/arm64/vm_machdep.c | 2 +- sys/arm64/include/pcb.h | 1 - sys/arm64/include/proc.h | 2 +- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/sys/arm64/arm64/genassym.c b/sys/arm64/arm64/genassym.c index 5df003cd8735..00b77a435867 100644 --- a/sys/arm64/arm64/genassym.c +++ b/sys/arm64/arm64/genassym.c @@ -50,12 +50,15 @@ ASSYM(PCB_SINGLE_STEP_SHIFT, PCB_SINGLE_STEP_SHIFT); ASSYM(PCB_REGS, offsetof(struct pcb, pcb_x)); ASSYM(PCB_SP, offsetof(struct pcb, pcb_sp)); ASSYM(PCB_TPIDRRO, offsetof(struct pcb, pcb_tpidrro_el0)); -ASSYM(PCB_L0ADDR, offsetof(struct pcb, pcb_l0addr)); ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags)); +ASSYM(P_MD, offsetof(struct proc, p_md)); +ASSYM(MD_L0ADDR, offsetof(struct mdproc, md_l0addr)); + ASSYM(SF_UC, offsetof(struct sigframe, sf_uc)); +ASSYM(TD_PROC, offsetof(struct thread, td_proc)); ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); ASSYM(TD_FLAGS, offsetof(struct thread, td_flags)); ASSYM(TD_FRAME, offsetof(struct thread, td_frame)); diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index e6d17acf6fd0..92c9b89b7469 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -4662,8 +4662,9 @@ pmap_activate(struct thread *td) critical_enter(); pmap = vmspace_pmap(td->td_proc->p_vmspace); - td->td_pcb->pcb_l0addr = vtophys(pmap->pm_l0); - __asm __volatile("msr ttbr0_el1, %0" : : "r"(td->td_pcb->pcb_l0addr)); + td->td_proc->p_md.md_l0addr = vtophys(pmap->pm_l0); + __asm __volatile("msr ttbr0_el1, %0" : : + "r"(td->td_proc->p_md.md_l0addr)); pmap_invalidate_all(pmap); critical_exit(); } diff --git a/sys/arm64/arm64/swtch.S b/sys/arm64/arm64/swtch.S index bb46da86a97e..1b7261ec073b 100644 --- a/sys/arm64/arm64/swtch.S +++ b/sys/arm64/arm64/swtch.S @@ -86,7 +86,8 @@ ENTRY(cpu_throw) */ /* Switch to the new pmap */ - ldr x5, [x4, #PCB_L0ADDR] + ldr x28, [x1, #TD_PROC] + ldr x5, [x28, #(P_MD + MD_L0ADDR)] msr ttbr0_el1, x5 isb @@ -186,8 +187,15 @@ ENTRY(cpu_switch) * to a user process. */ + /* + * Load the proc pointers. If these are the same then we are in the + * same process so don't need to switch page tables or issue a + * TLB invalidate. + */ + ldr x28, [x1, #TD_PROC] + /* Switch to the new pmap */ - ldr x5, [x4, #PCB_L0ADDR] + ldr x5, [x28, #(P_MD + MD_L0ADDR)] msr ttbr0_el1, x5 isb diff --git a/sys/arm64/arm64/vm_machdep.c b/sys/arm64/arm64/vm_machdep.c index e5a337e29fdb..e8c63b5c4023 100644 --- a/sys/arm64/arm64/vm_machdep.c +++ b/sys/arm64/arm64/vm_machdep.c @@ -91,7 +91,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) td2->td_pcb = pcb2; bcopy(td1->td_pcb, pcb2, sizeof(*pcb2)); - td2->td_pcb->pcb_l0addr = + td2->td_proc->p_md.md_l0addr = vtophys(vmspace_pmap(td2->td_proc->p_vmspace)->pm_l0); tf = (struct trapframe *)STACKALIGN((struct trapframe *)pcb2 - 1); diff --git a/sys/arm64/include/pcb.h b/sys/arm64/include/pcb.h index 602c0d6f8248..bd8b1b4235a8 100644 --- a/sys/arm64/include/pcb.h +++ b/sys/arm64/include/pcb.h @@ -43,7 +43,6 @@ struct pcb { uint64_t pcb_sp; uint64_t pcb_tpidr_el0; uint64_t pcb_tpidrro_el0; - vm_offset_t pcb_l0addr; /* Fault handler, the error value is passed in x0 */ vm_offset_t pcb_onfault; diff --git a/sys/arm64/include/proc.h b/sys/arm64/include/proc.h index 86dedbff0579..cae67386b0c8 100644 --- a/sys/arm64/include/proc.h +++ b/sys/arm64/include/proc.h @@ -40,7 +40,7 @@ struct mdthread { }; struct mdproc { - int dummy; + vm_offset_t md_l0addr; }; #define KINFO_PROC_SIZE 1088