direct-io.hg

changeset 11228:2b78726766d1

[HVM] Clean ups for PV-on-HVM drivers. In particular, platform-pci
driver can now handle multi-page hypercall stub areas.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Aug 22 17:16:58 2006 +0100 (2006-08-22)
parents bb8d13705aac
children 92066b3fcd86
files linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h linux-2.6-xen-sparse/include/xen/balloon.h unmodified_drivers/linux-2.6/platform-pci/platform-pci.c unmodified_drivers/linux-2.6/platform-pci/xen_support.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Aug 22 15:55:43 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Aug 22 17:16:58 2006 +0100
     1.3 @@ -1577,7 +1577,7 @@ static void xennet_set_features(struct n
     1.4  	xennet_set_sg(dev, 0);
     1.5  
     1.6  	/* We need checksum offload to enable scatter/gather and TSO. */
     1.7 -	if (!(dev->features & NETIF_F_ALL_CSUM))
     1.8 +	if (!(dev->features & NETIF_F_IP_CSUM))
     1.9  		return;
    1.10  
    1.11  	if (!xennet_set_sg(dev, 1))
     2.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h	Tue Aug 22 15:55:43 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h	Tue Aug 22 17:16:58 2006 +0100
     2.3 @@ -42,11 +42,21 @@
     2.4  #define __STR(x) #x
     2.5  #define STR(x) __STR(x)
     2.6  
     2.7 +#ifdef CONFIG_XEN
     2.8 +#define HYPERCALL_STR(name)					\
     2.9 +	"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
    2.10 +#else
    2.11 +#define HYPERCALL_STR(name)					\
    2.12 +	"mov hypercall_stubs,%%eax; "				\
    2.13 +	"add $("STR(__HYPERVISOR_##name)" * 32),%%eax; "	\
    2.14 +	"call *%%eax"
    2.15 +#endif
    2.16 +
    2.17  #define _hypercall0(type, name)			\
    2.18  ({						\
    2.19  	long __res;				\
    2.20  	asm volatile (				\
    2.21 -		"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
    2.22 +		HYPERCALL_STR(name)		\
    2.23  		: "=a" (__res)			\
    2.24  		:				\
    2.25  		: "memory" );			\
    2.26 @@ -57,7 +67,7 @@
    2.27  ({								\
    2.28  	long __res, __ign1;					\
    2.29  	asm volatile (						\
    2.30 -		"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
    2.31 +		HYPERCALL_STR(name)				\
    2.32  		: "=a" (__res), "=b" (__ign1)			\
    2.33  		: "1" ((long)(a1))				\
    2.34  		: "memory" );					\
    2.35 @@ -68,7 +78,7 @@
    2.36  ({								\
    2.37  	long __res, __ign1, __ign2;				\
    2.38  	asm volatile (						\
    2.39 -		"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
    2.40 +		HYPERCALL_STR(name)				\
    2.41  		: "=a" (__res), "=b" (__ign1), "=c" (__ign2)	\
    2.42  		: "1" ((long)(a1)), "2" ((long)(a2))		\
    2.43  		: "memory" );					\
    2.44 @@ -79,7 +89,7 @@
    2.45  ({								\
    2.46  	long __res, __ign1, __ign2, __ign3;			\
    2.47  	asm volatile (						\
    2.48 -		"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
    2.49 +		HYPERCALL_STR(name)				\
    2.50  		: "=a" (__res), "=b" (__ign1), "=c" (__ign2), 	\
    2.51  		"=d" (__ign3)					\
    2.52  		: "1" ((long)(a1)), "2" ((long)(a2)),		\
    2.53 @@ -92,7 +102,7 @@
    2.54  ({								\
    2.55  	long __res, __ign1, __ign2, __ign3, __ign4;		\
    2.56  	asm volatile (						\
    2.57 -		"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
    2.58 +		HYPERCALL_STR(name)				\
    2.59  		: "=a" (__res), "=b" (__ign1), "=c" (__ign2),	\
    2.60  		"=d" (__ign3), "=S" (__ign4)			\
    2.61  		: "1" ((long)(a1)), "2" ((long)(a2)),		\
    2.62 @@ -105,7 +115,7 @@
    2.63  ({								\
    2.64  	long __res, __ign1, __ign2, __ign3, __ign4, __ign5;	\
    2.65  	asm volatile (						\
    2.66 -		"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
    2.67 +		HYPERCALL_STR(name)				\
    2.68  		: "=a" (__res), "=b" (__ign1), "=c" (__ign2),	\
    2.69  		"=d" (__ign3), "=S" (__ign4), "=D" (__ign5)	\
    2.70  		: "1" ((long)(a1)), "2" ((long)(a2)),		\
     3.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h	Tue Aug 22 15:55:43 2006 +0100
     3.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h	Tue Aug 22 17:16:58 2006 +0100
     3.3 @@ -46,11 +46,21 @@
     3.4  #define __STR(x) #x
     3.5  #define STR(x) __STR(x)
     3.6  
     3.7 +#ifdef CONFIG_XEN
     3.8 +#define HYPERCALL_STR(name)					\
     3.9 +	"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
    3.10 +#else
    3.11 +#define HYPERCALL_STR(name)					\
    3.12 +	"mov hypercall_stubs,%%rax; "				\
    3.13 +	"add $("STR(__HYPERVISOR_##name)" * 32),%%rax; "	\
    3.14 +	"call *%%rax"
    3.15 +#endif
    3.16 +
    3.17  #define _hypercall0(type, name)			\
    3.18  ({						\
    3.19  	long __res;				\
    3.20  	asm volatile (				\
    3.21 -		"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
    3.22 +		HYPERCALL_STR(name)		\
    3.23  		: "=a" (__res)			\
    3.24  		:				\
    3.25  		: "memory" );			\
    3.26 @@ -61,7 +71,7 @@
    3.27  ({								\
    3.28  	long __res, __ign1;					\
    3.29  	asm volatile (						\
    3.30 -		"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
    3.31 +		HYPERCALL_STR(name)				\
    3.32  		: "=a" (__res), "=D" (__ign1)			\
    3.33  		: "1" ((long)(a1))				\
    3.34  		: "memory" );					\
    3.35 @@ -72,7 +82,7 @@
    3.36  ({								\
    3.37  	long __res, __ign1, __ign2;				\
    3.38  	asm volatile (						\
    3.39 -		"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
    3.40 +		HYPERCALL_STR(name)				\
    3.41  		: "=a" (__res), "=D" (__ign1), "=S" (__ign2)	\
    3.42  		: "1" ((long)(a1)), "2" ((long)(a2))		\
    3.43  		: "memory" );					\
    3.44 @@ -83,7 +93,7 @@
    3.45  ({								\
    3.46  	long __res, __ign1, __ign2, __ign3;			\
    3.47  	asm volatile (						\
    3.48 -		"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
    3.49 +		HYPERCALL_STR(name)				\
    3.50  		: "=a" (__res), "=D" (__ign1), "=S" (__ign2), 	\
    3.51  		"=d" (__ign3)					\
    3.52  		: "1" ((long)(a1)), "2" ((long)(a2)),		\
    3.53 @@ -97,7 +107,7 @@
    3.54  	long __res, __ign1, __ign2, __ign3;			\
    3.55  	asm volatile (						\
    3.56  		"movq %7,%%r10; "				\
    3.57 -		"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
    3.58 +		HYPERCALL_STR(name)				\
    3.59  		: "=a" (__res), "=D" (__ign1), "=S" (__ign2),	\
    3.60  		"=d" (__ign3)					\
    3.61  		: "1" ((long)(a1)), "2" ((long)(a2)),		\
    3.62 @@ -111,7 +121,7 @@
    3.63  	long __res, __ign1, __ign2, __ign3;			\
    3.64  	asm volatile (						\
    3.65  		"movq %7,%%r10; movq %8,%%r8; "			\
    3.66 -		"call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
    3.67 +		HYPERCALL_STR(name)				\
    3.68  		: "=a" (__res), "=D" (__ign1), "=S" (__ign2),	\
    3.69  		"=d" (__ign3)					\
    3.70  		: "1" ((long)(a1)), "2" ((long)(a2)),		\
     4.1 --- a/linux-2.6-xen-sparse/include/xen/balloon.h	Tue Aug 22 15:55:43 2006 +0100
     4.2 +++ b/linux-2.6-xen-sparse/include/xen/balloon.h	Tue Aug 22 17:16:58 2006 +0100
     4.3 @@ -38,21 +38,23 @@
     4.4   * Inform the balloon driver that it should allow some slop for device-driver
     4.5   * memory activities.
     4.6   */
     4.7 -extern void
     4.8 +void
     4.9  balloon_update_driver_allowance(
    4.10  	long delta);
    4.11  
    4.12  /* Allocate an empty low-memory page range. */
    4.13 -extern struct page *
    4.14 +struct page *
    4.15  balloon_alloc_empty_page_range(
    4.16  	unsigned long nr_pages);
    4.17  
    4.18  /* Deallocate an empty page range, adding to the balloon. */
    4.19 -extern void
    4.20 +void
    4.21  balloon_dealloc_empty_page_range(
    4.22  	struct page *page, unsigned long nr_pages);
    4.23  
    4.24 -void balloon_release_driver_page(struct page *page);
    4.25 +void
    4.26 +balloon_release_driver_page(
    4.27 +	struct page *page);
    4.28  
    4.29  /*
    4.30   * Prevent the balloon driver from changing the memory reservation during
     5.1 --- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Tue Aug 22 15:55:43 2006 +0100
     5.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c	Tue Aug 22 17:16:58 2006 +0100
     5.3 @@ -39,8 +39,8 @@
     5.4  #define DRV_VERSION "0.10"
     5.5  #define DRV_RELDATE "03/03/2005"
     5.6  
     5.7 -char hypercall_page[PAGE_SIZE];
     5.8 -EXPORT_SYMBOL(hypercall_page);
     5.9 +char *hypercall_stubs;
    5.10 +EXPORT_SYMBOL(hypercall_stubs);
    5.11  
    5.12  // Used to be xiaofeng.ling@intel.com
    5.13  MODULE_AUTHOR("ssmith@xensource.com");
    5.14 @@ -116,10 +116,9 @@ unsigned long alloc_xen_mmio(unsigned lo
    5.15  }
    5.16  
    5.17  /* Lifted from hvmloader.c */
    5.18 -static int get_hypercall_page(void)
    5.19 +static int get_hypercall_stubs(void)
    5.20  {
    5.21 -	void *tmp_hypercall_page;
    5.22 -	uint32_t eax, ebx, ecx, edx;
    5.23 +	uint32_t eax, ebx, ecx, edx, pages, msr, order, i;
    5.24  	char signature[13];
    5.25  
    5.26  	cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
    5.27 @@ -128,9 +127,10 @@ static int get_hypercall_page(void)
    5.28  	*(uint32_t*)(signature + 8) = edx;
    5.29  	signature[12] = 0;
    5.30  
    5.31 -	if (strcmp("XenVMMXenVMM", signature) || eax < 0x40000002) {
    5.32 +	if (strcmp("XenVMMXenVMM", signature) || (eax < 0x40000002)) {
    5.33  		printk(KERN_WARNING
    5.34 -		       "Detected Xen platform device but not Xen VMM? (sig %s, eax %x)\n",
    5.35 +		       "Detected Xen platform device but not Xen VMM?"
    5.36 +		       " (sig %s, eax %x)\n",
    5.37  		       signature, eax);
    5.38  		return -EINVAL;
    5.39  	}
    5.40 @@ -139,24 +139,24 @@ static int get_hypercall_page(void)
    5.41  
    5.42  	printk(KERN_INFO "Xen version %d.%d.\n", eax >> 16, eax & 0xffff);
    5.43  
    5.44 -	cpuid(0x40000002, &eax, &ebx, &ecx, &edx);
    5.45 +	cpuid(0x40000002, &pages, &msr, &ecx, &edx);
    5.46 +
    5.47 +	i = pages - 1;
    5.48 +	for (order = 0; i != 0; order++)
    5.49 +		i >>= 1;
    5.50 +
    5.51 +	printk(KERN_INFO "Hypercall area is %u pages (order %u allocation)\n",
    5.52 +	       pages, order);
    5.53  
    5.54 -	if (eax != 1) {
    5.55 -		printk(KERN_WARNING
    5.56 -		       "This Xen version uses a %d page hypercall area,"
    5.57 -		       "but these modules only support 1 page.\n",
    5.58 -		       eax);
    5.59 -		return -EINVAL;
    5.60 -	}
    5.61 +	hypercall_stubs = (void *)__get_free_pages(GFP_KERNEL, order);
    5.62 +	if (hypercall_stubs == NULL)
    5.63 +		return -ENOMEM;
    5.64  
    5.65 -	tmp_hypercall_page = (void *)__get_free_page(GFP_KERNEL);
    5.66 -	if (!tmp_hypercall_page)
    5.67 -		return -ENOMEM;
    5.68 -	memset(tmp_hypercall_page, 0xcc, PAGE_SIZE);
    5.69 -	if (wrmsr_safe(ebx, virt_to_phys(tmp_hypercall_page), 0))
    5.70 -		panic("Can't do wrmsr; not running on Xen?\n");
    5.71 -	memcpy(hypercall_page, tmp_hypercall_page, PAGE_SIZE);
    5.72 -	free_page((unsigned long)tmp_hypercall_page);
    5.73 +	for (i = 0; i < pages; i++)
    5.74 +		wrmsrl(ebx,
    5.75 +		       virt_to_phys(hypercall_stubs) +	/* base address      */
    5.76 +		       (i << PAGE_SHIFT) +		/* offset of page @i */
    5.77 +		       i);				/* request page @i   */
    5.78  
    5.79  	return 0;
    5.80  }
    5.81 @@ -201,7 +201,7 @@ static int __devinit platform_pci_init(s
    5.82  	platform_mmio = mmio_addr;
    5.83  	platform_mmiolen = mmio_len;
    5.84  
    5.85 -	ret = get_hypercall_page();
    5.86 +	ret = get_hypercall_stubs();
    5.87  	if (ret < 0)
    5.88  		goto out;
    5.89  
     6.1 --- a/unmodified_drivers/linux-2.6/platform-pci/xen_support.c	Tue Aug 22 15:55:43 2006 +0100
     6.2 +++ b/unmodified_drivers/linux-2.6/platform-pci/xen_support.c	Tue Aug 22 17:16:58 2006 +0100
     6.3 @@ -26,14 +26,18 @@
     6.4  #include <asm/hypervisor.h>
     6.5  #include "platform-pci.h"
     6.6  
     6.7 -EXPORT_SYMBOL(xen_machphys_update);
     6.8  void xen_machphys_update(unsigned long mfn, unsigned long pfn)
     6.9  {
    6.10  	BUG();
    6.11  }
    6.12 +EXPORT_SYMBOL(xen_machphys_update);
    6.13  
    6.14  void balloon_update_driver_allowance(long delta)
    6.15  {
    6.16  }
    6.17 +EXPORT_SYMBOL(balloon_update_driver_allowance);
    6.18  
    6.19 -EXPORT_SYMBOL(balloon_update_driver_allowance);
    6.20 +void balloon_release_driver_page(struct page *page)
    6.21 +{
    6.22 +}
    6.23 +EXPORT_SYMBOL(balloon_release_driver_page);