x86/HVM: fixed _hvm_hw_fix_cpu()
authorRazvan Cojocaru <rzvncj@gmail.com>
Thu, 24 Jan 2013 14:08:19 +0000 (15:08 +0100)
committerRazvan Cojocaru <rzvncj@gmail.com>
Thu, 24 Jan 2013 14:08:19 +0000 (15:08 +0100)
Prevent the compiler from re-ordering the reads and writes.
Suggested by Jan Beulich.

Signed-off-by: Razvan Cojocaru <rzvncj@gmail.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Jan Beulich <jbeulich@suse.com>
xen/include/public/arch-x86/hvm/save.h

index a82a5ee4211994c36d748eb5555ca6de0821c420..3664aaf831d1b0b49718f89b713ababf6d9ca2ed 100644 (file)
@@ -269,15 +269,18 @@ struct hvm_hw_cpu_compat {
 };
 
 static inline int _hvm_hw_fix_cpu(void *h) {
-    struct hvm_hw_cpu *new=h;
-    struct hvm_hw_cpu_compat *old=h;
+
+    union hvm_hw_cpu_union {
+        struct hvm_hw_cpu nat;
+        struct hvm_hw_cpu_compat cmp;
+    } *ucpu = (union hvm_hw_cpu_union *)h;
 
     /* If we copy from the end backwards, we should
      * be able to do the modification in-place */
-    new->error_code=old->error_code;
-    new->pending_event=old->pending_event;
-    new->tsc=old->tsc;
-    new->msr_tsc_aux=0;
+    ucpu->nat.error_code = ucpu->cmp.error_code;
+    ucpu->nat.pending_event = ucpu->cmp.pending_event;
+    ucpu->nat.tsc = ucpu->cmp.tsc;
+    ucpu->nat.msr_tsc_aux = 0;
 
     return 0;
 }