Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Feb 2003 23:00:53 -0800 (PST)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 24871 for review
Message-ID:  <200302090700.h1970rMw092698@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=24871

Change 24871 by marcel@marcel_vaio on 2003/02/08 23:00:07

	o  Insert a fixed translation in the TR for the EPC gateway page.
	   consequently, we cannot have the page in regions 0-4 (non-
	   constant RIDs). Use the first page in region 5 for the gateway
	   page.
	o  Export the address of the EPC page to userland in ar.k7.
	   Previously it held the current thread, but was never used.
	   We can move the EPC page around all we want now...
	o  Reorder the text sections in the kernel so that we reduce the
	   padding between the ELF headers and the first section. Add the
	   EPC gateway page.
	o  Remove adding a translation for the PAL from locore.s and
	   add it to mp_machdep.c, where we now also insert translations
	   for the EPC page and the I/O port range.
	
	Note: the gateway page has been reduced to a single page for the
	      following reasons:
	      o  A fixed translation of a 1MB page requires us to align the
		 page at a 1MB boundary. This is mostly a waste of space.
	      o  With a large page it's easy to get things wrong and create
		 security holes.
	      o  With the gateway page in region 5, we would be required to
		 manually relocate calls outside the gateway page. This is
		 a pain.
	
	This change does not break previous behaviour.

Affected files ...

.. //depot/projects/ia64/sys/conf/ldscript.ia64#6 edit
.. //depot/projects/ia64/sys/ia64/ia64/exception.s#17 edit
.. //depot/projects/ia64/sys/ia64/ia64/locore.s#12 edit
.. //depot/projects/ia64/sys/ia64/ia64/machdep.c#61 edit
.. //depot/projects/ia64/sys/ia64/ia64/mp_machdep.c#28 edit
.. //depot/projects/ia64/sys/ia64/ia64/pmap.c#54 edit
.. //depot/projects/ia64/sys/ia64/ia64/swtch.s#12 edit
.. //depot/projects/ia64/sys/ia64/ia64/syscall.s#5 edit
.. //depot/projects/ia64/sys/ia64/ia64/trap.c#41 edit
.. //depot/projects/ia64/sys/ia64/include/asm.h#7 edit
.. //depot/projects/ia64/sys/ia64/include/cpu.h#10 edit
.. //depot/projects/ia64/sys/ia64/include/pmap.h#9 edit
.. //depot/projects/ia64/sys/ia64/include/vmparam.h#7 edit

Differences ...

==== //depot/projects/ia64/sys/conf/ldscript.ia64#6 (text+ko) ====

@@ -11,10 +11,11 @@
 
   .text      :
   {
+    *(.text)
+    *(.text.syscall)
+    *(.text.gateway)
     *(.text.ivt)
     . += 8192;
-    *(.text.syscall)
-    *(.text)
     *(.stub)
     /* .gnu.warning sections are handled specially by elf32.em.  */
     *(.gnu.warning)

==== //depot/projects/ia64/sys/ia64/ia64/exception.s#17 (text+ko) ====

@@ -31,7 +31,7 @@
 #include <assym.s>
 
 /*
- * ar.k7 = curthread
+ * ar.k7 = address of gateway page
  * ar.k6 = ksp
  * ar.k5 = kbsp
  * ar.k4 = pcpup

==== //depot/projects/ia64/sys/ia64/ia64/locore.s#12 (text+ko) ====

@@ -221,7 +221,6 @@
 	movl	r16 = ap_stack
 	movl	r17 = ap_pcpu
 	mov	ar.rsc = 0
-	movl	gp = __gp
 	;;
 	ld8	r16 = [r16]
 	ld8	r17 = [r17]
@@ -229,39 +228,15 @@
 	;;
 	add	sp = r18, r16
 	mov	ar.bspstore = r16
-	mov	ar.k4 = r17
-	mov	r13 = r17	/* gas doesn't know tp as an alias for r13 */
 	;;
 	loadrs
-	movl	r16 = ia64_pal_base
+	movl	gp = __gp
 	;;
+	mov	ar.k4 = r17
 	mov	ar.rsc = 3
-	ld8	r16 = [r16]
+	mov	r13 = r17	/* gas doesn't know tp as an alias for r13 */
 	;;
-	cmp.eq	p1, p0 = 0, r16
-(p1)	br.cond.spnt	1f
-	;;
-	mov	r18 = 28<<2
-	movl	r17 = 7<<61
-	;;
-	mov	cr.itir = r18
-	or	r17 = r17, r16
-	mov	r16 = (PTE_P|PTE_MA_WB|PTE_A|PTE_D|PTE_PL_KERN|PTE_AR_RWX)
-	;;
-	mov	cr.ifa = r17
-	extr.u  r18 = r17, 12, 38
-	;;
-	srlz.i
-	shl	r18 = r18, 12
-	;;
-	add	r17 = 1, r0
-	or	r16 = r16, r18
-	;;
-	itr.i	itr[r17] = r16
-	;;
-	srlz.i
-	;;
-1:	alloc	r16 = ar.pfs, 0, 0, 0, 0
+	alloc	r16 = ar.pfs, 0, 0, 0, 0
 	;;
 	br.call.sptk.few rp = ia64_ap_startup
 	/* NOT REACHED */

==== //depot/projects/ia64/sys/ia64/ia64/machdep.c#61 (text+ko) ====

@@ -103,6 +103,8 @@
 
 extern u_int64_t kernel_text[], _end[];
 
+extern u_int64_t ia64_gateway_page[];
+
 FPSWA_INTERFACE *fpswa_interface;
 
 u_int64_t ia64_pal_base;
@@ -325,6 +327,39 @@
 	__asm __volatile("srlz.d");
 }
 
+void
+map_gateway_page(void)
+{
+	struct ia64_pte pte;
+	u_int64_t psr;
+
+	bzero(&pte, sizeof(pte));
+	pte.pte_p = 1;
+	pte.pte_ma = PTE_MA_WB;
+	pte.pte_a = 1;
+	pte.pte_d = 1;
+	pte.pte_pl = PTE_PL_KERN;
+	pte.pte_ar = PTE_AR_X_RX;
+	pte.pte_ppn = IA64_RR_MASK((u_int64_t)ia64_gateway_page) >> 12;
+
+	__asm __volatile("ptr.d %0,%1; ptr.i %0,%1" ::
+	    "r"(VM_MAX_ADDRESS), "r"(PAGE_SHIFT << 2));
+
+	__asm __volatile("mov	%0=psr" : "=r"(psr));
+	__asm __volatile("rsm	psr.ic|psr.i");
+	__asm __volatile("srlz.i");
+	__asm __volatile("mov	cr.ifa=%0" :: "r"(VM_MAX_ADDRESS));
+	__asm __volatile("mov	cr.itir=%0" :: "r"(PAGE_SHIFT << 2));
+	__asm __volatile("itr.d	dtr[%0]=%1" :: "r"(3), "r"(*(u_int64_t*)&pte));
+	__asm __volatile("srlz.d");		/* XXX not needed. */
+	__asm __volatile("itr.i	itr[%0]=%1" :: "r"(3), "r"(*(u_int64_t*)&pte));
+	__asm __volatile("mov	psr.l=%0" :: "r" (psr));
+	__asm __volatile("srlz.i");
+
+	/* Expose the mapping to userland in ar.k7 */
+	ia64_set_k7(VM_MAX_ADDRESS);
+}
+
 static void
 calculate_frequencies(void)
 {

==== //depot/projects/ia64/sys/ia64/ia64/mp_machdep.c#28 (text+ko) ====

@@ -81,19 +81,21 @@
 void
 ia64_ap_startup(void)
 {
+	ap_awake = 1;
+	ap_delay = 0;
+
 	__asm __volatile("mov cr.pta=%0;; srlz.i;;" ::
 	    "r" (vhpt_base + (1<<8) + (vhpt_size<<2) + 1));
 
+	map_pal_code();
+	map_port_space();
+	map_gateway_page();
+
 	ia64_set_fpsr(IA64_FPSR_DEFAULT);
 
-	/*
-	 * Set ia32 control registers.
-	 */
+	/* Set ia32 control registers. */
 	ia64_set_cflg(CR0_PE | CR0_PG | ((long)(CR4_XMM|CR4_FXSR) << 32));
 
-	ap_awake = 1;
-	ap_delay = 0;
-
 	/* Wait until it's time for us to be unleashed */
 	while (ap_spin)
 		/* spin */;

==== //depot/projects/ia64/sys/ia64/ia64/pmap.c#54 (text+ko) ====

@@ -121,6 +121,7 @@
 
 #include <sys/user.h>
 
+#include <machine/cpu.h>
 #include <machine/pal.h>
 #include <machine/md_var.h>
 
@@ -191,9 +192,6 @@
 
 vm_offset_t vhpt_base, vhpt_size;
 
-/* Syscall gateway page. */
-extern u_int64_t ia64_syscall_page[];
-
 /*
  * We use an object to own the kernel's 'page tables'. For simplicity,
  * we use one page directory to index a set of pages containing
@@ -424,8 +422,8 @@
 	__asm __volatile("mov cr.pta=%0;; srlz.i;;"
 			 :: "r" (vhpt_base + (1<<8) + (vhpt_size<<2) + 1));
 
-	virtual_avail = IA64_RR_BASE(5);
-	virtual_end = IA64_RR_BASE(6)-1;
+	virtual_avail = VM_MIN_KERNEL_ADDRESS;
+	virtual_end = VM_MAX_KERNEL_ADDRESS;
 
 	/*
 	 * Initialize protection array.
@@ -472,6 +470,8 @@
 	 * Clear out any random TLB entries left over from booting.
 	 */
 	pmap_invalidate_all(kernel_pmap);
+
+	map_gateway_page();
 }
 
 void *
@@ -908,7 +908,7 @@
 
 	if (kernel_vm_end == 0) {
 		kernel_vm_end = nkpt * PAGE_SIZE * NKPTEPG
-			+ IA64_RR_BASE(5);
+		    + VM_MIN_KERNEL_ADDRESS;
 	}
 	addr = (addr + PAGE_SIZE * NKPTEPG) & ~(PAGE_SIZE * NKPTEPG - 1);
 	while (kernel_vm_end < addr) {
@@ -1796,21 +1796,6 @@
 	pmap_install(oldpmap);
 }
 
-int
-pmap_wire_syscall_page(pmap, va)
-	pmap_t pmap;
-	vm_offset_t va;
-{
-	vm_offset_t d, pa;
-	struct ia64_lpte *pte;
-
-	d = va - VM_MAX_ADDRESS;
-	pa = IA64_RR_MASK((u_int64_t)ia64_syscall_page) + d;
-	pte = pmap_find_pte(va);
-	pmap_set_pte(pte, va, pa, PTE_IG_MANAGED, PTE_PL_KERN, PTE_AR_X_RX);
-	return (0);
-}
-
 /*
  * Make temporary mapping for a physical address. This is called
  * during dump.

==== //depot/projects/ia64/sys/ia64/ia64/swtch.s#12 (text+ko) ====

@@ -417,8 +417,6 @@
 	add	r14=PC_CURTHREAD,r13
 	;;
 	st8	[r14]=r4		// set r13->pc_curthread
-	mov	ar.k7=r4
-	;;
 	add	r15=TD_PCB,r4
 	;;
 	ld8	r15=[r15]

==== //depot/projects/ia64/sys/ia64/ia64/syscall.s#5 (text+ko) ====

@@ -65,17 +65,35 @@
  *	r10		-	syscall error flag
  */
 
-	.section	.text.syscall, "ax"
+	.section	.text.gateway, "ax"
+	.align		PAGE_SIZE
+	.global		ia64_gateway_page
+ia64_gateway_page:
+{	.mfb
+	nop.m		0
+	nop.f		0
+	epc
+	;;
+}
+{	.mlx
+	nop.m		0
+	movl		r16=epc_syscall
+	;;
+}
+{	.mib
+	nop.m		0
+	mov		b7=r16
+	br		b7
+	;;
+}
 	.align		PAGE_SIZE
-	.global		ia64_syscall_page
-ia64_syscall_page:
+
 
+	.section	.text.syscall, "ax"
 	.global		epc_syscall
 	.proc		epc_syscall
 	.regstk		8,0,0,0
 epc_syscall:
-	epc
-	;;
 	mov		r16=psr			// psr substitute
 	mov		r17=ar.rsc
 	mov		r18=sp
@@ -242,12 +260,10 @@
 	ld8	r17=[r31]		// restore cr.ipsr
 	;;
 	ld8	r18=[r30]		// restore cr.iip
-	mov	cr.ifs=r22
+	mov	pr=r16,0x1ffff
 	;;
-	mov	cr.iip=r18
-	mov	cr.ipsr=r17
-	mov	pr=r16,0x1ffff
-	br.ret.sptk	rp
+	mov		b6=r18
+	br.ret.sptk	b6
 	;;
 	.endp		epc_syscall
 

==== //depot/projects/ia64/sys/ia64/ia64/trap.c#41 (text+ko) ====

@@ -562,10 +562,6 @@
 			vm = (p != NULL) ? p->p_vmspace : NULL;
 			if (vm == NULL)
 				goto no_fault_in;
-			if (va >= VM_MAX_ADDRESS) {
-				if (!pmap_wire_syscall_page(&vm->vm_pmap, va))
-					goto out;
-			}
 			map = &vm->vm_map;
 		}
 

==== //depot/projects/ia64/sys/ia64/include/asm.h#7 (text+ko) ====

@@ -156,16 +156,15 @@
  * System call glue.
  */
 #define	SYSCALLNUM(name)	SYS_ ## name
-#define	GATEWAY_PAGE		((5 << 61) - 1048576)
 
 #define	CALLSYS_NOERROR(name)			\
 	mov	r15=SYSCALLNUM(name);		\
 	break	0x100000 ;;
 
 #define	EPC_CALLSYS_NOERROR(name)				\
-{	.mlx ;							\
+{	.mmi ;							\
 	alloc		r9 = ar.pfs, 0, 0, 8, 0 ;		\
-	movl		r14 = GATEWAY_PAGE ;; }			\
+	mov		r14 = ar.k7 ;; }			\
 {	.mib ;							\
 	mov		r8 = SYSCALLNUM(name) ;			\
 	mov		b7 = r14 ; 				\

==== //depot/projects/ia64/sys/ia64/include/cpu.h#10 (text+ko) ====

@@ -135,6 +135,7 @@
 void	trap(int vector, int imm, struct trapframe *framep);
 void	ia64_probe_sapics(void);
 int	ia64_count_cpus(void);
+void	map_gateway_page(void);
 void	map_pal_code(void);
 void	map_port_space(void);
 void	cpu_mp_add(uint, uint, uint);

==== //depot/projects/ia64/sys/ia64/include/pmap.h#9 (text+ko) ====

@@ -137,7 +137,6 @@
 void	pmap_set_opt	(unsigned *);
 void	pmap_set_opt_bsp	(void);
 struct pmap *pmap_install(struct pmap *pmap);
-int	pmap_wire_syscall_page(struct pmap *pmap, vm_offset_t);
 
 #endif /* _KERNEL */
 

==== //depot/projects/ia64/sys/ia64/include/vmparam.h#7 (text+ko) ====

@@ -139,12 +139,12 @@
 
 /* user/kernel map constants */
 #define VM_MIN_ADDRESS		0
-#define VM_MAXUSER_ADDRESS	IA64_RR_BASE(5)
-#define VM_MAX_ADDRESS		VM_MAXUSER_ADDRESS - (1024*1024)
-#define VM_MIN_KERNEL_ADDRESS	IA64_RR_BASE(5)
+#define VM_MAX_ADDRESS		IA64_RR_BASE(5)
+#define VM_MAXUSER_ADDRESS	VM_MAX_ADDRESS + PAGE_SIZE
+#define VM_MIN_KERNEL_ADDRESS	VM_MAXUSER_ADDRESS
 #define VM_MAX_KERNEL_ADDRESS	(IA64_RR_BASE(6) - 1)
 
-#define	KERNBASE		(VM_MIN_KERNEL_ADDRESS)
+#define	KERNBASE		VM_MAX_ADDRESS
 
 /* virtual sizes (bytes) for various kernel submaps */
 #ifndef VM_KMEM_SIZE

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




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