ia64/xen-unstable

changeset 16682:7515dc56c124

[IA64] 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.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Sun Dec 30 13:02:16 2007 -0700 (2007-12-30)
parents ecdc7b5f650b
children 9d22f78d9e5a
files xen/arch/ia64/vmx/mmio.c xen/arch/ia64/vmx/vmx_fault.c xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/vcpu.c xen/include/asm-ia64/domain.h xen/include/public/arch-ia64.h
line diff
     1.1 --- a/xen/arch/ia64/vmx/mmio.c	Sun Dec 30 12:56:16 2007 -0700
     1.2 +++ b/xen/arch/ia64/vmx/mmio.c	Sun Dec 30 13:02:16 2007 -0700
     1.3 @@ -253,11 +253,11 @@ static int vmx_identity_mappings_save(st
     1.4      const struct opt_feature *optf = &d->arch.opt_feature;
     1.5      struct hvm_hw_ia64_identity_mappings im_save;
     1.6  
     1.7 -    __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4,
     1.8 +    __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4_FLG,
     1.9                                  &optf->im_reg4, &im_save.im_reg4);
    1.10 -    __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5,
    1.11 +    __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5_FLG,
    1.12                                  &optf->im_reg5, &im_save.im_reg5);
    1.13 -    __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG7,
    1.14 +    __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG7_FLG,
    1.15                                  &optf->im_reg7, &im_save.im_reg7);
    1.16  
    1.17      return hvm_save_entry(OPT_FEATURE_IDENTITY_MAPPINGS, 0, h, &im_save);
     2.1 --- a/xen/arch/ia64/vmx/vmx_fault.c	Sun Dec 30 12:56:16 2007 -0700
     2.2 +++ b/xen/arch/ia64/vmx/vmx_fault.c	Sun Dec 30 13:02:16 2007 -0700
     2.3 @@ -392,7 +392,7 @@ try_again:
     2.4  
     2.5          if (!vhpt_enabled(v, vadr, misr.rs ? RSE_REF : DATA_REF)) {
     2.6              /* windows use region 4 and 5 for identity mapping */
     2.7 -            if ((optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4) &&
     2.8 +            if ((optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4_FLG) &&
     2.9                  REGION_NUMBER(vadr) == 4 && !(regs->cr_ipsr & IA64_PSR_CPL) &&
    2.10                  REGION_OFFSET(vadr) <= _PAGE_PPN_MASK) {
    2.11  
    2.12 @@ -402,7 +402,7 @@ try_again:
    2.13                      goto try_again;
    2.14                  return IA64_NO_FAULT;
    2.15              }
    2.16 -            if ((optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5) &&
    2.17 +            if ((optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5_FLG) &&
    2.18                  REGION_NUMBER(vadr) == 5 && !(regs->cr_ipsr & IA64_PSR_CPL) &&
    2.19                  REGION_OFFSET(vadr) <= _PAGE_PPN_MASK) {
    2.20  
    2.21 @@ -428,8 +428,8 @@ try_again:
    2.22          }
    2.23  
    2.24          /* avoid recursively walking (short format) VHPT */
    2.25 -        if (!(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4) &&
    2.26 -            !(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5) &&
    2.27 +        if (!(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4_FLG) &&
    2.28 +            !(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5_FLG) &&
    2.29              (((vadr ^ vpta.val) << 3) >> (vpta.size + 3)) == 0) {
    2.30              goto inject_dtlb_fault;
    2.31          }
     3.1 --- a/xen/arch/ia64/xen/domain.c	Sun Dec 30 12:56:16 2007 -0700
     3.2 +++ b/xen/arch/ia64/xen/domain.c	Sun Dec 30 13:02:16 2007 -0700
     3.3 @@ -2277,16 +2277,36 @@ custom_param("dom0_mem", parse_dom0_mem)
     3.4   * Helper function for the optimization stuff handling the identity mapping
     3.5   * feature.
     3.6   */
     3.7 +static inline unsigned long
     3.8 +optf_identity_mapping_cmd_to_flg(unsigned long cmd)
     3.9 +{
    3.10 +	switch(cmd) {
    3.11 +	case XEN_IA64_OPTF_IDENT_MAP_REG7:
    3.12 +		return XEN_IA64_OPTF_IDENT_MAP_REG7_FLG;
    3.13 +	case XEN_IA64_OPTF_IDENT_MAP_REG4:
    3.14 +		return XEN_IA64_OPTF_IDENT_MAP_REG4_FLG;
    3.15 +	case XEN_IA64_OPTF_IDENT_MAP_REG5:
    3.16 +		return XEN_IA64_OPTF_IDENT_MAP_REG5_FLG;
    3.17 +	default:
    3.18 +		BUG();
    3.19 +		return 0;
    3.20 +	}
    3.21 +
    3.22 +	/* NOTREACHED */
    3.23 +}
    3.24 +
    3.25  static inline void
    3.26  optf_set_identity_mapping(unsigned long* mask, struct identity_mapping* im,
    3.27  			  struct xen_ia64_opt_feature* f)
    3.28  {
    3.29 +	unsigned long flag = optf_identity_mapping_cmd_to_flg(f->cmd);
    3.30 +
    3.31  	if (f->on) {
    3.32 -		*mask |= f->cmd;
    3.33 +		*mask |= flag;
    3.34  		im->pgprot = f->pgprot;
    3.35  		im->key = f->key;
    3.36  	} else {
    3.37 -		*mask &= ~(f->cmd);
    3.38 +		*mask &= ~flag;
    3.39  		im->pgprot = 0;
    3.40  		im->key = 0;
    3.41  	}
     4.1 --- a/xen/arch/ia64/xen/vcpu.c	Sun Dec 30 12:56:16 2007 -0700
     4.2 +++ b/xen/arch/ia64/xen/vcpu.c	Sun Dec 30 13:02:16 2007 -0700
     4.3 @@ -1779,7 +1779,7 @@ IA64FAULT vcpu_translate(VCPU * vcpu, u6
     4.4  		struct opt_feature* optf = &(vcpu->domain->arch.opt_feature);
     4.5  
     4.6  		/* Optimization for identity mapped region 7 OS (linux) */
     4.7 -		if (optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG7 &&
     4.8 +		if (optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG7_FLG &&
     4.9  		    region == 7 && ia64_psr(regs)->cpl == CONFIG_CPL0_EMUL) {
    4.10  			pte.val = address & _PAGE_PPN_MASK;
    4.11  			pte.val = pte.val | optf->im_reg7.pgprot;
     5.1 --- a/xen/include/asm-ia64/domain.h	Sun Dec 30 12:56:16 2007 -0700
     5.2 +++ b/xen/include/asm-ia64/domain.h	Sun Dec 30 13:02:16 2007 -0700
     5.3 @@ -93,6 +93,29 @@ struct identity_mapping {
     5.4          unsigned long key;	/* A protection key. */
     5.5  };
     5.6  
     5.7 +/* opt_feature mask */
     5.8 +/*
     5.9 + * If this feature is switched on, the hypervisor inserts the
    5.10 + * tlb entries without calling the guests traphandler.
    5.11 + * This is useful in guests using region 7 for identity mapping
    5.12 + * like the linux kernel does.
    5.13 + */
    5.14 +#define XEN_IA64_OPTF_IDENT_MAP_REG7_FLG_BIT    0
    5.15 +#define XEN_IA64_OPTF_IDENT_MAP_REG7_FLG        \
    5.16 +	(1UL << XEN_IA64_OPTF_IDENT_MAP_REG7_FLG_BIT)
    5.17 +
    5.18 +/* Identity mapping of region 4 addresses in HVM. */
    5.19 +#define XEN_IA64_OPTF_IDENT_MAP_REG4_FLG_BIT    \
    5.20 +        (XEN_IA64_OPTF_IDENT_MAP_REG7_FLG_BIT + 1)
    5.21 +#define XEN_IA64_OPTF_IDENT_MAP_REG4_FLG        \
    5.22 +        (1UL << XEN_IA64_OPTF_IDENT_MAP_REG4_FLG_BIT)
    5.23 +
    5.24 +/* Identity mapping of region 5 addresses in HVM. */
    5.25 +#define XEN_IA64_OPTF_IDENT_MAP_REG5_FLG_BIT    \
    5.26 +        (XEN_IA64_OPTF_IDENT_MAP_REG7_FLG_BIT + 2)
    5.27 +#define XEN_IA64_OPTF_IDENT_MAP_REG5_FLG        \
    5.28 +        (1UL << XEN_IA64_OPTF_IDENT_MAP_REG5_FLG_BIT)
    5.29 +
    5.30  /* Central structure for optimzation features used by the hypervisor.  */
    5.31  struct opt_feature {
    5.32      unsigned long mask;			/* For every feature one bit. */
     6.1 --- a/xen/include/public/arch-ia64.h	Sun Dec 30 12:56:16 2007 -0700
     6.2 +++ b/xen/include/public/arch-ia64.h	Sun Dec 30 13:02:16 2007 -0700
     6.3 @@ -604,21 +604,13 @@ struct xen_ia64_boot_param {
     6.4   * This is useful in guests using region 7 for identity mapping
     6.5   * like the linux kernel does.
     6.6   */
     6.7 -#define XEN_IA64_OPTF_IDENT_MAP_REG7_BIT	0
     6.8 -#define XEN_IA64_OPTF_IDENT_MAP_REG7		\
     6.9 -	(1UL << XEN_IA64_OPTF_IDENT_MAP_REG7_BIT)
    6.10 +#define XEN_IA64_OPTF_IDENT_MAP_REG7    1
    6.11  
    6.12  /* Identity mapping of region 4 addresses in HVM. */
    6.13 -#define XEN_IA64_OPTF_IDENT_MAP_REG4_BIT        \
    6.14 -        (XEN_IA64_OPTF_IDENT_MAP_REG7_BIT + 1)
    6.15 -#define XEN_IA64_OPTF_IDENT_MAP_REG4            \
    6.16 -        (1UL << XEN_IA64_OPTF_IDENT_MAP_REG4_BIT)
    6.17 +#define XEN_IA64_OPTF_IDENT_MAP_REG4    2
    6.18  
    6.19  /* Identity mapping of region 5 addresses in HVM. */
    6.20 -#define XEN_IA64_OPTF_IDENT_MAP_REG5_BIT        \
    6.21 -        (XEN_IA64_OPTF_IDENT_MAP_REG7_BIT + 2)
    6.22 -#define XEN_IA64_OPTF_IDENT_MAP_REG5            \
    6.23 -        (1UL << XEN_IA64_OPTF_IDENT_MAP_REG5_BIT)
    6.24 +#define XEN_IA64_OPTF_IDENT_MAP_REG5    3
    6.25  
    6.26  #define XEN_IA64_OPTF_IDENT_MAP_NOT_SET  (0)
    6.27