PERFORCE change 124077 for review
Rink Springer
rink at FreeBSD.org
Wed Jul 25 09:16:32 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=124077
Change 124077 by rink at rink_pitchfork2 on 2007/07/25 09:16:27
First set of fixed for GCC 4. This includes massive changes to
the paging initalization code (it's a lot more like NetBSD now).
Futhermore, avoid polluting i386/i386/locore.S and ship our own file
(the changes to i386/i38/locore.S will be reversted)
Affected files ...
.. //depot/projects/xen3/src/sys/conf/files.i386-xen#9 edit
.. //depot/projects/xen3/src/sys/i386-xen/i386-xen/locore.s#1 add
.. //depot/projects/xen3/src/sys/i386-xen/i386-xen/xen_machdep.c#18 edit
.. //depot/projects/xen3/src/sys/i386-xen/include/xenvar.h#9 edit
.. //depot/projects/xen3/src/sys/i386/i386/locore.s#4 edit
Differences ...
==== //depot/projects/xen3/src/sys/conf/files.i386-xen#9 (text+ko) ====
@@ -279,7 +279,7 @@
i386/i386/k6_mem.c optional mem
i386/i386/legacy.c standard
i386/i386/local_apic.c optional apic
-i386/i386/locore.s standard no-obj
+i386-xen/i386-xen/locore.s standard no-obj
i386/i386/longrun.c optional cpu_enable_longrun
i386-xen/i386-xen/machdep.c standard
i386/i386/mem.c optional mem
==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/xen_machdep.c#18 (text+ko) ====
@@ -72,10 +72,9 @@
shared_info_t *HYPERVISOR_shared_info;
unsigned long *xen_machine_phys = ((unsigned long *)VADDR(1008, 0));
unsigned long *xen_phys_machine;
-int preemptable;
-int init_first;
+int preemptable, init_first;
+extern unsigned int avail_space;
-
void ni_cli(void);
void ni_sti(void);
@@ -314,6 +313,7 @@
struct mmuext_op op;
op.cmd = MMUEXT_PIN_L1_TABLE;
op.arg1.mfn = ma >> PAGE_SHIFT;
+ printk("xen_pt_pin(): mfn=%x\n", op.arg1.mfn);
xen_flush_queue();
PANIC_IF(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
}
@@ -583,6 +583,52 @@
bootmem_current -= size;
}
+static vm_paddr_t
+xpmap_mtop2(vm_paddr_t mpa)
+{
+ return ((machine_to_phys_mapping[mpa >> PAGE_SHIFT] << PAGE_SHIFT)
+ ) | (mpa & ~PG_FRAME);
+}
+
+static pd_entry_t
+xpmap_get_bootpde(vm_paddr_t va)
+{
+
+ return ((pd_entry_t *)xen_start_info->pt_base)[va >> 22];
+}
+
+static pd_entry_t
+xpmap_get_vbootpde(vm_paddr_t va)
+{
+ pd_entry_t pde;
+
+ pde = xpmap_get_bootpde(va);
+ if ((pde & PG_V) == 0)
+ return (pde & ~PG_FRAME);
+ return (pde & ~PG_FRAME) |
+ (xpmap_mtop2(pde & PG_FRAME) + KERNBASE);
+}
+
+static pt_entry_t *
+xpmap_get_bootptep(vm_paddr_t va)
+{
+ pd_entry_t pde;
+
+ pde = xpmap_get_vbootpde(va);
+ if ((pde & PG_V) == 0)
+ return (void *)-1;
+#define PT_MASK 0x003ff000 /* page table address bits */
+ return &(((pt_entry_t *)(pde & PG_FRAME))[(va & PT_MASK) >> PAGE_SHIFT]);
+}
+
+static pt_entry_t
+xpmap_get_bootpte(vm_paddr_t va)
+{
+
+ return xpmap_get_bootptep(va)[0];
+}
+
+
static vm_offset_t *pdir_shadow;
#ifdef ADD_ISA_HOLE
@@ -614,9 +660,6 @@
for (i = 0; i < nr_pages; i++) {
xen_machphys_update(phys_machine[i], i);
}
-
-
-
memset(phys_machine, INVALID_P2M_ENTRY, PAGE_SIZE);
}
@@ -625,16 +668,13 @@
void
initvalues(start_info_t *startinfo)
{
- int i, round_tmpindex;
+ int i;
+ unsigned int cur_space = avail_space;
vm_paddr_t pdir_shadow_ma, KPTphys, *IdlePTDma;
physdev_op_t op;
-#ifdef SMP
- int j;
-#endif
+ printk("initvalues(): wooh - availmem=%x,%x\n",avail_space, cur_space);
- printk("initvalues(): wooh\n");
-
#ifdef WRITABLE_PAGETABLES
printk("using writable pagetables\n");
HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
@@ -644,14 +684,13 @@
xen_phys_machine = (unsigned long *)startinfo->mfn_list;
/* number of pages allocated after the pts + 1*/;
- unsigned long tmpindex = (VTOPFN(xen_start_info->pt_base) + xen_start_info->nr_pt_frames) + 3;
- printk("KERNBASE=%x,pt_base=%x, VTOPFN(base)=%x, nr_pt_frames=%x, initial tmpindex = %x\n", KERNBASE,xen_start_info->pt_base, VTOPFN(xen_start_info->pt_base), xen_start_info->nr_pt_frames, tmpindex);
+ printk("KERNBASE=%x,pt_base=%x, VTOPFN(base)=%x, nr_pt_frames=%x\n", KERNBASE,xen_start_info->pt_base, VTOPFN(xen_start_info->pt_base), xen_start_info->nr_pt_frames);
xendebug_flags = 0; /* 0xffffffff; */
/* allocate 4 pages for bootmem allocator */
- bootmem_start = bootmem_current = (char *)PFNTOV(tmpindex);
- tmpindex += 4;
- bootmem_end = (char *)PFNTOV(tmpindex);
+ bootmem_start = bootmem_current = (char *)cur_space;
+ cur_space += (4 * PAGE_SIZE);
+ bootmem_end = (char *)cur_space;
#ifdef ADD_ISA_HOLE
shift_phys_machine(xen_phys_machine, xen_start_info->nr_pages);
@@ -659,10 +698,9 @@
/*
* pre-zero unused mapped pages - mapped on 4MB boundary
*/
-#ifndef PAE
- round_tmpindex = (((tmpindex - 1) / 1024) + 1)*1024;
-#endif
- bzero((char *)PFNTOV(tmpindex), (round_tmpindex - tmpindex)*PAGE_SIZE);
+/*
+ bzero((char *)cur_space, (cur_space + 0x3fffff) % 0x400000);
+ */
IdlePTD = (pd_entry_t *)VTOP(startinfo->pt_base);
IdlePTDma = (pd_entry_t *)xpmap_ptom(VTOP(startinfo->pt_base));
@@ -674,111 +712,84 @@
xen_start_info->flags, xen_start_info->pt_base,
xen_start_info->mod_start, xen_start_info->mod_len);
+ XENPRINTF("c0100000: %08x\n",
+ xpmap_get_bootpte(0xc0100000));
/* Map proc0's KSTACK */
- proc0kstack = PFNTOV(tmpindex);
- tmpindex += KSTACK_PAGES;
+ proc0kstack = cur_space; cur_space += (KSTACK_PAGES * PAGE_SIZE);
+ printk("proc0kstack=%u\n", proc0kstack);
/* allocate page for gdt */
- gdt = (union descriptor *)PFNTOV(tmpindex);
- tmpindex++;
+ gdt = (union descriptor *)cur_space; cur_space += PAGE_SIZE;
/* allocate page for ldt */
- ldt = (union descriptor *)PFNTOV(tmpindex);
- tmpindex++;
+ ldt = (union descriptor *)cur_space; cur_space += PAGE_SIZE;
/* vm86/bios stack */
- tmpindex += 1;
+ cur_space += PAGE_SIZE;
/* Map space for the vm86 region */
- vm86paddr = (vm_offset_t)PFNTOV(tmpindex);
- tmpindex += 3;
-
+ vm86paddr = (vm_offset_t)cur_space;
+ cur_space += (PAGE_SIZE * 3);
/* initialize page directory shadow page */
- pdir_shadow = (vm_offset_t *)PFNTOV(tmpindex);
- i686_pagezero(pdir_shadow);
- pdir_shadow_ma = xpmap_ptom(tmpindex << PAGE_SHIFT);
+ pdir_shadow = (vm_offset_t *)cur_space; cur_space += PAGE_SIZE;
+ bzero(pdir_shadow, PAGE_SIZE);
+ pdir_shadow_ma = xpmap_ptom(VTOP(pdir_shadow));
+ XENPRINTF("pdir_shadow=%x,pdir_shadow_ma=%x\n", pdir_shadow, pdir_shadow_ma);
PT_SET_MA(pdir_shadow, pdir_shadow_ma | PG_V | PG_A);
- tmpindex++;
/* setup shadow mapping first so vtomach will work */
- xen_pt_pin((vm_paddr_t)pdir_shadow_ma);
+ xen_pt_pin(pdir_shadow_ma);
xen_queue_pt_update((vm_paddr_t)(IdlePTDma + PTDPTDI),
pdir_shadow_ma | PG_KERNEL);
xen_queue_pt_update(pdir_shadow_ma + PTDPTDI*sizeof(vm_paddr_t),
((vm_paddr_t)IdlePTDma) | PG_V | PG_A);
xen_queue_pt_update(pdir_shadow_ma + (KPTDI + ISA_PDR_OFFSET)*sizeof(vm_paddr_t),
KPTphys | PG_V | PG_A);
-
xen_flush_queue();
-
-
-#ifdef SMP
- /* allocate cpu0 private page */
- cpu0prvpage = PFNTOV(tmpindex);
- tmpindex++;
-
- /* allocate SMP page table */
- SMPpt = (unsigned long *)PFNTOV(tmpindex);
-
- /* Map the private page into the SMP page table */
- SMPpt[0] = vtomach(cpu0prvpage) | PG_RW | PG_M | PG_V | PG_A;
-
- /* map SMP page table RO */
- PT_SET_MA(SMPpt, *vtopte((vm_offset_t)SMPpt) & ~PG_RW);
-
- /* put the page table into the page directory */
- xen_queue_pt_update((vm_paddr_t)(IdlePTDma + MPPTDI),
- xpmap_ptom((tmpindex << PAGE_SHIFT))| PG_KERNEL);
- xen_queue_pt_update(pdir_shadow_ma + MPPTDI*sizeof(vm_paddr_t),
- xpmap_ptom((tmpindex << PAGE_SHIFT))| PG_V | PG_A);
- tmpindex++;
-#endif
-
-#ifdef PMAP_DEBUG
- pteinfo_list = (pteinfo_t *)PFNTOV(tmpindex);
- tmpindex += ((xen_start_info->nr_pages >> 10) + 1)*(1 + XPQ_CALL_DEPTH*XPQ_CALL_COUNT);
-
- if (tmpindex > 980)
- __asm__("int3");
-#endif
- /* unmap remaining pages from initial 4MB chunk
- */
- //printk("tmpindex=%lu,i=%lu\n", tmpindex, tmpindex - ISA_INDEX_OFFSET);
- for (i = (tmpindex - ISA_INDEX_OFFSET); i%400 != 0; i++) {
- //printk("doing page %lu(m=%lu)\n", i, i%400 /* XXX 1024 */);
+ /* unmap remaining pages from initial 4MB chunk */
+ for (i = cur_space >> PAGE_SHIFT; i%400 != 0; i++) {
xen_queue_pt_update(KPTphys + i*sizeof(vm_paddr_t), 0);
}
xen_flush_queue();
+
/* allocate remainder of NKPT pages */
- for (i = 0; i < NKPT-1; i++, tmpindex++) {
+ printk("#1\n");
+ for (i = 0; i < NKPT-1; i++, cur_space += PAGE_SIZE) {
/* KERNBASE left unmapped (+ 1) KERNLOAD already mapped (+1) == + 2 */
- xen_queue_pt_update((vm_paddr_t)(IdlePTDma + KPTDI + i + 1 + ISA_PDR_OFFSET),
- xpmap_ptom((tmpindex << PAGE_SHIFT)| PG_KERNEL));
- xen_queue_pt_update(pdir_shadow_ma + (KPTDI + i + 1 + ISA_PDR_OFFSET)*sizeof(vm_paddr_t),
- xpmap_ptom((tmpindex << PAGE_SHIFT)| PG_V | PG_A));
+ printk("#2: i=%i,offs=%u->%x\n", i, KPTDI + i + 1,
+ xpmap_ptom(VTOP(cur_space)) | PG_KERNEL);
+/*
+ xen_queue_pt_update((vm_paddr_t)(IdlePTDma + KPTDI + i + 1),
+ xpmap_ptom(VTOP(cur_space)) | PG_KERNEL);*/
+ PT_UPDATES_FLUSH();
+ xen_queue_pt_update(pdir_shadow_ma + (KPTDI + i + 1)*sizeof(vm_paddr_t),
+ xpmap_ptom(VTOP(cur_space)) | PG_V | PG_A);
+ PT_UPDATES_FLUSH();
}
- tmpindex += NKPT-1;
- PT_UPDATES_FLUSH();
+ printk("#3\n");
- HYPERVISOR_shared_info = (shared_info_t *)PFNTOV(tmpindex);
+ HYPERVISOR_shared_info = (shared_info_t *)cur_space;
PT_SET_MA(HYPERVISOR_shared_info,
xen_start_info->shared_info | PG_KERNEL);
- tmpindex++;
+ cur_space += PAGE_SIZE;
+
+ printk("#4\n");
- xen_store = (struct ringbuf_head *)PFNTOV(tmpindex);
+ xen_store = (struct ringbuf_head *)cur_space;
PT_SET_MA(xen_store,
(xen_start_info->store_mfn << PAGE_SHIFT)| PG_KERNEL);
- tmpindex++;
- console_page = (char *)PFNTOV(tmpindex);
+ cur_space += PAGE_SIZE;
+ console_page = (char *)cur_space;
PT_SET_MA(console_page,
(xen_start_info->console_mfn << PAGE_SHIFT)| PG_KERNEL);
- tmpindex++;
-
+ cur_space += PAGE_SIZE;
+
+ printk("#5\n");
HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list = (unsigned long)xen_phys_machine;
#ifdef SMP
@@ -796,14 +807,17 @@
op.cmd = PHYSDEVOP_SET_IOPL;
op.u.set_iopl.iopl = 1;
PANIC_IF(HYPERVISOR_physdev_op(&op));
+
+ printk("#6\n");
/* add page table for KERNBASE */
xen_queue_pt_update((vm_paddr_t)(IdlePTDma + KPTDI),
- xpmap_ptom((tmpindex << PAGE_SHIFT)| PG_KERNEL));
+ xpmap_ptom(VTOP(cur_space) | PG_KERNEL));
xen_queue_pt_update(pdir_shadow_ma + KPTDI*sizeof(vm_paddr_t),
- xpmap_ptom((tmpindex << PAGE_SHIFT)| PG_V | PG_A));
+ xpmap_ptom(VTOP(cur_space) | PG_V | PG_A));
xen_flush_queue();
- tmpindex++;
+ cur_space += PAGE_SIZE;
+ printk("#6\n");
if (xen_start_info->flags & SIF_INITDOMAIN) {
/* Map first megabyte */
@@ -811,8 +825,12 @@
PT_SET_MA(KERNBASE + i, i | PG_KERNEL | PG_NC_PCD);
xen_flush_queue();
}
- init_first = tmpindex;
+ printk("#7\n");
+
+ init_first = (cur_space >> PAGE_SHIFT);
+
+ printk("#8, proc0kstack=%u\n", proc0kstack);
}
==== //depot/projects/xen3/src/sys/i386-xen/include/xenvar.h#9 (text+ko) ====
@@ -27,7 +27,7 @@
*/
-#define ADD_ISA_HOLE
+#undef ADD_ISA_HOLE /* XXX */
#ifdef ADD_ISA_HOLE
#define ISA_INDEX_OFFSET 1024
==== //depot/projects/xen3/src/sys/i386/i386/locore.s#4 (text+ko) ====
@@ -58,7 +58,7 @@
#ifdef XEN
.section __xen_guest
- .asciz "LOADER=generic,GUEST_OS=freebsd,GUEST_VER=7.0,XEN_VER=xen-3.0,BSD_SYMTAB,VIRT_BASE=0xc0400000"
+ .asciz "LOADER=generic,GUEST_OS=freebsd,GUEST_VER=7.0,XEN_VER=xen-3.0,BSD_SYMTAB,VIRT_BASE=0xc0000000"
#endif
/*
More information about the p4-projects
mailing list