ia64/xen-unstable

changeset 10667:63595abd80c5

[IA64] separate mapped_regs and vpd, handle various page size

Allow Xen page size != 16KB.

Decorelate XSI size and page_size.
Separate mapped_regs and vpd to save memory in non-VTi mode.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Fri Jul 07 10:34:45 2006 -0600 (2006-07-07)
parents 7c8955f73b18
children 50ed5c116b4d
files xen/arch/ia64/vmx/vmx_init.c xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/ivt.S xen/arch/ia64/xen/privop.c xen/arch/ia64/xen/xenasm.S xen/arch/ia64/xen/xensetup.c xen/include/asm-ia64/xenpage.h xen/include/public/arch-ia64.h
line diff
     1.1 --- a/xen/arch/ia64/vmx/vmx_init.c	Fri Jul 07 10:19:44 2006 -0600
     1.2 +++ b/xen/arch/ia64/vmx/vmx_init.c	Fri Jul 07 10:34:45 2006 -0600
     1.3 @@ -156,6 +156,7 @@ static vpd_t *alloc_vpd(void)
     1.4  	int i;
     1.5  	cpuid3_t cpuid3;
     1.6  	vpd_t *vpd;
     1.7 +	mapped_regs_t *mregs;
     1.8  
     1.9  	vpd = alloc_xenheap_pages(get_order(VPD_SIZE));
    1.10  	if (!vpd) {
    1.11 @@ -165,23 +166,25 @@ static vpd_t *alloc_vpd(void)
    1.12  
    1.13  	printk("vpd base: 0x%p, vpd size:%ld\n", vpd, sizeof(vpd_t));
    1.14  	memset(vpd, 0, VPD_SIZE);
    1.15 +	mregs = &vpd->vpd_low;
    1.16 +
    1.17  	/* CPUID init */
    1.18  	for (i = 0; i < 5; i++)
    1.19 -		vpd->vcpuid[i] = ia64_get_cpuid(i);
    1.20 +		mregs->vcpuid[i] = ia64_get_cpuid(i);
    1.21  
    1.22  	/* Limit the CPUID number to 5 */
    1.23 -	cpuid3.value = vpd->vcpuid[3];
    1.24 +	cpuid3.value = mregs->vcpuid[3];
    1.25  	cpuid3.number = 4;	/* 5 - 1 */
    1.26 -	vpd->vcpuid[3] = cpuid3.value;
    1.27 +	mregs->vcpuid[3] = cpuid3.value;
    1.28  
    1.29 -    vpd->vac.a_from_int_cr = 1;
    1.30 -    vpd->vac.a_to_int_cr = 1;
    1.31 -    vpd->vac.a_from_psr = 1;
    1.32 -    vpd->vac.a_from_cpuid = 1;
    1.33 -    vpd->vac.a_cover = 1;
    1.34 -    vpd->vac.a_bsw = 1;
    1.35 +	mregs->vac.a_from_int_cr = 1;
    1.36 +	mregs->vac.a_to_int_cr = 1;
    1.37 +	mregs->vac.a_from_psr = 1;
    1.38 +	mregs->vac.a_from_cpuid = 1;
    1.39 +	mregs->vac.a_cover = 1;
    1.40 +	mregs->vac.a_bsw = 1;
    1.41  
    1.42 -	vpd->vdc.d_vmsw = 1;
    1.43 +	mregs->vdc.d_vmsw = 1;
    1.44  
    1.45  	return vpd;
    1.46  }
    1.47 @@ -201,7 +204,7 @@ static void
    1.48  vmx_create_vp(struct vcpu *v)
    1.49  {
    1.50  	u64 ret;
    1.51 -	vpd_t *vpd = v->arch.privregs;
    1.52 +	vpd_t *vpd = (vpd_t *)v->arch.privregs;
    1.53  	u64 ivt_base;
    1.54      extern char vmx_ia64_ivt;
    1.55  	/* ia64_ivt is function pointer, so need this tranlation */
    1.56 @@ -274,8 +277,8 @@ vmx_final_setup_guest(struct vcpu *v)
    1.57  	vpd = alloc_vpd();
    1.58  	ASSERT(vpd);
    1.59  
    1.60 -	v->arch.privregs = vpd;
    1.61 -	vpd->virt_env_vaddr = vm_buffer;
    1.62 +	v->arch.privregs = (mapped_regs_t *)vpd;
    1.63 +	vpd->vpd_low.virt_env_vaddr = vm_buffer;
    1.64  
    1.65  	/* Per-domain vTLB and vhpt implementation. Now vmx domain will stick
    1.66  	 * to this solution. Maybe it can be deferred until we know created
     2.1 --- a/xen/arch/ia64/xen/domain.c	Fri Jul 07 10:19:44 2006 -0600
     2.2 +++ b/xen/arch/ia64/xen/domain.c	Fri Jul 07 10:34:45 2006 -0600
     2.3 @@ -313,7 +313,8 @@ void free_vcpu_struct(struct vcpu *v)
     2.4  		vmx_relinquish_vcpu_resources(v);
     2.5  	else {
     2.6  		if (v->arch.privregs != NULL)
     2.7 -			free_xenheap_pages(v->arch.privregs, get_order(sizeof(mapped_regs_t)));
     2.8 +			free_xenheap_pages(v->arch.privregs,
     2.9 +			              get_order_from_shift(XMAPPEDREGS_SHIFT));
    2.10  	}
    2.11  
    2.12  	free_xenheap_pages(v, KERNEL_STACK_SIZE_ORDER);
    2.13 @@ -350,11 +351,13 @@ int arch_domain_create(struct domain *d)
    2.14  	if (is_idle_domain(d))
    2.15  	    return 0;
    2.16  
    2.17 -	if ((d->shared_info = (void *)alloc_xenheap_page()) == NULL)
    2.18 +	d->shared_info = alloc_xenheap_pages(get_order_from_shift(XSI_SHIFT));
    2.19 +	if (d->shared_info == NULL)
    2.20  	    goto fail_nomem;
    2.21 -	memset(d->shared_info, 0, PAGE_SIZE);
    2.22 -	share_xen_page_with_guest(virt_to_page(d->shared_info),
    2.23 -	                          d, XENSHARE_writable);
    2.24 +	memset(d->shared_info, 0, XSI_SIZE);
    2.25 +	for (i = 0; i < XSI_SIZE; i += PAGE_SIZE)
    2.26 +	    share_xen_page_with_guest(virt_to_page((char *)d->shared_info + i),
    2.27 +	                              d, XENSHARE_writable);
    2.28  
    2.29  	d->max_pages = (128UL*1024*1024)/PAGE_SIZE; // 128MB default // FIXME
    2.30  	/* We may also need emulation rid for region4, though it's unlikely
    2.31 @@ -376,7 +379,7 @@ fail_nomem:
    2.32  	if (d->arch.mm.pgd != NULL)
    2.33  	    pgd_free(d->arch.mm.pgd);
    2.34  	if (d->shared_info != NULL)
    2.35 -	    free_xenheap_page(d->shared_info);
    2.36 +	    free_xenheap_pages(d->shared_info, get_order_from_shift(XSI_SHIFT));
    2.37  	return -ENOMEM;
    2.38  }
    2.39  
    2.40 @@ -384,7 +387,7 @@ void arch_domain_destroy(struct domain *
    2.41  {
    2.42  	BUG_ON(d->arch.mm.pgd != NULL);
    2.43  	if (d->shared_info != NULL)
    2.44 -		free_xenheap_page(d->shared_info);
    2.45 +	    free_xenheap_pages(d->shared_info, get_order_from_shift(XSI_SHIFT));
    2.46  
    2.47  	domain_flush_destroy (d);
    2.48  
     3.1 --- a/xen/arch/ia64/xen/ivt.S	Fri Jul 07 10:19:44 2006 -0600
     3.2 +++ b/xen/arch/ia64/xen/ivt.S	Fri Jul 07 10:34:45 2006 -0600
     3.3 @@ -591,7 +591,7 @@ GLOBAL_ENTRY(frametable_miss)
     3.4  	shladd r24=r19,3,r24	// r24=&pte[pte_offset(addr)]
     3.5  	;;
     3.6  (p7)	ld8 r24=[r24]		// r24=pte[pte_offset(addr)]
     3.7 -	mov r25=0x700|(_PAGE_SIZE_16K<<2) // key=7
     3.8 +	mov r25=0x700|(PAGE_SHIFT<<2) // key=7
     3.9  (p6)	br.spnt.few frametable_fault
    3.10  	;;
    3.11  	mov cr.itir=r25
     4.1 --- a/xen/arch/ia64/xen/privop.c	Fri Jul 07 10:19:44 2006 -0600
     4.2 +++ b/xen/arch/ia64/xen/privop.c	Fri Jul 07 10:34:45 2006 -0600
     4.3 @@ -700,10 +700,9 @@ ia64_hyperprivop(unsigned long iim, REGS
     4.4  	UINT64 val;
     4.5  	UINT64 itir, ifa;
     4.6  
     4.7 -// FIXME: Handle faults appropriately for these
     4.8  	if (!iim || iim > HYPERPRIVOP_MAX) {
     4.9 -		panic_domain(regs, "bad hyperprivop ignored; iim=%lx, "
    4.10 -		             "iip=0x%lx\n", iim, regs->cr_iip);
    4.11 +		panic_domain(regs, "bad hyperprivop: iim=%lx, iip=0x%lx\n",
    4.12 +		             iim, regs->cr_iip);
    4.13  		return 1;
    4.14  	}
    4.15  	slow_hyperpriv_cnt[iim]++;
     5.1 --- a/xen/arch/ia64/xen/xenasm.S	Fri Jul 07 10:19:44 2006 -0600
     5.2 +++ b/xen/arch/ia64/xen/xenasm.S	Fri Jul 07 10:34:45 2006 -0600
     5.3 @@ -131,7 +131,7 @@ 1:
     5.4  #endif
     5.5  
     5.6  	//  Shared info
     5.7 -	mov r24=PAGE_SHIFT<<2
     5.8 +	mov r24=XSI_SHIFT<<2
     5.9  	movl r25=__pgprot(__DIRTY_BITS | _PAGE_PL_2 | _PAGE_AR_RW)
    5.10  	;;
    5.11  	ptr.d	in3,r24
    5.12 @@ -144,7 +144,7 @@ 1:
    5.13  	
    5.14  	// Map mapped_regs
    5.15  	mov r22=XMAPPEDREGS_OFS
    5.16 -	mov r24=PAGE_SHIFT<<2
    5.17 +	mov r24=XMAPPEDREGS_SHIFT<<2
    5.18  	;; 
    5.19  	add r22=r22,in3
    5.20  	;;
     6.1 --- a/xen/arch/ia64/xen/xensetup.c	Fri Jul 07 10:19:44 2006 -0600
     6.2 +++ b/xen/arch/ia64/xen/xensetup.c	Fri Jul 07 10:34:45 2006 -0600
     6.3 @@ -26,10 +26,9 @@
     6.4  #include <linux/efi.h>
     6.5  #include <asm/iosapic.h>
     6.6  
     6.7 -/* Be sure the struct shared_info fits on a page because it is mapped in
     6.8 -   domain. */
     6.9 -#if SHARED_INFO_SIZE > PAGE_SIZE
    6.10 - #error "struct shared_info does not not fit in PAGE_SIZE"
    6.11 +/* Be sure the struct shared_info size is <= XSI_SIZE.  */
    6.12 +#if SHARED_INFO_SIZE > XSI_SIZE
    6.13 +#error "struct shared_info bigger than XSI_SIZE"
    6.14  #endif
    6.15  
    6.16  unsigned long xenheap_phys_end, total_pages;
     7.1 --- a/xen/include/asm-ia64/xenpage.h	Fri Jul 07 10:19:44 2006 -0600
     7.2 +++ b/xen/include/asm-ia64/xenpage.h	Fri Jul 07 10:34:45 2006 -0600
     7.3 @@ -60,6 +60,13 @@ static inline int get_order_from_pages(u
     7.4      return order;
     7.5  }
     7.6  
     7.7 +static inline int get_order_from_shift(unsigned long shift)
     7.8 +{
     7.9 +    if (shift <= PAGE_SHIFT)
    7.10 +	return 0;
    7.11 +    else
    7.12 +	return shift - PAGE_SHIFT;
    7.13 +}
    7.14  #endif
    7.15  
    7.16  #undef __pa
     8.1 --- a/xen/include/public/arch-ia64.h	Fri Jul 07 10:19:44 2006 -0600
     8.2 +++ b/xen/include/public/arch-ia64.h	Fri Jul 07 10:34:45 2006 -0600
     8.3 @@ -276,12 +276,16 @@ struct mapped_regs {
     8.4              unsigned long tmp[8]; // temp registers (e.g. for hyperprivops)
     8.5          };
     8.6      };
     8.7 +};
     8.8 +typedef struct mapped_regs mapped_regs_t;
     8.9 +
    8.10 +struct vpd {
    8.11 +    struct mapped_regs vpd_low;
    8.12      unsigned long  reserved6[3456];
    8.13      unsigned long  vmm_avail[128];
    8.14      unsigned long  reserved7[4096];
    8.15  };
    8.16 -typedef struct mapped_regs mapped_regs_t;
    8.17 -typedef mapped_regs_t vpd_t;
    8.18 +typedef struct vpd vpd_t;
    8.19  
    8.20  struct arch_vcpu_info {
    8.21  };
    8.22 @@ -365,13 +369,13 @@ struct xen_ia64_boot_param {
    8.23  
    8.24  /* Address of shared_info in domain virtual space.
    8.25     This is the default address, for compatibility only.  */
    8.26 -#define XSI_BASE				0xf100000000000000
    8.27 +#define XSI_BASE			0xf100000000000000
    8.28  
    8.29  /* Size of the shared_info area (this is not related to page size).  */
    8.30 -#define XSI_LOG_SIZE			14
    8.31 -#define XSI_SIZE				(1 << XSI_LOG_SIZE)
    8.32 +#define XSI_SHIFT			14
    8.33 +#define XSI_SIZE			(1 << XSI_SHIFT)
    8.34  /* Log size of mapped_regs area (64 KB - only 4KB is used).  */
    8.35 -#define XMAPPEDREGS_LOG_SIZE	16
    8.36 +#define XMAPPEDREGS_SHIFT		12
    8.37  /* Offset of XASI (Xen arch shared info) wrt XSI_BASE.  */
    8.38  #define XMAPPEDREGS_OFS			XSI_SIZE
    8.39