WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [HVM] Clean ups for PV-on-HVM drivers. In

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [HVM] Clean ups for PV-on-HVM drivers. In particular, platform-pci
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Aug 2006 12:20:13 +0000
Delivery-date: Wed, 23 Aug 2006 05:20:46 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 2b78726766d1cdf426dce65e08c45dde6e391df3
# Parent  bb8d13705aaca58a9f5254e30071c2254d9c7737
[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@xxxxxxxxxxxxx>
---
 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c             |    2 
 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h   |   22 +++-
 linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h |   22 +++-
 linux-2.6-xen-sparse/include/xen/balloon.h                       |   10 +
 unmodified_drivers/linux-2.6/platform-pci/platform-pci.c         |   52 
+++++-----
 unmodified_drivers/linux-2.6/platform-pci/xen_support.c          |    8 +
 6 files changed, 71 insertions(+), 45 deletions(-)

diff -r bb8d13705aac -r 2b78726766d1 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Tue Aug 22 
15:55:43 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Tue Aug 22 
17:16:58 2006 +0100
@@ -1577,7 +1577,7 @@ static void xennet_set_features(struct n
        xennet_set_sg(dev, 0);
 
        /* We need checksum offload to enable scatter/gather and TSO. */
-       if (!(dev->features & NETIF_F_ALL_CSUM))
+       if (!(dev->features & NETIF_F_IP_CSUM))
                return;
 
        if (!xennet_set_sg(dev, 1))
diff -r bb8d13705aac -r 2b78726766d1 
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h    Tue Aug 
22 15:55:43 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypercall.h    Tue Aug 
22 17:16:58 2006 +0100
@@ -42,11 +42,21 @@
 #define __STR(x) #x
 #define STR(x) __STR(x)
 
+#ifdef CONFIG_XEN
+#define HYPERCALL_STR(name)                                    \
+       "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
+#else
+#define HYPERCALL_STR(name)                                    \
+       "mov hypercall_stubs,%%eax; "                           \
+       "add $("STR(__HYPERVISOR_##name)" * 32),%%eax; "        \
+       "call *%%eax"
+#endif
+
 #define _hypercall0(type, name)                        \
 ({                                             \
        long __res;                             \
        asm volatile (                          \
-               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+               HYPERCALL_STR(name)             \
                : "=a" (__res)                  \
                :                               \
                : "memory" );                   \
@@ -57,7 +67,7 @@
 ({                                                             \
        long __res, __ign1;                                     \
        asm volatile (                                          \
-               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+               HYPERCALL_STR(name)                             \
                : "=a" (__res), "=b" (__ign1)                   \
                : "1" ((long)(a1))                              \
                : "memory" );                                   \
@@ -68,7 +78,7 @@
 ({                                                             \
        long __res, __ign1, __ign2;                             \
        asm volatile (                                          \
-               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+               HYPERCALL_STR(name)                             \
                : "=a" (__res), "=b" (__ign1), "=c" (__ign2)    \
                : "1" ((long)(a1)), "2" ((long)(a2))            \
                : "memory" );                                   \
@@ -79,7 +89,7 @@
 ({                                                             \
        long __res, __ign1, __ign2, __ign3;                     \
        asm volatile (                                          \
-               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+               HYPERCALL_STR(name)                             \
                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
                "=d" (__ign3)                                   \
                : "1" ((long)(a1)), "2" ((long)(a2)),           \
@@ -92,7 +102,7 @@
 ({                                                             \
        long __res, __ign1, __ign2, __ign3, __ign4;             \
        asm volatile (                                          \
-               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+               HYPERCALL_STR(name)                             \
                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
                "=d" (__ign3), "=S" (__ign4)                    \
                : "1" ((long)(a1)), "2" ((long)(a2)),           \
@@ -105,7 +115,7 @@
 ({                                                             \
        long __res, __ign1, __ign2, __ign3, __ign4, __ign5;     \
        asm volatile (                                          \
-               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+               HYPERCALL_STR(name)                             \
                : "=a" (__res), "=b" (__ign1), "=c" (__ign2),   \
                "=d" (__ign3), "=S" (__ign4), "=D" (__ign5)     \
                : "1" ((long)(a1)), "2" ((long)(a2)),           \
diff -r bb8d13705aac -r 2b78726766d1 
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h  Tue Aug 
22 15:55:43 2006 +0100
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/hypercall.h  Tue Aug 
22 17:16:58 2006 +0100
@@ -46,11 +46,21 @@
 #define __STR(x) #x
 #define STR(x) __STR(x)
 
+#ifdef CONFIG_XEN
+#define HYPERCALL_STR(name)                                    \
+       "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
+#else
+#define HYPERCALL_STR(name)                                    \
+       "mov hypercall_stubs,%%rax; "                           \
+       "add $("STR(__HYPERVISOR_##name)" * 32),%%rax; "        \
+       "call *%%rax"
+#endif
+
 #define _hypercall0(type, name)                        \
 ({                                             \
        long __res;                             \
        asm volatile (                          \
-               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+               HYPERCALL_STR(name)             \
                : "=a" (__res)                  \
                :                               \
                : "memory" );                   \
@@ -61,7 +71,7 @@
 ({                                                             \
        long __res, __ign1;                                     \
        asm volatile (                                          \
-               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+               HYPERCALL_STR(name)                             \
                : "=a" (__res), "=D" (__ign1)                   \
                : "1" ((long)(a1))                              \
                : "memory" );                                   \
@@ -72,7 +82,7 @@
 ({                                                             \
        long __res, __ign1, __ign2;                             \
        asm volatile (                                          \
-               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+               HYPERCALL_STR(name)                             \
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2)    \
                : "1" ((long)(a1)), "2" ((long)(a2))            \
                : "memory" );                                   \
@@ -83,7 +93,7 @@
 ({                                                             \
        long __res, __ign1, __ign2, __ign3;                     \
        asm volatile (                                          \
-               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+               HYPERCALL_STR(name)                             \
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2),   \
                "=d" (__ign3)                                   \
                : "1" ((long)(a1)), "2" ((long)(a2)),           \
@@ -97,7 +107,7 @@
        long __res, __ign1, __ign2, __ign3;                     \
        asm volatile (                                          \
                "movq %7,%%r10; "                               \
-               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+               HYPERCALL_STR(name)                             \
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2),   \
                "=d" (__ign3)                                   \
                : "1" ((long)(a1)), "2" ((long)(a2)),           \
@@ -111,7 +121,7 @@
        long __res, __ign1, __ign2, __ign3;                     \
        asm volatile (                                          \
                "movq %7,%%r10; movq %8,%%r8; "                 \
-               "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+               HYPERCALL_STR(name)                             \
                : "=a" (__res), "=D" (__ign1), "=S" (__ign2),   \
                "=d" (__ign3)                                   \
                : "1" ((long)(a1)), "2" ((long)(a2)),           \
diff -r bb8d13705aac -r 2b78726766d1 linux-2.6-xen-sparse/include/xen/balloon.h
--- a/linux-2.6-xen-sparse/include/xen/balloon.h        Tue Aug 22 15:55:43 
2006 +0100
+++ b/linux-2.6-xen-sparse/include/xen/balloon.h        Tue Aug 22 17:16:58 
2006 +0100
@@ -38,21 +38,23 @@
  * Inform the balloon driver that it should allow some slop for device-driver
  * memory activities.
  */
-extern void
+void
 balloon_update_driver_allowance(
        long delta);
 
 /* Allocate an empty low-memory page range. */
-extern struct page *
+struct page *
 balloon_alloc_empty_page_range(
        unsigned long nr_pages);
 
 /* Deallocate an empty page range, adding to the balloon. */
-extern void
+void
 balloon_dealloc_empty_page_range(
        struct page *page, unsigned long nr_pages);
 
-void balloon_release_driver_page(struct page *page);
+void
+balloon_release_driver_page(
+       struct page *page);
 
 /*
  * Prevent the balloon driver from changing the memory reservation during
diff -r bb8d13705aac -r 2b78726766d1 
unmodified_drivers/linux-2.6/platform-pci/platform-pci.c
--- a/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c  Tue Aug 22 
15:55:43 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c  Tue Aug 22 
17:16:58 2006 +0100
@@ -39,8 +39,8 @@
 #define DRV_VERSION "0.10"
 #define DRV_RELDATE "03/03/2005"
 
-char hypercall_page[PAGE_SIZE];
-EXPORT_SYMBOL(hypercall_page);
+char *hypercall_stubs;
+EXPORT_SYMBOL(hypercall_stubs);
 
 // Used to be xiaofeng.ling@xxxxxxxxx
 MODULE_AUTHOR("ssmith@xxxxxxxxxxxxx");
@@ -116,10 +116,9 @@ unsigned long alloc_xen_mmio(unsigned lo
 }
 
 /* Lifted from hvmloader.c */
-static int get_hypercall_page(void)
-{
-       void *tmp_hypercall_page;
-       uint32_t eax, ebx, ecx, edx;
+static int get_hypercall_stubs(void)
+{
+       uint32_t eax, ebx, ecx, edx, pages, msr, order, i;
        char signature[13];
 
        cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
@@ -128,9 +127,10 @@ static int get_hypercall_page(void)
        *(uint32_t*)(signature + 8) = edx;
        signature[12] = 0;
 
-       if (strcmp("XenVMMXenVMM", signature) || eax < 0x40000002) {
+       if (strcmp("XenVMMXenVMM", signature) || (eax < 0x40000002)) {
                printk(KERN_WARNING
-                      "Detected Xen platform device but not Xen VMM? (sig %s, 
eax %x)\n",
+                      "Detected Xen platform device but not Xen VMM?"
+                      " (sig %s, eax %x)\n",
                       signature, eax);
                return -EINVAL;
        }
@@ -139,24 +139,24 @@ static int get_hypercall_page(void)
 
        printk(KERN_INFO "Xen version %d.%d.\n", eax >> 16, eax & 0xffff);
 
-       cpuid(0x40000002, &eax, &ebx, &ecx, &edx);
-
-       if (eax != 1) {
-               printk(KERN_WARNING
-                      "This Xen version uses a %d page hypercall area,"
-                      "but these modules only support 1 page.\n",
-                      eax);
-               return -EINVAL;
-       }
-
-       tmp_hypercall_page = (void *)__get_free_page(GFP_KERNEL);
-       if (!tmp_hypercall_page)
+       cpuid(0x40000002, &pages, &msr, &ecx, &edx);
+
+       i = pages - 1;
+       for (order = 0; i != 0; order++)
+               i >>= 1;
+
+       printk(KERN_INFO "Hypercall area is %u pages (order %u allocation)\n",
+              pages, order);
+
+       hypercall_stubs = (void *)__get_free_pages(GFP_KERNEL, order);
+       if (hypercall_stubs == NULL)
                return -ENOMEM;
-       memset(tmp_hypercall_page, 0xcc, PAGE_SIZE);
-       if (wrmsr_safe(ebx, virt_to_phys(tmp_hypercall_page), 0))
-               panic("Can't do wrmsr; not running on Xen?\n");
-       memcpy(hypercall_page, tmp_hypercall_page, PAGE_SIZE);
-       free_page((unsigned long)tmp_hypercall_page);
+
+       for (i = 0; i < pages; i++)
+               wrmsrl(ebx,
+                      virt_to_phys(hypercall_stubs) +  /* base address      */
+                      (i << PAGE_SHIFT) +              /* offset of page @i */
+                      i);                              /* request page @i   */
 
        return 0;
 }
@@ -201,7 +201,7 @@ static int __devinit platform_pci_init(s
        platform_mmio = mmio_addr;
        platform_mmiolen = mmio_len;
 
-       ret = get_hypercall_page();
+       ret = get_hypercall_stubs();
        if (ret < 0)
                goto out;
 
diff -r bb8d13705aac -r 2b78726766d1 
unmodified_drivers/linux-2.6/platform-pci/xen_support.c
--- a/unmodified_drivers/linux-2.6/platform-pci/xen_support.c   Tue Aug 22 
15:55:43 2006 +0100
+++ b/unmodified_drivers/linux-2.6/platform-pci/xen_support.c   Tue Aug 22 
17:16:58 2006 +0100
@@ -26,14 +26,18 @@
 #include <asm/hypervisor.h>
 #include "platform-pci.h"
 
-EXPORT_SYMBOL(xen_machphys_update);
 void xen_machphys_update(unsigned long mfn, unsigned long pfn)
 {
        BUG();
 }
+EXPORT_SYMBOL(xen_machphys_update);
 
 void balloon_update_driver_allowance(long delta)
 {
 }
+EXPORT_SYMBOL(balloon_update_driver_allowance);
 
-EXPORT_SYMBOL(balloon_update_driver_allowance);
+void balloon_release_driver_page(struct page *page)
+{
+}
+EXPORT_SYMBOL(balloon_release_driver_page);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [HVM] Clean ups for PV-on-HVM drivers. In particular, platform-pci, Xen patchbot-unstable <=