From 75c3a203651fb38a406d3da5092dcecdf0ad6fb1 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Fri, 3 Jun 2005 08:12:15 +0000 Subject: bitkeeper revision 1.1659 (42a010dfU0RKWV-1WrueKEs8brwyOg) Ensure that _PAGE_GLOBAL bit is never set in any pagetable if the CPU does not support PGE (Page Global Extension). Signed-off-by: Keir Fraser --- xen/arch/x86/setup.c | 4 ++-- xen/arch/x86/x86_32/mm.c | 32 +++++++++++++++++--------------- xen/include/asm-x86/page.h | 5 ----- xen/include/asm-x86/x86_32/page.h | 5 +++++ xen/include/asm-x86/x86_64/page.h | 3 +++ 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 599389aaad..c0db9f9c7d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -147,6 +147,8 @@ static void __init start_of_day(void) early_cpu_init(); + paging_init(); + /* Unmap the first page of CPU0's stack. */ memguard_guard_stack(cpu0_stack); @@ -168,8 +170,6 @@ static void __init start_of_day(void) smp_alloc_memory(); - paging_init(); - dmi_scan_machine(); generic_apic_probe(); diff --git a/xen/arch/x86/x86_32/mm.c b/xen/arch/x86/x86_32/mm.c index 89537fe7af..99dd178fea 100644 --- a/xen/arch/x86/x86_32/mm.c +++ b/xen/arch/x86/x86_32/mm.c @@ -28,6 +28,9 @@ #include #include +unsigned int PAGE_HYPERVISOR = __PAGE_HYPERVISOR; +unsigned int PAGE_HYPERVISOR_NOCACHE = __PAGE_HYPERVISOR_NOCACHE; + static unsigned long mpt_size; struct pfn_info *alloc_xen_pagetable(void) @@ -72,6 +75,19 @@ void __init paging_init(void) idle0_vcpu.arch.monitor_table = mk_pagetable(__pa(idle_pg_table)); + if ( cpu_has_pge ) + { + /* Suitable Xen mapping can be GLOBAL. */ + PAGE_HYPERVISOR |= _PAGE_GLOBAL; + PAGE_HYPERVISOR_NOCACHE |= _PAGE_GLOBAL; + /* Transform early mappings (e.g., the frametable). */ + for ( v = HYPERVISOR_VIRT_START; v; v += (1 << L2_PAGETABLE_SHIFT) ) + if ( (l2e_get_flags(idle_pg_table_l2[l2_linear_offset(v)]) & + (_PAGE_PSE|_PAGE_PRESENT)) == (_PAGE_PSE|_PAGE_PRESENT) ) + l2e_add_flags(idle_pg_table_l2[l2_linear_offset(v)], + _PAGE_GLOBAL); + } + /* * Allocate and map the machine-to-phys table and create read-only mapping * of MPT for guest-OS use. Without PAE we'll end up with one 4MB page, @@ -86,26 +102,12 @@ void __init paging_init(void) if ( (pg = alloc_domheap_pages(NULL, PAGETABLE_ORDER)) == NULL ) panic("Not enough memory to bootstrap Xen.\n"); idle_pg_table_l2[l2_linear_offset(RDWR_MPT_VIRT_START) + i] = - l2e_from_page(pg, __PAGE_HYPERVISOR | _PAGE_PSE); + l2e_from_page(pg, PAGE_HYPERVISOR | _PAGE_PSE); idle_pg_table_l2[l2_linear_offset(RO_MPT_VIRT_START) + i] = l2e_from_page(pg, (__PAGE_HYPERVISOR | _PAGE_PSE) & ~_PAGE_RW); } memset((void *)RDWR_MPT_VIRT_START, 0x55, mpt_size); - /* Xen PSE mappings can all be GLOBAL. */ - if ( cpu_has_pge ) - { - for ( v = HYPERVISOR_VIRT_START; v; v += (1 << L2_PAGETABLE_SHIFT) ) - { - if ( (l2e_get_flags(idle_pg_table_l2[l2_linear_offset(v)]) & - (_PAGE_PSE|_PAGE_PRESENT)) != (_PAGE_PSE|_PAGE_PRESENT) ) - continue; - if ( (v >= RO_MPT_VIRT_START) && (v < RO_MPT_VIRT_END) ) - continue; - l2e_add_flags(idle_pg_table_l2[l2_linear_offset(v)], _PAGE_GLOBAL); - } - } - /* Create page tables for ioremap(). */ for ( i = 0; i < (IOREMAP_MBYTES >> (L2_PAGETABLE_SHIFT - 20)); i++ ) { diff --git a/xen/include/asm-x86/page.h b/xen/include/asm-x86/page.h index 126f3591ab..536cb63275 100644 --- a/xen/include/asm-x86/page.h +++ b/xen/include/asm-x86/page.h @@ -257,11 +257,6 @@ extern void paging_init(void); #define __PAGE_HYPERVISOR_NOCACHE \ (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_PCD | _PAGE_ACCESSED) -#define MAKE_GLOBAL(_x) ((_x) | _PAGE_GLOBAL) - -#define PAGE_HYPERVISOR MAKE_GLOBAL(__PAGE_HYPERVISOR) -#define PAGE_HYPERVISOR_NOCACHE MAKE_GLOBAL(__PAGE_HYPERVISOR_NOCACHE) - #ifndef __ASSEMBLY__ static __inline__ int get_order(unsigned long size) diff --git a/xen/include/asm-x86/x86_32/page.h b/xen/include/asm-x86/x86_32/page.h index 988da65811..9546706876 100644 --- a/xen/include/asm-x86/x86_32/page.h +++ b/xen/include/asm-x86/x86_32/page.h @@ -20,6 +20,11 @@ #define l1_linear_offset(_a) ((_a) >> L1_PAGETABLE_SHIFT) #define l2_linear_offset(_a) ((_a) >> L2_PAGETABLE_SHIFT) +#ifndef __ASSEMBLY__ +extern unsigned int PAGE_HYPERVISOR; +extern unsigned int PAGE_HYPERVISOR_NOCACHE; +#endif + #endif /* __X86_32_PAGE_H__ */ /* diff --git a/xen/include/asm-x86/x86_64/page.h b/xen/include/asm-x86/x86_64/page.h index 21712d19d9..eeafe4fea5 100644 --- a/xen/include/asm-x86/x86_64/page.h +++ b/xen/include/asm-x86/x86_64/page.h @@ -76,6 +76,9 @@ typedef l4_pgentry_t root_pgentry_t; #define L3_DISALLOW_MASK (0xFFFFF180U & ~_PAGE_NX) /* must-be-zero */ #define L4_DISALLOW_MASK (0xFFFFF180U & ~_PAGE_NX) /* must-be-zero */ +#define PAGE_HYPERVISOR (__PAGE_HYPERVISOR | _PAGE_GLOBAL) +#define PAGE_HYPERVISOR_NOCACHE (__PAGE_HYPERVISOR_NOCACHE | _PAGE_GLOBAL) + #endif /* __X86_64_PAGE_H__ */ /* -- cgit v1.2.3