From owner-p4-projects@FreeBSD.ORG Wed Feb 1 08:39:28 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 92A3D16A423; Wed, 1 Feb 2006 08:39:27 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 49DD216A420 for ; Wed, 1 Feb 2006 08:39:27 +0000 (GMT) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id C3E4643D48 for ; Wed, 1 Feb 2006 08:39:26 +0000 (GMT) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k118dQWn031046 for ; Wed, 1 Feb 2006 08:39:26 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k118dQUJ031043 for perforce@freebsd.org; Wed, 1 Feb 2006 08:39:26 GMT (envelope-from kmacy@freebsd.org) Date: Wed, 1 Feb 2006 08:39:26 GMT Message-Id: <200602010839.k118dQUJ031043@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 90861 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Feb 2006 08:39:28 -0000 http://perforce.freebsd.org/chv.cgi?CH=90861 Change 90861 by kmacy@kmacy:freebsd7_xen3 on 2006/02/01 08:38:24 cleanups related to adding back isa hole don't run bios checks unless privileged use IdlePTD where it was used previously have IdlePTD be physical address instead of machine address Affected files ... .. //depot/projects/xen3/src/sys/i386-xen/i386-xen/machdep.c#8 edit .. //depot/projects/xen3/src/sys/i386-xen/i386-xen/pmap.c#2 edit .. //depot/projects/xen3/src/sys/i386-xen/i386-xen/xen_machdep.c#8 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xenpmap.h#3 edit .. //depot/projects/xen3/src/sys/i386-xen/include/xenvar.h#5 edit .. //depot/projects/xen3/src/sys/i386/i386/bios.c#2 edit Differences ... ==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/machdep.c#8 (text+ko) ==== @@ -2449,7 +2449,7 @@ dblfault_tss.tss_ldt = GSEL(GLDT_SEL, SEL_KPL); #ifndef XEN - /* can be made to work */ + /* XXX - this can be made to work */ vm86_initialize(); #endif getmemsize(first); @@ -2489,9 +2489,9 @@ /* setup proc 0's pcb */ thread0.td_pcb->pcb_flags = 0; /* XXXKSE */ #ifdef PAE - thread0.td_pcb->pcb_cr3 = xpmap_mtop((int)IdlePDPT); + thread0.td_pcb->pcb_cr3 = (int)IdlePDPT; #else - thread0.td_pcb->pcb_cr3 = xpmap_mtop((int)IdlePTD); + thread0.td_pcb->pcb_cr3 = (int)IdlePTD; #endif thread0.td_pcb->pcb_ext = 0; thread0.td_frame = &proc0_tf; ==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/pmap.c#2 (text+ko) ==== @@ -378,11 +378,7 @@ * Initialize the kernel pmap (which is statically allocated). */ PMAP_LOCK_INIT(kernel_pmap); -#ifdef XEN - kernel_pmap->pm_pdir = (pd_entry_t *) xen_start_info->pt_base; -#else kernel_pmap->pm_pdir = (pd_entry_t *) (KERNBASE + (u_int)IdlePTD); -#endif #ifdef PAE kernel_pmap->pm_pdpt = (pdpt_entry_t *) (KERNBASE + (u_int)IdlePDPT); #endif @@ -1132,11 +1128,7 @@ { PMAP_LOCK_INIT(pmap); -#ifdef XEN - pmap->pm_pdir = (pd_entry_t *)(xen_start_info->pt_base); -#else pmap->pm_pdir = (pd_entry_t *)(KERNBASE + (vm_offset_t)IdlePTD); -#endif #ifdef PAE pmap->pm_pdpt = (pdpt_entry_t *)(KERNBASE + (vm_offset_t)IdlePDPT); #endif ==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/xen_machdep.c#8 (text+ko) ==== @@ -552,14 +552,14 @@ bootmem_current -= size; } - +static vm_offset_t *pdir_shadow; void initvalues(start_info_t *startinfo) { int i, round_tmpindex; - vm_paddr_t pdir_shadow_ma, KPTphys; - vm_offset_t *pdir_shadow; + vm_paddr_t pdir_shadow_ma, KPTphys, *IdlePTDma; + #ifdef SMP int j; #endif @@ -583,7 +583,8 @@ #endif bzero((char *)PFNTOV(tmpindex), (round_tmpindex - tmpindex)*PAGE_SIZE); - IdlePTD = (pd_entry_t *)xpmap_ptom(VTOP(startinfo->pt_base)); + IdlePTD = (pd_entry_t *)VTOP(startinfo->pt_base); + IdlePTDma = (pd_entry_t *)xpmap_ptom(VTOP(startinfo->pt_base)); KPTphys = xpmap_ptom(VTOP(startinfo->pt_base + PAGE_SIZE)); XENPRINTF("IdlePTD %p\n", IdlePTD); XENPRINTF("nr_pages: %ld shared_info: 0x%lx flags: 0x%lx pt_base: 0x%lx " @@ -619,11 +620,11 @@ /* setup shadow mapping first so vtomach will work */ xen_pt_pin((vm_paddr_t)pdir_shadow_ma); - xen_queue_pt_update((vm_paddr_t)(IdlePTD + PTDPTDI), + 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)IdlePTD) | PG_V | PG_A); - xen_queue_pt_update(pdir_shadow_ma + KPTDI*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(); @@ -645,7 +646,7 @@ 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)(IdlePTD + MPPTDI), + 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); @@ -659,16 +660,18 @@ if (tmpindex > 980) __asm__("int3"); #endif - /* unmap remaining pages from initial 4MB chunk */ - for (i = tmpindex; i%1024 != 0; i++) + /* unmap remaining pages from initial 4MB chunk + */ + for (i = (tmpindex - ISA_INDEX_OFFSET); i%1024 != 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++) { - xen_queue_pt_update((vm_paddr_t)(IdlePTD + KPTDI + i + 1), + /* 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)*sizeof(vm_paddr_t), + 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)); } tmpindex += NKPT-1; ==== //depot/projects/xen3/src/sys/i386-xen/include/xenpmap.h#3 (text+ko) ==== @@ -33,7 +33,6 @@ #ifndef _XEN_XENPMAP_H_ #define _XEN_XENPMAP_H_ -#include void xen_invlpg(vm_offset_t); void xen_load_cr3(vm_paddr_t); void xen_queue_pt_update(vm_paddr_t, vm_paddr_t); @@ -170,12 +169,10 @@ xen_flush_queue(); \ } while (/*CONSTCOND*/0) - static __inline uint32_t xpmap_mtop(uint32_t mpa) { - return (((xen_machine_phys[(mpa >> PAGE_SHIFT)]) << PAGE_SHIFT) - | (mpa & ~PG_FRAME)); + return machtophys(mpa) | (mpa & ~PG_FRAME); } static __inline vm_paddr_t ==== //depot/projects/xen3/src/sys/i386-xen/include/xenvar.h#5 (text+ko) ==== @@ -1,6 +1,5 @@ #ifndef XENVAR_H_ #define XENVAR_H_ - #define XBOOTUP 0x1 #define XPMAP 0x2 extern int xendebug_flags; @@ -16,15 +15,35 @@ if (xendebug_flags & argflags) XENPRINTF("(file=%s, line=%d) " _f "\n", __FILE__, __LINE__, ## _a); extern unsigned long *xen_machine_phys; -#define PFNTOMFN(i) (((unsigned long *)xen_phys_machine)[i]) -#define MFNTOPFN(i) (xen_machine_phys[i]) +/* Xen starts physical pages after the 4MB ISA hole - + * FreeBSD doesn't + */ + +#ifdef ADD_ISA_HOLE +#define ISA_INDEX_OFFSET 1024 +#define ISA_PDR_OFFSET 1 +#else +#define ISA_INDEX_OFFSET 0 +#define ISA_PDR_OFFSET 0 +#endif + + +#define PFNTOMFN(i) (((unsigned long *)xen_phys_machine)[(i) - ISA_INDEX_OFFSET]) +#define MFNTOPFN(i) (xen_machine_phys[i] + ISA_INDEX_OFFSET) + +#define VTOP(x) ((unsigned long)(x) - KERNBASE) +#define PTOV(x) ((unsigned long)(x) + KERNBASE) + +#define VTOPFN(x) (VTOP(x) >> PAGE_SHIFT) +#define PFNTOV(x) PTOV((unsigned long)(x) << PAGE_SHIFT) + #define VTOMFN(va) (vtomach(va) >> PAGE_SHIFT) #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) -#define VTOP(x) ((unsigned long)(x) - KERNBASE) -#define VTOPFN(x) (((unsigned long)(x) - KERNBASE) >> PAGE_SHIFT) -#define PFNTOV(x) (((unsigned long)(x) << PAGE_SHIFT) + KERNBASE) + +#define phystomach(pa) (PFNTOMFN((pa) >> PAGE_SHIFT) << PAGE_SHIFT) +#define machtophys(ma) (MFNTOPFN((ma) >> PAGE_SHIFT) << PAGE_SHIFT) + -#define phystomach(pa) ((((unsigned long *)xen_phys_machine)[(pa >> PAGE_SHIFT)]) << PAGE_SHIFT) void xpq_init(void); #define BITS_PER_LONG 32 ==== //depot/projects/xen3/src/sys/i386/i386/bios.c#2 (text+ko) ==== @@ -83,6 +83,9 @@ int i; char *p; +#if defined(XEN) && !defined(XEN_PRIVILEGED_GUEST) + return; +#endif /* * BIOS32 Service Directory, PCI BIOS */