On some architectures, the switcher can be put in the VDSO or gate-page, which makes it unnecessary to explicitly map in the switcher. This makes the code only do the switcher mapping if the architecture defines LGUEST_SWITCHER_NEEDS_MAPPING in it's asm/lguest.h Signed-off-by: Jes Sorensen --- drivers/lguest/core.c | 9 +++++++++ include/asm-i386/lguest.h | 2 ++ 2 files changed, 11 insertions(+) Index: linux-2.6.23-rc3/drivers/lguest/core.c =================================================================== --- linux-2.6.23-rc3.orig/drivers/lguest/core.c +++ linux-2.6.23-rc3/drivers/lguest/core.c @@ -37,7 +37,11 @@ DEFINE_MUTEX(lguest_lock); * Trying to map memory at a particular address is an unusual thing to do, so * it's not a simple one-liner. We also set up the per-cpu parts of the * Switcher here. + * + * For architectures where the switcher is located in the VDSO or gate-page + * section, mapping in the switcher does not need to be done seperately. */ +#ifdef LGUEST_SWITCHER_NEEDS_MAPPING static __init int map_switcher(void) { int i, err; @@ -118,12 +122,14 @@ free_some_pages: out: return err; } +#endif /*:*/ /* Cleaning up the mapping when the module is unloaded is almost... * too easy. */ static void unmap_switcher(void) { +#ifdef LGUEST_SWITCHER_NEEDS_MAPPING unsigned int i; /* vunmap() undoes *both* map_vm_area() and __get_vm_area(). */ @@ -131,6 +137,7 @@ static void unmap_switcher(void) /* Now we just need to free the pages we copied the switcher into */ for (i = 0; i < TOTAL_SWITCHER_PAGES; i++) __free_pages(switcher_page[i], 0); +#endif } /*L:305 @@ -285,6 +292,7 @@ static int __init init(void) return -EPERM; } +#ifdef LGUEST_SWITCHER_NEEDS_MAPPING /* First we put the Switcher up in very high virtual memory. */ err = map_switcher(); if (err) @@ -296,6 +304,7 @@ static int __init init(void) unmap_switcher(); return err; } +#endif /* The I/O subsystem needs some things initialized. */ lguest_io_init(); Index: linux-2.6.23-rc3/include/asm-i386/lguest.h =================================================================== --- linux-2.6.23-rc3.orig/include/asm-i386/lguest.h +++ linux-2.6.23-rc3/include/asm-i386/lguest.h @@ -9,6 +9,8 @@ #ifndef __ASSEMBLY__ #include +#define LGUEST_SWITCHER_NEEDS_MAPPING 1 + /* Every guest maps the core switcher code. */ #define SHARED_SWITCHER_PAGES \ DIV_ROUND_UP(end_switcher_text - start_switcher_text, PAGE_SIZE)