ia64/xen-unstable

changeset 16158:3ad0080ad9b5

ia64: configure VHPT size per domain: ia64 part
Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
author Keir Fraser <keir@xensource.com>
date Fri Oct 19 09:28:21 2007 +0100 (2007-10-19)
parents c5530fbbe9d0
children bc4afcd4c612
files xen/arch/ia64/vmx/vmmu.c xen/arch/ia64/xen/dom0_ops.c xen/arch/ia64/xen/vhpt.c xen/include/asm-ia64/domain.h xen/include/asm-ia64/vhpt.h
line diff
     1.1 --- a/xen/arch/ia64/vmx/vmmu.c	Fri Oct 19 09:27:55 2007 +0100
     1.2 +++ b/xen/arch/ia64/vmx/vmmu.c	Fri Oct 19 09:28:21 2007 +0100
     1.3 @@ -22,6 +22,7 @@
     1.4  #include <asm/vmx_vcpu.h>
     1.5  #include <asm/vmx_pal_vsa.h>
     1.6  #include <xen/sched-if.h>
     1.7 +#include <asm/vhpt.h>
     1.8  
     1.9  static int default_vtlb_sz = DEFAULT_VTLB_SZ;
    1.10  static int default_vhpt_sz = DEFAULT_VHPT_SZ;
    1.11 @@ -38,17 +39,6 @@ static void __init parse_vtlb_size(char 
    1.12      }
    1.13  }
    1.14  
    1.15 -static int canonicalize_vhpt_size(int sz)
    1.16 -{
    1.17 -    /* minimum 32KB */
    1.18 -    if (sz < 15)
    1.19 -        return 15;
    1.20 -    /* maximum 8MB (since purging TR is hard coded) */
    1.21 -    if (sz > IA64_GRANULE_SHIFT - 1)
    1.22 -        return IA64_GRANULE_SHIFT - 1;
    1.23 -    return sz;
    1.24 -}
    1.25 -
    1.26  static void __init parse_vhpt_size(char *s)
    1.27  {
    1.28      int sz = parse_size_and_unit(s, NULL);
    1.29 @@ -96,8 +86,14 @@ static u64 get_mfn(struct domain *d, u64
    1.30  static int init_domain_vhpt(struct vcpu *v)
    1.31  {
    1.32      int rc;
    1.33 +    u64 size = v->domain->arch.hvm_domain.params[HVM_PARAM_VHPT_SIZE];
    1.34  
    1.35 -    rc = thash_alloc(&(v->arch.vhpt), default_vhpt_sz, "vhpt");
    1.36 +    if (size == 0)
    1.37 +        size = default_vhpt_sz;
    1.38 +    else
    1.39 +        size = canonicalize_vhpt_size(size);
    1.40 +
    1.41 +    rc = thash_alloc(&(v->arch.vhpt), size, "vhpt");
    1.42      v->arch.arch_vmx.mpta = v->arch.vhpt.pta.val;
    1.43      return rc;
    1.44  }
     2.1 --- a/xen/arch/ia64/xen/dom0_ops.c	Fri Oct 19 09:27:55 2007 +0100
     2.2 +++ b/xen/arch/ia64/xen/dom0_ops.c	Fri Oct 19 09:28:21 2007 +0100
     2.3 @@ -93,6 +93,9 @@ long arch_do_domctl(xen_domctl_t *op, XE
     2.4              ds->maxmem = d->arch.convmem_end;
     2.5              ds->xsi_va = d->arch.shared_info_va;
     2.6              ds->hypercall_imm = d->arch.breakimm;
     2.7 +#ifdef CONFIG_XEN_IA64_PERVCPU_VHPT
     2.8 +            ds->vhpt_size_log2 = d->arch.vhpt_size_log2;
     2.9 +#endif
    2.10              /* Copy back.  */
    2.11              if ( copy_to_guest(u_domctl, op, 1) )
    2.12                  ret = -EFAULT;
    2.13 @@ -116,6 +119,20 @@ long arch_do_domctl(xen_domctl_t *op, XE
    2.14                      for_each_vcpu (d, v)
    2.15                          v->arch.breakimm = d->arch.breakimm;
    2.16                  }
    2.17 +#ifdef CONFIG_XEN_IA64_PERVCPU_VHPT
    2.18 +                if (ds->vhpt_size_log2 == -1) {
    2.19 +                    d->arch.has_pervcpu_vhpt = 0;
    2.20 +                    ds->vhpt_size_log2 = -1;
    2.21 +                    printk(XENLOG_INFO "XEN_DOMCTL_arch_setup: "
    2.22 +                           "domain %d VHPT is global.\n", d->domain_id);
    2.23 +                } else {
    2.24 +                    d->arch.has_pervcpu_vhpt = 1;
    2.25 +                    d->arch.vhpt_size_log2 = ds->vhpt_size_log2;
    2.26 +                    printk(XENLOG_INFO "XEN_DOMCTL_arch_setup: "
    2.27 +                           "domain %d VHPT is per vcpu. size=2**%d\n",
    2.28 +                           d->domain_id, ds->vhpt_size_log2);
    2.29 +                }
    2.30 +#endif
    2.31                  if (ds->xsi_va)
    2.32                      d->arch.shared_info_va = ds->xsi_va;
    2.33                  ret = dom_fw_setup(d, ds->bp, ds->maxmem);
     3.1 --- a/xen/arch/ia64/xen/vhpt.c	Fri Oct 19 09:27:55 2007 +0100
     3.2 +++ b/xen/arch/ia64/xen/vhpt.c	Fri Oct 19 09:28:21 2007 +0100
     3.3 @@ -28,12 +28,13 @@ DEFINE_PER_CPU(volatile u32, vhpt_tlbflu
     3.4  #endif
     3.5  
     3.6  static void
     3.7 -__vhpt_flush(unsigned long vhpt_maddr)
     3.8 +__vhpt_flush(unsigned long vhpt_maddr, unsigned long vhpt_size_log2)
     3.9  {
    3.10  	struct vhpt_lf_entry *v = (struct vhpt_lf_entry*)__va(vhpt_maddr);
    3.11 +	unsigned long num_entries = 1 << (vhpt_size_log2 - 5);
    3.12  	int i;
    3.13  
    3.14 -	for (i = 0; i < VHPT_NUM_ENTRIES; i++, v++)
    3.15 +	for (i = 0; i < num_entries; i++, v++)
    3.16  		v->ti_tag = INVALID_TI_TAG;
    3.17  }
    3.18  
    3.19 @@ -42,7 +43,7 @@ local_vhpt_flush(void)
    3.20  {
    3.21  	/* increment flush clock before flush */
    3.22  	u32 flush_time = tlbflush_clock_inc_and_return();
    3.23 -	__vhpt_flush(__ia64_per_cpu_var(vhpt_paddr));
    3.24 +	__vhpt_flush(__ia64_per_cpu_var(vhpt_paddr), VHPT_SIZE_LOG2);
    3.25  	/* this must be after flush */
    3.26  	tlbflush_update_time(&__get_cpu_var(vhpt_tlbflush_timestamp),
    3.27  	                     flush_time);
    3.28 @@ -52,17 +53,23 @@ local_vhpt_flush(void)
    3.29  void
    3.30  vcpu_vhpt_flush(struct vcpu* v)
    3.31  {
    3.32 -	__vhpt_flush(vcpu_vhpt_maddr(v));
    3.33 +	unsigned long vhpt_size_log2 = VHPT_SIZE_LOG2;
    3.34 +#ifdef CONFIG_XEN_IA64_PERVCPU_VHPT
    3.35 +	if (HAS_PERVCPU_VHPT(v->domain))
    3.36 +		vhpt_size_log2 = v->arch.pta.size;
    3.37 +#endif
    3.38 +	__vhpt_flush(vcpu_vhpt_maddr(v), vhpt_size_log2);
    3.39  	perfc_incr(vcpu_vhpt_flush);
    3.40  }
    3.41  
    3.42  static void
    3.43 -vhpt_erase(unsigned long vhpt_maddr)
    3.44 +vhpt_erase(unsigned long vhpt_maddr, unsigned long vhpt_size_log2)
    3.45  {
    3.46  	struct vhpt_lf_entry *v = (struct vhpt_lf_entry*)__va(vhpt_maddr);
    3.47 +	unsigned long num_entries = 1 << (vhpt_size_log2 - 5);
    3.48  	int i;
    3.49  
    3.50 -	for (i = 0; i < VHPT_NUM_ENTRIES; i++, v++) {
    3.51 +	for (i = 0; i < num_entries; i++, v++) {
    3.52  		v->itir = 0;
    3.53  		v->CChain = 0;
    3.54  		v->page_flags = 0;
    3.55 @@ -140,7 +147,7 @@ void __init vhpt_init(void)
    3.56  	__get_cpu_var(vhpt_pend) = paddr + (1 << VHPT_SIZE_LOG2) - 1;
    3.57  	printk(XENLOG_DEBUG "vhpt_init: vhpt paddr=0x%lx, end=0x%lx\n",
    3.58  	       paddr, __get_cpu_var(vhpt_pend));
    3.59 -	vhpt_erase(paddr);
    3.60 +	vhpt_erase(paddr, VHPT_SIZE_LOG2);
    3.61  	// we don't enable VHPT here.
    3.62  	// context_switch() or schedule_tail() does it.
    3.63  }
    3.64 @@ -151,6 +158,11 @@ pervcpu_vhpt_alloc(struct vcpu *v)
    3.65  {
    3.66  	unsigned long vhpt_size_log2 = VHPT_SIZE_LOG2;
    3.67  
    3.68 +	if (v->domain->arch.vhpt_size_log2 > 0)
    3.69 +	    vhpt_size_log2 =
    3.70 +		canonicalize_vhpt_size(v->domain->arch.vhpt_size_log2);
    3.71 +	printk(XENLOG_DEBUG "%s vhpt_size_log2=%ld\n",
    3.72 +	       __func__, vhpt_size_log2);
    3.73  	v->arch.vhpt_entries =
    3.74  		(1UL << vhpt_size_log2) / sizeof(struct vhpt_lf_entry);
    3.75  	v->arch.vhpt_page =
    3.76 @@ -164,11 +176,11 @@ pervcpu_vhpt_alloc(struct vcpu *v)
    3.77  
    3.78  	v->arch.pta.val = 0; // to zero reserved bits
    3.79  	v->arch.pta.ve = 1; // enable vhpt
    3.80 -	v->arch.pta.size = VHPT_SIZE_LOG2;
    3.81 +	v->arch.pta.size = vhpt_size_log2;
    3.82  	v->arch.pta.vf = 1; // long format
    3.83  	v->arch.pta.base = __va_ul(v->arch.vhpt_maddr) >> 15;
    3.84  
    3.85 -	vhpt_erase(v->arch.vhpt_maddr);
    3.86 +	vhpt_erase(v->arch.vhpt_maddr, vhpt_size_log2);
    3.87  	smp_mb(); // per vcpu vhpt may be used by another physical cpu.
    3.88  	return 0;
    3.89  }
    3.90 @@ -178,7 +190,7 @@ pervcpu_vhpt_free(struct vcpu *v)
    3.91  {
    3.92  	if (likely(v->arch.vhpt_page != NULL))
    3.93  		free_domheap_pages(v->arch.vhpt_page,
    3.94 -		                   VHPT_SIZE_LOG2 - PAGE_SHIFT);
    3.95 +		                   v->arch.pta.size - PAGE_SHIFT);
    3.96  }
    3.97  #endif
    3.98  
     4.1 --- a/xen/include/asm-ia64/domain.h	Fri Oct 19 09:27:55 2007 +0100
     4.2 +++ b/xen/include/asm-ia64/domain.h	Fri Oct 19 09:28:21 2007 +0100
     4.3 @@ -123,6 +123,7 @@ struct arch_domain {
     4.4              unsigned int is_vti : 1;
     4.5  #ifdef CONFIG_XEN_IA64_PERVCPU_VHPT
     4.6              unsigned int has_pervcpu_vhpt : 1;
     4.7 +            unsigned int vhpt_size_log2 : 6;
     4.8  #endif
     4.9          };
    4.10      };
     5.1 --- a/xen/include/asm-ia64/vhpt.h	Fri Oct 19 09:27:55 2007 +0100
     5.2 +++ b/xen/include/asm-ia64/vhpt.h	Fri Oct 19 09:28:21 2007 +0100
     5.3 @@ -84,5 +84,18 @@ vcpu_pta(struct vcpu* v)
     5.4          (VHPT_SIZE_LOG2 << 2) | VHPT_ENABLED;
     5.5  }
     5.6  
     5.7 +static inline int
     5.8 +canonicalize_vhpt_size(int sz)
     5.9 +{
    5.10 +    /* minimum 32KB */
    5.11 +    if (sz < 15)
    5.12 +        return 15;
    5.13 +    /* maximum 8MB (since purging TR is hard coded) */
    5.14 +    if (sz > IA64_GRANULE_SHIFT - 1)
    5.15 +        return IA64_GRANULE_SHIFT - 1;
    5.16 +    return sz;
    5.17 +}
    5.18 +
    5.19 +
    5.20  #endif /* !__ASSEMBLY */
    5.21  #endif