From: "Jan Beulich" Subject: [PATCH] implement vmap() Date: Fri, 09 Nov 2012 13:28:12 +0000 Message-ID: <509D12FC02000078000A77E4@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part5D6C9DFC.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part5D6C9DFC.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline ... and use it as basis for a proper ioremap() on x86. Signed-off-by: Jan Beulich --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -100,6 +100,7 @@ #include #include #include +#include #include #include #include @@ -5460,6 +5561,32 @@ void __set_fixmap( map_pages_to_xen(fix_to_virt(idx), mfn, 1, flags); } =20 +void *__init arch_vmap_virt_end(void) +{ + return (void *)fix_to_virt(__end_of_fixed_addresses); +} + +void __iomem *ioremap(paddr_t pa, size_t len) +{ + unsigned long pfn =3D PFN_DOWN(pa); + void *va; + + WARN_ON(page_is_ram_type(pfn, RAM_TYPE_CONVENTIONAL)); + + /* The low first Mb is always mapped. */ + if ( !((pa + len - 1) >> 20) ) + va =3D __va(pa); + else + { + unsigned int offs =3D pa & (PAGE_SIZE - 1); + unsigned int nr =3D PFN_UP(offs + len); + + va =3D __vmap(&pfn, nr, 1, 1, PAGE_HYPERVISOR_NOCACHE) + offs; + } + + return (void __force __iomem *)va; +} + #ifdef MEMORY_GUARD =20 void memguard_init(void) --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1104,6 +1104,7 @@ void __init __start_xen(unsigned long mb end_boot_allocator(); system_state =3D SYS_STATE_boot; =20 + vm_init(); vesa_init(); =20 softirq_init(); --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -36,6 +36,7 @@ obj-y +=3D time.o obj-y +=3D timer.o obj-y +=3D trace.o obj-y +=3D version.o +obj-y +=3D vmap.o obj-y +=3D vsprintf.o obj-y +=3D wait.o obj-y +=3D xmalloc_tlsf.o --- /dev/null +++ b/xen/common/vmap.c @@ -0,0 +1,204 @@ +#ifdef VMAP_VIRT_START +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static DEFINE_SPINLOCK(vm_lock); +static void *__read_mostly vm_base; +#define vm_bitmap ((unsigned long *)vm_base) +/* highest allocated bit in the bitmap */ +static unsigned int __read_mostly vm_top; +/* total number of bits in the bitmap */ +static unsigned int __read_mostly vm_end; +/* lowest known clear bit in the bitmap */ +static unsigned int vm_low; + +void __init vm_init(void) +{ + unsigned int i, nr; + unsigned long va; + + vm_base =3D (void *)VMAP_VIRT_START; + vm_end =3D PFN_DOWN(arch_vmap_virt_end() - vm_base); + vm_low =3D PFN_UP((vm_end + 7) / 8); + nr =3D PFN_UP((vm_low + 7) / 8); + vm_top =3D nr * PAGE_SIZE * 8; + + for ( i =3D 0, va =3D (unsigned long)vm_bitmap; i < nr; ++i, va +=3D = PAGE_SIZE ) + { + struct page_info *pg =3D alloc_domheap_page(NULL, 0); + + map_pages_to_xen(va, page_to_mfn(pg), 1, PAGE_HYPERVISOR); + clear_page((void *)va); + } + bitmap_fill(vm_bitmap, vm_low); + + /* Populate page tables for the bitmap if necessary. */ + map_pages_to_xen(va, 0, vm_low - nr, MAP_SMALL_PAGES); +} + +void *vm_alloc(unsigned int nr, unsigned int align) +{ + unsigned int start, bit; + + if ( !align ) + align =3D 1; + else if ( align & (align - 1) ) + align &=3D -align; + + spin_lock(&vm_lock); + for ( ; ; ) + { + struct page_info *pg; + + ASSERT(!test_bit(vm_low, vm_bitmap)); + for ( start =3D vm_low; ; ) + { + bit =3D find_next_bit(vm_bitmap, vm_top, start + 1); + if ( bit > vm_top ) + bit =3D vm_top; + /* + * Note that this skips the first bit, making the + * corresponding page a guard one. + */ + start =3D (start + align) & ~(align - 1); + if ( start + nr <=3D bit ) + break; + start =3D bit < vm_top ? + find_next_zero_bit(vm_bitmap, vm_top, bit + 1) : bit; + if ( start >=3D vm_top ) + break; + } + + if ( start < vm_top ) + break; + + spin_unlock(&vm_lock); + + if ( vm_top >=3D vm_end ) + return NULL; + + pg =3D alloc_domheap_page(NULL, 0); + if ( !pg ) + return NULL; + + spin_lock(&vm_lock); + + if ( start >=3D vm_top ) + { + unsigned long va =3D (unsigned long)vm_bitmap + vm_top / 8; + + if ( !map_pages_to_xen(va, page_to_mfn(pg), 1, PAGE_HYPERVISOR= ) ) + { + clear_page((void *)va); + vm_top +=3D PAGE_SIZE * 8; + if ( vm_top > vm_end ) + vm_top =3D vm_end; + continue; + } + } + + free_domheap_page(pg); + + if ( start >=3D vm_top ) + { + spin_unlock(&vm_lock); + return NULL; + } + } + + for ( bit =3D start; bit < start + nr; ++bit ) + __set_bit(bit, vm_bitmap); + if ( start <=3D vm_low + 2 ) + vm_low =3D bit; + spin_unlock(&vm_lock); + + return vm_base + start * PAGE_SIZE; +} + +static unsigned int vm_index(const void *va) +{ + unsigned long addr =3D (unsigned long)va & ~(PAGE_SIZE - 1); + unsigned int idx; + + if ( addr < VMAP_VIRT_START + (vm_end / 8) || + addr >=3D VMAP_VIRT_START + vm_top * PAGE_SIZE ) + return 0; + + idx =3D PFN_DOWN(va - vm_base); + return !test_bit(idx - 1, vm_bitmap) && + test_bit(idx, vm_bitmap) ? idx : 0; +} + +static unsigned int vm_size(const void *va) +{ + unsigned int start =3D vm_index(va), end; + + if ( !start ) + return 0; + + end =3D find_next_zero_bit(vm_bitmap, vm_top, start + 1); + + return min(end, vm_top) - start; +} + +void vm_free(const void *va) +{ + unsigned int bit =3D vm_index(va); + + if ( !bit ) + { + WARN_ON(va !=3D NULL); + return; + } + + spin_lock(&vm_lock); + if ( bit < vm_low ) + { + vm_low =3D bit - 1; + while ( !test_bit(vm_low - 1, vm_bitmap) ) + --vm_low; + } + while ( __test_and_clear_bit(bit, vm_bitmap) ) + if ( ++bit =3D=3D vm_top ) + break; + spin_unlock(&vm_lock); +} + +void *__vmap(const unsigned long *mfn, unsigned int granularity, + unsigned int nr, unsigned int align, unsigned int flags) +{ + void *va =3D vm_alloc(nr * granularity, align); + unsigned long cur =3D (unsigned long)va; + + for ( ; va && nr--; ++mfn, cur +=3D PAGE_SIZE * granularity ) + { + if ( map_pages_to_xen(cur, *mfn, granularity, flags) ) + { + vunmap(va); + va =3D NULL; + } + } + + return va; +} + +void *vmap(const unsigned long *mfn, unsigned int nr) +{ + return __vmap(mfn, 1, nr, 1, PAGE_HYPERVISOR); +} + +void vunmap(const void *va) +{ + unsigned long addr =3D (unsigned long)va; + + destroy_xen_mappings(addr, addr + PAGE_SIZE * vm_size(va)); + vm_free(va); +} +#endif --- a/xen/drivers/acpi/apei/erst.c +++ b/xen/drivers/acpi/apei/erst.c @@ -247,9 +247,6 @@ static int erst_exec_move_data(struct ap { int rc; u64 offset; -#ifdef CONFIG_X86 - enum fixed_addresses idx; -#endif void *src, *dst; =20 /* ioremap does not work in interrupt context */ @@ -263,39 +260,11 @@ static int erst_exec_move_data(struct ap if (rc) return rc; =20 -#ifdef CONFIG_X86 - switch (ctx->var2) { - case 0: - return 0; - case 1 ... PAGE_SIZE: - break; - default: - printk(KERN_WARNING - "MOVE_DATA cannot be used for %#"PRIx64" bytes of = data\n", - ctx->var2); - return -EOPNOTSUPP; - } - - src =3D __acpi_map_table(ctx->src_base + offset, ctx->var2); -#else src =3D ioremap(ctx->src_base + offset, ctx->var2); -#endif if (!src) return -ENOMEM; =20 -#ifdef CONFIG_X86 - BUILD_BUG_ON(FIX_ACPI_PAGES < 4); - idx =3D virt_to_fix((unsigned long)src + 2 * PAGE_SIZE); - offset +=3D ctx->dst_base; - dst =3D (void *)fix_to_virt(idx) + (offset & ~PAGE_MASK); - set_fixmap(idx, offset); - if (PFN_DOWN(offset) !=3D PFN_DOWN(offset + ctx->var2 - 1)) { - idx =3D virt_to_fix((unsigned long)dst + PAGE_SIZE); - set_fixmap(idx, offset + PAGE_SIZE); - } -#else dst =3D ioremap(ctx->dst_base + offset, ctx->var2); -#endif if (dst) { memmove(dst, src, ctx->var2); iounmap(dst); --- a/xen/drivers/video/vesa.c +++ b/xen/drivers/video/vesa.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "font.h" =20 @@ -101,13 +102,11 @@ void __init vesa_init(void) if ( !line_len ) goto fail; =20 - if ( map_pages_to_xen(IOREMAP_VIRT_START, - vlfb_info.lfb_base >> PAGE_SHIFT, - vram_remap >> PAGE_SHIFT, - PAGE_HYPERVISOR_NOCACHE) ) + lfb =3D ioremap(vlfb_info.lfb_base, vram_remap); + if ( !lfb ) goto fail; =20 - lfb =3D memset((void *)IOREMAP_VIRT_START, 0, vram_remap); + memset(lfb, 0, vram_remap); =20 vga_puts =3D vesa_redraw_puts; =20 --- a/xen/include/asm-x86/config.h +++ b/xen/include/asm-x86/config.h @@ -144,7 +144,7 @@ extern unsigned char boot_edid_info[128] * 0xffff828000000000 - 0xffff82bfffffffff [256GB, 2^38 bytes, PML4:261] * Machine-to-phys translation table. * 0xffff82c000000000 - 0xffff82c3ffffffff [16GB, 2^34 bytes, PML4:261] - * ioremap()/fixmap area. + * vmap()/ioremap()/fixmap area. * 0xffff82c400000000 - 0xffff82c43fffffff [1GB, 2^30 bytes, PML4:261] * Compatibility machine-to-phys translation table. * 0xffff82c440000000 - 0xffff82c47fffffff [1GB, 2^30 bytes, PML4:261] @@ -205,11 +205,11 @@ extern unsigned char boot_edid_info[128] /* Slot 261: machine-to-phys conversion table (256GB). */ #define RDWR_MPT_VIRT_START (PML4_ADDR(261)) #define RDWR_MPT_VIRT_END (RDWR_MPT_VIRT_START + MPT_VIRT_SIZE) -/* Slot 261: ioremap()/fixmap area (16GB). */ -#define IOREMAP_VIRT_START RDWR_MPT_VIRT_END -#define IOREMAP_VIRT_END (IOREMAP_VIRT_START + GB(16)) +/* Slot 261: vmap()/ioremap()/fixmap area (16GB). */ +#define VMAP_VIRT_START RDWR_MPT_VIRT_END +#define VMAP_VIRT_END (VMAP_VIRT_START + GB(16)) /* Slot 261: compatibility machine-to-phys conversion table (1GB). */ -#define RDWR_COMPAT_MPT_VIRT_START IOREMAP_VIRT_END +#define RDWR_COMPAT_MPT_VIRT_START VMAP_VIRT_END #define RDWR_COMPAT_MPT_VIRT_END (RDWR_COMPAT_MPT_VIRT_START + GB(1)) /* Slot 261: high read-only compat machine-to-phys conversion table = (1GB). */ #define HIRO_COMPAT_MPT_VIRT_START RDWR_COMPAT_MPT_VIRT_END --- a/xen/include/asm-x86/fixmap.h +++ b/xen/include/asm-x86/fixmap.h @@ -15,7 +15,7 @@ #include #include =20 -#define FIXADDR_TOP (IOREMAP_VIRT_END - PAGE_SIZE) +#define FIXADDR_TOP (VMAP_VIRT_END - PAGE_SIZE) =20 #ifndef __ASSEMBLY__ =20 --- a/xen/include/asm-x86/io.h +++ b/xen/include/asm-x86/io.h @@ -1,14 +1,10 @@ #ifndef _ASM_IO_H #define _ASM_IO_H =20 -#include +#include #include #include =20 -/* We don't need real ioremap() on Xen/x86. */ -#define ioremap(x,l) (__va(x)) -#define iounmap(p) ((void)0) - #define readb(x) (*(volatile char *)(x)) #define readw(x) (*(volatile short *)(x)) #define readl(x) (*(volatile int *)(x)) --- /dev/null +++ b/xen/include/xen/vmap.h @@ -0,0 +1,24 @@ +#if !defined(__XEN_VMAP_H__) && defined(VMAP_VIRT_START) +#define __XEN_VMAP_H__ + +#include + +void *vm_alloc(unsigned int nr, unsigned int align); +void vm_free(const void *); + +void *__vmap(const unsigned long *mfn, unsigned int granularity, + unsigned int nr, unsigned int align, unsigned int flags); +void *vmap(const unsigned long *mfn, unsigned int nr); +void vunmap(const void *); + +void __iomem *ioremap(paddr_t, size_t); + +static inline void iounmap(void __iomem *va) +{ + vunmap((void __force *)va); +} + +void vm_init(void); +void *arch_vmap_virt_end(void); + +#endif /* __XEN_VMAP_H__ */ --=__Part5D6C9DFC.0__= Content-Type: text/plain; name="vmap.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="vmap.patch" implement vmap()=0A=0A... and use it as basis for a proper ioremap() on = x86.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/arch/x86/mm.c=0A+++ b/xen/arch/x86/mm.c=0A@@ -100,6 +100,7 @@=0A = #include =0A #include =0A #include = =0A+#include =0A #include =0A = #include =0A #include =0A@@ -5460,6 +5561,32 = @@ void __set_fixmap(=0A map_pages_to_xen(fix_to_virt(idx), mfn, 1, = flags);=0A }=0A =0A+void *__init arch_vmap_virt_end(void)=0A+{=0A+ = return (void *)fix_to_virt(__end_of_fixed_addresses);=0A+}=0A+=0A+void = __iomem *ioremap(paddr_t pa, size_t len)=0A+{=0A+ unsigned long pfn =3D = PFN_DOWN(pa);=0A+ void *va;=0A+=0A+ WARN_ON(page_is_ram_type(pfn, = RAM_TYPE_CONVENTIONAL));=0A+=0A+ /* The low first Mb is always mapped. = */=0A+ if ( !((pa + len - 1) >> 20) )=0A+ va =3D __va(pa);=0A+ = else=0A+ {=0A+ unsigned int offs =3D pa & (PAGE_SIZE - 1);=0A+ = unsigned int nr =3D PFN_UP(offs + len);=0A+=0A+ va =3D = __vmap(&pfn, nr, 1, 1, PAGE_HYPERVISOR_NOCACHE) + offs;=0A+ }=0A+=0A+ = return (void __force __iomem *)va;=0A+}=0A+=0A #ifdef MEMORY_GUARD=0A =0A = void memguard_init(void)=0A--- a/xen/arch/x86/setup.c=0A+++ b/xen/arch/x86/= setup.c=0A@@ -1104,6 +1104,7 @@ void __init __start_xen(unsigned long = mb=0A end_boot_allocator();=0A system_state =3D SYS_STATE_boot;=0A = =0A+ vm_init();=0A vesa_init();=0A =0A softirq_init();=0A--- = a/xen/common/Makefile=0A+++ b/xen/common/Makefile=0A@@ -36,6 +36,7 @@ = obj-y +=3D time.o=0A obj-y +=3D timer.o=0A obj-y +=3D trace.o=0A obj-y = +=3D version.o=0A+obj-y +=3D vmap.o=0A obj-y +=3D vsprintf.o=0A obj-y +=3D = wait.o=0A obj-y +=3D xmalloc_tlsf.o=0A--- /dev/null=0A+++ b/xen/common/vmap= .c=0A@@ -0,0 +1,204 @@=0A+#ifdef VMAP_VIRT_START=0A+#include = =0A+#include =0A+#include =0A+#include = =0A+#include =0A+#include =0A+#include = =0A+#include =0A+#include =0A+=0A+stat= ic DEFINE_SPINLOCK(vm_lock);=0A+static void *__read_mostly vm_base;=0A+#def= ine vm_bitmap ((unsigned long *)vm_base)=0A+/* highest allocated bit in = the bitmap */=0A+static unsigned int __read_mostly vm_top;=0A+/* total = number of bits in the bitmap */=0A+static unsigned int __read_mostly = vm_end;=0A+/* lowest known clear bit in the bitmap */=0A+static unsigned = int vm_low;=0A+=0A+void __init vm_init(void)=0A+{=0A+ unsigned int i, = nr;=0A+ unsigned long va;=0A+=0A+ vm_base =3D (void *)VMAP_VIRT_START= ;=0A+ vm_end =3D PFN_DOWN(arch_vmap_virt_end() - vm_base);=0A+ = vm_low =3D PFN_UP((vm_end + 7) / 8);=0A+ nr =3D PFN_UP((vm_low + 7) / = 8);=0A+ vm_top =3D nr * PAGE_SIZE * 8;=0A+=0A+ for ( i =3D 0, va =3D = (unsigned long)vm_bitmap; i < nr; ++i, va +=3D PAGE_SIZE )=0A+ {=0A+ = struct page_info *pg =3D alloc_domheap_page(NULL, 0);=0A+=0A+ = map_pages_to_xen(va, page_to_mfn(pg), 1, PAGE_HYPERVISOR);=0A+ = clear_page((void *)va);=0A+ }=0A+ bitmap_fill(vm_bitmap, vm_low);=0A+= =0A+ /* Populate page tables for the bitmap if necessary. */=0A+ = map_pages_to_xen(va, 0, vm_low - nr, MAP_SMALL_PAGES);=0A+}=0A+=0A+void = *vm_alloc(unsigned int nr, unsigned int align)=0A+{=0A+ unsigned int = start, bit;=0A+=0A+ if ( !align )=0A+ align =3D 1;=0A+ else = if ( align & (align - 1) )=0A+ align &=3D -align;=0A+=0A+ = spin_lock(&vm_lock);=0A+ for ( ; ; )=0A+ {=0A+ struct = page_info *pg;=0A+=0A+ ASSERT(!test_bit(vm_low, vm_bitmap));=0A+ = for ( start =3D vm_low; ; )=0A+ {=0A+ bit =3D = find_next_bit(vm_bitmap, vm_top, start + 1);=0A+ if ( bit > = vm_top )=0A+ bit =3D vm_top;=0A+ /*=0A+ = * Note that this skips the first bit, making the=0A+ * = corresponding page a guard one.=0A+ */=0A+ start = =3D (start + align) & ~(align - 1);=0A+ if ( start + nr <=3D = bit )=0A+ break;=0A+ start =3D bit < vm_top = ?=0A+ find_next_zero_bit(vm_bitmap, vm_top, bit + 1) : = bit;=0A+ if ( start >=3D vm_top )=0A+ break;=0A+ = }=0A+=0A+ if ( start < vm_top )=0A+ break;=0A+=0A+= spin_unlock(&vm_lock);=0A+=0A+ if ( vm_top >=3D vm_end = )=0A+ return NULL;=0A+=0A+ pg =3D alloc_domheap_page(NULL= , 0);=0A+ if ( !pg )=0A+ return NULL;=0A+=0A+ = spin_lock(&vm_lock);=0A+=0A+ if ( start >=3D vm_top )=0A+ = {=0A+ unsigned long va =3D (unsigned long)vm_bitmap + vm_top / = 8;=0A+=0A+ if ( !map_pages_to_xen(va, page_to_mfn(pg), 1, = PAGE_HYPERVISOR) )=0A+ {=0A+ clear_page((void = *)va);=0A+ vm_top +=3D PAGE_SIZE * 8;=0A+ if = ( vm_top > vm_end )=0A+ vm_top =3D vm_end;=0A+ = continue;=0A+ }=0A+ }=0A+=0A+ free_domheap_p= age(pg);=0A+=0A+ if ( start >=3D vm_top )=0A+ {=0A+ = spin_unlock(&vm_lock);=0A+ return NULL;=0A+ }=0A+ = }=0A+=0A+ for ( bit =3D start; bit < start + nr; ++bit )=0A+ = __set_bit(bit, vm_bitmap);=0A+ if ( start <=3D vm_low + 2 )=0A+ = vm_low =3D bit;=0A+ spin_unlock(&vm_lock);=0A+=0A+ return vm_base + = start * PAGE_SIZE;=0A+}=0A+=0A+static unsigned int vm_index(const void = *va)=0A+{=0A+ unsigned long addr =3D (unsigned long)va & ~(PAGE_SIZE - = 1);=0A+ unsigned int idx;=0A+=0A+ if ( addr < VMAP_VIRT_START + = (vm_end / 8) ||=0A+ addr >=3D VMAP_VIRT_START + vm_top * PAGE_SIZE = )=0A+ return 0;=0A+=0A+ idx =3D PFN_DOWN(va - vm_base);=0A+ = return !test_bit(idx - 1, vm_bitmap) &&=0A+ test_bit(idx, = vm_bitmap) ? idx : 0;=0A+}=0A+=0A+static unsigned int vm_size(const void = *va)=0A+{=0A+ unsigned int start =3D vm_index(va), end;=0A+=0A+ if ( = !start )=0A+ return 0;=0A+=0A+ end =3D find_next_zero_bit(vm_bitm= ap, vm_top, start + 1);=0A+=0A+ return min(end, vm_top) - start;=0A+}=0A= +=0A+void vm_free(const void *va)=0A+{=0A+ unsigned int bit =3D = vm_index(va);=0A+=0A+ if ( !bit )=0A+ {=0A+ WARN_ON(va !=3D = NULL);=0A+ return;=0A+ }=0A+=0A+ spin_lock(&vm_lock);=0A+ = if ( bit < vm_low )=0A+ {=0A+ vm_low =3D bit - 1;=0A+ = while ( !test_bit(vm_low - 1, vm_bitmap) )=0A+ --vm_low;=0A+ = }=0A+ while ( __test_and_clear_bit(bit, vm_bitmap) )=0A+ if ( = ++bit =3D=3D vm_top )=0A+ break;=0A+ spin_unlock(&vm_lock);= =0A+}=0A+=0A+void *__vmap(const unsigned long *mfn, unsigned int granularit= y,=0A+ unsigned int nr, unsigned int align, unsigned int = flags)=0A+{=0A+ void *va =3D vm_alloc(nr * granularity, align);=0A+ = unsigned long cur =3D (unsigned long)va;=0A+=0A+ for ( ; va && nr--; = ++mfn, cur +=3D PAGE_SIZE * granularity )=0A+ {=0A+ if ( = map_pages_to_xen(cur, *mfn, granularity, flags) )=0A+ {=0A+ = vunmap(va);=0A+ va =3D NULL;=0A+ }=0A+ }=0A+=0A+ = return va;=0A+}=0A+=0A+void *vmap(const unsigned long *mfn, unsigned int = nr)=0A+{=0A+ return __vmap(mfn, 1, nr, 1, PAGE_HYPERVISOR);=0A+}=0A+=0A+= void vunmap(const void *va)=0A+{=0A+ unsigned long addr =3D (unsigned = long)va;=0A+=0A+ destroy_xen_mappings(addr, addr + PAGE_SIZE * = vm_size(va));=0A+ vm_free(va);=0A+}=0A+#endif=0A--- a/xen/drivers/acpi/a= pei/erst.c=0A+++ b/xen/drivers/acpi/apei/erst.c=0A@@ -247,9 +247,6 @@ = static int erst_exec_move_data(struct ap=0A {=0A int rc;=0A = u64 offset;=0A-#ifdef CONFIG_X86=0A- enum fixed_addresses idx;=0A-#endif= =0A void *src, *dst;=0A =0A /* ioremap does not work in = interrupt context */=0A@@ -263,39 +260,11 @@ static int erst_exec_move_data= (struct ap=0A if (rc)=0A return rc;=0A =0A-#ifdef CONFIG_X86= =0A- switch (ctx->var2) {=0A- case 0:=0A- return = 0;=0A- case 1 ... PAGE_SIZE:=0A- break;=0A- default:=0A= - printk(KERN_WARNING=0A- "MOVE_DATA cannot = be used for %#"PRIx64" bytes of data\n",=0A- ctx->var2);= =0A- return -EOPNOTSUPP;=0A- }=0A-=0A- src =3D __acpi_map_= table(ctx->src_base + offset, ctx->var2);=0A-#else=0A src =3D ioremap(ctx= ->src_base + offset, ctx->var2);=0A-#endif=0A if (!src)=0A = return -ENOMEM;=0A =0A-#ifdef CONFIG_X86=0A- BUILD_BUG_ON(FIX_ACPI_PAGES= < 4);=0A- idx =3D virt_to_fix((unsigned long)src + 2 * PAGE_SIZE);=0A= - offset +=3D ctx->dst_base;=0A- dst =3D (void *)fix_to_virt(idx) + = (offset & ~PAGE_MASK);=0A- set_fixmap(idx, offset);=0A- if = (PFN_DOWN(offset) !=3D PFN_DOWN(offset + ctx->var2 - 1)) {=0A- = idx =3D virt_to_fix((unsigned long)dst + PAGE_SIZE);=0A- = set_fixmap(idx, offset + PAGE_SIZE);=0A- }=0A-#else=0A dst =3D = ioremap(ctx->dst_base + offset, ctx->var2);=0A-#endif=0A if (dst) = {=0A memmove(dst, src, ctx->var2);=0A iounmap(dst= );=0A--- a/xen/drivers/video/vesa.c=0A+++ b/xen/drivers/video/vesa.c=0A@@ = -10,6 +10,7 @@=0A #include =0A #include =0A = #include =0A+#include =0A #include =0A = #include "font.h"=0A =0A@@ -101,13 +102,11 @@ void __init vesa_init(void)= =0A if ( !line_len )=0A goto fail;=0A =0A- if ( map_pages_to= _xen(IOREMAP_VIRT_START,=0A- vlfb_info.lfb_base = >> PAGE_SHIFT,=0A- vram_remap >> PAGE_SHIFT,=0A- = PAGE_HYPERVISOR_NOCACHE) )=0A+ lfb =3D = ioremap(vlfb_info.lfb_base, vram_remap);=0A+ if ( !lfb )=0A = goto fail;=0A =0A- lfb =3D memset((void *)IOREMAP_VIRT_START, 0, = vram_remap);=0A+ memset(lfb, 0, vram_remap);=0A =0A vga_puts =3D = vesa_redraw_puts;=0A =0A--- a/xen/include/asm-x86/config.h=0A+++ b/xen/incl= ude/asm-x86/config.h=0A@@ -144,7 +144,7 @@ extern unsigned char boot_edid_i= nfo[128]=0A * 0xffff828000000000 - 0xffff82bfffffffff [256GB, 2^38 = bytes, PML4:261]=0A * Machine-to-phys translation table.=0A * = 0xffff82c000000000 - 0xffff82c3ffffffff [16GB, 2^34 bytes, PML4:261]=0A- = * ioremap()/fixmap area.=0A+ * vmap()/ioremap()/fixmap area.=0A * = 0xffff82c400000000 - 0xffff82c43fffffff [1GB, 2^30 bytes, PML4:261]=0A = * Compatibility machine-to-phys translation table.=0A * 0xffff82c44000= 0000 - 0xffff82c47fffffff [1GB, 2^30 bytes, PML4:261]=0A@@ -205,11 = +205,11 @@ extern unsigned char boot_edid_info[128]=0A /* Slot 261: = machine-to-phys conversion table (256GB). */=0A #define RDWR_MPT_VIRT_START= (PML4_ADDR(261))=0A #define RDWR_MPT_VIRT_END (RDWR_MPT_VIRT_STA= RT + MPT_VIRT_SIZE)=0A-/* Slot 261: ioremap()/fixmap area (16GB). = */=0A-#define IOREMAP_VIRT_START RDWR_MPT_VIRT_END=0A-#define = IOREMAP_VIRT_END (IOREMAP_VIRT_START + GB(16))=0A+/* Slot 261: = vmap()/ioremap()/fixmap area (16GB). */=0A+#define VMAP_VIRT_START = RDWR_MPT_VIRT_END=0A+#define VMAP_VIRT_END (VMAP_VIRT_START + = GB(16))=0A /* Slot 261: compatibility machine-to-phys conversion table = (1GB). */=0A-#define RDWR_COMPAT_MPT_VIRT_START IOREMAP_VIRT_END=0A+#define= RDWR_COMPAT_MPT_VIRT_START VMAP_VIRT_END=0A #define RDWR_COMPAT_MPT_VIRT_E= ND (RDWR_COMPAT_MPT_VIRT_START + GB(1))=0A /* Slot 261: high read-only = compat machine-to-phys conversion table (1GB). */=0A #define HIRO_COMPAT_MP= T_VIRT_START RDWR_COMPAT_MPT_VIRT_END=0A--- a/xen/include/asm-x86/fixmap.h= =0A+++ b/xen/include/asm-x86/fixmap.h=0A@@ -15,7 +15,7 @@=0A #include = =0A #include =0A =0A-#define FIXADDR_TOP = (IOREMAP_VIRT_END - PAGE_SIZE)=0A+#define FIXADDR_TOP (VMAP_VIRT_END - = PAGE_SIZE)=0A =0A #ifndef __ASSEMBLY__=0A =0A--- a/xen/include/asm-x86/io.h= =0A+++ b/xen/include/asm-x86/io.h=0A@@ -1,14 +1,10 @@=0A #ifndef = _ASM_IO_H=0A #define _ASM_IO_H=0A =0A-#include =0A+#include = =0A #include =0A #include =0A =0A-/* = We don't need real ioremap() on Xen/x86. */=0A-#define ioremap(x,l) = (__va(x))=0A-#define iounmap(p) ((void)0)=0A-=0A #define readb(x) = (*(volatile char *)(x))=0A #define readw(x) (*(volatile short *)(x))=0A = #define readl(x) (*(volatile int *)(x))=0A--- /dev/null=0A+++ b/xen/include= /xen/vmap.h=0A@@ -0,0 +1,24 @@=0A+#if !defined(__XEN_VMAP_H__) && = defined(VMAP_VIRT_START)=0A+#define __XEN_VMAP_H__=0A+=0A+#include = =0A+=0A+void *vm_alloc(unsigned int nr, unsigned int = align);=0A+void vm_free(const void *);=0A+=0A+void *__vmap(const unsigned = long *mfn, unsigned int granularity,=0A+ unsigned int nr, = unsigned int align, unsigned int flags);=0A+void *vmap(const unsigned long = *mfn, unsigned int nr);=0A+void vunmap(const void *);=0A+=0A+void __iomem = *ioremap(paddr_t, size_t);=0A+=0A+static inline void iounmap(void __iomem = *va)=0A+{=0A+ vunmap((void __force *)va);=0A+}=0A+=0A+void vm_init(void)= ;=0A+void *arch_vmap_virt_end(void);=0A+=0A+#endif /* __XEN_VMAP_H__ */=0A --=__Part5D6C9DFC.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part5D6C9DFC.0__=--