# HG changeset patch # User yamahata@xxxxxxxxxxxxx # Date 1198208024 -32400 # Node ID 506c05bad4634203ef336ac249a66f80d45eab96 # Parent 7b7b123625d03fe51cda7ffc634306ba2b0db5b3 sort out the XEN_IA64_OPTF_IDENT_MAP_REG[457] constants confusion. Currently the constants are used for two different purpose. one is for the OPTF hypercall sub command. another is bit flag for struct opt_feature::mask. They are different spaces, split them out. PATCHNAME: xen_ia64_optf_ident_map_const Signed-off-by: Isaku Yamahata diff -r 7b7b123625d0 -r 506c05bad463 xen/arch/ia64/vmx/mmio.c --- a/xen/arch/ia64/vmx/mmio.c Thu Dec 20 09:40:33 2007 -0700 +++ b/xen/arch/ia64/vmx/mmio.c Fri Dec 21 12:33:44 2007 +0900 @@ -253,11 +253,11 @@ static int vmx_identity_mappings_save(st const struct opt_feature *optf = &d->arch.opt_feature; struct hvm_hw_ia64_identity_mappings im_save; - __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4, + __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4_FLG, &optf->im_reg4, &im_save.im_reg4); - __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5, + __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5_FLG, &optf->im_reg5, &im_save.im_reg5); - __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG7, + __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG7_FLG, &optf->im_reg7, &im_save.im_reg7); return hvm_save_entry(OPT_FEATURE_IDENTITY_MAPPINGS, 0, h, &im_save); diff -r 7b7b123625d0 -r 506c05bad463 xen/arch/ia64/vmx/vmx_fault.c --- a/xen/arch/ia64/vmx/vmx_fault.c Thu Dec 20 09:40:33 2007 -0700 +++ b/xen/arch/ia64/vmx/vmx_fault.c Fri Dec 21 12:33:44 2007 +0900 @@ -392,7 +392,7 @@ try_again: if (!vhpt_enabled(v, vadr, misr.rs ? RSE_REF : DATA_REF)) { /* windows use region 4 and 5 for identity mapping */ - if ((optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4) && + if ((optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4_FLG) && REGION_NUMBER(vadr) == 4 && !(regs->cr_ipsr & IA64_PSR_CPL) && REGION_OFFSET(vadr) <= _PAGE_PPN_MASK) { @@ -402,7 +402,7 @@ try_again: goto try_again; return IA64_NO_FAULT; } - if ((optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5) && + if ((optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5_FLG) && REGION_NUMBER(vadr) == 5 && !(regs->cr_ipsr & IA64_PSR_CPL) && REGION_OFFSET(vadr) <= _PAGE_PPN_MASK) { @@ -428,8 +428,8 @@ try_again: } /* avoid recursively walking (short format) VHPT */ - if (!(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4) && - !(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5) && + if (!(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4_FLG) && + !(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5_FLG) && (((vadr ^ vpta.val) << 3) >> (vpta.size + 3)) == 0) { goto inject_dtlb_fault; } diff -r 7b7b123625d0 -r 506c05bad463 xen/arch/ia64/xen/domain.c --- a/xen/arch/ia64/xen/domain.c Thu Dec 20 09:40:33 2007 -0700 +++ b/xen/arch/ia64/xen/domain.c Fri Dec 21 12:33:44 2007 +0900 @@ -2277,16 +2277,35 @@ custom_param("dom0_mem", parse_dom0_mem) * Helper function for the optimization stuff handling the identity mapping * feature. */ +static inline unsigned long +optf_identity_mapping_cmd_to_flg(unsigned long cmd) +{ + switch(cmd) { + case XEN_IA64_OPTF_IDENT_MAP_REG7: + return XEN_IA64_OPTF_IDENT_MAP_REG7_FLG; + case XEN_IA64_OPTF_IDENT_MAP_REG4: + return XEN_IA64_OPTF_IDENT_MAP_REG4_FLG; + case XEN_IA64_OPTF_IDENT_MAP_REG5: + return XEN_IA64_OPTF_IDENT_MAP_REG5_FLG; + default: + BUG(); + return 0; + } + + /* NOTREACHED */ +} + static inline void optf_set_identity_mapping(unsigned long* mask, struct identity_mapping* im, struct xen_ia64_opt_feature* f) { + unsigned long flag = optf_identity_mapping_cmd_to_flg(f->cmd); if (f->on) { - *mask |= f->cmd; + *mask |= flag; im->pgprot = f->pgprot; im->key = f->key; } else { - *mask &= ~(f->cmd); + *mask &= ~flag; im->pgprot = 0; im->key = 0; } diff -r 7b7b123625d0 -r 506c05bad463 xen/arch/ia64/xen/vcpu.c --- a/xen/arch/ia64/xen/vcpu.c Thu Dec 20 09:40:33 2007 -0700 +++ b/xen/arch/ia64/xen/vcpu.c Fri Dec 21 12:33:44 2007 +0900 @@ -1779,7 +1779,7 @@ IA64FAULT vcpu_translate(VCPU * vcpu, u6 struct opt_feature* optf = &(vcpu->domain->arch.opt_feature); /* Optimization for identity mapped region 7 OS (linux) */ - if (optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG7 && + if (optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG7_FLG && region == 7 && ia64_psr(regs)->cpl == CONFIG_CPL0_EMUL) { pte.val = address & _PAGE_PPN_MASK; pte.val = pte.val | optf->im_reg7.pgprot; diff -r 7b7b123625d0 -r 506c05bad463 xen/include/asm-ia64/domain.h --- a/xen/include/asm-ia64/domain.h Thu Dec 20 09:40:33 2007 -0700 +++ b/xen/include/asm-ia64/domain.h Fri Dec 21 12:33:44 2007 +0900 @@ -92,6 +92,29 @@ struct identity_mapping { unsigned long pgprot; /* The page protection bit mask of the pte.*/ unsigned long key; /* A protection key. */ }; + +/* opt_feature mask */ +/* + * If this feature is switched on, the hypervisor inserts the + * tlb entries without calling the guests traphandler. + * This is useful in guests using region 7 for identity mapping + * like the linux kernel does. + */ +#define XEN_IA64_OPTF_IDENT_MAP_REG7_FLG_BIT 0 +#define XEN_IA64_OPTF_IDENT_MAP_REG7_FLG \ + (1UL << XEN_IA64_OPTF_IDENT_MAP_REG7_FLG_BIT) + +/* Identity mapping of region 4 addresses in HVM. */ +#define XEN_IA64_OPTF_IDENT_MAP_REG4_FLG_BIT \ + (XEN_IA64_OPTF_IDENT_MAP_REG7_FLG_BIT + 1) +#define XEN_IA64_OPTF_IDENT_MAP_REG4_FLG \ + (1UL << XEN_IA64_OPTF_IDENT_MAP_REG4_FLG_BIT) + +/* Identity mapping of region 5 addresses in HVM. */ +#define XEN_IA64_OPTF_IDENT_MAP_REG5_FLG_BIT \ + (XEN_IA64_OPTF_IDENT_MAP_REG7_FLG_BIT + 2) +#define XEN_IA64_OPTF_IDENT_MAP_REG5_FLG \ + (1UL << XEN_IA64_OPTF_IDENT_MAP_REG5_FLG_BIT) /* Central structure for optimzation features used by the hypervisor. */ struct opt_feature { diff -r 7b7b123625d0 -r 506c05bad463 xen/include/public/arch-ia64.h --- a/xen/include/public/arch-ia64.h Thu Dec 20 09:40:33 2007 -0700 +++ b/xen/include/public/arch-ia64.h Fri Dec 21 12:33:44 2007 +0900 @@ -602,21 +602,13 @@ struct xen_ia64_boot_param { * This is useful in guests using region 7 for identity mapping * like the linux kernel does. */ -#define XEN_IA64_OPTF_IDENT_MAP_REG7_BIT 0 -#define XEN_IA64_OPTF_IDENT_MAP_REG7 \ - (1UL << XEN_IA64_OPTF_IDENT_MAP_REG7_BIT) +#define XEN_IA64_OPTF_IDENT_MAP_REG7 1 /* Identity mapping of region 4 addresses in HVM. */ -#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) +#define XEN_IA64_OPTF_IDENT_MAP_REG4 2 /* Identity mapping of region 5 addresses in HVM. */ -#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) +#define XEN_IA64_OPTF_IDENT_MAP_REG5 3 #define XEN_IA64_OPTF_IDENT_MAP_NOT_SET (0)