[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-3.0-testing] Export machine_to_phys start and end addresses to guests.
# HG changeset patch # User kaf24@xxxxxxxxxxxxxxxxxxxx # Node ID 538d832ebf4ec2c778fa9d71940fb983c8119a01 # Parent 794a23f9195ad13c3ee5f2f7fc4056fa2405b8d0 Export machine_to_phys start and end addresses to guests. Use this info in Linux to bounds-check accesses to the m2p table. Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> xen-unstable changeset: 10460:f7bb99cdc391a4a23ee41d48dfd19f3d5b0c69c3 xen-unstable date: Tue Jun 20 12:01:09 2006 +0100 [LINUX] Fix i386 build -- define max_mapnr in mfn_to_pfn(). Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> xen-unstable changeset: 10464:674890dc1ee2ebc4e0f271c27bbe9b021249b554 xen-unstable date: Tue Jun 20 13:42:08 2006 +0100 [LINUX] Another fix to i386 mfn_to_pfn(). Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> xen-unstable changeset: 10465:b6ee2a730139b4e8b627c2f412fb8c46dac50185 xen-unstable date: Tue Jun 20 13:45:23 2006 +0100 --- linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h | 19 +++++++----- linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h | 18 ++++++----- xen/arch/x86/setup.c | 4 +- xen/include/public/arch-x86_32.h | 9 +++++ xen/include/public/arch-x86_64.h | 14 +++++--- 5 files changed, 43 insertions(+), 21 deletions(-) diff -r 794a23f9195a -r 538d832ebf4e linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h Mon Jun 19 15:30:10 2006 +0100 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h Tue Jun 20 15:00:13 2006 +0100 @@ -84,24 +84,29 @@ static inline int phys_to_machine_mappin static inline unsigned long mfn_to_pfn(unsigned long mfn) { + extern unsigned long max_mapnr; unsigned long pfn; if (xen_feature(XENFEAT_auto_translated_physmap)) return mfn; - /* - * The array access can fail (e.g., device space beyond end of RAM). - * In such cases it doesn't matter what we return (we return garbage), - * but we must handle the fault without crashing! - */ + if (mfn >= MACH2PHYS_NR_ENTRIES) + return max_mapnr; + + /* The array access can fail (e.g., device space beyond end of RAM). */ asm ( "1: movl %1,%0\n" "2:\n" + ".section .fixup,\"ax\"\n" + "3: movl %2,%0\n" + " jmp 2b\n" + ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" - " .long 1b,2b\n" + " .long 1b,3b\n" ".previous" - : "=r" (pfn) : "m" (machine_to_phys_mapping[mfn]) ); + : "=r" (pfn) + : "m" (machine_to_phys_mapping[mfn]), "ir" (max_mapnr) ); return pfn; } diff -r 794a23f9195a -r 538d832ebf4e linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h Mon Jun 19 15:30:10 2006 +0100 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h Tue Jun 20 15:00:13 2006 +0100 @@ -107,19 +107,23 @@ static inline unsigned long mfn_to_pfn(u if (xen_feature(XENFEAT_auto_translated_physmap)) return mfn; - /* - * The array access can fail (e.g., device space beyond end of RAM). - * In such cases it doesn't matter what we return (we return garbage), - * but we must handle the fault without crashing! - */ + if (mfn >= MACH2PHYS_NR_ENTRIES) + return end_pfn; + + /* The array access can fail (e.g., device space beyond end of RAM). */ asm ( "1: movq %1,%0\n" "2:\n" + ".section .fixup,\"ax\"\n" + "3: movq %2,%0\n" + " jmp 2b\n" + ".previous\n" ".section __ex_table,\"a\"\n" " .align 8\n" - " .quad 1b,2b\n" + " .quad 1b,3b\n" ".previous" - : "=r" (pfn) : "m" (machine_to_phys_mapping[mfn]) ); + : "=r" (pfn) + : "m" (machine_to_phys_mapping[mfn]), "ir" (end_pfn) ); return pfn; } diff -r 794a23f9195a -r 538d832ebf4e xen/arch/x86/setup.c --- a/xen/arch/x86/setup.c Mon Jun 19 15:30:10 2006 +0100 +++ b/xen/arch/x86/setup.c Tue Jun 20 15:00:13 2006 +0100 @@ -363,11 +363,13 @@ void __init __start_xen(multiboot_info_t BUG_ON(sizeof(shared_info_t) > PAGE_SIZE); BUG_ON(sizeof(vcpu_info_t) != 64); - /* __foo are defined in public headers. Check they match internal defs. */ + /* Check definitions in public headers match internal defs. */ BUG_ON(__HYPERVISOR_VIRT_START != HYPERVISOR_VIRT_START); #ifdef HYPERVISOR_VIRT_END BUG_ON(__HYPERVISOR_VIRT_END != HYPERVISOR_VIRT_END); #endif + BUG_ON(MACH2PHYS_VIRT_START != RO_MPT_VIRT_START); + BUG_ON(MACH2PHYS_VIRT_END != RO_MPT_VIRT_END); init_frametable(); diff -r 794a23f9195a -r 538d832ebf4e xen/include/public/arch-x86_32.h --- a/xen/include/public/arch-x86_32.h Mon Jun 19 15:30:10 2006 +0100 +++ b/xen/include/public/arch-x86_32.h Tue Jun 20 15:00:13 2006 +0100 @@ -72,16 +72,23 @@ DEFINE_GUEST_HANDLE(void); */ #ifdef CONFIG_X86_PAE #define __HYPERVISOR_VIRT_START 0xF5800000 +#define __MACH2PHYS_VIRT_START 0xF5800000 +#define __MACH2PHYS_VIRT_END 0xF6800000 #else #define __HYPERVISOR_VIRT_START 0xFC000000 +#define __MACH2PHYS_VIRT_START 0xFC000000 +#define __MACH2PHYS_VIRT_END 0xFC400000 #endif #ifndef HYPERVISOR_VIRT_START #define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START) #endif +#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START) +#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END) +#define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>2) #ifndef machine_to_phys_mapping -#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START) +#define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START) #endif /* Maximum number of virtual CPUs in multi-processor guests. */ diff -r 794a23f9195a -r 538d832ebf4e xen/include/public/arch-x86_64.h --- a/xen/include/public/arch-x86_64.h Mon Jun 19 15:30:10 2006 +0100 +++ b/xen/include/public/arch-x86_64.h Tue Jun 20 15:00:13 2006 +0100 @@ -83,21 +83,25 @@ DEFINE_GUEST_HANDLE(void); #define __HYPERVISOR_VIRT_START 0xFFFF800000000000 #define __HYPERVISOR_VIRT_END 0xFFFF880000000000 +#define __MACH2PHYS_VIRT_START 0xFFFF800000000000 +#define __MACH2PHYS_VIRT_END 0xFFFF804000000000 #ifndef HYPERVISOR_VIRT_START #define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START) #define HYPERVISOR_VIRT_END mk_unsigned_long(__HYPERVISOR_VIRT_END) #endif +#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START) +#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END) +#define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>3) +#ifndef machine_to_phys_mapping +#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START) +#endif + /* Maximum number of virtual CPUs in multi-processor guests. */ #define MAX_VIRT_CPUS 32 #ifndef __ASSEMBLY__ - -/* The machine->physical mapping table starts at this address, read-only. */ -#ifndef machine_to_phys_mapping -#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START) -#endif /* * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base) _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |