PERFORCE change 133854 for review

Scott Long scottl at FreeBSD.org
Tue Jan 22 00:22:38 PST 2008


http://perforce.freebsd.org/chv.cgi?CH=133854

Change 133854 by scottl at scottl-deimos on 2008/01/22 08:21:37

	Catch up to more pmap/vm fixes and changes.

Affected files ...

.. //depot/projects/xen31-xenbus/sys/i386/i386/machdep.c#3 integrate
.. //depot/projects/xen31-xenbus/sys/i386/i386/trap.c#2 integrate
.. //depot/projects/xen31-xenbus/sys/i386/include/vmparam.h#2 integrate
.. //depot/projects/xen31-xenbus/sys/i386/include/xen/hypercall.h#2 integrate
.. //depot/projects/xen31-xenbus/sys/i386/xen/exception.s#2 integrate
.. //depot/projects/xen31-xenbus/sys/i386/xen/locore.s#2 integrate
.. //depot/projects/xen31-xenbus/sys/i386/xen/pmap.c#5 integrate
.. //depot/projects/xen31-xenbus/sys/i386/xen/xen_machdep.c#3 integrate
.. //depot/projects/xen31-xenbus/sys/sys/cdefs.h#2 integrate

Differences ...

==== //depot/projects/xen31-xenbus/sys/i386/i386/machdep.c#3 (text+ko) ====

@@ -2162,9 +2162,7 @@
 extern vm_paddr_t *pdir_shadow;
 
 
-#define MTOPSIZE (1<<(12 + PAGE_SHIFT))
-
-
+#define MTOPSIZE (1<<(14 + PAGE_SHIFT))
 void
 init386(int first)
 {

==== //depot/projects/xen31-xenbus/sys/i386/i386/trap.c#2 (text+ko) ====

@@ -746,7 +746,7 @@
 	struct vmspace *vm = NULL;
 	vm_map_t map;
 	int rv = 0;
-	vm_prot_t ftype;
+	vm_prot_t ftype = 0;
 	struct thread *td = curthread;
 	struct proc *p = td->td_proc;
 
@@ -832,7 +832,11 @@
 		trap_fatal(frame, eva);
 		return (-1);
 	}
-
+#ifdef XEN
+	if (rv == KERN_PROTECTION_FAILURE)
+		printf("SIGBUS: p=%s va=0x%x ftype=0x%x eip=0x%x\n", p->p_comm, va, ftype, frame->tf_eip);
+#endif
+	    
 	return((rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV);
 }
 

==== //depot/projects/xen31-xenbus/sys/i386/include/vmparam.h#2 (text+ko) ====

@@ -160,7 +160,11 @@
  * messy at times, but hey, we'll do anything to save a page :-)
  */
 
+#ifdef XEN
+#define VM_MAX_KERNEL_ADDRESS	HYPERVISOR_VIRT_START
+#else	
 #define VM_MAX_KERNEL_ADDRESS	VADDR(KPTDI+NKPDE-1, NPTEPG-1)
+#endif
 #define VM_MIN_KERNEL_ADDRESS	VADDR(PTDPTDI, PTDPTDI)
 
 #define	KERNBASE		VADDR(KPTDI, 0)

==== //depot/projects/xen31-xenbus/sys/i386/include/xen/hypercall.h#2 (text+ko) ====

@@ -33,80 +33,91 @@
 #include <xen/interface/xen.h>
 #include <xen/interface/sched.h>
 
-#define _hypercall0(type, name)			\
-({						\
-	long __res;				\
-	asm volatile (				\
-		TRAP_INSTR			\
-		: "=a" (__res)			\
-		: "0" (__HYPERVISOR_##name)	\
-		: "memory" );			\
-	(type)__res;				\
+#define __STR(x) #x
+#define STR(x) __STR(x)
+
+#if defined(XEN)
+#define HYPERCALL_STR(name)                                     \
+        "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
+#else
+#define HYPERCALL_STR(name)                                     \
+        "mov hypercall_stubs,%%eax; "                           \
+        "add $("STR(__HYPERVISOR_##name)" * 32),%%eax; "        \
+        "call *%%eax"
+#endif
+
+#define _hypercall0(type, name)                 \
+({                                              \
+        long __res;                             \
+        __asm__ volatile (                          \
+                HYPERCALL_STR(name)             \
+                : "=a" (__res)                  \
+                :                               \
+                : "memory" );                   \
+        (type)__res;                            \
 })
 
-#define _hypercall1(type, name, a1)				\
-({								\
-	long __res, __ign1;					\
-	__asm__ volatile (						\
-		TRAP_INSTR					\
-		: "=a" (__res), "=b" (__ign1)			\
-		: "0" (__HYPERVISOR_##name), "1" ((long)(a1))	\
-		: "memory" );					\
-	(type)__res;						\
+#define _hypercall1(type, name, a1)                             \
+({                                                              \
+        long __res, __ign1;                                     \
+        __asm__ volatile (                                          \
+                HYPERCALL_STR(name)                             \
+                : "=a" (__res), "=b" (__ign1)                   \
+                : "1" ((long)(a1))                              \
+                : "memory" );                                   \
+        (type)__res;                                            \
 })
 
-#define _hypercall2(type, name, a1, a2)				\
-({								\
-	long __res, __ign1, __ign2;				\
-	__asm__ volatile (						\
-		TRAP_INSTR					\
-		: "=a" (__res), "=b" (__ign1), "=c" (__ign2)	\
-		: "0" (__HYPERVISOR_##name), "1" ((long)(a1)),	\
-		"2" ((long)(a2))				\
-		: "memory" );					\
-	(type)__res;						\
+#define _hypercall2(type, name, a1, a2)                         \
+({                                                              \
+        long __res, __ign1, __ign2;                             \
+        __asm__ volatile (                                          \
+                HYPERCALL_STR(name)                             \
+                : "=a" (__res), "=b" (__ign1), "=c" (__ign2)    \
+                : "1" ((long)(a1)), "2" ((long)(a2))            \
+                : "memory" );                                   \
+        (type)__res;                                            \
 })
 
-#define _hypercall3(type, name, a1, a2, a3)			\
-({								\
-	long __res, __ign1, __ign2, __ign3;			\
-	__asm__ volatile (						\
-		TRAP_INSTR					\
-		: "=a" (__res), "=b" (__ign1), "=c" (__ign2), 	\
-		"=d" (__ign3)					\
-		: "0" (__HYPERVISOR_##name), "1" ((long)(a1)),	\
-		"2" ((long)(a2)), "3" ((long)(a3))		\
-		: "memory" );					\
-	(type)__res;						\
+#define _hypercall3(type, name, a1, a2, a3)                     \
+({                                                              \
+        long __res, __ign1, __ign2, __ign3;                     \
+        __asm__ volatile (                                          \
+                HYPERCALL_STR(name)                             \
+                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
+                "=d" (__ign3)                                   \
+                : "1" ((long)(a1)), "2" ((long)(a2)),           \
+                "3" ((long)(a3))                                \
+                : "memory" );                                   \
+        (type)__res;                                            \
 })
 
-#define _hypercall4(type, name, a1, a2, a3, a4)			\
-({								\
-	long __res, __ign1, __ign2, __ign3, __ign4;		\
-	__asm__ volatile (						\
-		TRAP_INSTR					\
-		: "=a" (__res), "=b" (__ign1), "=c" (__ign2),	\
-		"=d" (__ign3), "=S" (__ign4)			\
-		: "0" (__HYPERVISOR_##name), "1" ((long)(a1)),	\
-		"2" ((long)(a2)), "3" ((long)(a3)),		\
-		"4" ((long)(a4))				\
-		: "memory" );					\
-	(type)__res;						\
+#define _hypercall4(type, name, a1, a2, a3, a4)                 \
+({                                                              \
+        long __res, __ign1, __ign2, __ign3, __ign4;             \
+        __asm__ volatile (                                          \
+                HYPERCALL_STR(name)                             \
+                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
+                "=d" (__ign3), "=S" (__ign4)                    \
+                : "1" ((long)(a1)), "2" ((long)(a2)),           \
+                "3" ((long)(a3)), "4" ((long)(a4))              \
+                : "memory" );                                   \
+        (type)__res;                                            \
 })
 
-#define _hypercall5(type, name, a1, a2, a3, a4, a5)		\
-({								\
-	long __res, __ign1, __ign2, __ign3, __ign4, __ign5;	\
-	__asm__ volatile (						\
-		TRAP_INSTR					\
-		: "=a" (__res), "=b" (__ign1), "=c" (__ign2),	\
-		"=d" (__ign3), "=S" (__ign4), "=D" (__ign5)	\
-		: "0" (__HYPERVISOR_##name), "1" ((long)(a1)),	\
-		"2" ((long)(a2)), "3" ((long)(a3)),		\
-		"4" ((long)(a4)), "5" ((long)(a5))		\
-		: "memory" );					\
-	(type)__res;						\
-})
+#define _hypercall5(type, name, a1, a2, a3, a4, a5)             \
+({                                                              \
+        long __res, __ign1, __ign2, __ign3, __ign4, __ign5;     \
+        __asm__ volatile (                                          \
+                HYPERCALL_STR(name)                             \
+                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
+                "=d" (__ign3), "=S" (__ign4), "=D" (__ign5)     \
+                : "1" ((long)(a1)), "2" ((long)(a2)),           \
+                "3" ((long)(a3)), "4" ((long)(a4)),             \
+                "5" ((long)(a5))                                \
+                : "memory" );                                   \
+        (type)__res;                                            \
+})								
 
 static inline int
 HYPERVISOR_set_trap_table(

==== //depot/projects/xen31-xenbus/sys/i386/xen/exception.s#2 (text+ko) ====

@@ -37,10 +37,12 @@
 #include <machine/psl.h>
 #include <machine/trap.h>
 
+
 #include "assym.s"
 
 #define	SEL_RPL_MASK	0x0002
-
+#define __HYPERVISOR_iret	23
+	
 /* Offsets into shared_info_t. */
 #define evtchn_upcall_pending /* 0 */
 #define evtchn_upcall_mask       1
@@ -367,7 +369,7 @@
 	addl	$8,%esp
 	.globl	doreti_iret
 doreti_iret:
-	iret
+	jmp	hypercall_page + (__HYPERVISOR_iret * 32)
 	.globl	ecrit
 ecrit:
   	/*

==== //depot/projects/xen31-xenbus/sys/i386/xen/locore.s#2 (text+ko) ====

@@ -56,7 +56,7 @@
 
 #define __ASSEMBLY__	
 #include <xen/interface/elfnote.h>
-	
+		
 /* The defines below have been lifted out of <machine/xen-public/arch-x86_32.h> */
 #define FLAT_RING1_CS 0xe019    /* GDT index 259 */
 #define FLAT_RING1_DS 0xe021    /* GDT index 260 */
@@ -76,15 +76,12 @@
 	ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      .long,  KERNBASE)
 	ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET,   .long,  KERNBASE)
 	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          .long,  btext)
-#ifdef notyet	
 	ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .long,  hypercall_page)
-#endif	
 	ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW,   .long,  HYPERVISOR_VIRT_START)
-#ifdef notyet	
+#if 0
 	ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz, "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel")
-#else 
-	ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz, "pae_pgdir_above_4gb|supervisor_mode_kernel|writable_descriptor_tables")
 #endif
+	ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz, "writable_page_tables|supervisor_mode_kernel|writable_descriptor_tables")
 		
 #ifdef PAE
 	ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz, "yes")
@@ -242,6 +239,16 @@
 	.long	tmpstack, KERNEL_DS
 
 	.text
+
+.p2align 12,	0x90	
+		
+#define HYPERCALL_PAGE_OFFSET 0x1000
+.org HYPERCALL_PAGE_OFFSET
+ENTRY(hypercall_page)
+	.cfi_startproc
+	.skip	0x1000
+	.cfi_endproc
+
 /**********************************************************************
  *
  * This is where the bootblocks start us, set the ball rolling...

==== //depot/projects/xen31-xenbus/sys/i386/xen/pmap.c#5 (text+ko) ====

@@ -1173,7 +1173,7 @@
 	pt_entry_t *pte;
 
 	pte = vtopte(va);
-	pte_clear(pte);
+	PT_CLEAR_VA(pte, FALSE);
 }
 
 /*
@@ -1224,13 +1224,15 @@
 	endpte = pte + count;
 	while (pte < endpte) {
 		oldpte |= *pte;
-		pte_store(pte, VM_PAGE_TO_PHYS(*ma) | pgeflag | PG_RW | PG_V);
+		PT_SET_VA(pte, VM_PAGE_TO_PHYS(*ma) | pgeflag | PG_RW | PG_V, FALSE);
 		pte++;
 		ma++;
 	}
 	if ((oldpte & PG_V) != 0)
 		pmap_invalidate_range(kernel_pmap, sva, sva + count *
 		    PAGE_SIZE);
+	else
+		PT_UPDATES_FLUSH();
 }
 
 /*
@@ -3056,8 +3058,7 @@
 					 * accessed (referenced) bits
 					 * during the copy.
 					 */
-					*dst_pte = ptetemp & ~(PG_W | PG_M |
-					    PG_A);
+					PT_SET_VA_MA(dst_pte, ptetemp & ~(PG_W | PG_M | PG_A), FALSE);
 					dst_pmap->pm_stats.resident_count++;
 	 			} else {
 					free = NULL;
@@ -3077,6 +3078,7 @@
 	}
 	if (*PMAP1)
 		*PMAP1 = 0;
+	PT_UPDATES_FLUSH();
 	sched_unpin();
 	vm_page_unlock_queues();
 	PMAP_UNLOCK(src_pmap);
@@ -3319,8 +3321,8 @@
 					(uintmax_t)tpte));
 
 
-				pte_clear(pte);
-
+				PT_CLEAR_VA(pte, FALSE);
+				
 				/*
 				 * Update the vm_page_t clean/reference bits.
 				 */
@@ -3342,6 +3344,7 @@
 				pmap->pm_stats.resident_count--;			
 			}
 		}
+		PT_UPDATES_FLUSH();
 		if (allfree) {
 			PV_STAT(pv_entry_spare -= _NPCPV);
 			PV_STAT(pc_chunk_count--);
@@ -3408,16 +3411,8 @@
 pmap_is_prefaultable(pmap_t pmap, vm_offset_t addr)
 {
 	pt_entry_t *pte;
-	boolean_t rv;
+	boolean_t rv = FALSE;
 
-	rv = FALSE;
-	/* XXX 
-	 * in order for writable pagetables to help, 
-	 * this has to work - check if we aren't doing 
-	 * an invlpg on the page tables linear mappings
-	 */  
-	return (rv);
-	
 	PMAP_LOCK(pmap);
 	if (*pmap_pde(pmap, addr)) {
 		pte = vtopte(addr);

==== //depot/projects/xen31-xenbus/sys/i386/xen/xen_machdep.c#3 (text+ko) ====

@@ -261,7 +261,6 @@
 	struct mmuext_op op;
 	op.cmd = MMUEXT_INVLPG_ALL;
 	op.arg1.linear_addr = va & ~PAGE_MASK;
-	xen_flush_queue();
 	PANIC_IF(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
@@ -710,7 +709,13 @@
 
 
 	HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
-
+	HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);	
+#ifdef notyet
+	/*
+	 * need to install handler
+	 */
+	HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments_notify);	
+#endif	
 	xen_start_info = startinfo;
 	xen_phys_machine = (xen_pfn_t *)startinfo->mfn_list;
 

==== //depot/projects/xen31-xenbus/sys/sys/cdefs.h#2 (text+ko) ====

@@ -49,7 +49,7 @@
  * Can update to a more recent version when we implement
  * the hypercall page
  */
-#define  __XEN_INTERFACE_VERSION__ 0x00030202
+#define  __XEN_INTERFACE_VERSION__ 0x00030204
 #endif
 /*
  * This code has been put in place to help reduce the addition of


More information about the p4-projects mailing list