- 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@valinux.co.jp>
}
}
-/* 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:
optf_set_identity_mapping(&optf->mask, &optf->im_reg4, f);
rc = -ENOSYS;
break;
}
+
+ for_each_vcpu(d, v) {
+ if (v != current)
+ vcpu_unpause(v);
+ }
+
return rc;
}
* 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*);
* 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 */