[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Various cleanups and fixes for PV-on-HVM drivers.



# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1175719744 -3600
# Node ID f4318c89291afa42cb087945c902d05e71a77dfb
# Parent  2bbd28891160a1d03e45ebc571d8d61ae16ef876
Various cleanups and fixes for PV-on-HVM drivers.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c                |   27 
+++-----
 linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c              |    5 -
 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c                    |    4 -
 linux-2.6-xen-sparse/drivers/xen/core/reboot.c                    |    4 +
 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h   |    6 +
 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/maddr.h        |    2 
 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h         |    6 -
 linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/maddr.h      |    2 
 linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h       |    6 -
 unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h |    8 ++
 unmodified_drivers/linux-2.6/mkbuildtree                          |    1 
 xen/arch/x86/hvm/hvm.c                                            |   33 
+++++-----
 xen/arch/x86/hvm/svm/svm.c                                        |    4 -
 xen/arch/x86/hvm/vmx/vmx.c                                        |    4 -
 14 files changed, 59 insertions(+), 53 deletions(-)

diff -r 2bbd28891160 -r f4318c89291a 
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Wed Apr 04 
19:59:10 2007 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Wed Apr 04 
21:49:04 2007 +0100
@@ -59,10 +59,6 @@
 #include <xen/xenbus.h>
 #include "common.h"
 
-#ifndef CONFIG_XEN 
-#define scrub_pages(_p,_n)
-#endif
-
 #ifdef CONFIG_PROC_FS
 static struct proc_dir_entry *balloon_pde;
 #endif
@@ -250,8 +246,6 @@ static int increase_reservation(unsigned
 
        return 0;
 }
-
-extern void xen_invalidate_foreign_mappings(void);
 
 static int decrease_reservation(unsigned long nr_pages)
 {
@@ -286,7 +280,7 @@ static int decrease_reservation(unsigned
                                (unsigned long)v, __pte_ma(0), 0);
                        BUG_ON(ret);
                }
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_SCRUB_PAGES
                else {
                        v = kmap(page);
                        scrub_pages(v, 1);
@@ -306,13 +300,18 @@ static int decrease_reservation(unsigned
        /* No more mappings: invalidate P2M and add to balloon. */
        for (i = 0; i < nr_pages; i++) {
                pfn = mfn_to_pfn(frame_list[i]);
-#ifdef CONFIG_XEN
                set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
-#endif
                balloon_append(pfn_to_page(pfn));
        }
 
-        xen_invalidate_foreign_mappings(); 
+#ifndef CONFIG_XEN
+       /* XXX Temporary hack. */
+       {
+               extern void xen_invalidate_foreign_mappings(void);
+               xen_invalidate_foreign_mappings(); 
+       }
+#endif
+
        set_xen_guest_handle(reservation.extent_start, frame_list);
        reservation.nr_extents   = nr_pages;
        ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
@@ -476,7 +475,7 @@ static int __init balloon_init(void)
        bs.current_pages = min(xen_start_info->nr_pages, max_pfn);
        totalram_pages   = bs.current_pages;
 #else 
-        bs.current_pages = totalram_pages; 
+       bs.current_pages = totalram_pages; 
 #endif
        bs.target_pages  = bs.current_pages;
        bs.balloon_low   = 0;
@@ -592,9 +591,9 @@ struct page **alloc_empty_pages_and_page
 #ifdef CONFIG_XEN
                        ret = apply_to_page_range(&init_mm, vaddr, PAGE_SIZE,
                                                  dealloc_pte_fn, NULL);
-#else 
-                        /* cannot handle non-auto translate mode */
-                        ret = 1; 
+#else
+                       /* Cannot handle non-auto translate mode. */
+                       ret = 1;
 #endif
                }
 
diff -r 2bbd28891160 -r f4318c89291a 
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Wed Apr 04 
19:59:10 2007 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Wed Apr 04 
21:49:04 2007 +0100
@@ -661,9 +661,10 @@ void do_blkif_request(request_queue_t *r
                if (RING_FULL(&info->ring))
                        goto wait;
 
-               DPRINTK("do_blk_req %p: cmd %p, sec %lx, "
+               DPRINTK("do_blk_req %p: cmd %p, sec %llx, "
                        "(%u/%li) buffer:%p [%s]\n",
-                       req, req->cmd, req->sector, req->current_nr_sectors,
+                       req, req->cmd, (long long)req->sector,
+                       req->current_nr_sectors,
                        req->nr_sectors, req->buffer,
                        rq_data_dir(req) ? "write" : "read");
 
diff -r 2bbd28891160 -r f4318c89291a 
linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c    Wed Apr 04 19:59:10 
2007 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c    Wed Apr 04 21:49:04 
2007 +0100
@@ -407,13 +407,11 @@ static unsigned int __max_nr_grant_frame
 static unsigned int __max_nr_grant_frames(void)
 {
        struct gnttab_query_size query;
-       int rc = -1;
+       int rc;
 
        query.dom = DOMID_SELF;
 
-#ifdef CONFIG_XEN
        rc = HYPERVISOR_grant_table_op(GNTTABOP_query_size, &query, 1);
-#endif
        if ((rc < 0) || (query.status != GNTST_okay))
                return 4; /* Legacy max supported number of frames */
 
diff -r 2bbd28891160 -r f4318c89291a 
linux-2.6-xen-sparse/drivers/xen/core/reboot.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c    Wed Apr 04 19:59:10 
2007 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c    Wed Apr 04 21:49:04 
2007 +0100
@@ -8,6 +8,10 @@
 #include <asm/hypervisor.h>
 #include <xen/xenbus.h>
 #include <linux/kthread.h>
+
+#ifdef HAVE_XEN_PLATFORM_COMPAT_H
+#include <xen/platform-compat.h>
+#endif
 
 MODULE_LICENSE("Dual BSD/GPL");
 
diff -r 2bbd28891160 -r f4318c89291a 
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h   Wed Apr 
04 19:59:10 2007 +0100
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h   Wed Apr 
04 21:49:04 2007 +0100
@@ -122,6 +122,12 @@ void xen_destroy_contiguous_region(
 /* Turn jiffies into Xen system time. */
 u64 jiffies_to_st(unsigned long jiffies);
 
+#ifdef CONFIG_XEN_SCRUB_PAGES
+#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
+#else
+#define scrub_pages(_p,_n) ((void)0)
+#endif
+
 #include <asm/hypercall.h>
 
 #if defined(CONFIG_X86_64)
diff -r 2bbd28891160 -r f4318c89291a 
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/maddr.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/maddr.h        Wed Apr 
04 19:59:10 2007 +0100
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/maddr.h        Wed Apr 
04 21:49:04 2007 +0100
@@ -158,7 +158,7 @@ static inline paddr_t pte_machine_to_phy
 #define pfn_to_mfn(pfn) (pfn)
 #define mfn_to_pfn(mfn) (mfn)
 #define mfn_to_local_pfn(mfn) (mfn)
-#define set_phys_to_machine(pfn, mfn) BUG_ON((pfn) != (mfn))
+#define set_phys_to_machine(pfn, mfn) ((void)0)
 #define phys_to_machine_mapping_valid(pfn) (1)
 #define phys_to_machine(phys) ((maddr_t)(phys))
 #define machine_to_phys(mach) ((paddr_t)(mach))
diff -r 2bbd28891160 -r f4318c89291a 
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h Wed Apr 04 
19:59:10 2007 +0100
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h Wed Apr 04 
21:49:04 2007 +0100
@@ -44,12 +44,6 @@
        foreign;                                \
 })
 #define HAVE_ARCH_FREE_PAGE
-
-#ifdef CONFIG_XEN_SCRUB_PAGES
-#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
-#else
-#define scrub_pages(_p,_n) ((void)0)
-#endif
 
 #ifdef CONFIG_X86_USE_3DNOW
 
diff -r 2bbd28891160 -r f4318c89291a 
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/maddr.h
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/maddr.h      Wed Apr 
04 19:59:10 2007 +0100
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/maddr.h      Wed Apr 
04 21:49:04 2007 +0100
@@ -140,7 +140,7 @@ static inline paddr_t pte_machine_to_phy
 #define pfn_to_mfn(pfn) (pfn)
 #define mfn_to_pfn(mfn) (mfn)
 #define mfn_to_local_pfn(mfn) (mfn)
-#define set_phys_to_machine(pfn, mfn) BUG_ON((pfn) != (mfn))
+#define set_phys_to_machine(pfn, mfn) ((void)0)
 #define phys_to_machine_mapping_valid(pfn) (1)
 #define phys_to_machine(phys) ((maddr_t)(phys))
 #define machine_to_phys(mach) ((paddr_t)(mach))
diff -r 2bbd28891160 -r f4318c89291a 
linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h
--- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h       Wed Apr 
04 19:59:10 2007 +0100
+++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h       Wed Apr 
04 21:49:04 2007 +0100
@@ -23,12 +23,6 @@
        foreign;                                \
 })
 #define HAVE_ARCH_FREE_PAGE
-
-#ifdef CONFIG_XEN_SCRUB_PAGES
-#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
-#else
-#define scrub_pages(_p,_n) ((void)0)
-#endif
 
 /* PAGE_SHIFT determines the page size */
 #define PAGE_SHIFT     12
diff -r 2bbd28891160 -r f4318c89291a 
unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h
--- a/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Apr 
04 19:59:10 2007 +0100
+++ b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h Wed Apr 
04 21:49:04 2007 +0100
@@ -23,6 +23,10 @@
 
 #if defined(_LINUX_SKBUFF_H) && !defined(NET_IP_ALIGN)
 #define NET_IP_ALIGN 0
+#endif
+
+#if defined(_LINUX_SKBUFF_H) && !defined(CHECKSUM_HW)
+#define CHECKSUM_HW CHECKSUM_PARTIAL
 #endif
 
 #if defined(_LINUX_ERR_H) && !defined(IS_ERR_VALUE)
@@ -76,6 +80,10 @@ extern char *kasprintf(gfp_t gfp, const 
        __attribute__ ((format (printf, 2, 3)));
 #endif
 
+#if defined(_LINUX_SYSRQ_H) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
+#define handle_sysrq(x,y,z) handle_sysrq(x,y)
+#endif
+
 /*
  * This variable at present is referenced by netfront, but only in code that
  * is dead when running in hvm guests. To detect potential active uses of it
diff -r 2bbd28891160 -r f4318c89291a unmodified_drivers/linux-2.6/mkbuildtree
--- a/unmodified_drivers/linux-2.6/mkbuildtree  Wed Apr 04 19:59:10 2007 +0100
+++ b/unmodified_drivers/linux-2.6/mkbuildtree  Wed Apr 04 21:49:04 2007 +0100
@@ -50,7 +50,6 @@ i[34567]86)
     ln -sf ${XL}/include/asm-i386/mach-xen/asm/hypercall.h include/asm
     ln -sf ${XL}/include/asm-i386/mach-xen/asm/synch_bitops.h include/asm
     ln -sf ${XL}/include/asm-i386/mach-xen/asm/maddr.h include/asm
-    ln -sf ${XL}/include/asm-i386/mach-xen/asm/page.h include/asm
   ;;
 "ia64")
     ln -sf ${XL}/include/asm-ia64/hypervisor.h include/asm
diff -r 2bbd28891160 -r f4318c89291a xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Wed Apr 04 19:59:10 2007 +0100
+++ b/xen/arch/x86/hvm/hvm.c    Wed Apr 04 21:49:04 2007 +0100
@@ -531,25 +531,22 @@ int hvm_do_hypercall(struct cpu_user_reg
 
     if ( (pregs->eax >= NR_hypercalls) || !hvm_hypercall_table[pregs->eax] )
     {
-        gdprintk(XENLOG_WARNING, "HVM vcpu %d:%d did a bad hypercall %d.\n",
-                current->domain->domain_id, current->vcpu_id,
-                pregs->eax);
+        if ( pregs->eax != __HYPERVISOR_grant_table_op )
+            gdprintk(XENLOG_WARNING, "HVM vcpu %d:%d bad hypercall %d.\n",
+                     current->domain->domain_id, current->vcpu_id, pregs->eax);
         pregs->eax = -ENOSYS;
         return 0;
     }
 
-    /* Install a canary value in regs->eip so can check for continuation */
-    pregs->eip |= 0xF; 
+    /* Check for preemption: EIP will be modified from this dummy value. */
+    pregs->eip = 0xF0F0F0FF;
 
     pregs->eax = hvm_hypercall_table[pregs->eax](
         pregs->ebx, pregs->ecx, pregs->edx, pregs->esi, pregs->edi);
 
-    /* XXX: pot fake IO instr here to inform the emulator to flush mapcache */
-
-    if( (pregs->eip & 0xF) == 0 ) /* preempted */
-        return 1; 
-
-    return 0; 
+    /* XXX: put fake IO instr here to inform the emulator to flush mapcache */
+
+    return (pregs->eip != 0xF0F0F0FF); /* preempted? */
 }
 
 #else /* defined(__x86_64__) */
@@ -620,12 +617,15 @@ int hvm_do_hypercall(struct cpu_user_reg
     pregs->rax = (uint32_t)pregs->eax; /* mask in case compat32 caller */
     if ( (pregs->rax >= NR_hypercalls) || !hvm_hypercall64_table[pregs->rax] )
     {
-        gdprintk(XENLOG_WARNING, "HVM vcpu %d:%d did a bad hypercall %ld.\n",
-                current->domain->domain_id, current->vcpu_id,
-                pregs->rax);
+        if ( pregs->rax != __HYPERVISOR_grant_table_op )
+            gdprintk(XENLOG_WARNING, "HVM vcpu %d:%d bad hypercall %ld.\n",
+                     current->domain->domain_id, current->vcpu_id, pregs->rax);
         pregs->rax = -ENOSYS;
         return 0;
     }
+
+    /* Check for preemption: RIP will be modified from this dummy value. */
+    pregs->rip = 0xF0F0F0FF;
 
     if ( current->arch.paging.mode->guest_levels == 4 )
     {
@@ -643,7 +643,10 @@ int hvm_do_hypercall(struct cpu_user_reg
                                                        (uint32_t)pregs->esi,
                                                        (uint32_t)pregs->edi);
     }
-    return 0; /* XXX SMH: fix for preempt here */
+
+    /* XXX: put fake IO instr here to inform the emulator to flush mapcache */
+
+    return (pregs->rip != 0xF0F0F0FF); /* preempted? */
 }
 
 #endif /* defined(__x86_64__) */
diff -r 2bbd28891160 -r f4318c89291a xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c        Wed Apr 04 19:59:10 2007 +0100
+++ b/xen/arch/x86/hvm/svm/svm.c        Wed Apr 04 21:49:04 2007 +0100
@@ -2275,8 +2275,8 @@ asmlinkage void svm_vmexit_handler(struc
         inst_len = __get_instruction_length(v, INSTR_VMCALL, NULL);
         ASSERT(inst_len > 0);
         HVMTRACE_1D(VMMCALL, v, regs->eax);
-        if(hvm_do_hypercall(regs) == 0) /* not preempted */
-            __update_guest_eip(vmcb, inst_len);
+        if ( !hvm_do_hypercall(regs) )
+            __update_guest_eip(vmcb, inst_len); /* not preempted */
         break;
 
     case VMEXIT_CR0_READ:
diff -r 2bbd28891160 -r f4318c89291a xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Wed Apr 04 19:59:10 2007 +0100
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Wed Apr 04 21:49:04 2007 +0100
@@ -2628,8 +2628,8 @@ asmlinkage void vmx_vmexit_handler(struc
     {
         HVMTRACE_1D(VMMCALL, v, regs->eax);
         inst_len = __get_instruction_length(); /* Safe: VMCALL */
-        if(hvm_do_hypercall(regs) == 0)        /* not preempted */
-            __update_guest_eip(inst_len);
+        if ( !hvm_do_hypercall(regs) )
+            __update_guest_eip(inst_len); /* preempted */
         break;
     }
     case EXIT_REASON_CR_ACCESS:

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.