From 28e5434fbafbc260d68f6c2ea2b96dfa0ff2c37e Mon Sep 17 00:00:00 2001 From: "sos22@douglas.cl.cam.ac.uk" Date: Fri, 14 Jan 2005 17:52:01 +0000 Subject: [PATCH] bitkeeper revision 1.1159.170.95 (41e806c1QTDH4lQM5LGTCWlIJEeiSw) machine_to_phys_mapping isn't direct mapped, and so we can't call virt_to_phys on it. Make sure that we don't. --- xen/arch/x86/domain.c | 3 +-- xen/arch/x86/memory.c | 12 ++++++------ xen/arch/x86/x86_32/mm.c | 3 +++ xen/include/asm-x86/mm.h | 3 +++ 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index d0cf493522..fa73e458ef 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -227,8 +227,7 @@ void arch_do_createdomain(struct domain *d) d->shared_info = (void *)alloc_xenheap_page(); memset(d->shared_info, 0, PAGE_SIZE); - d->shared_info->arch.mfn_to_pfn_start = - virt_to_phys(&machine_to_phys_mapping[0])>>PAGE_SHIFT; + d->shared_info->arch.mfn_to_pfn_start = m2p_start_mfn; SHARE_PFN_WITH_DOMAIN(virt_to_page(d->shared_info), d); machine_to_phys_mapping[virt_to_phys(d->shared_info) >> PAGE_SHIFT] = INVALID_P2M_ENTRY; diff --git a/xen/arch/x86/memory.c b/xen/arch/x86/memory.c index 966f92c972..e51ae6235f 100644 --- a/xen/arch/x86/memory.c +++ b/xen/arch/x86/memory.c @@ -168,7 +168,7 @@ void __init init_frametable(void) void arch_init_memory(void) { - unsigned long mfn, i; + unsigned long i; /* * We are rather picky about the layout of 'struct pfn_info'. The @@ -211,13 +211,13 @@ void arch_init_memory(void) dom_io->id = DOMID_IO; /* M2P table is mappable read-only by privileged domains. */ - mfn = l2_pgentry_to_pagenr( - idle_pg_table[RDWR_MPT_VIRT_START >> L2_PAGETABLE_SHIFT]); for ( i = 0; i < 1024; i++ ) { - frame_table[mfn+i].count_info = PGC_allocated | 1; - frame_table[mfn+i].u.inuse.type_info = PGT_gdt_page | 1; /* non-RW */ - frame_table[mfn+i].u.inuse.domain = dom_xen; + frame_table[m2p_start_mfn+i].count_info = PGC_allocated | 1; + /* gdt to make sure it's only mapped read-only by non-privileged + domains. */ + frame_table[m2p_start_mfn+i].u.inuse.type_info = PGT_gdt_page | 1; + frame_table[m2p_start_mfn+i].u.inuse.domain = dom_xen; } } diff --git a/xen/arch/x86/x86_32/mm.c b/xen/arch/x86/x86_32/mm.c index d532ea8e9c..4fc5623dc8 100644 --- a/xen/arch/x86/x86_32/mm.c +++ b/xen/arch/x86/x86_32/mm.c @@ -27,6 +27,8 @@ #include #include +unsigned long m2p_start_mfn; + static inline void set_pte_phys(unsigned long vaddr, l1_pgentry_t entry) { @@ -63,6 +65,7 @@ void __init paging_init(void) /* Allocate and map the machine-to-phys table. */ if ( (pg = alloc_domheap_pages(NULL, 10)) == NULL ) panic("Not enough memory to bootstrap Xen.\n"); + m2p_start_mfn = page_to_pfn(pg); idle_pg_table[RDWR_MPT_VIRT_START >> L2_PAGETABLE_SHIFT] = mk_l2_pgentry(page_to_phys(pg) | __PAGE_HYPERVISOR | _PAGE_PSE); diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 8f35bd96e7..a37f9f2544 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -218,7 +218,10 @@ void synchronise_pagetables(unsigned long cpu_mask); #ifdef __x86_64__ extern unsigned long *machine_to_phys_mapping; #else +/* Don't call virt_to_phys on this: it isn't direct mapped. Using + m2p_start_mfn instead. */ #define machine_to_phys_mapping ((unsigned long *)RDWR_MPT_VIRT_START) +extern unsigned long m2p_start_mfn; #endif #define DEFAULT_GDT_ENTRIES (LAST_RESERVED_GDT_ENTRY+1) -- 2.39.5