Enable compatibility mode operation for HYPERVISOR_physdev_op and
authorEmmanuel Ackaouy <ack@xensource.com>
Fri, 5 Jan 2007 17:34:32 +0000 (17:34 +0000)
committerEmmanuel Ackaouy <ack@xensource.com>
Fri, 5 Jan 2007 17:34:32 +0000 (17:34 +0000)
HYPERVISOR_event_channel_op.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
xen/arch/x86/compat.c
xen/arch/x86/physdev.c
xen/arch/x86/x86_64/Makefile
xen/arch/x86/x86_64/compat.c [new file with mode: 0644]
xen/arch/x86/x86_64/compat/entry.S
xen/arch/x86/x86_64/physdev.c [new file with mode: 0644]
xen/common/compat/xlat.c
xen/include/asm-x86/hypercall.h
xen/include/xlat.lst

index 431c4560fdffef12d04984efadcfa62ef5115646..a4fda062d60bf97a5414291a87303d8709f5e466 100644 (file)
@@ -9,17 +9,23 @@
 #include <xen/guest_access.h>
 #include <xen/hypercall.h>
 
+#ifndef COMPAT
+typedef long ret_t;
+#endif
+
 /* Legacy hypercall (as of 0x00030202). */
-long do_physdev_op_compat(XEN_GUEST_HANDLE(physdev_op_t) uop)
+ret_t do_physdev_op_compat(XEN_GUEST_HANDLE(physdev_op_t) uop)
 {
     struct physdev_op op;
 
     if ( unlikely(copy_from_guest(&op, uop, 1) != 0) )
         return -EFAULT;
 
-    return do_physdev_op(op.cmd, (XEN_GUEST_HANDLE(void)) { &uop.p->u });
+    return do_physdev_op(op.cmd, guest_handle_from_ptr(&uop.p->u, void));
 }
 
+#ifndef COMPAT
+
 /* Legacy hypercall (as of 0x00030202). */
 long do_event_channel_op_compat(XEN_GUEST_HANDLE(evtchn_op_t) uop)
 {
@@ -28,5 +34,7 @@ long do_event_channel_op_compat(XEN_GUEST_HANDLE(evtchn_op_t) uop)
     if ( unlikely(copy_from_guest(&op, uop, 1) != 0) )
         return -EFAULT;
 
-    return do_event_channel_op(op.cmd, (XEN_GUEST_HANDLE(void)) {&uop.p->u });
+    return do_event_channel_op(op.cmd, guest_handle_from_ptr(&uop.p->u, void));
 }
+
+#endif
index d24aad62aad70c03bc22ecffce7a7585818b92af..356e4079be5f9c2e1cc10db43db0293a680b77c3 100644 (file)
@@ -9,9 +9,14 @@
 #include <xen/guest_access.h>
 #include <asm/current.h>
 #include <asm/smpboot.h>
+#include <asm/hypercall.h>
 #include <public/xen.h>
 #include <public/physdev.h>
 
+#ifndef COMPAT
+typedef long ret_t;
+#endif
+
 int
 ioapic_guest_read(
     unsigned long physbase, unsigned int reg, u32 *pval);
@@ -19,10 +24,10 @@ int
 ioapic_guest_write(
     unsigned long physbase, unsigned int reg, u32 pval);
 
-long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
+ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
 {
     int irq;
-    long ret;
+    ret_t ret;
 
     switch ( cmd )
     {
@@ -129,7 +134,11 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
              (set_iobitmap.nr_ports > 65536) )
             break;
         ret = 0;
+#ifndef COMPAT
         current->arch.iobmp       = set_iobitmap.bitmap;
+#else
+        guest_from_compat_handle(current->arch.iobmp, set_iobitmap.bitmap);
+#endif
         current->arch.iobmp_limit = set_iobitmap.nr_ports;
         break;
     }
index b9e0ab46c308fd521373ad1848206e357af9c938..dc1f0be689cf9af3419abfa784b271f38f83c394 100644 (file)
@@ -3,9 +3,14 @@ obj-y += gpr_switch.o
 obj-y += mm.o
 obj-y += traps.o
 
+obj-$(CONFIG_COMPAT) += compat.o
+obj-$(CONFIG_COMPAT) += physdev.o
+
 ifeq ($(CONFIG_COMPAT),y)
 # extra dependencies
+compat.o:      ../compat.c
 entry.o:       compat/entry.S
 mm.o:          compat/mm.c
+physdev.o:     ../physdev.c
 traps.o:       compat/traps.c
 endif
diff --git a/xen/arch/x86/x86_64/compat.c b/xen/arch/x86/x86_64/compat.c
new file mode 100644 (file)
index 0000000..2a14d18
--- /dev/null
@@ -0,0 +1,30 @@
+/******************************************************************************
+ * compat.c
+ */
+
+#include <xen/config.h>
+#include <xen/hypercall.h>
+#include <compat/xen.h>
+#include <compat/physdev.h>
+
+DEFINE_XEN_GUEST_HANDLE(physdev_op_compat_t);
+#define physdev_op                    compat_physdev_op
+#define physdev_op_t                  physdev_op_compat_t
+#define do_physdev_op                 compat_physdev_op
+#define do_physdev_op_compat(x)       compat_physdev_op_compat(_##x)
+
+#define COMPAT
+#define _XEN_GUEST_HANDLE(t) XEN_GUEST_HANDLE(t)
+typedef int ret_t;
+
+#include "../compat.c"
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index 923392192ef368c45b68e6465259d1cdd824ae2c..5bb7309bac6afe493d37144d0a3b84c01a20b640 100644 (file)
@@ -283,15 +283,11 @@ CFIX14:
 #define compat_platform_op domain_crash_synchronous
 #define compat_multicall domain_crash_synchronous
 #define compat_set_timer_op domain_crash_synchronous
-#define compat_event_channel_op_compat domain_crash_synchronous
-#define compat_physdev_op_compat domain_crash_synchronous
 #define compat_grant_table_op domain_crash_synchronous
 #define compat_vcpu_op domain_crash_synchronous
 #define compat_acm_op domain_crash_synchronous
 #define compat_arch_sched_op domain_crash_synchronous
 #define compat_xenoprof_op domain_crash_synchronous
-#define compat_event_channel_op domain_crash_synchronous
-#define compat_physdev_op domain_crash_synchronous
 #define compat_sysctl domain_crash_synchronous
 #define compat_domctl domain_crash_synchronous
 
@@ -312,7 +308,7 @@ ENTRY(compat_hypercall_table)
         .quad compat_multicall
         .quad compat_update_va_mapping
         .quad compat_set_timer_op       /* 15 */
-        .quad compat_event_channel_op_compat
+        .quad do_event_channel_op_compat
         .quad compat_xen_version
         .quad do_console_io
         .quad compat_physdev_op_compat
@@ -328,7 +324,7 @@ ENTRY(compat_hypercall_table)
         .quad compat_arch_sched_op
         .quad compat_callback_op        /* 30 */
         .quad compat_xenoprof_op
-        .quad compat_event_channel_op
+        .quad do_event_channel_op
         .quad compat_physdev_op
         .quad compat_ni_hypercall
         .quad compat_sysctl             /* 35 */
diff --git a/xen/arch/x86/x86_64/physdev.c b/xen/arch/x86/x86_64/physdev.c
new file mode 100644 (file)
index 0000000..42b8269
--- /dev/null
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * physdev.c
+ */
+
+#include <xen/config.h>
+#include <xen/types.h>
+#include <xen/guest_access.h>
+#include <compat/xen.h>
+#include <compat/event_channel.h>
+#include <compat/physdev.h>
+#include <asm/hypercall.h>
+
+#define do_physdev_op compat_physdev_op
+
+#define physdev_apic               compat_physdev_apic
+#define physdev_apic_t             physdev_apic_compat_t
+
+#define physdev_eoi                compat_physdev_eoi
+#define physdev_eoi_t              physdev_eoi_compat_t
+
+#define physdev_set_iobitmap       compat_physdev_set_iobitmap
+#define physdev_set_iobitmap_t     physdev_set_iobitmap_compat_t
+
+#define physdev_set_iopl           compat_physdev_set_iopl
+#define physdev_set_iopl_t         physdev_set_iopl_compat_t
+
+#define physdev_irq                compat_physdev_irq
+#define physdev_irq_t              physdev_irq_compat_t
+
+#define physdev_irq_status_query   compat_physdev_irq_status_query
+#define physdev_irq_status_query_t physdev_irq_status_query_compat_t
+
+#define COMPAT
+#undef guest_handle_okay
+#define guest_handle_okay          compat_handle_okay
+typedef int ret_t;
+
+#include "../physdev.c"
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index 1440001ba02afba511f301145f21d499aabef62a..cae7debcbf0df6f3fd02f397d4ec1d8e60ccfa75 100644 (file)
@@ -4,8 +4,8 @@
 
 #include <xen/compat.h>
 #include <xen/lib.h>
-#include <public/xen.h>
 #include <compat/xen.h>
+#include <compat/event_channel.h>
 
 /* In-place translation functons: */
 void xlat_start_info(struct start_info *native,
@@ -21,6 +21,30 @@ void xlat_start_info(struct start_info *native,
 CHECK_dom0_vga_console_info;
 #undef dom0_vga_console_info
 
+#define xen_evtchn_alloc_unbound evtchn_alloc_unbound
+#define xen_evtchn_bind_interdomain evtchn_bind_interdomain
+#define xen_evtchn_bind_ipi evtchn_bind_ipi
+#define xen_evtchn_bind_pirq evtchn_bind_pirq
+#define xen_evtchn_bind_vcpu evtchn_bind_vcpu
+#define xen_evtchn_bind_virq evtchn_bind_virq
+#define xen_evtchn_close evtchn_close
+#define xen_evtchn_op evtchn_op
+#define xen_evtchn_send evtchn_send
+#define xen_evtchn_status evtchn_status
+#define xen_evtchn_unmask evtchn_unmask
+CHECK_evtchn_op;
+#undef xen_evtchn_alloc_unbound
+#undef xen_evtchn_bind_interdomain
+#undef xen_evtchn_bind_ipi
+#undef xen_evtchn_bind_pirq
+#undef xen_evtchn_bind_vcpu
+#undef xen_evtchn_bind_virq
+#undef xen_evtchn_close
+#undef xen_evtchn_op
+#undef xen_evtchn_send
+#undef xen_evtchn_status
+#undef xen_evtchn_unmask
+
 #define xen_mmu_update mmu_update
 CHECK_mmu_update;
 #undef xen_mmu_update
index ee911a91b03c230c70f33c04566e99486009b5be..34216f243536de4b745a772497a7fe9c9c1ac14c 100644 (file)
@@ -123,4 +123,13 @@ do_set_callbacks(
 
 #endif
 
+#ifdef CONFIG_COMPAT
+
+extern int
+compat_physdev_op(
+    int cmd,
+    XEN_GUEST_HANDLE(void) arg);
+
+#endif
+
 #endif /* __ASM_X86_HYPERCALL_H__ */
index 0027ed65c04b039ccc1838f0fc840040354746e7..45f000ddbe4c3c39f01f9378df5200d40718358f 100644 (file)
@@ -6,6 +6,17 @@
 !      mmuext_op                       xen.h
 !      start_info                      xen.h
 ?      vcpu_time_info                  xen.h
+?      evtchn_alloc_unbound            event_channel.h
+?      evtchn_bind_interdomain         event_channel.h
+?      evtchn_bind_ipi                 event_channel.h
+?      evtchn_bind_pirq                event_channel.h
+?      evtchn_bind_vcpu                event_channel.h
+?      evtchn_bind_virq                event_channel.h
+?      evtchn_close                    event_channel.h
+?      evtchn_op                       event_channel.h
+?      evtchn_send                     event_channel.h
+?      evtchn_status                   event_channel.h
+?      evtchn_unmask                   event_channel.h
 !      add_to_physmap                  memory.h
 !      foreign_memory_map              memory.h
 !      memory_exchange                 memory.h