vm-assist: prepare for discontiguous used bit numbers
authorJan Beulich <jbeulich@suse.com>
Mon, 23 Mar 2015 15:49:42 +0000 (16:49 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 23 Mar 2015 15:49:42 +0000 (16:49 +0100)
Since the a flag will get assigned a value discontiguous to the
existing ones (in order to preserve the low bits, as only those are
currently accessible to 32-bit guests), this requires a little bit of
rework of the VM assist code in general: An architecture specific
VM_ASSIST_VALID definition gets introduced (with an optional compat
mode counterpart), and compilation of the respective code becomes
conditional upon this being defined (ARM doesn't wire these up and
hence doesn't need that code).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
xen/common/compat/kernel.c
xen/common/domain.c
xen/common/kernel.c
xen/include/asm-x86/config.h
xen/include/public/xen.h
xen/include/xen/lib.h

index 6a1e41f93a182f189d22f2bf51c6d49e5dab0d97..65cc25bd492203e712c3f3fdef3af18971348b77 100644 (file)
@@ -41,6 +41,11 @@ CHECK_TYPE(domain_handle);
 #define xennmi_callback compat_nmi_callback
 #define xennmi_callback_t compat_nmi_callback_t
 
+#ifdef COMPAT_VM_ASSIST_VALID
+#undef VM_ASSIST_VALID
+#define VM_ASSIST_VALID COMPAT_VM_ASSIST_VALID
+#endif
+
 #define DO(fn) int compat_##fn
 #define COMPAT
 
index aa78fd74e2fdfd004f8c625cee435e7dbe2b5b3d..2b192ab88e0929c3b949fffc2bad548e73861f3a 100644 (file)
@@ -1318,9 +1318,11 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
     return rc;
 }
 
-long vm_assist(struct domain *p, unsigned int cmd, unsigned int type)
+#ifdef VM_ASSIST_VALID
+long vm_assist(struct domain *p, unsigned int cmd, unsigned int type,
+               unsigned long valid)
 {
-    if ( type > MAX_VMASST_TYPE )
+    if ( type >= BITS_PER_LONG || !test_bit(type, &valid) )
         return -EINVAL;
 
     switch ( cmd )
@@ -1335,6 +1337,7 @@ long vm_assist(struct domain *p, unsigned int cmd, unsigned int type)
 
     return -ENOSYS;
 }
+#endif
 
 struct pirq *pirq_get_info(struct domain *d, int pirq)
 {
index d8c31bc89f580681fb803334dc5e8b0e1f2e7052..3a29d9bbbad4ec786a61802df47f71ced1090d5e 100644 (file)
@@ -386,10 +386,12 @@ DO(nmi_op)(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
     return rc;
 }
 
+#ifdef VM_ASSIST_VALID
 DO(vm_assist)(unsigned int cmd, unsigned int type)
 {
-    return vm_assist(current->domain, cmd, type);
+    return vm_assist(current->domain, cmd, type, VM_ASSIST_VALID);
 }
+#endif
 
 DO(ni_hypercall)(void)
 {
index 270f69495df3d35db2a0107e8e492aaa12e297b5..3569753da7a5355ef3cd0582123ca033f1824265 100644 (file)
@@ -343,6 +343,14 @@ extern unsigned long xen_phys_start;
 #define ARG_XLAT_START(v)        \
     (ARG_XLAT_VIRT_START + ((v)->vcpu_id << ARG_XLAT_VA_SHIFT))
 
+#define NATIVE_VM_ASSIST_VALID   ((1UL << VMASST_TYPE_4gb_segments)        | \
+                                  (1UL << VMASST_TYPE_4gb_segments_notify) | \
+                                  (1UL << VMASST_TYPE_writable_pagetables) | \
+                                  (1UL << VMASST_TYPE_pae_extended_cr3))
+#define VM_ASSIST_VALID          NATIVE_VM_ASSIST_VALID
+#define COMPAT_VM_ASSIST_VALID   (NATIVE_VM_ASSIST_VALID & \
+                                  ((1UL << COMPAT_BITS_PER_LONG) - 1))
+
 #define ELFSIZE 64
 
 #define ARCH_CRASH_SAVE_VMCOREINFO
index 3703c3936e837fc3f53100e02bbb57b8a37ae4cc..a354f5c8d6f7ad840d23aa652a6c47be1779135f 100644 (file)
@@ -486,7 +486,9 @@ DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
 /* x86/PAE guests: support PDPTs above 4GB. */
 #define VMASST_TYPE_pae_extended_cr3     3
 
+#if __XEN_INTERFACE_VERSION__ < 0x00040600
 #define MAX_VMASST_TYPE                  3
+#endif
 
 #ifndef __ASSEMBLY__
 
index 6c8dd86ae823362a8eedfe6a6c1e4e1cc9ae0e17..8fa95ac52a80c0ed44b361b7ccf3cf8eb5bfcacd 100644 (file)
@@ -80,7 +80,8 @@ extern void guest_printk(const struct domain *d, const char *format, ...)
     __attribute__ ((format (printf, 2, 3)));
 extern void noreturn panic(const char *format, ...)
     __attribute__ ((format (printf, 1, 2)));
-extern long vm_assist(struct domain *, unsigned int, unsigned int);
+extern long vm_assist(struct domain *, unsigned int cmd, unsigned int type,
+                      unsigned long valid);
 extern int __printk_ratelimit(int ratelimit_ms, int ratelimit_burst);
 extern int printk_ratelimit(void);