ia64/xen-unstable

changeset 14726:f4318c89291a

Various cleanups and fixes for PV-on-HVM drivers.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Wed Apr 04 21:49:04 2007 +0100 (2007-04-04)
parents 2bbd28891160
children 1ec1affb1b50
files linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6-xen-sparse/drivers/xen/core/gnttab.c linux-2.6-xen-sparse/drivers/xen/core/reboot.c linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/maddr.h linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/maddr.h linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h unmodified_drivers/linux-2.6/mkbuildtree xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/vmx/vmx.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Apr 04 19:59:10 2007 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Apr 04 21:49:04 2007 +0100
     1.3 @@ -59,10 +59,6 @@
     1.4  #include <xen/xenbus.h>
     1.5  #include "common.h"
     1.6  
     1.7 -#ifndef CONFIG_XEN 
     1.8 -#define scrub_pages(_p,_n)
     1.9 -#endif
    1.10 -
    1.11  #ifdef CONFIG_PROC_FS
    1.12  static struct proc_dir_entry *balloon_pde;
    1.13  #endif
    1.14 @@ -251,8 +247,6 @@ static int increase_reservation(unsigned
    1.15  	return 0;
    1.16  }
    1.17  
    1.18 -extern void xen_invalidate_foreign_mappings(void);
    1.19 -
    1.20  static int decrease_reservation(unsigned long nr_pages)
    1.21  {
    1.22  	unsigned long  pfn, i, flags;
    1.23 @@ -286,7 +280,7 @@ static int decrease_reservation(unsigned
    1.24  				(unsigned long)v, __pte_ma(0), 0);
    1.25  			BUG_ON(ret);
    1.26  		}
    1.27 -#ifdef CONFIG_XEN
    1.28 +#ifdef CONFIG_XEN_SCRUB_PAGES
    1.29  		else {
    1.30  			v = kmap(page);
    1.31  			scrub_pages(v, 1);
    1.32 @@ -306,13 +300,18 @@ static int decrease_reservation(unsigned
    1.33  	/* No more mappings: invalidate P2M and add to balloon. */
    1.34  	for (i = 0; i < nr_pages; i++) {
    1.35  		pfn = mfn_to_pfn(frame_list[i]);
    1.36 -#ifdef CONFIG_XEN
    1.37  		set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
    1.38 -#endif
    1.39  		balloon_append(pfn_to_page(pfn));
    1.40  	}
    1.41  
    1.42 -        xen_invalidate_foreign_mappings(); 
    1.43 +#ifndef CONFIG_XEN
    1.44 +	/* XXX Temporary hack. */
    1.45 +	{
    1.46 +		extern void xen_invalidate_foreign_mappings(void);
    1.47 +		xen_invalidate_foreign_mappings(); 
    1.48 +	}
    1.49 +#endif
    1.50 +
    1.51  	set_xen_guest_handle(reservation.extent_start, frame_list);
    1.52  	reservation.nr_extents   = nr_pages;
    1.53  	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
    1.54 @@ -476,7 +475,7 @@ static int __init balloon_init(void)
    1.55  	bs.current_pages = min(xen_start_info->nr_pages, max_pfn);
    1.56  	totalram_pages   = bs.current_pages;
    1.57  #else 
    1.58 -        bs.current_pages = totalram_pages; 
    1.59 +	bs.current_pages = totalram_pages; 
    1.60  #endif
    1.61  	bs.target_pages  = bs.current_pages;
    1.62  	bs.balloon_low   = 0;
    1.63 @@ -592,9 +591,9 @@ struct page **alloc_empty_pages_and_page
    1.64  #ifdef CONFIG_XEN
    1.65  			ret = apply_to_page_range(&init_mm, vaddr, PAGE_SIZE,
    1.66  						  dealloc_pte_fn, NULL);
    1.67 -#else 
    1.68 -                        /* cannot handle non-auto translate mode */
    1.69 -                        ret = 1; 
    1.70 +#else
    1.71 +			/* Cannot handle non-auto translate mode. */
    1.72 +			ret = 1;
    1.73  #endif
    1.74  		}
    1.75  
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Wed Apr 04 19:59:10 2007 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Wed Apr 04 21:49:04 2007 +0100
     2.3 @@ -661,9 +661,10 @@ void do_blkif_request(request_queue_t *r
     2.4  		if (RING_FULL(&info->ring))
     2.5  			goto wait;
     2.6  
     2.7 -		DPRINTK("do_blk_req %p: cmd %p, sec %lx, "
     2.8 +		DPRINTK("do_blk_req %p: cmd %p, sec %llx, "
     2.9  			"(%u/%li) buffer:%p [%s]\n",
    2.10 -			req, req->cmd, req->sector, req->current_nr_sectors,
    2.11 +			req, req->cmd, (long long)req->sector,
    2.12 +			req->current_nr_sectors,
    2.13  			req->nr_sectors, req->buffer,
    2.14  			rq_data_dir(req) ? "write" : "read");
    2.15  
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Wed Apr 04 19:59:10 2007 +0100
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c	Wed Apr 04 21:49:04 2007 +0100
     3.3 @@ -407,13 +407,11 @@ grow_nomem:
     3.4  static unsigned int __max_nr_grant_frames(void)
     3.5  {
     3.6  	struct gnttab_query_size query;
     3.7 -	int rc = -1;
     3.8 +	int rc;
     3.9  
    3.10  	query.dom = DOMID_SELF;
    3.11  
    3.12 -#ifdef CONFIG_XEN
    3.13  	rc = HYPERVISOR_grant_table_op(GNTTABOP_query_size, &query, 1);
    3.14 -#endif
    3.15  	if ((rc < 0) || (query.status != GNTST_okay))
    3.16  		return 4; /* Legacy max supported number of frames */
    3.17  
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Wed Apr 04 19:59:10 2007 +0100
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/reboot.c	Wed Apr 04 21:49:04 2007 +0100
     4.3 @@ -9,6 +9,10 @@
     4.4  #include <xen/xenbus.h>
     4.5  #include <linux/kthread.h>
     4.6  
     4.7 +#ifdef HAVE_XEN_PLATFORM_COMPAT_H
     4.8 +#include <xen/platform-compat.h>
     4.9 +#endif
    4.10 +
    4.11  MODULE_LICENSE("Dual BSD/GPL");
    4.12  
    4.13  #define SHUTDOWN_INVALID  -1
     5.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Wed Apr 04 19:59:10 2007 +0100
     5.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h	Wed Apr 04 21:49:04 2007 +0100
     5.3 @@ -122,6 +122,12 @@ void xen_destroy_contiguous_region(
     5.4  /* Turn jiffies into Xen system time. */
     5.5  u64 jiffies_to_st(unsigned long jiffies);
     5.6  
     5.7 +#ifdef CONFIG_XEN_SCRUB_PAGES
     5.8 +#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
     5.9 +#else
    5.10 +#define scrub_pages(_p,_n) ((void)0)
    5.11 +#endif
    5.12 +
    5.13  #include <asm/hypercall.h>
    5.14  
    5.15  #if defined(CONFIG_X86_64)
     6.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/maddr.h	Wed Apr 04 19:59:10 2007 +0100
     6.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/maddr.h	Wed Apr 04 21:49:04 2007 +0100
     6.3 @@ -158,7 +158,7 @@ static inline paddr_t pte_machine_to_phy
     6.4  #define pfn_to_mfn(pfn) (pfn)
     6.5  #define mfn_to_pfn(mfn) (mfn)
     6.6  #define mfn_to_local_pfn(mfn) (mfn)
     6.7 -#define set_phys_to_machine(pfn, mfn) BUG_ON((pfn) != (mfn))
     6.8 +#define set_phys_to_machine(pfn, mfn) ((void)0)
     6.9  #define phys_to_machine_mapping_valid(pfn) (1)
    6.10  #define phys_to_machine(phys) ((maddr_t)(phys))
    6.11  #define machine_to_phys(mach) ((paddr_t)(mach))
     7.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h	Wed Apr 04 19:59:10 2007 +0100
     7.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/page.h	Wed Apr 04 21:49:04 2007 +0100
     7.3 @@ -45,12 +45,6 @@
     7.4  })
     7.5  #define HAVE_ARCH_FREE_PAGE
     7.6  
     7.7 -#ifdef CONFIG_XEN_SCRUB_PAGES
     7.8 -#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
     7.9 -#else
    7.10 -#define scrub_pages(_p,_n) ((void)0)
    7.11 -#endif
    7.12 -
    7.13  #ifdef CONFIG_X86_USE_3DNOW
    7.14  
    7.15  #include <asm/mmx.h>
     8.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/maddr.h	Wed Apr 04 19:59:10 2007 +0100
     8.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/maddr.h	Wed Apr 04 21:49:04 2007 +0100
     8.3 @@ -140,7 +140,7 @@ static inline paddr_t pte_machine_to_phy
     8.4  #define pfn_to_mfn(pfn) (pfn)
     8.5  #define mfn_to_pfn(mfn) (mfn)
     8.6  #define mfn_to_local_pfn(mfn) (mfn)
     8.7 -#define set_phys_to_machine(pfn, mfn) BUG_ON((pfn) != (mfn))
     8.8 +#define set_phys_to_machine(pfn, mfn) ((void)0)
     8.9  #define phys_to_machine_mapping_valid(pfn) (1)
    8.10  #define phys_to_machine(phys) ((maddr_t)(phys))
    8.11  #define machine_to_phys(mach) ((paddr_t)(mach))
     9.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h	Wed Apr 04 19:59:10 2007 +0100
     9.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/page.h	Wed Apr 04 21:49:04 2007 +0100
     9.3 @@ -24,12 +24,6 @@
     9.4  })
     9.5  #define HAVE_ARCH_FREE_PAGE
     9.6  
     9.7 -#ifdef CONFIG_XEN_SCRUB_PAGES
     9.8 -#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
     9.9 -#else
    9.10 -#define scrub_pages(_p,_n) ((void)0)
    9.11 -#endif
    9.12 -
    9.13  /* PAGE_SHIFT determines the page size */
    9.14  #define PAGE_SHIFT	12
    9.15  #ifdef __ASSEMBLY__
    10.1 --- a/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h	Wed Apr 04 19:59:10 2007 +0100
    10.2 +++ b/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h	Wed Apr 04 21:49:04 2007 +0100
    10.3 @@ -25,6 +25,10 @@
    10.4  #define NET_IP_ALIGN 0
    10.5  #endif
    10.6  
    10.7 +#if defined(_LINUX_SKBUFF_H) && !defined(CHECKSUM_HW)
    10.8 +#define CHECKSUM_HW CHECKSUM_PARTIAL
    10.9 +#endif
   10.10 +
   10.11  #if defined(_LINUX_ERR_H) && !defined(IS_ERR_VALUE)
   10.12  #define IS_ERR_VALUE(x) unlikely((x) > (unsigned long)-1000L)
   10.13  #endif
   10.14 @@ -76,6 +80,10 @@ extern char *kasprintf(gfp_t gfp, const 
   10.15         __attribute__ ((format (printf, 2, 3)));
   10.16  #endif
   10.17  
   10.18 +#if defined(_LINUX_SYSRQ_H) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
   10.19 +#define handle_sysrq(x,y,z) handle_sysrq(x,y)
   10.20 +#endif
   10.21 +
   10.22  /*
   10.23   * This variable at present is referenced by netfront, but only in code that
   10.24   * is dead when running in hvm guests. To detect potential active uses of it
    11.1 --- a/unmodified_drivers/linux-2.6/mkbuildtree	Wed Apr 04 19:59:10 2007 +0100
    11.2 +++ b/unmodified_drivers/linux-2.6/mkbuildtree	Wed Apr 04 21:49:04 2007 +0100
    11.3 @@ -50,7 +50,6 @@ i[34567]86)
    11.4      ln -sf ${XL}/include/asm-i386/mach-xen/asm/hypercall.h include/asm
    11.5      ln -sf ${XL}/include/asm-i386/mach-xen/asm/synch_bitops.h include/asm
    11.6      ln -sf ${XL}/include/asm-i386/mach-xen/asm/maddr.h include/asm
    11.7 -    ln -sf ${XL}/include/asm-i386/mach-xen/asm/page.h include/asm
    11.8    ;;
    11.9  "ia64")
   11.10      ln -sf ${XL}/include/asm-ia64/hypervisor.h include/asm
    12.1 --- a/xen/arch/x86/hvm/hvm.c	Wed Apr 04 19:59:10 2007 +0100
    12.2 +++ b/xen/arch/x86/hvm/hvm.c	Wed Apr 04 21:49:04 2007 +0100
    12.3 @@ -531,25 +531,22 @@ int hvm_do_hypercall(struct cpu_user_reg
    12.4  
    12.5      if ( (pregs->eax >= NR_hypercalls) || !hvm_hypercall_table[pregs->eax] )
    12.6      {
    12.7 -        gdprintk(XENLOG_WARNING, "HVM vcpu %d:%d did a bad hypercall %d.\n",
    12.8 -                current->domain->domain_id, current->vcpu_id,
    12.9 -                pregs->eax);
   12.10 +        if ( pregs->eax != __HYPERVISOR_grant_table_op )
   12.11 +            gdprintk(XENLOG_WARNING, "HVM vcpu %d:%d bad hypercall %d.\n",
   12.12 +                     current->domain->domain_id, current->vcpu_id, pregs->eax);
   12.13          pregs->eax = -ENOSYS;
   12.14          return 0;
   12.15      }
   12.16  
   12.17 -    /* Install a canary value in regs->eip so can check for continuation */
   12.18 -    pregs->eip |= 0xF; 
   12.19 +    /* Check for preemption: EIP will be modified from this dummy value. */
   12.20 +    pregs->eip = 0xF0F0F0FF;
   12.21  
   12.22      pregs->eax = hvm_hypercall_table[pregs->eax](
   12.23          pregs->ebx, pregs->ecx, pregs->edx, pregs->esi, pregs->edi);
   12.24  
   12.25 -    /* XXX: pot fake IO instr here to inform the emulator to flush mapcache */
   12.26 +    /* XXX: put fake IO instr here to inform the emulator to flush mapcache */
   12.27  
   12.28 -    if( (pregs->eip & 0xF) == 0 ) /* preempted */
   12.29 -        return 1; 
   12.30 -
   12.31 -    return 0; 
   12.32 +    return (pregs->eip != 0xF0F0F0FF); /* preempted? */
   12.33  }
   12.34  
   12.35  #else /* defined(__x86_64__) */
   12.36 @@ -620,13 +617,16 @@ int hvm_do_hypercall(struct cpu_user_reg
   12.37      pregs->rax = (uint32_t)pregs->eax; /* mask in case compat32 caller */
   12.38      if ( (pregs->rax >= NR_hypercalls) || !hvm_hypercall64_table[pregs->rax] )
   12.39      {
   12.40 -        gdprintk(XENLOG_WARNING, "HVM vcpu %d:%d did a bad hypercall %ld.\n",
   12.41 -                current->domain->domain_id, current->vcpu_id,
   12.42 -                pregs->rax);
   12.43 +        if ( pregs->rax != __HYPERVISOR_grant_table_op )
   12.44 +            gdprintk(XENLOG_WARNING, "HVM vcpu %d:%d bad hypercall %ld.\n",
   12.45 +                     current->domain->domain_id, current->vcpu_id, pregs->rax);
   12.46          pregs->rax = -ENOSYS;
   12.47          return 0;
   12.48      }
   12.49  
   12.50 +    /* Check for preemption: RIP will be modified from this dummy value. */
   12.51 +    pregs->rip = 0xF0F0F0FF;
   12.52 +
   12.53      if ( current->arch.paging.mode->guest_levels == 4 )
   12.54      {
   12.55          pregs->rax = hvm_hypercall64_table[pregs->rax](pregs->rdi,
   12.56 @@ -643,7 +643,10 @@ int hvm_do_hypercall(struct cpu_user_reg
   12.57                                                         (uint32_t)pregs->esi,
   12.58                                                         (uint32_t)pregs->edi);
   12.59      }
   12.60 -    return 0; /* XXX SMH: fix for preempt here */
   12.61 +
   12.62 +    /* XXX: put fake IO instr here to inform the emulator to flush mapcache */
   12.63 +
   12.64 +    return (pregs->rip != 0xF0F0F0FF); /* preempted? */
   12.65  }
   12.66  
   12.67  #endif /* defined(__x86_64__) */
    13.1 --- a/xen/arch/x86/hvm/svm/svm.c	Wed Apr 04 19:59:10 2007 +0100
    13.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Wed Apr 04 21:49:04 2007 +0100
    13.3 @@ -2275,8 +2275,8 @@ asmlinkage void svm_vmexit_handler(struc
    13.4          inst_len = __get_instruction_length(v, INSTR_VMCALL, NULL);
    13.5          ASSERT(inst_len > 0);
    13.6          HVMTRACE_1D(VMMCALL, v, regs->eax);
    13.7 -        if(hvm_do_hypercall(regs) == 0) /* not preempted */
    13.8 -            __update_guest_eip(vmcb, inst_len);
    13.9 +        if ( !hvm_do_hypercall(regs) )
   13.10 +            __update_guest_eip(vmcb, inst_len); /* not preempted */
   13.11          break;
   13.12  
   13.13      case VMEXIT_CR0_READ:
    14.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Wed Apr 04 19:59:10 2007 +0100
    14.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Wed Apr 04 21:49:04 2007 +0100
    14.3 @@ -2628,8 +2628,8 @@ asmlinkage void vmx_vmexit_handler(struc
    14.4      {
    14.5          HVMTRACE_1D(VMMCALL, v, regs->eax);
    14.6          inst_len = __get_instruction_length(); /* Safe: VMCALL */
    14.7 -        if(hvm_do_hypercall(regs) == 0)        /* not preempted */
    14.8 -            __update_guest_eip(inst_len);
    14.9 +        if ( !hvm_do_hypercall(regs) )
   14.10 +            __update_guest_eip(inst_len); /* preempted */
   14.11          break;
   14.12      }
   14.13      case EXIT_REASON_CR_ACCESS: