Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Feb 2006 02:33:30 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 90948 for review
Message-ID:  <200602030233.k132XU00045401@repoman.freebsd.org>

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

Change 90948 by kmacy@kmacy:freebsd7_xen3 on 2006/02/03 02:32:36

	bump PHYSMAP_SIZE 
	fix formatting in memory map code
	enable IOPL for OS
	improve panic output when console isn't up 

Affected files ...

.. //depot/projects/xen3/src/sys/i386-xen/i386-xen/machdep.c#10 edit
.. //depot/projects/xen3/src/sys/i386-xen/i386-xen/xen_machdep.c#11 edit
.. //depot/projects/xen3/src/sys/i386-xen/include/xen-os.h#3 edit

Differences ...

==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/machdep.c#10 (text+ko) ====

@@ -1640,7 +1640,7 @@
 	ssd->ssd_gran  = sd->sd_gran;
 }
 
-#define PHYSMAP_SIZE	(2 * 8)
+#define PHYSMAP_SIZE	(2 * 12)
 
 /*
  * Populate the (physmap) array with base/bound pairs describing the
@@ -1696,55 +1696,58 @@
 	 * figure out how little I can get away with there
 	 */
 	if (xen_start_info->flags & SIF_INITDOMAIN) {
-	map = bootmem_alloc(PAGE_SIZE);
-	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
-	op.u.physical_memory_map.max_map_entries = 
-		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
-	PANIC_IF(HYPERVISOR_dom0_op(&op));
-	
-	last = 0x100000000ULL;
-	gapstart = 0x10000000;
-	gapsize = 0x400000;
-
-	for (i = op.u.physical_memory_map.nr_map_entries - 1; i >= 0; i--) {
+		map = bootmem_alloc(PAGE_SIZE);
+		op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
+		op.u.physical_memory_map.memory_map = map;
+		op.u.physical_memory_map.max_map_entries = 
+			PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
+		/* 
+		 * if this fails - check for a header versioning mismatch
+		 */
+		PANIC_IF(HYPERVISOR_dom0_op(&op));
+		
+		last = 0x100000000ULL;
+		gapstart = 0x10000000;
+		gapsize = 0x400000;
+		
+		for (i = op.u.physical_memory_map.nr_map_entries - 1; i >= 0; i--) {
 #if 0
-		struct resource *res;
+			struct resource *res;
 #endif
-		if ((last > map[i].end) && ((last - map[i].end) > gapsize)) {
-			gapsize = last - map[i].end;
-			gapstart = map[i].end;
-		}
-		if (map[i].start < last)
-			last = map[i].start;
-
-		if (map[i].end > 0x100000000ULL)
-			continue;
-		/* XXXEN need to handle reserved */
-		phys_avail[2*i] = map[i].start;
-		phys_avail[2*i + 1] = map[i].end;
-		PANIC_IF(i*2 >= PHYSMAP_SIZE);
+			if ((last > map[i].end) && ((last - map[i].end) > gapsize)) {
+				gapsize = last - map[i].end;
+				gapstart = map[i].end;
+			}
+			if (map[i].start < last)
+				last = map[i].start;
+			
+			if (map[i].end > 0x100000000ULL)
+				continue;
+			/* XXXEN need to handle reserved */
+			phys_avail[2*i] = map[i].start;
+			phys_avail[2*i + 1] = map[i].end;
+			PANIC_IF(i*2 >= PHYSMAP_SIZE);
 		
 #if 0
-		res = bootmem_alloc(sizeof(struct resource));
-		res->name = map[i].is_ram ? "System RAM" : "reserved";
-		res->start = map[i].start;
-		res->end = map[i].end - 1;
-		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-		request_resource(&iomem_resource, res);
+			res = bootmem_alloc(sizeof(struct resource));
+			res->name = map[i].is_ram ? "System RAM" : "reserved";
+			res->start = map[i].start;
+			res->end = map[i].end - 1;
+			res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+			request_resource(&iomem_resource, res);
 #endif
-	}
-
-	bootmem_free(map, PAGE_SIZE);
-
-	/*
-	 * Start allocating dynamic PCI memory a bit into the gap,
-	 * aligned up to the nearest megabyte.
-	 *
-	 * Question: should we try to pad it up a bit (do something
-	 * like " + (gapsize >> 3)" in there too?). We now have the
-	 * technology.
-	 */
+		}
+		
+		bootmem_free(map, PAGE_SIZE);
+		
+		/*
+		 * Start allocating dynamic PCI memory a bit into the gap,
+		 * aligned up to the nearest megabyte.
+		 *
+		 * Question: should we try to pad it up a bit (do something
+		 * like " + (gapsize >> 3)" in there too?). We now have the
+		 * technology.
+		 */
 #ifdef notyet
 	pci_mem_start = (gapstart + 0xfffff) & ~0xfffff;
 
@@ -1753,6 +1756,7 @@
 #endif
 	}
 
+#endif
 #if defined(XEN)
 	Maxmem = xen_start_info->nr_pages - init_first;
 	pmap_bootstrap((init_first << PAGE_SHIFT), 0);
@@ -1765,7 +1769,6 @@
 	phys_avail[1] = avail_end;
 	return;
 #endif
-#endif
 	hasbrokenint12 = 0;
 	TUNABLE_INT_FETCH("hw.hasbrokenint12", &hasbrokenint12);
 	bzero(&vmf, sizeof(vmf));
@@ -2384,12 +2387,14 @@
 	/*
 	 * Initialize the console before we print anything out.
 	 */
+	XENPRINTF("cninit\n");
 	cninit();
 
 	if (metadata_missing)
 		printf("WARNING: loader(8) metadata is missing!\n");
 
 #ifdef DEV_ISA
+	XENPRINTF("ISA probing\n");
 	if (xen_start_info->flags & SIF_PRIVILEGED) {
 		elcr_probe();
 		atpic_startup();

==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/xen_machdep.c#11 (text+ko) ====

@@ -596,6 +596,7 @@
 { 
 	int i, round_tmpindex;
 	vm_paddr_t pdir_shadow_ma, KPTphys, *IdlePTDma;
+	physdev_op_t op;
 
 #ifdef SMP
 	int j;
@@ -745,7 +746,23 @@
 	}
 	xen_flush_queue();
 #endif
-    
+
+	op.cmd             = PHYSDEVOP_SET_IOPL;
+	op.u.set_iopl.iopl = 1;
+	PANIC_IF(HYPERVISOR_physdev_op(&op));
+	
+	if (xen_start_info->flags & SIF_INITDOMAIN) {
+		/* add page table for KERNBASE */
+		xen_queue_pt_update((vm_paddr_t)(IdlePTDma + KPTDI), 
+				    xpmap_ptom((tmpindex << PAGE_SHIFT)| PG_KERNEL));
+		xen_queue_pt_update(pdir_shadow_ma + KPTDI*sizeof(vm_paddr_t), 
+				    xpmap_ptom((tmpindex << PAGE_SHIFT)| PG_V | PG_A));
+		xen_flush_queue();
+		/* Map first megabyte */
+		for (i = 0; i < (256 << PAGE_SHIFT); i += PAGE_SIZE) 
+			PT_SET_MA(KERNBASE + i, i | PG_KERNEL | PG_NC_PCD);
+		xen_flush_queue();
+	}
 	init_first = tmpindex;
     
 }

==== //depot/projects/xen3/src/sys/i386-xen/include/xen-os.h#3 (text+ko) ====

@@ -14,7 +14,7 @@
 
 #define strchr index
 #define strrchr rindex
-#define PANIC_IF(exp) if (unlikely(exp)) {printk("%s failed\n",#exp); panic("%s: %s:%d", #exp, __FILE__, __LINE__);} 
+#define PANIC_IF(exp) if (unlikely(exp)) {printk("panic - %s: %s:%d\n",#exp, __FILE__, __LINE__); panic("%s: %s:%d", #exp, __FILE__, __LINE__);} 
 
 /* Somewhere in the middle of the GCC 2.96 development cycle, we implemented
    a mechanism by which the user can annotate likely branch directions and



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