Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Aug 2017 13:16:14 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r322786 - in head/sys/arm64: arm64 include
Message-ID:  <201708221316.v7MDGEP0005957@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Tue Aug 22 13:16:14 2017
New Revision: 322786
URL: https://svnweb.freebsd.org/changeset/base/322786

Log:
  Move the l0 pagetable address to struct mdproc. It is a property of the
  whole process so should live there.
  
  Sponsored by:	DARPA, AFRL

Modified:
  head/sys/arm64/arm64/genassym.c
  head/sys/arm64/arm64/pmap.c
  head/sys/arm64/arm64/swtch.S
  head/sys/arm64/arm64/vm_machdep.c
  head/sys/arm64/include/pcb.h
  head/sys/arm64/include/proc.h

Modified: head/sys/arm64/arm64/genassym.c
==============================================================================
--- head/sys/arm64/arm64/genassym.c	Tue Aug 22 13:08:22 2017	(r322785)
+++ head/sys/arm64/arm64/genassym.c	Tue Aug 22 13:16:14 2017	(r322786)
@@ -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));

Modified: head/sys/arm64/arm64/pmap.c
==============================================================================
--- head/sys/arm64/arm64/pmap.c	Tue Aug 22 13:08:22 2017	(r322785)
+++ head/sys/arm64/arm64/pmap.c	Tue Aug 22 13:16:14 2017	(r322786)
@@ -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();
 }

Modified: head/sys/arm64/arm64/swtch.S
==============================================================================
--- head/sys/arm64/arm64/swtch.S	Tue Aug 22 13:08:22 2017	(r322785)
+++ head/sys/arm64/arm64/swtch.S	Tue Aug 22 13:16:14 2017	(r322786)
@@ -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
 

Modified: head/sys/arm64/arm64/vm_machdep.c
==============================================================================
--- head/sys/arm64/arm64/vm_machdep.c	Tue Aug 22 13:08:22 2017	(r322785)
+++ head/sys/arm64/arm64/vm_machdep.c	Tue Aug 22 13:16:14 2017	(r322786)
@@ -91,7 +91,7 @@ cpu_fork(struct thread *td1, struct proc *p2, struct t
 	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);

Modified: head/sys/arm64/include/pcb.h
==============================================================================
--- head/sys/arm64/include/pcb.h	Tue Aug 22 13:08:22 2017	(r322785)
+++ head/sys/arm64/include/pcb.h	Tue Aug 22 13:16:14 2017	(r322786)
@@ -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;

Modified: head/sys/arm64/include/proc.h
==============================================================================
--- head/sys/arm64/include/proc.h	Tue Aug 22 13:08:22 2017	(r322785)
+++ head/sys/arm64/include/proc.h	Tue Aug 22 13:16:14 2017	(r322786)
@@ -40,7 +40,7 @@ struct mdthread {
 };
 
 struct mdproc {
-	int dummy;
+	vm_offset_t	md_l0addr;
 };
 
 #define	KINFO_PROC_SIZE	1088



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708221316.v7MDGEP0005957>