ia64/xen-unstable

changeset 11443:655281bca306

[HVM] pv drivers: Allocate hypercall area as an executable region.
We have to use __vmalloc() and __PAGE_KERNEL because vmalloc_exec()
and PAGE_KERNEL_EXEC are not exported to modules.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Sep 08 19:15:11 2006 +0100 (2006-09-08)
parents 8013b84df1ac
children 126bef38ce05
files unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
line diff
     1.1 --- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Fri Sep 08 18:55:53 2006 +0100
     1.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Fri Sep 08 19:15:11 2006 +0100
     1.3 @@ -17,6 +17,7 @@
     1.4   * Place - Suite 330, Boston, MA 02111-1307 USA.
     1.5   *
     1.6   */
     1.7 +
     1.8  #include <linux/module.h>
     1.9  #include <linux/kernel.h>
    1.10  #include <linux/sched.h>
    1.11 @@ -25,6 +26,8 @@
    1.12  #include <linux/init.h>
    1.13  #include <linux/version.h>
    1.14  #include <linux/interrupt.h>
    1.15 +#include <linux/vmalloc.h>
    1.16 +#include <linux/mm.h>
    1.17  #include <asm/system.h>
    1.18  #include <asm/io.h>
    1.19  #include <asm/irq.h>
    1.20 @@ -47,7 +50,6 @@ MODULE_AUTHOR("ssmith@xensource.com");
    1.21  MODULE_DESCRIPTION("Xen platform PCI device");
    1.22  MODULE_LICENSE("GPL");
    1.23  
    1.24 -
    1.25  unsigned long *phys_to_machine_mapping;
    1.26  EXPORT_SYMBOL(phys_to_machine_mapping);
    1.27  
    1.28 @@ -118,7 +120,7 @@ unsigned long alloc_xen_mmio(unsigned lo
    1.29  /* Lifted from hvmloader.c */
    1.30  static int get_hypercall_stubs(void)
    1.31  {
    1.32 -	uint32_t eax, ebx, ecx, edx, pages, msr, order, i;
    1.33 +	uint32_t eax, ebx, ecx, edx, pages, msr, i;
    1.34  	char signature[13];
    1.35  
    1.36  	cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
    1.37 @@ -141,22 +143,22 @@ static int get_hypercall_stubs(void)
    1.38  
    1.39  	cpuid(0x40000002, &pages, &msr, &ecx, &edx);
    1.40  
    1.41 -	i = pages - 1;
    1.42 -	for (order = 0; i != 0; order++)
    1.43 -		i >>= 1;
    1.44 +	printk(KERN_INFO "Hypercall area is %u pages.\n", pages);
    1.45  
    1.46 -	printk(KERN_INFO "Hypercall area is %u pages (order %u allocation)\n",
    1.47 -	       pages, order);
    1.48 -
    1.49 -	hypercall_stubs = (void *)__get_free_pages(GFP_KERNEL, order);
    1.50 +	/* Use __vmalloc() because vmalloc_exec() is not an exported symbol. */
    1.51 +	/* PAGE_KERNEL_EXEC also is not exported, hence we use PAGE_KERNEL. */
    1.52 +	/* hypercall_stubs = vmalloc_exec(pages * PAGE_SIZE); */
    1.53 +	hypercall_stubs = __vmalloc(pages * PAGE_SIZE,
    1.54 +				    GFP_KERNEL | __GFP_HIGHMEM,
    1.55 +				    __pgprot(__PAGE_KERNEL & ~_PAGE_NX));
    1.56  	if (hypercall_stubs == NULL)
    1.57  		return -ENOMEM;
    1.58  
    1.59 -	for (i = 0; i < pages; i++)
    1.60 -		wrmsrl(msr,
    1.61 -		       virt_to_phys(hypercall_stubs) +	/* base address      */
    1.62 -		       (i << PAGE_SHIFT) +		/* offset of page @i */
    1.63 -		       i);				/* request page @i   */
    1.64 +	for (i = 0; i < pages; i++) {
    1.65 +		unsigned long pfn;
    1.66 +		pfn = vmalloc_to_pfn((char *)hypercall_stubs + i*PAGE_SIZE);
    1.67 +		wrmsrl(msr, ((u64)pfn << PAGE_SHIFT) + i);
    1.68 +	}
    1.69  
    1.70  	return 0;
    1.71  }