[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [IA64] vti save-restore: fix opt_feature hypercall



# HG changeset patch
# User Alex Williamson <alex.williamson@xxxxxx>
# Date 1195575075 25200
# Node ID b444678b94ea13e0eb6c0e06dbae501be2393e3a
# Parent  428679ca60d856b68cae2bcc415233ee8a743c86
[IA64] vti save-restore: fix opt_feature hypercall

- Fix XEN_IA64_OPTF_IDENT_MAP_REG[457] definitions.
- SMP fix. writing to domain->arch.opt_feature is racy.

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
---
 xen/arch/ia64/xen/domain.c     |   20 ++++++++++++++++++--
 xen/include/asm-ia64/domain.h  |   10 ++++++++--
 xen/include/public/arch-ia64.h |    4 +++-
 3 files changed, 29 insertions(+), 5 deletions(-)

diff -r 428679ca60d8 -r b444678b94ea xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Tue Nov 20 08:46:24 2007 -0700
+++ b/xen/arch/ia64/xen/domain.c        Tue Nov 20 09:11:15 2007 -0700
@@ -2285,12 +2285,22 @@ optf_set_identity_mapping(unsigned long*
        }
 }
 
-/* Switch a optimization feature on/off. */
+/*
+ * Switch an optimization feature on/off.
+ * The vcpu must be paused to avoid racy access to opt_feature.
+ */
 int
 domain_opt_feature(struct xen_ia64_opt_feature* f)
 {
-       struct opt_feature* optf = &(current->domain->arch.opt_feature);
+       struct domain *d = current->domain;
+       struct opt_feature* optf = &d->arch.opt_feature;
+       struct vcpu *v;
        long rc = 0;
+
+       for_each_vcpu(d, v) {
+               if (v != current)
+                       vcpu_pause(v);
+       }
 
        switch (f->cmd) {
        case XEN_IA64_OPTF_IDENT_MAP_REG4:
@@ -2307,6 +2317,12 @@ domain_opt_feature(struct xen_ia64_opt_f
                rc = -ENOSYS;
                break;
        }
+
+       for_each_vcpu(d, v) {
+               if (v != current)
+                       vcpu_unpause(v);
+       }
+
        return rc;
 }
 
diff -r 428679ca60d8 -r b444678b94ea xen/include/asm-ia64/domain.h
--- a/xen/include/asm-ia64/domain.h     Tue Nov 20 08:46:24 2007 -0700
+++ b/xen/include/asm-ia64/domain.h     Tue Nov 20 09:11:15 2007 -0700
@@ -105,9 +105,15 @@ struct opt_feature {
  * The base XEN_IA64_OPTF_IDENT_MAP_REG7 is defined in public/arch-ia64.h.
  * Identity mapping of region 4 addresses in HVM.
  */
-#define XEN_IA64_OPTF_IDENT_MAP_REG4   (XEN_IA64_OPTF_IDENT_MAP_REG7 + 1)
+#define XEN_IA64_OPTF_IDENT_MAP_REG4_BIT        \
+    (XEN_IA64_OPTF_IDENT_MAP_REG7_BIT + 1)
+#define XEN_IA64_OPTF_IDENT_MAP_REG4            \
+    (1UL << XEN_IA64_OPTF_IDENT_MAP_REG4_BIT)
 /* Identity mapping of region 5 addresses in HVM. */
-#define XEN_IA64_OPTF_IDENT_MAP_REG5   (XEN_IA64_OPTF_IDENT_MAP_REG4 + 1)
+#define XEN_IA64_OPTF_IDENT_MAP_REG5_BIT        \
+    (XEN_IA64_OPTF_IDENT_MAP_REG7_BIT + 2)
+#define XEN_IA64_OPTF_IDENT_MAP_REG5            \
+    (1UL << XEN_IA64_OPTF_IDENT_MAP_REG5_BIT)
 
 /* Set an optimization feature in the struct arch_domain. */
 extern int domain_opt_feature(struct xen_ia64_opt_feature*);
diff -r 428679ca60d8 -r b444678b94ea xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h    Tue Nov 20 08:46:24 2007 -0700
+++ b/xen/include/public/arch-ia64.h    Tue Nov 20 09:11:15 2007 -0700
@@ -674,7 +674,9 @@ DEFINE_XEN_GUEST_HANDLE(xen_ia64_debug_o
  * This is useful in guests using region 7 for identity mapping
  * like the linux kernel does.
  */
-#define XEN_IA64_OPTF_IDENT_MAP_REG7   0x1UL
+#define XEN_IA64_OPTF_IDENT_MAP_REG7_BIT       0
+#define XEN_IA64_OPTF_IDENT_MAP_REG7           \
+       (1UL << XEN_IA64_OPTF_IDENT_MAP_REG7_BIT)
 
 struct xen_ia64_opt_feature {
        unsigned long cmd;              /* Which feature */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.