ia64/linux-2.6.18-xen.hg

changeset 607:2c80783731a2

xen/x86: fix compatibility handling

A recent need for our kernel was to be able to run on 3.0.2-based Xen,
and this pointed out that while the fallback code in hypercall.h deals
with most of the cases, the multicalls used in the context switch code
didn't have appropriate fallback mechanisms. Short of breaking up the
multicall or checking individual operation status, the easier method
to fix this seemed to be to simply use the old hypercalls when
CONFIG_XEN_COMPAT_030002_AND_LATER is defined.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jul 18 11:26:26 2008 +0100 (2008-07-18)
parents f23e94e1c335
children 905f275ed4d8
files arch/i386/kernel/process-xen.c arch/x86_64/kernel/process-xen.c
line diff
     1.1 --- a/arch/i386/kernel/process-xen.c	Fri Jul 18 11:25:56 2008 +0100
     1.2 +++ b/arch/i386/kernel/process-xen.c	Fri Jul 18 11:26:26 2008 +0100
     1.3 @@ -552,8 +552,14 @@ struct task_struct fastcall * __switch_t
     1.4  #ifndef CONFIG_X86_NO_TSS
     1.5  	struct tss_struct *tss = &per_cpu(init_tss, cpu);
     1.6  #endif
     1.7 +#if CONFIG_XEN_COMPAT > 0x030002
     1.8  	struct physdev_set_iopl iopl_op;
     1.9  	struct physdev_set_iobitmap iobmp_op;
    1.10 +#else
    1.11 +	struct physdev_op _pdo[2], *pdo = _pdo;
    1.12 +#define iopl_op pdo->u.set_iopl
    1.13 +#define iobmp_op pdo->u.set_iobitmap
    1.14 +#endif
    1.15  	multicall_entry_t _mcl[8], *mcl = _mcl;
    1.16  
    1.17  	/* XEN NOTE: FS/GS saved in switch_mm(), not here. */
    1.18 @@ -601,9 +607,15 @@ struct task_struct fastcall * __switch_t
    1.19  
    1.20  	if (unlikely(prev->iopl != next->iopl)) {
    1.21  		iopl_op.iopl = (next->iopl == 0) ? 1 : (next->iopl >> 12) & 3;
    1.22 +#if CONFIG_XEN_COMPAT > 0x030002
    1.23  		mcl->op      = __HYPERVISOR_physdev_op;
    1.24  		mcl->args[0] = PHYSDEVOP_set_iopl;
    1.25  		mcl->args[1] = (unsigned long)&iopl_op;
    1.26 +#else
    1.27 +		mcl->op      = __HYPERVISOR_physdev_op_compat;
    1.28 +		pdo->cmd     = PHYSDEVOP_set_iopl;
    1.29 +		mcl->args[0] = (unsigned long)pdo++;
    1.30 +#endif
    1.31  		mcl++;
    1.32  	}
    1.33  
    1.34 @@ -611,12 +623,21 @@ struct task_struct fastcall * __switch_t
    1.35  		set_xen_guest_handle(iobmp_op.bitmap,
    1.36  				     (char *)next->io_bitmap_ptr);
    1.37  		iobmp_op.nr_ports = next->io_bitmap_ptr ? IO_BITMAP_BITS : 0;
    1.38 +#if CONFIG_XEN_COMPAT > 0x030002
    1.39  		mcl->op      = __HYPERVISOR_physdev_op;
    1.40  		mcl->args[0] = PHYSDEVOP_set_iobitmap;
    1.41  		mcl->args[1] = (unsigned long)&iobmp_op;
    1.42 +#else
    1.43 +		mcl->op      = __HYPERVISOR_physdev_op_compat;
    1.44 +		pdo->cmd     = PHYSDEVOP_set_iobitmap;
    1.45 +		mcl->args[0] = (unsigned long)pdo++;
    1.46 +#endif
    1.47  		mcl++;
    1.48  	}
    1.49  
    1.50 +#if CONFIG_XEN_COMPAT <= 0x030002
    1.51 +	BUG_ON(pdo > _pdo + ARRAY_SIZE(_pdo));
    1.52 +#endif
    1.53  	BUG_ON(mcl > _mcl + ARRAY_SIZE(_mcl));
    1.54  	if (unlikely(HYPERVISOR_multicall_check(_mcl, mcl - _mcl, NULL)))
    1.55  		BUG();
     2.1 --- a/arch/x86_64/kernel/process-xen.c	Fri Jul 18 11:25:56 2008 +0100
     2.2 +++ b/arch/x86_64/kernel/process-xen.c	Fri Jul 18 11:26:26 2008 +0100
     2.3 @@ -491,8 +491,14 @@ static inline void __save_init_fpu( stru
     2.4  #ifndef CONFIG_X86_NO_TSS
     2.5  	struct tss_struct *tss = &per_cpu(init_tss, cpu);
     2.6  #endif
     2.7 +#if CONFIG_XEN_COMPAT > 0x030002
     2.8  	struct physdev_set_iopl iopl_op;
     2.9  	struct physdev_set_iobitmap iobmp_op;
    2.10 +#else
    2.11 +	struct physdev_op _pdo[2], *pdo = _pdo;
    2.12 +#define iopl_op pdo->u.set_iopl
    2.13 +#define iobmp_op pdo->u.set_iobitmap
    2.14 +#endif
    2.15  	multicall_entry_t _mcl[8], *mcl = _mcl;
    2.16  
    2.17  	/*
    2.18 @@ -535,9 +541,15 @@ static inline void __save_init_fpu( stru
    2.19  
    2.20  	if (unlikely(prev->iopl != next->iopl)) {
    2.21  		iopl_op.iopl = (next->iopl == 0) ? 1 : next->iopl;
    2.22 +#if CONFIG_XEN_COMPAT > 0x030002
    2.23  		mcl->op      = __HYPERVISOR_physdev_op;
    2.24  		mcl->args[0] = PHYSDEVOP_set_iopl;
    2.25  		mcl->args[1] = (unsigned long)&iopl_op;
    2.26 +#else
    2.27 +		mcl->op      = __HYPERVISOR_physdev_op_compat;
    2.28 +		pdo->cmd     = PHYSDEVOP_set_iopl;
    2.29 +		mcl->args[0] = (unsigned long)pdo++;
    2.30 +#endif
    2.31  		mcl++;
    2.32  	}
    2.33  
    2.34 @@ -545,12 +557,21 @@ static inline void __save_init_fpu( stru
    2.35  		set_xen_guest_handle(iobmp_op.bitmap,
    2.36  				     (char *)next->io_bitmap_ptr);
    2.37  		iobmp_op.nr_ports = next->io_bitmap_ptr ? IO_BITMAP_BITS : 0;
    2.38 +#if CONFIG_XEN_COMPAT > 0x030002
    2.39  		mcl->op      = __HYPERVISOR_physdev_op;
    2.40  		mcl->args[0] = PHYSDEVOP_set_iobitmap;
    2.41  		mcl->args[1] = (unsigned long)&iobmp_op;
    2.42 +#else
    2.43 +		mcl->op      = __HYPERVISOR_physdev_op_compat;
    2.44 +		pdo->cmd     = PHYSDEVOP_set_iobitmap;
    2.45 +		mcl->args[0] = (unsigned long)pdo++;
    2.46 +#endif
    2.47  		mcl++;
    2.48  	}
    2.49  
    2.50 +#if CONFIG_XEN_COMPAT <= 0x030002
    2.51 +	BUG_ON(pdo > _pdo + ARRAY_SIZE(_pdo));
    2.52 +#endif
    2.53  	BUG_ON(mcl > _mcl + ARRAY_SIZE(_mcl));
    2.54  	if (unlikely(HYPERVISOR_multicall_check(_mcl, mcl - _mcl, NULL)))
    2.55  		BUG();