# HG changeset patch
# User Emmanuel Ackaouy <ack@xxxxxxxxxxxxx>
# Date 1168018478 0
# Node ID d80684d19ef4abff8658d762be4303fe2cfe01d0
# Parent 62f3df867d0e48827cfdb4191530015fbebbe096
Enable compatibility mode operation for HYPERVISOR_sysctl.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
xen/arch/x86/sysctl.c | 8 ++
xen/arch/x86/x86_64/Makefile | 2
xen/arch/x86/x86_64/compat/entry.S | 1
xen/arch/x86/x86_64/sysctl.c | 33 +++++++++++
xen/common/compat/Makefile | 2
xen/common/compat/sysctl.c | 102 +++++++++++++++++++++++++++++++++++++
xen/common/sysctl.c | 18 +++---
xen/include/xen/domain.h | 4 +
xen/include/xen/perfc.h | 3 +
xen/include/xlat.lst | 5 +
10 files changed, 167 insertions(+), 11 deletions(-)
diff -r 62f3df867d0e -r d80684d19ef4 xen/arch/x86/sysctl.c
--- a/xen/arch/x86/sysctl.c Fri Jan 05 17:34:37 2007 +0000
+++ b/xen/arch/x86/sysctl.c Fri Jan 05 17:34:38 2007 +0000
@@ -25,10 +25,14 @@
#include <asm/hvm/support.h>
#include <asm/processor.h>
-long arch_do_sysctl(
+#ifndef COMPAT
+typedef long ret_t;
+#endif
+
+ret_t arch_do_sysctl(
struct xen_sysctl *sysctl, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
{
- long ret = 0;
+ ret_t ret = 0;
switch ( sysctl->cmd )
{
diff -r 62f3df867d0e -r d80684d19ef4 xen/arch/x86/x86_64/Makefile
--- a/xen/arch/x86/x86_64/Makefile Fri Jan 05 17:34:37 2007 +0000
+++ b/xen/arch/x86/x86_64/Makefile Fri Jan 05 17:34:38 2007 +0000
@@ -7,6 +7,7 @@ obj-$(CONFIG_COMPAT) += domain.o
obj-$(CONFIG_COMPAT) += domain.o
obj-$(CONFIG_COMPAT) += physdev.o
obj-$(CONFIG_COMPAT) += platform_hypercall.o
+obj-$(CONFIG_COMPAT) += sysctl.o
ifeq ($(CONFIG_COMPAT),y)
# extra dependencies
@@ -15,5 +16,6 @@ mm.o: compat/mm.c
mm.o: compat/mm.c
physdev.o: ../physdev.c
platform_hypercall.o: ../platform_hypercall.c
+sysctl.o: ../sysctl.c
traps.o: compat/traps.c
endif
diff -r 62f3df867d0e -r d80684d19ef4 xen/arch/x86/x86_64/compat/entry.S
--- a/xen/arch/x86/x86_64/compat/entry.S Fri Jan 05 17:34:37 2007 +0000
+++ b/xen/arch/x86/x86_64/compat/entry.S Fri Jan 05 17:34:38 2007 +0000
@@ -278,7 +278,6 @@ CFIX14:
.section .rodata, "a", @progbits
-#define compat_sysctl domain_crash_synchronous
#define compat_domctl domain_crash_synchronous
ENTRY(compat_hypercall_table)
diff -r 62f3df867d0e -r d80684d19ef4 xen/arch/x86/x86_64/sysctl.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/arch/x86/x86_64/sysctl.c Fri Jan 05 17:34:38 2007 +0000
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * Arch-specific compatibility sysctl.c
+ */
+
+#include <xen/config.h>
+#include <compat/sysctl.h>
+
+DEFINE_XEN_GUEST_HANDLE(compat_sysctl_t);
+#define xen_sysctl compat_sysctl
+#define xen_sysctl_t compat_sysctl_t
+#define arch_do_sysctl(x, h) arch_compat_sysctl(x, _##h)
+
+#define xen_sysctl_physinfo compat_sysctl_physinfo
+#define xen_sysctl_physinfo_t compat_sysctl_physinfo_t
+
+#define xen_sysctl_ioport_emulation compat_sysctl_ioport_emulation
+#define xen_sysctl_ioport_emulation_t compat_sysctl_ioport_emulation_t
+
+#define COMPAT
+#define _XEN_GUEST_HANDLE(t) XEN_GUEST_HANDLE(t)
+typedef int ret_t;
+
+#include "../sysctl.c"
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -r 62f3df867d0e -r d80684d19ef4 xen/common/compat/Makefile
--- a/xen/common/compat/Makefile Fri Jan 05 17:34:37 2007 +0000
+++ b/xen/common/compat/Makefile Fri Jan 05 17:34:38 2007 +0000
@@ -2,8 +2,10 @@ obj-y += kernel.o
obj-y += kernel.o
obj-y += memory.o
obj-y += multicall.o
+obj-y += sysctl.o
obj-y += xlat.o
# extra dependencies
kernel.o: ../kernel.c
multicall.o: ../multicall.c
+sysctl.o: ../sysctl.c
diff -r 62f3df867d0e -r d80684d19ef4 xen/common/compat/sysctl.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/common/compat/sysctl.c Fri Jan 05 17:34:38 2007 +0000
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * compat/sysctl.c
+ */
+
+#include <xen/config.h>
+#include <compat/sysctl.h>
+#include <xen/domain.h>
+#include <xen/guest_access.h>
+#include <xen/perfc.h>
+#include <xen/trace.h>
+
+DEFINE_XEN_GUEST_HANDLE(compat_sysctl_t);
+#define xen_sysctl compat_sysctl
+#define xen_sysctl_t compat_sysctl_t
+#define do_sysctl(h) compat_sysctl(_##h)
+#define arch_do_sysctl(x, h) arch_compat_sysctl(x, _##h)
+
+#define xen_sysctl_readconsole compat_sysctl_readconsole
+#define xen_sysctl_readconsole_t compat_sysctl_readconsole_t
+
+static int compat_tb_control(struct compat_sysctl_tbuf_op *cmp_tbc)
+{
+ struct xen_sysctl_tbuf_op nat_tbc;
+ int ret;
+
+#define XLAT_ctl_cpumap_HNDL_bitmap(_d_, _s_) \
+ guest_from_compat_handle((_d_)->bitmap, (_s_)->bitmap)
+ XLAT_sysctl_tbuf_op(&nat_tbc, cmp_tbc);
+#undef XLAT_ctl_cpumap_HNDL_bitmap
+ ret = tb_control(&nat_tbc);
+#define XLAT_ctl_cpumap_HNDL_bitmap(_d_, _s_) ((void)0)
+ XLAT_sysctl_tbuf_op(cmp_tbc, &nat_tbc);
+#undef XLAT_ctl_cpumap_HNDL_bitmap
+ return ret;
+}
+#define xen_sysctl_tbuf_op compat_sysctl_tbuf_op
+#define xen_sysctl_tbuf_op_t compat_sysctl_tbuf_op_t
+#define tb_control(p) compat_tb_control(p)
+
+#define xen_sysctl_sched_id compat_sysctl_sched_id
+#define xen_sysctl_sched_id_t compat_sysctl_sched_id_t
+
+static void compat_getdomaininfo(struct domain *d, struct
compat_domctl_getdomaininfo *ci)
+{
+ struct xen_domctl_getdomaininfo ni;
+
+ getdomaininfo(d, &ni);
+ XLAT_domctl_getdomaininfo(ci, &ni);
+}
+#define xen_sysctl_getdomaininfolist compat_sysctl_getdomaininfolist
+#define xen_sysctl_getdomaininfolist_t compat_sysctl_getdomaininfolist_t
+#define xen_domctl_getdomaininfo compat_domctl_getdomaininfo
+#define xen_domctl_getdomaininfo_t compat_domctl_getdomaininfo_t
+#define getdomaininfo(d, i) compat_getdomaininfo(d, i)
+
+#ifdef PERF_COUNTERS
+static int compat_perfc_control(struct compat_sysctl_perfc_op *cmp_pc)
+{
+ CHECK_sysctl_perfc_desc;
+ CHECK_TYPE(sysctl_perfc_val);
+ struct xen_sysctl_perfc_op nat_pc;
+ int ret;
+
+#define XLAT_sysctl_perfc_op_HNDL_desc(_d_, _s_) \
+ guest_from_compat_handle((_d_)->desc, (_s_)->desc)
+#define XLAT_sysctl_perfc_op_HNDL_val(_d_, _s_) \
+ guest_from_compat_handle((_d_)->val, (_s_)->val)
+ XLAT_sysctl_perfc_op(&nat_pc, cmp_pc);
+#undef XLAT_sysctl_perfc_op_HNDL_val
+#undef XLAT_sysctl_perfc_op_HNDL_desc
+ ret = perfc_control(&nat_pc);
+#define XLAT_sysctl_perfc_op_HNDL_desc(_d_, _s_)
+#define XLAT_sysctl_perfc_op_HNDL_val(_d_, _s_)
+ XLAT_sysctl_perfc_op(cmp_pc, &nat_pc);
+#undef XLAT_sysctl_perfc_op_HNDL_val
+#undef XLAT_sysctl_perfc_op_HNDL_desc
+ return ret;
+}
+#define xen_sysctl_perfc_op compat_sysctl_perfc_op
+#define xen_sysctl_perfc_op_t compat_sysctl_perfc_op_t
+#define perfc_control(p) compat_perfc_control(p)
+#endif
+
+#define COMPAT
+#define _XEN_GUEST_HANDLE(t) XEN_GUEST_HANDLE(t)
+#define _u_sysctl u_sysctl
+#undef guest_handle_cast
+#define guest_handle_cast compat_handle_cast
+#define copy_to_xxx_offset copy_to_compat_offset
+typedef int ret_t;
+
+#include "../sysctl.c"
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -r 62f3df867d0e -r d80684d19ef4 xen/common/sysctl.c
--- a/xen/common/sysctl.c Fri Jan 05 17:34:37 2007 +0000
+++ b/xen/common/sysctl.c Fri Jan 05 17:34:38 2007 +0000
@@ -21,14 +21,17 @@
#include <asm/current.h>
#include <public/sysctl.h>
-extern long arch_do_sysctl(
+#ifndef COMPAT
+typedef long ret_t;
+#define copy_to_xxx_offset copy_to_guest_offset
+#endif
+
+extern ret_t arch_do_sysctl(
struct xen_sysctl *op, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl);
-extern void getdomaininfo(
- struct domain *d, struct xen_domctl_getdomaininfo *info);
-long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
+ret_t do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
{
- long ret = 0;
+ ret_t ret = 0;
struct xen_sysctl curop, *op = &curop;
static DEFINE_SPINLOCK(sysctl_lock);
@@ -98,8 +101,8 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
put_domain(d);
- if ( copy_to_guest_offset(op->u.getdomaininfolist.buffer,
- num_domains, &info, 1) )
+ if ( copy_to_xxx_offset(op->u.getdomaininfolist.buffer,
+ num_domains, &info, 1) )
{
ret = -EFAULT;
break;
@@ -123,7 +126,6 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
#ifdef PERF_COUNTERS
case XEN_SYSCTL_perfc_op:
{
- extern int perfc_control(xen_sysctl_perfc_op_t *);
ret = perfc_control(&op->u.perfc_op);
if ( copy_to_guest(u_sysctl, op, 1) )
ret = -EFAULT;
diff -r 62f3df867d0e -r d80684d19ef4 xen/include/xen/domain.h
--- a/xen/include/xen/domain.h Fri Jan 05 17:34:37 2007 +0000
+++ b/xen/include/xen/domain.h Fri Jan 05 17:34:38 2007 +0000
@@ -10,6 +10,10 @@ struct vcpu *alloc_idle_vcpu(unsigned in
struct domain *alloc_domain(domid_t domid);
void free_domain(struct domain *d);
+
+struct xen_domctl_getdomaininfo;
+void getdomaininfo(
+ struct domain *d, struct xen_domctl_getdomaininfo *info);
/*
* Arch-specifics.
diff -r 62f3df867d0e -r d80684d19ef4 xen/include/xen/perfc.h
--- a/xen/include/xen/perfc.h Fri Jan 05 17:34:37 2007 +0000
+++ b/xen/include/xen/perfc.h Fri Jan 05 17:34:38 2007 +0000
@@ -102,6 +102,9 @@ extern struct perfcounter perfcounters;
#else
#define perfc_incr_histo(_x,_v,_n) ((void)0)
#endif
+
+struct xen_sysctl_perfc_op;
+int perfc_control(struct xen_sysctl_perfc_op *);
#else /* PERF_COUNTERS */
diff -r 62f3df867d0e -r d80684d19ef4 xen/include/xlat.lst
--- a/xen/include/xlat.lst Fri Jan 05 17:34:37 2007 +0000
+++ b/xen/include/xlat.lst Fri Jan 05 17:34:38 2007 +0000
@@ -10,6 +10,8 @@
! trap_info arch-x86/xen.h
! vcpu_guest_context arch-x86/xen.h
? acm_getdecision acm_ops.h
+! ctl_cpumap domctl.h
+! domctl_getdomaininfo domctl.h
? evtchn_alloc_unbound event_channel.h
? evtchn_bind_interdomain event_channel.h
? evtchn_bind_ipi event_channel.h
@@ -37,6 +39,9 @@
! sched_poll sched.h
? sched_remote_shutdown sched.h
? sched_shutdown sched.h
+? sysctl_perfc_desc sysctl.h
+! sysctl_perfc_op sysctl.h
+! sysctl_tbuf_op sysctl.h
! vcpu_runstate_info vcpu.h
? xenoprof_init xenoprof.h
? xenoprof_passive xenoprof.h
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|