# HG changeset patch # User yamahata@xxxxxxxxxxxxx # Date 1195551349 -32400 # Node ID 02d9248aadb7c0a18776c732569f3fe9530e1e93 # Parent c2337862609abf79dc3212d8de6f6141cb63219f fix opt_feature hypercall. - fix XEN_IA64_OPTF_IDENT_MAP_REG[457] definitions. - smp fix. writing to domain->arch.opt_feature is racy. PATCHNAME: fix_opt_feature_hypercall Signed-off-by: Isaku Yamahata diff -r c2337862609a -r 02d9248aadb7 xen/arch/ia64/xen/domain.c --- a/xen/arch/ia64/xen/domain.c Tue Nov 20 19:24:42 2007 +0900 +++ b/xen/arch/ia64/xen/domain.c Tue Nov 20 18:35:49 2007 +0900 @@ -2285,12 +2285,22 @@ optf_set_identity_mapping(unsigned long* } } -/* Switch a optimization feature on/off. */ +/* + * Switch a 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 c2337862609a -r 02d9248aadb7 xen/include/asm-ia64/domain.h --- a/xen/include/asm-ia64/domain.h Tue Nov 20 19:24:42 2007 +0900 +++ b/xen/include/asm-ia64/domain.h Tue Nov 20 18:35:49 2007 +0900 @@ -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 c2337862609a -r 02d9248aadb7 xen/include/public/arch-ia64.h --- a/xen/include/public/arch-ia64.h Tue Nov 20 19:24:42 2007 +0900 +++ b/xen/include/public/arch-ia64.h Tue Nov 20 18:35:49 2007 +0900 @@ -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 */