Skip to contentSkip to conversation

revive VCPUOP_register_time_memory_area

RFC PATCH New Paolo Bonzini 1 participant 1 message Feb 3, 2011

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 revive VCPUOP_register_time_memory_area

Hi all,

the attached patch tries to revive the support for userspace vcpu_time_info. Writing the information is done after context switch to prevent the memory corruption that led to the disabling of the hypercall.

The patch also fixes the write of version_update_begin(_u.version) into the userspace vcpu_time_info.

A while ago, Jeremy wrote that he was "not sure that the Xen clock algorithm can give strict enough monotonicity for usermode use". Has anybody else ever put some thought into this, and maybe shared (or not shared) his worries?

The patch is mostly untested because Xen 4.1 fails to boot the (non-pvops) dom0 kernels I have around; a very similar patch _was_ tested though and worked. :)

Paolo

xen/arch/x86/domain.c +5 -6
@@ -994,15 +994,14 @@ arch_do_vcpu_op(
         break;
     }
 
-    /*
-     * XXX Disable for 4.0.0: __update_vcpu_system_time() writes to the given
-     * virtual address even when running in another domain's address space.
-     */
-#if 0
     case VCPUOP_register_vcpu_time_memory_area:
     {
         struct vcpu_register_time_memory_area area;
 
+        rc = -EINVAL;
+        if ( v != current )
+            break; 
+
         rc = -EFAULT;
         if ( copy_from_guest(&area, arg, 1) )
             break;
@@ -1017,7 +1016,6 @@ arch_do_vcpu_op(
 
         break;
     }
-#endif
 
     case VCPUOP_get_physid:
     {
@@ -1494,6 +1492,7 @@ void context_switch(struct vcpu *prev, s
 
     context_saved(prev);
 
+    update_vcpu_time_info_area(next);
     if (prev != next)
         update_runstate_area(next);
 
xen/arch/x86/time.c +58 -37

160 lines not on this page · raw message

xen/include/asm-x86/time.h +1 -0
@@ -69,6 +69,7 @@ void tsc_get_info(struct domain *d, uint
    
 
 void force_update_vcpu_system_time(struct vcpu *v);
+void update_vcpu_time_info_area(struct vcpu *v);
 
 int host_tsc_is_safe(void);
 void cpuid_time_leaf(uint32_t sub_idx, unsigned int *eax, unsigned int *ebx,

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel