direct-io.hg

changeset 8286:a08aef9f1c8e

Make balloon driver arch-neutral.

Signed-off-by: Dan Magenheimer <dan.magenheimer@hp.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Dec 08 15:33:10 2005 +0100 (2005-12-08)
parents 89a223305611
children c9772105fead
files linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu Dec 08 15:25:44 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu Dec 08 15:33:10 2005 +0100
     1.3 @@ -192,8 +192,8 @@ static int increase_reservation(unsigned
     1.4  		page = balloon_retrieve();
     1.5  		BUG_ON(page == NULL);
     1.6  
     1.7 -		pfn = page - mem_map;
     1.8 -		BUG_ON(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY);
     1.9 +		pfn = page_to_pfn(page);
    1.10 +		BUG_ON(phys_to_machine_mapping_valid(pfn));
    1.11  
    1.12  		/* Update P->M and M->P tables. */
    1.13  		set_phys_to_machine(pfn, mfn_list[i]);
    1.14 @@ -253,8 +253,8 @@ static int decrease_reservation(unsigned
    1.15  			break;
    1.16  		}
    1.17  
    1.18 -		pfn = page - mem_map;
    1.19 -		mfn_list[i] = phys_to_machine_mapping[pfn];
    1.20 +		pfn = page_to_pfn(page);
    1.21 +		mfn_list[i] = pfn_to_mfn(pfn);
    1.22  
    1.23  		if (!PageHighMem(page)) {
    1.24  			v = phys_to_virt(pfn << PAGE_SHIFT);
    1.25 @@ -444,6 +444,9 @@ static int __init balloon_init(void)
    1.26  
    1.27  	IPRINTK("Initialising balloon driver.\n");
    1.28  
    1.29 +	if (xen_init() < 0)
    1.30 +		return -1;
    1.31 +
    1.32  	current_pages = min(xen_start_info->nr_pages, max_pfn);
    1.33  	target_pages  = current_pages;
    1.34  	balloon_low   = 0;
    1.35 @@ -465,7 +468,7 @@ static int __init balloon_init(void)
    1.36      
    1.37  	/* Initialise the balloon with excess memory space. */
    1.38  	for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {
    1.39 -		page = &mem_map[pfn];
    1.40 +		page = pfn_to_page(pfn);
    1.41  		if (!PageReserved(page))
    1.42  			balloon_append(page);
    1.43  	}
     2.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Thu Dec 08 15:25:44 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h	Thu Dec 08 15:33:10 2005 +0100
     2.3 @@ -65,6 +65,8 @@
     2.4  extern unsigned long *phys_to_machine_mapping;
     2.5  #define pfn_to_mfn(pfn)	\
     2.6  (phys_to_machine_mapping[(unsigned int)(pfn)] & ~(1UL<<31))
     2.7 +#define	phys_to_machine_mapping_valid(pfn) \
     2.8 +	(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY)
     2.9  static inline unsigned long mfn_to_pfn(unsigned long mfn)
    2.10  {
    2.11  	unsigned long pfn;
     3.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h	Thu Dec 08 15:25:44 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypercall.h	Thu Dec 08 15:33:10 2005 +0100
     3.3 @@ -355,34 +355,27 @@ HYPERVISOR_multicall(
     3.4  #endif
     3.5      return 1;
     3.6  }
     3.7 +#endif
     3.8  
     3.9  static inline int
    3.10  HYPERVISOR_update_va_mapping(
    3.11      unsigned long va, pte_t new_val, unsigned long flags)
    3.12  {
    3.13 -#if 0
    3.14 -    int ret;
    3.15 -    unsigned long ign1, ign2, ign3;
    3.16 -
    3.17 -    __asm__ __volatile__ (
    3.18 -        TRAP_INSTR
    3.19 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
    3.20 -	: "0" (__HYPERVISOR_update_va_mapping), 
    3.21 -          "1" (va), "2" ((new_val).pte_low), "3" (flags)
    3.22 -	: "memory" );
    3.23 -
    3.24 -    if ( unlikely(ret < 0) )
    3.25 -    {
    3.26 -        printk(KERN_ALERT "Failed update VA mapping: %08lx, %08lx, %08lx\n",
    3.27 -               va, (new_val).pte_low, flags);
    3.28 -        BUG();
    3.29 -    }
    3.30 -
    3.31 -    return ret;
    3.32 -#endif
    3.33 +    /* no-op */
    3.34      return 1;
    3.35  }
    3.36 -#endif
    3.37 +
    3.38 +static inline int
    3.39 +HYPERVISOR_memory_op(
    3.40 +    unsigned int cmd, void *arg)
    3.41 +{
    3.42 +    int ret;
    3.43 +    __asm__ __volatile__ ( ";; mov r14=%2 ; mov r15=%3 ; mov r2=%1 ; break 0x1000 ;; mov %0=r8 ;;"
    3.44 +        : "=r" (ret)
    3.45 +        : "i" (__HYPERVISOR_console_io), "r"(cmd), "r"(arg)
    3.46 +        : "r14","r15","r2","r8","memory" );
    3.47 +    return ret;
    3.48 +}
    3.49  
    3.50  static inline int
    3.51  HYPERVISOR_event_channel_op(
     4.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h	Thu Dec 08 15:25:44 2005 +0100
     4.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/hypervisor.h	Thu Dec 08 15:33:10 2005 +0100
     4.3 @@ -52,4 +52,19 @@ void force_evtchn_callback(void);
     4.4  #define	mfn_to_pfn(x)	(x)
     4.5  #define machine_to_phys_mapping 0
     4.6  
     4.7 +// for drivers/xen/balloon/balloon.c
     4.8 +#ifdef CONFIG_XEN_SCRUB_PAGES
     4.9 +#define scrub_pages(_p,_n) memset((void *)(_p), 0, (_n) << PAGE_SHIFT)
    4.10 +#else
    4.11 +#define scrub_pages(_p,_n) ((void)0)
    4.12 +#endif
    4.13 +#define	pte_mfn(_x)	pte_pfn(_x)
    4.14 +#define INVALID_P2M_ENTRY	(~0UL)
    4.15 +#define __pte_ma(_x)	((pte_t) {(_x)})
    4.16 +#define phys_to_machine_mapping_valid(_x)	(1)
    4.17 +#define	kmap_flush_unused()	do {} while (0)
    4.18 +#define set_phys_to_machine(_x,_y)	do {} while (0)
    4.19 +#define xen_machphys_update(_x,_y)	do {} while (0)
    4.20 +#define pfn_pte_ma(_x,_y)	__pte_ma(0)
    4.21 +
    4.22  #endif /* __HYPERVISOR_H__ */
     5.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Thu Dec 08 15:25:44 2005 +0100
     5.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/page.h	Thu Dec 08 15:33:10 2005 +0100
     5.3 @@ -67,6 +67,8 @@ void copy_page(void *, void *);
     5.4  extern unsigned long *phys_to_machine_mapping;
     5.5  #define pfn_to_mfn(pfn)	\
     5.6  (phys_to_machine_mapping[(unsigned int)(pfn)] & ~(1UL << 63))
     5.7 +#define	phys_to_machine_mapping_valid(pfn) \
     5.8 +	(phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY)
     5.9  static inline unsigned long mfn_to_pfn(unsigned long mfn)
    5.10  {
    5.11  	unsigned long pfn;