ia64/xen-unstable

changeset 9375:369bdeb29606

[IA64] dom0_max_vcpus and dom0 vcpus creation

dom0_max_vcpus option added (default is 1).
Create dom0 vcpus.
Fix creations issue for SMP-g.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Wed Mar 22 08:53:20 2006 -0700 (2006-03-22)
parents a9f5cf43451f
children 695aa28b7cb1
files xen/arch/ia64/xen/dom_fw.c xen/arch/ia64/xen/domain.c xen/include/asm-ia64/dom_fw.h
line diff
     1.1 --- a/xen/arch/ia64/xen/dom_fw.c	Tue Mar 21 11:19:11 2006 -0700
     1.2 +++ b/xen/arch/ia64/xen/dom_fw.c	Wed Mar 22 08:53:20 2006 -0700
     1.3 @@ -79,7 +79,7 @@ static void dom_fw_pal_hypercall_patch(s
     1.4  // FIXME: This is really a hack: Forcing the boot parameter block
     1.5  // at domain mpaddr 0 page, then grabbing only the low bits of the
     1.6  // Xen imva, which is the offset into the page
     1.7 -unsigned long dom_fw_setup(struct domain *d, char *args, int arglen)
     1.8 +unsigned long dom_fw_setup(struct domain *d, const char *args, int arglen)
     1.9  {
    1.10  	struct ia64_boot_param *bp;
    1.11  
    1.12 @@ -349,28 +349,31 @@ static void print_md(efi_memory_desc_t *
    1.13  #endif
    1.14  }
    1.15  
    1.16 -#define LSAPIC_NUM 16	// TEMP
    1.17 -static u32 lsapic_flag=1;
    1.18  
    1.19 -/* Provide only one LP to guest */
    1.20 +static u32 lsapic_nbr;
    1.21 +
    1.22 +/* Modify lsapic table.  Provides LPs.  */
    1.23  static int 
    1.24  acpi_update_lsapic (acpi_table_entry_header *header, const unsigned long end)
    1.25  {
    1.26  	struct acpi_table_lsapic *lsapic;
    1.27 +	int enable;
    1.28  
    1.29  	lsapic = (struct acpi_table_lsapic *) header;
    1.30  	if (!lsapic)
    1.31  		return -EINVAL;
    1.32  
    1.33 -	if (lsapic->flags.enabled && lsapic_flag) {
    1.34 +	if (lsapic_nbr < MAX_VIRT_CPUS && dom0->vcpu[lsapic_nbr] != NULL)
    1.35 +		enable = 1;
    1.36 +	else
    1.37 +		enable = 0;
    1.38 +	if (lsapic->flags.enabled && enable) {
    1.39  		printk("enable lsapic entry: 0x%lx\n", (u64)lsapic);
    1.40 -		lsapic_flag = 0; /* disable all the following processros */
    1.41 +		lsapic_nbr++;
    1.42  	} else if (lsapic->flags.enabled) {
    1.43  		printk("DISABLE lsapic entry: 0x%lx\n", (u64)lsapic);
    1.44  		lsapic->flags.enabled = 0;
    1.45 -	} else
    1.46 -		printk("lsapic entry is already disabled: 0x%lx\n", (u64)lsapic);
    1.47 -
    1.48 +	}
    1.49  	return 0;
    1.50  }
    1.51  
    1.52 @@ -403,6 +406,7 @@ acpi_update_madt_checksum (unsigned long
    1.53  /* base is physical address of acpi table */
    1.54  static void touch_acpi_table(void)
    1.55  {
    1.56 +	lsapic_nbr = 0;
    1.57  	if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_update_lsapic, 0) < 0)
    1.58  		printk("Error parsing MADT - no LAPIC entires\n");
    1.59  	acpi_table_parse(ACPI_APIC, acpi_update_madt_checksum);
     2.1 --- a/xen/arch/ia64/xen/domain.c	Tue Mar 21 11:19:11 2006 -0700
     2.2 +++ b/xen/arch/ia64/xen/domain.c	Wed Mar 22 08:53:20 2006 -0700
     2.3 @@ -52,23 +52,23 @@
     2.4  #include <public/arch-ia64.h>
     2.5  #include <asm/tlbflush.h>
     2.6  #include <asm/regionreg.h>
     2.7 +#include <asm/dom_fw.h>
     2.8  
     2.9  #define CONFIG_DOMAIN0_CONTIGUOUS
    2.10  unsigned long dom0_start = -1L;
    2.11  unsigned long dom0_size = 512*1024*1024;
    2.12  unsigned long dom0_align = 64*1024*1024;
    2.13  
    2.14 +/* dom0_max_vcpus: maximum number of VCPUs to create for dom0.  */
    2.15 +static unsigned int dom0_max_vcpus = 1;
    2.16 +integer_param("dom0_max_vcpus", dom0_max_vcpus); 
    2.17 +
    2.18  // initialized by arch/ia64/setup.c:find_initrd()
    2.19  unsigned long initrd_start = 0, initrd_end = 0;
    2.20  extern unsigned long running_on_sim;
    2.21  
    2.22  #define IS_XEN_ADDRESS(d,a) ((a >= d->xen_vastart) && (a <= d->xen_vaend))
    2.23  
    2.24 -//extern int loadelfimage(char *);
    2.25 -extern int readelfimage_base_and_size(char *, unsigned long,
    2.26 -	              unsigned long *, unsigned long *, unsigned long *);
    2.27 -
    2.28 -extern unsigned long dom_fw_setup(struct domain *, char *, int);
    2.29  /* FIXME: where these declarations should be there ? */
    2.30  extern void domain_pend_keyboard_interrupt(int);
    2.31  extern long platform_is_hp_ski(void);
    2.32 @@ -315,22 +315,28 @@ int arch_set_info_guest(struct vcpu *v, 
    2.33  	}
    2.34  
    2.35  	*regs = c->regs;
    2.36 -	d->arch.sys_pgnr = c->sys_pgnr;
    2.37 -	d->arch.initrd_start = c->initrd.start;
    2.38 -	d->arch.initrd_len   = c->initrd.size;
    2.39 -	d->arch.cmdline      = c->cmdline;
    2.40 +	if (v == d->vcpu[0]) {
    2.41 +	    /* Only for first vcpu.  */
    2.42 +	    d->arch.sys_pgnr = c->sys_pgnr;
    2.43 +	    d->arch.initrd_start = c->initrd.start;
    2.44 +	    d->arch.initrd_len   = c->initrd.size;
    2.45 +	    d->arch.cmdline      = c->cmdline;
    2.46 +	    d->shared_info->arch = c->shared;
    2.47 +
    2.48 +	    /* FIXME: it is required here ?  */
    2.49 +	    sync_split_caches();
    2.50 +	}
    2.51  	new_thread(v, regs->cr_iip, 0, 0);
    2.52  
    2.53 -	sync_split_caches();
    2.54   	v->vcpu_info->arch.evtchn_vector = c->vcpu.evtchn_vector;
    2.55  	if ( c->vcpu.privregs && copy_from_user(v->arch.privregs,
    2.56  			   c->vcpu.privregs, sizeof(mapped_regs_t))) {
    2.57 -	    printk("Bad ctxt address in arch_set_info_guest: %p\n", c->vcpu.privregs);
    2.58 +	    printk("Bad ctxt address in arch_set_info_guest: %p\n",
    2.59 +		   c->vcpu.privregs);
    2.60  	    return -EFAULT;
    2.61  	}
    2.62  
    2.63  	v->arch.domain_itm_last = -1L;
    2.64 -	d->shared_info->arch = c->shared;
    2.65  
    2.66  	/* Don't redo final setup */
    2.67  	set_bit(_VCPUF_initialised, &v->vcpu_flags);
    2.68 @@ -419,7 +425,7 @@ void new_thread(struct vcpu *v,
    2.69  	extern char dom0_command_line[];
    2.70  
    2.71  #ifdef CONFIG_DOMAIN0_CONTIGUOUS
    2.72 -	if (d == dom0) start_pc += dom0_start;
    2.73 +	if (d == dom0 && v->vcpu_id == 0) start_pc += dom0_start;
    2.74  #endif
    2.75  
    2.76  	regs = vcpu_regs (v);
    2.77 @@ -447,24 +453,33 @@ void new_thread(struct vcpu *v,
    2.78  		VCPU(v, dcr) = 0;
    2.79  	} else {
    2.80  		init_all_rr(v);
    2.81 -		if (d == dom0) 
    2.82 -		    regs->r28 = dom_fw_setup(d,dom0_command_line,
    2.83 -					     COMMAND_LINE_SIZE);
    2.84 -		else {
    2.85 -		    regs->ar_rsc |= (2 << 2); /* force PL2/3 */
    2.86 -		    if (*d->arch.cmdline == '\0') {
    2.87 +		if (v->vcpu_id == 0) {
    2.88 +			/* Build the firmware.  */
    2.89 +			if (d == dom0) 
    2.90 +				regs->r28 = dom_fw_setup(d,dom0_command_line,
    2.91 +							 COMMAND_LINE_SIZE);
    2.92 +			else {
    2.93 +				const char *cmdline = d->arch.cmdline;
    2.94 +				int len;
    2.95 +
    2.96 +				if (*cmdline == 0) {
    2.97  #define DEFAULT_CMDLINE "nomca nosmp xencons=tty0 console=tty0 root=/dev/hda1"
    2.98 -			regs->r28 = dom_fw_setup(d,DEFAULT_CMDLINE,
    2.99 -						 sizeof (DEFAULT_CMDLINE));
   2.100 -			printf("domU command line defaulted to"
   2.101 -				DEFAULT_CMDLINE "\n");
   2.102 -		    }
   2.103 -		    else regs->r28 = dom_fw_setup(d,d->arch.cmdline, 
   2.104 -						  IA64_COMMAND_LINE_SIZE);
   2.105 +					cmdline = DEFAULT_CMDLINE;
   2.106 +					len = sizeof (DEFAULT_CMDLINE);
   2.107 +					printf("domU command line defaulted to"
   2.108 +					       DEFAULT_CMDLINE "\n");
   2.109 +				}
   2.110 +				else
   2.111 +					len = IA64_COMMAND_LINE_SIZE;
   2.112 +
   2.113 +				regs->r28 = dom_fw_setup (d, cmdline, len);
   2.114 +			}
   2.115 +			d->shared_info->arch.flags = (d == dom0) ?
   2.116 +				(SIF_INITDOMAIN|SIF_PRIVILEGED) : 0;
   2.117  		}
   2.118 +		regs->ar_rsc |= (2 << 2); /* force PL2/3 */
   2.119  		VCPU(v, banknum) = 1;
   2.120  		VCPU(v, metaphysical_mode) = 1;
   2.121 -		d->shared_info->arch.flags = (d == dom0) ? (SIF_INITDOMAIN|SIF_PRIVILEGED) : 0;
   2.122  	}
   2.123  }
   2.124  
   2.125 @@ -960,6 +975,18 @@ int construct_dom0(struct domain *d,
   2.126  	for ( i = 1; i < MAX_VIRT_CPUS; i++ )
   2.127  	    d->shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
   2.128  
   2.129 +	if (dom0_max_vcpus == 0)
   2.130 +	    dom0_max_vcpus = MAX_VIRT_CPUS;
   2.131 +	if (dom0_max_vcpus > num_online_cpus())
   2.132 +	    dom0_max_vcpus = num_online_cpus();
   2.133 +	if (dom0_max_vcpus > MAX_VIRT_CPUS)
   2.134 +	    dom0_max_vcpus = MAX_VIRT_CPUS;
   2.135 +	
   2.136 +	printf ("Dom0 max_vcpus=%d\n", dom0_max_vcpus);
   2.137 +	for ( i = 1; i < dom0_max_vcpus; i++ )
   2.138 +	    if (alloc_vcpu(d, i, i) == NULL)
   2.139 +		printf ("Cannot allocate dom0 vcpu %d\n", i);
   2.140 +
   2.141  #ifdef VALIDATE_VT 
   2.142  	/* Construct a frame-allocation list for the initial domain, since these
   2.143  	 * pages are allocated by boot allocator and pfns are not set properly
     3.1 --- a/xen/include/asm-ia64/dom_fw.h	Tue Mar 21 11:19:11 2006 -0700
     3.2 +++ b/xen/include/asm-ia64/dom_fw.h	Wed Mar 22 08:53:20 2006 -0700
     3.3 @@ -6,7 +6,7 @@
     3.4   */
     3.5  
     3.6  extern unsigned long dom_pa(unsigned long);
     3.7 -extern unsigned long dom_fw_setup(struct domain *, char *, int);
     3.8 +extern unsigned long dom_fw_setup(struct domain *, const char *, int);
     3.9  
    3.10  #ifndef MB
    3.11  #define MB (1024*1024)
    3.12 @@ -135,5 +135,3 @@ extern struct ia64_pal_retval pal_emulat
    3.13  
    3.14  extern void build_pal_hypercall_bundles(unsigned long *imva, unsigned long brkimm, unsigned long hypnum);
    3.15  extern void build_hypercall_bundle(UINT64 *imva, UINT64 brkimm, UINT64 hypnum, UINT64 ret);
    3.16 -
    3.17 -