ia64/xen-unstable

changeset 13307:d80684d19ef4

Enable compatibility mode operation for HYPERVISOR_sysctl.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Emmanuel Ackaouy <ack@xensource.com>
date Fri Jan 05 17:34:38 2007 +0000 (2007-01-05)
parents 62f3df867d0e
children 5442b2458e1b
files xen/arch/x86/sysctl.c xen/arch/x86/x86_64/Makefile xen/arch/x86/x86_64/compat/entry.S xen/arch/x86/x86_64/sysctl.c xen/common/compat/Makefile xen/common/compat/sysctl.c xen/common/sysctl.c xen/include/xen/domain.h xen/include/xen/perfc.h xen/include/xlat.lst
line diff
     1.1 --- a/xen/arch/x86/sysctl.c	Fri Jan 05 17:34:37 2007 +0000
     1.2 +++ b/xen/arch/x86/sysctl.c	Fri Jan 05 17:34:38 2007 +0000
     1.3 @@ -25,10 +25,14 @@
     1.4  #include <asm/hvm/support.h>
     1.5  #include <asm/processor.h>
     1.6  
     1.7 -long arch_do_sysctl(
     1.8 +#ifndef COMPAT
     1.9 +typedef long ret_t;
    1.10 +#endif
    1.11 +
    1.12 +ret_t arch_do_sysctl(
    1.13      struct xen_sysctl *sysctl, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
    1.14  {
    1.15 -    long ret = 0;
    1.16 +    ret_t ret = 0;
    1.17  
    1.18      switch ( sysctl->cmd )
    1.19      {
     2.1 --- a/xen/arch/x86/x86_64/Makefile	Fri Jan 05 17:34:37 2007 +0000
     2.2 +++ b/xen/arch/x86/x86_64/Makefile	Fri Jan 05 17:34:38 2007 +0000
     2.3 @@ -7,6 +7,7 @@ obj-$(CONFIG_COMPAT) += compat.o
     2.4  obj-$(CONFIG_COMPAT) += domain.o
     2.5  obj-$(CONFIG_COMPAT) += physdev.o
     2.6  obj-$(CONFIG_COMPAT) += platform_hypercall.o
     2.7 +obj-$(CONFIG_COMPAT) += sysctl.o
     2.8  
     2.9  ifeq ($(CONFIG_COMPAT),y)
    2.10  # extra dependencies
    2.11 @@ -15,5 +16,6 @@ entry.o:	compat/entry.S
    2.12  mm.o:		compat/mm.c
    2.13  physdev.o:	../physdev.c
    2.14  platform_hypercall.o: ../platform_hypercall.c
    2.15 +sysctl.o:	../sysctl.c
    2.16  traps.o:	compat/traps.c
    2.17  endif
     3.1 --- a/xen/arch/x86/x86_64/compat/entry.S	Fri Jan 05 17:34:37 2007 +0000
     3.2 +++ b/xen/arch/x86/x86_64/compat/entry.S	Fri Jan 05 17:34:38 2007 +0000
     3.3 @@ -278,7 +278,6 @@ CFIX14:
     3.4  
     3.5  .section .rodata, "a", @progbits
     3.6  
     3.7 -#define compat_sysctl domain_crash_synchronous
     3.8  #define compat_domctl domain_crash_synchronous
     3.9  
    3.10  ENTRY(compat_hypercall_table)
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/xen/arch/x86/x86_64/sysctl.c	Fri Jan 05 17:34:38 2007 +0000
     4.3 @@ -0,0 +1,33 @@
     4.4 +/******************************************************************************
     4.5 + * Arch-specific compatibility sysctl.c
     4.6 + */
     4.7 +
     4.8 +#include <xen/config.h>
     4.9 +#include <compat/sysctl.h>
    4.10 +
    4.11 +DEFINE_XEN_GUEST_HANDLE(compat_sysctl_t);
    4.12 +#define xen_sysctl                    compat_sysctl
    4.13 +#define xen_sysctl_t                  compat_sysctl_t
    4.14 +#define arch_do_sysctl(x, h)          arch_compat_sysctl(x, _##h)
    4.15 +
    4.16 +#define xen_sysctl_physinfo           compat_sysctl_physinfo
    4.17 +#define xen_sysctl_physinfo_t         compat_sysctl_physinfo_t
    4.18 +
    4.19 +#define xen_sysctl_ioport_emulation   compat_sysctl_ioport_emulation
    4.20 +#define xen_sysctl_ioport_emulation_t compat_sysctl_ioport_emulation_t
    4.21 +
    4.22 +#define COMPAT
    4.23 +#define _XEN_GUEST_HANDLE(t)          XEN_GUEST_HANDLE(t)
    4.24 +typedef int ret_t;
    4.25 +
    4.26 +#include "../sysctl.c"
    4.27 +
    4.28 +/*
    4.29 + * Local variables:
    4.30 + * mode: C
    4.31 + * c-set-style: "BSD"
    4.32 + * c-basic-offset: 4
    4.33 + * tab-width: 4
    4.34 + * indent-tabs-mode: nil
    4.35 + * End:
    4.36 + */
     5.1 --- a/xen/common/compat/Makefile	Fri Jan 05 17:34:37 2007 +0000
     5.2 +++ b/xen/common/compat/Makefile	Fri Jan 05 17:34:38 2007 +0000
     5.3 @@ -2,8 +2,10 @@ obj-y += domain.o
     5.4  obj-y += kernel.o
     5.5  obj-y += memory.o
     5.6  obj-y += multicall.o
     5.7 +obj-y += sysctl.o
     5.8  obj-y += xlat.o
     5.9  
    5.10  # extra dependencies
    5.11  kernel.o:	../kernel.c
    5.12  multicall.o:	../multicall.c
    5.13 +sysctl.o:	../sysctl.c
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/xen/common/compat/sysctl.c	Fri Jan 05 17:34:38 2007 +0000
     6.3 @@ -0,0 +1,102 @@
     6.4 +/******************************************************************************
     6.5 + * compat/sysctl.c
     6.6 + */
     6.7 +
     6.8 +#include <xen/config.h>
     6.9 +#include <compat/sysctl.h>
    6.10 +#include <xen/domain.h>
    6.11 +#include <xen/guest_access.h>
    6.12 +#include <xen/perfc.h>
    6.13 +#include <xen/trace.h>
    6.14 +
    6.15 +DEFINE_XEN_GUEST_HANDLE(compat_sysctl_t);
    6.16 +#define xen_sysctl                     compat_sysctl
    6.17 +#define xen_sysctl_t                   compat_sysctl_t
    6.18 +#define do_sysctl(h)                   compat_sysctl(_##h)
    6.19 +#define arch_do_sysctl(x, h)           arch_compat_sysctl(x, _##h)
    6.20 +
    6.21 +#define xen_sysctl_readconsole         compat_sysctl_readconsole
    6.22 +#define xen_sysctl_readconsole_t       compat_sysctl_readconsole_t
    6.23 +
    6.24 +static int compat_tb_control(struct compat_sysctl_tbuf_op *cmp_tbc)
    6.25 +{
    6.26 +    struct xen_sysctl_tbuf_op nat_tbc;
    6.27 +    int ret;
    6.28 +
    6.29 +#define XLAT_ctl_cpumap_HNDL_bitmap(_d_, _s_) \
    6.30 +    guest_from_compat_handle((_d_)->bitmap, (_s_)->bitmap)
    6.31 +    XLAT_sysctl_tbuf_op(&nat_tbc, cmp_tbc);
    6.32 +#undef XLAT_ctl_cpumap_HNDL_bitmap
    6.33 +    ret = tb_control(&nat_tbc);
    6.34 +#define XLAT_ctl_cpumap_HNDL_bitmap(_d_, _s_) ((void)0)
    6.35 +    XLAT_sysctl_tbuf_op(cmp_tbc, &nat_tbc);
    6.36 +#undef XLAT_ctl_cpumap_HNDL_bitmap
    6.37 +    return ret;
    6.38 +}
    6.39 +#define xen_sysctl_tbuf_op             compat_sysctl_tbuf_op
    6.40 +#define xen_sysctl_tbuf_op_t           compat_sysctl_tbuf_op_t
    6.41 +#define tb_control(p)                  compat_tb_control(p)
    6.42 +
    6.43 +#define xen_sysctl_sched_id            compat_sysctl_sched_id
    6.44 +#define xen_sysctl_sched_id_t          compat_sysctl_sched_id_t
    6.45 +
    6.46 +static void compat_getdomaininfo(struct domain *d, struct compat_domctl_getdomaininfo *ci)
    6.47 +{
    6.48 +    struct xen_domctl_getdomaininfo ni;
    6.49 +
    6.50 +    getdomaininfo(d, &ni);
    6.51 +    XLAT_domctl_getdomaininfo(ci, &ni);
    6.52 +}
    6.53 +#define xen_sysctl_getdomaininfolist   compat_sysctl_getdomaininfolist
    6.54 +#define xen_sysctl_getdomaininfolist_t compat_sysctl_getdomaininfolist_t
    6.55 +#define xen_domctl_getdomaininfo       compat_domctl_getdomaininfo
    6.56 +#define xen_domctl_getdomaininfo_t     compat_domctl_getdomaininfo_t
    6.57 +#define getdomaininfo(d, i)            compat_getdomaininfo(d, i)
    6.58 +
    6.59 +#ifdef PERF_COUNTERS
    6.60 +static int compat_perfc_control(struct compat_sysctl_perfc_op *cmp_pc)
    6.61 +{
    6.62 +    CHECK_sysctl_perfc_desc;
    6.63 +    CHECK_TYPE(sysctl_perfc_val);
    6.64 +    struct xen_sysctl_perfc_op nat_pc;
    6.65 +    int ret;
    6.66 +
    6.67 +#define XLAT_sysctl_perfc_op_HNDL_desc(_d_, _s_) \
    6.68 +    guest_from_compat_handle((_d_)->desc, (_s_)->desc)
    6.69 +#define XLAT_sysctl_perfc_op_HNDL_val(_d_, _s_) \
    6.70 +    guest_from_compat_handle((_d_)->val, (_s_)->val)
    6.71 +    XLAT_sysctl_perfc_op(&nat_pc, cmp_pc);
    6.72 +#undef XLAT_sysctl_perfc_op_HNDL_val
    6.73 +#undef XLAT_sysctl_perfc_op_HNDL_desc
    6.74 +    ret = perfc_control(&nat_pc);
    6.75 +#define XLAT_sysctl_perfc_op_HNDL_desc(_d_, _s_)
    6.76 +#define XLAT_sysctl_perfc_op_HNDL_val(_d_, _s_)
    6.77 +    XLAT_sysctl_perfc_op(cmp_pc, &nat_pc);
    6.78 +#undef XLAT_sysctl_perfc_op_HNDL_val
    6.79 +#undef XLAT_sysctl_perfc_op_HNDL_desc
    6.80 +    return ret;
    6.81 +}
    6.82 +#define xen_sysctl_perfc_op            compat_sysctl_perfc_op
    6.83 +#define xen_sysctl_perfc_op_t          compat_sysctl_perfc_op_t
    6.84 +#define perfc_control(p)               compat_perfc_control(p)
    6.85 +#endif
    6.86 +
    6.87 +#define COMPAT
    6.88 +#define _XEN_GUEST_HANDLE(t)           XEN_GUEST_HANDLE(t)
    6.89 +#define _u_sysctl                      u_sysctl
    6.90 +#undef guest_handle_cast
    6.91 +#define guest_handle_cast              compat_handle_cast
    6.92 +#define copy_to_xxx_offset             copy_to_compat_offset
    6.93 +typedef int ret_t;
    6.94 +
    6.95 +#include "../sysctl.c"
    6.96 +
    6.97 +/*
    6.98 + * Local variables:
    6.99 + * mode: C
   6.100 + * c-set-style: "BSD"
   6.101 + * c-basic-offset: 4
   6.102 + * tab-width: 4
   6.103 + * indent-tabs-mode: nil
   6.104 + * End:
   6.105 + */
     7.1 --- a/xen/common/sysctl.c	Fri Jan 05 17:34:37 2007 +0000
     7.2 +++ b/xen/common/sysctl.c	Fri Jan 05 17:34:38 2007 +0000
     7.3 @@ -21,14 +21,17 @@
     7.4  #include <asm/current.h>
     7.5  #include <public/sysctl.h>
     7.6  
     7.7 -extern long arch_do_sysctl(
     7.8 +#ifndef COMPAT
     7.9 +typedef long ret_t;
    7.10 +#define copy_to_xxx_offset copy_to_guest_offset
    7.11 +#endif
    7.12 +
    7.13 +extern ret_t arch_do_sysctl(
    7.14      struct xen_sysctl *op, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl);
    7.15 -extern void getdomaininfo(
    7.16 -    struct domain *d, struct xen_domctl_getdomaininfo *info);
    7.17  
    7.18 -long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
    7.19 +ret_t do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
    7.20  {
    7.21 -    long ret = 0;
    7.22 +    ret_t ret = 0;
    7.23      struct xen_sysctl curop, *op = &curop;
    7.24      static DEFINE_SPINLOCK(sysctl_lock);
    7.25  
    7.26 @@ -98,8 +101,8 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
    7.27  
    7.28              put_domain(d);
    7.29  
    7.30 -            if ( copy_to_guest_offset(op->u.getdomaininfolist.buffer,
    7.31 -                                      num_domains, &info, 1) )
    7.32 +            if ( copy_to_xxx_offset(op->u.getdomaininfolist.buffer,
    7.33 +                                    num_domains, &info, 1) )
    7.34              {
    7.35                  ret = -EFAULT;
    7.36                  break;
    7.37 @@ -123,7 +126,6 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
    7.38  #ifdef PERF_COUNTERS
    7.39      case XEN_SYSCTL_perfc_op:
    7.40      {
    7.41 -        extern int perfc_control(xen_sysctl_perfc_op_t *);
    7.42          ret = perfc_control(&op->u.perfc_op);
    7.43          if ( copy_to_guest(u_sysctl, op, 1) )
    7.44              ret = -EFAULT;
     8.1 --- a/xen/include/xen/domain.h	Fri Jan 05 17:34:37 2007 +0000
     8.2 +++ b/xen/include/xen/domain.h	Fri Jan 05 17:34:38 2007 +0000
     8.3 @@ -11,6 +11,10 @@ struct vcpu *alloc_idle_vcpu(unsigned in
     8.4  struct domain *alloc_domain(domid_t domid);
     8.5  void free_domain(struct domain *d);
     8.6  
     8.7 +struct xen_domctl_getdomaininfo;
     8.8 +void getdomaininfo(
     8.9 +    struct domain *d, struct xen_domctl_getdomaininfo *info);
    8.10 +
    8.11  /*
    8.12   * Arch-specifics.
    8.13   */
     9.1 --- a/xen/include/xen/perfc.h	Fri Jan 05 17:34:37 2007 +0000
     9.2 +++ b/xen/include/xen/perfc.h	Fri Jan 05 17:34:38 2007 +0000
     9.3 @@ -102,6 +102,9 @@ extern struct perfcounter perfcounters;
     9.4  #else
     9.5  #define perfc_incr_histo(_x,_v,_n) ((void)0)
     9.6  #endif
     9.7 +
     9.8 +struct xen_sysctl_perfc_op;
     9.9 +int perfc_control(struct xen_sysctl_perfc_op *);
    9.10      
    9.11  #else /* PERF_COUNTERS */
    9.12  
    10.1 --- a/xen/include/xlat.lst	Fri Jan 05 17:34:37 2007 +0000
    10.2 +++ b/xen/include/xlat.lst	Fri Jan 05 17:34:38 2007 +0000
    10.3 @@ -10,6 +10,8 @@
    10.4  !	trap_info			arch-x86/xen.h
    10.5  !	vcpu_guest_context		arch-x86/xen.h
    10.6  ?	acm_getdecision			acm_ops.h
    10.7 +!	ctl_cpumap			domctl.h
    10.8 +!	domctl_getdomaininfo		domctl.h
    10.9  ?	evtchn_alloc_unbound		event_channel.h
   10.10  ?	evtchn_bind_interdomain		event_channel.h
   10.11  ?	evtchn_bind_ipi			event_channel.h
   10.12 @@ -37,6 +39,9 @@
   10.13  !	sched_poll			sched.h
   10.14  ?	sched_remote_shutdown		sched.h
   10.15  ?	sched_shutdown			sched.h
   10.16 +?	sysctl_perfc_desc		sysctl.h
   10.17 +!	sysctl_perfc_op			sysctl.h
   10.18 +!	sysctl_tbuf_op			sysctl.h
   10.19  !	vcpu_runstate_info		vcpu.h
   10.20  ?	xenoprof_init			xenoprof.h
   10.21  ?	xenoprof_passive		xenoprof.h