direct-io.hg

changeset 10416:0f3bd7d23737

[IA64] cleanup in domain.c

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Thu Jun 15 09:47:19 2006 -0600 (2006-06-15)
parents 511ced948390
children 75f791c710df
files xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/irq.c xen/include/asm-ia64/domain.h
line diff
     1.1 --- a/xen/arch/ia64/xen/domain.c	Thu Jun 15 09:10:14 2006 -0600
     1.2 +++ b/xen/arch/ia64/xen/domain.c	Thu Jun 15 09:47:19 2006 -0600
     1.3 @@ -70,14 +70,10 @@ unsigned long dom0_align = 64*1024*1024;
     1.4  static unsigned int dom0_max_vcpus = 1;
     1.5  integer_param("dom0_max_vcpus", dom0_max_vcpus); 
     1.6  
     1.7 -// initialized by arch/ia64/setup.c:find_initrd()
     1.8 -unsigned long initrd_start = 0, initrd_end = 0;
     1.9  extern unsigned long running_on_sim;
    1.10  
    1.11  extern char dom0_command_line[];
    1.12  
    1.13 -#define IS_XEN_ADDRESS(d,a) ((a >= d->xen_vastart) && (a <= d->xen_vaend))
    1.14 -
    1.15  /* FIXME: where these declarations should be there ? */
    1.16  extern void serial_input_init(void);
    1.17  static void init_switch_stack(struct vcpu *v);
    1.18 @@ -308,8 +304,6 @@ static void init_switch_stack(struct vcp
    1.19  int arch_domain_create(struct domain *d)
    1.20  {
    1.21  	// the following will eventually need to be negotiated dynamically
    1.22 -	d->xen_vastart = XEN_START_ADDR;
    1.23 -	d->xen_vaend = XEN_END_ADDR;
    1.24  	d->arch.shared_info_va = SHAREDINFO_ADDR;
    1.25  	d->arch.breakimm = 0x1000;
    1.26  	seqlock_init(&d->arch.vtlb_lock);
    1.27 @@ -538,40 +532,20 @@ int elf_sanity_check(Elf_Ehdr *ehdr)
    1.28  	return 1;
    1.29  }
    1.30  
    1.31 -static void copy_memory(void *dst, void *src, int size)
    1.32 -{
    1.33 -	int remain;
    1.34 -
    1.35 -	if (IS_XEN_ADDRESS(dom0,(unsigned long) src)) {
    1.36 -		memcpy(dst,src,size);
    1.37 -	}
    1.38 -	else {
    1.39 -		printf("About to call __copy_from_user(%p,%p,%d)\n",
    1.40 -			dst,src,size);
    1.41 -		while ((remain = __copy_from_user(dst,src,size)) != 0) {
    1.42 -			printf("incomplete user copy, %d remain of %d\n",
    1.43 -				remain,size);
    1.44 -			dst += size - remain; src += size - remain;
    1.45 -			size -= remain;
    1.46 -		}
    1.47 -	}
    1.48 -}
    1.49 -
    1.50  static void loaddomainelfimage(struct domain *d, unsigned long image_start)
    1.51  {
    1.52  	char *elfbase = (char *) image_start;
    1.53 -	//Elf_Ehdr *ehdr = (Elf_Ehdr *)image_start;
    1.54  	Elf_Ehdr ehdr;
    1.55  	Elf_Phdr phdr;
    1.56  	int h, filesz, memsz;
    1.57  	unsigned long elfaddr, dom_mpaddr, dom_imva;
    1.58  	struct page_info *p;
    1.59    
    1.60 -	copy_memory(&ehdr, (void *) image_start, sizeof(Elf_Ehdr));
    1.61 +	memcpy(&ehdr, (void *) image_start, sizeof(Elf_Ehdr));
    1.62  	for ( h = 0; h < ehdr.e_phnum; h++ ) {
    1.63 -		copy_memory(&phdr,
    1.64 -			    elfbase + ehdr.e_phoff + (h*ehdr.e_phentsize),
    1.65 -			    sizeof(Elf_Phdr));
    1.66 +		memcpy(&phdr,
    1.67 +		       elfbase + ehdr.e_phoff + (h*ehdr.e_phentsize),
    1.68 +		       sizeof(Elf_Phdr));
    1.69  		if ((phdr.p_type != PT_LOAD))
    1.70  		    continue;
    1.71  
    1.72 @@ -586,7 +560,7 @@ static void loaddomainelfimage(struct do
    1.73  			if (dom_mpaddr+memsz>dom0_size)
    1.74  				panic("Dom0 doesn't fit in memory space!\n");
    1.75  			dom_imva = __va_ul(dom_mpaddr + dom0_start);
    1.76 -			copy_memory((void *)dom_imva, (void *)elfaddr, filesz);
    1.77 +			memcpy((void *)dom_imva, (void *)elfaddr, filesz);
    1.78  			if (memsz > filesz)
    1.79  				memset((void *)dom_imva+filesz, 0,
    1.80  				       memsz-filesz);
    1.81 @@ -604,13 +578,13 @@ static void loaddomainelfimage(struct do
    1.82  			dom_imva = __va_ul(page_to_maddr(p));
    1.83  			if (filesz > 0) {
    1.84  				if (filesz >= PAGE_SIZE)
    1.85 -					copy_memory((void *) dom_imva,
    1.86 -						    (void *) elfaddr,
    1.87 -						    PAGE_SIZE);
    1.88 +					memcpy((void *) dom_imva,
    1.89 +					       (void *) elfaddr,
    1.90 +					       PAGE_SIZE);
    1.91  				else {
    1.92  					// copy partial page
    1.93 -					copy_memory((void *) dom_imva,
    1.94 -						    (void *) elfaddr, filesz);
    1.95 +					memcpy((void *) dom_imva,
    1.96 +					       (void *) elfaddr, filesz);
    1.97  					// zero the rest of page
    1.98  					memset((void *) dom_imva+filesz, 0,
    1.99  					       PAGE_SIZE-filesz);
   1.100 @@ -636,6 +610,29 @@ static void loaddomainelfimage(struct do
   1.101  
   1.102  void alloc_dom0(void)
   1.103  {
   1.104 +	/* Check dom0 size.  */
   1.105 +	if (dom0_size < 4 * 1024 * 1024) {
   1.106 +		panic("dom0_mem is too small, boot aborted"
   1.107 +			" (try e.g. dom0_mem=256M or dom0_mem=65536K)\n");
   1.108 +	}
   1.109 +
   1.110 +	/* Check dom0 align.  */
   1.111 +	if ((dom0_align - 1) & dom0_align) { /* not a power of two */
   1.112 +		panic("dom0_align (%lx) must be power of two, boot aborted"
   1.113 +		      " (try e.g. dom0_align=256M or dom0_align=65536K)\n",
   1.114 +		      dom0_align);
   1.115 +	}
   1.116 +	if (dom0_align < PAGE_SIZE) {
   1.117 +		panic("dom0_align must be >= %ld, boot aborted"
   1.118 +		      " (try e.g. dom0_align=256M or dom0_align=65536K)\n",
   1.119 +		      PAGE_SIZE);
   1.120 +	}
   1.121 +	if (dom0_size % dom0_align) {
   1.122 +		dom0_size = (dom0_size / dom0_align + 1) * dom0_align;
   1.123 +		printf("dom0_size rounded up to %ld, due to dom0_align=%lx\n",
   1.124 +		     dom0_size,dom0_align);
   1.125 +	}
   1.126 +
   1.127  	if (running_on_sim) {
   1.128  		dom0_size = 128*1024*1024; //FIXME: Should be configurable
   1.129  	}
   1.130 @@ -677,7 +674,6 @@ static void physdev_init_dom0(struct dom
   1.131  		BUG();
   1.132  }
   1.133  
   1.134 -static unsigned int vmx_dom0 = 0;
   1.135  int construct_dom0(struct domain *d, 
   1.136  	               unsigned long image_start, unsigned long image_len, 
   1.137  	               unsigned long initrd_start, unsigned long initrd_len,
   1.138 @@ -700,6 +696,7 @@ int construct_dom0(struct domain *d,
   1.139  	struct page_info *start_info_page;
   1.140  
   1.141  #ifdef VALIDATE_VT
   1.142 +	unsigned int vmx_dom0 = 0;
   1.143  	unsigned long mfn;
   1.144  	struct page_info *page = NULL;
   1.145  #endif
   1.146 @@ -862,12 +859,15 @@ int construct_dom0(struct domain *d,
   1.147  	if (cmdline != NULL)
   1.148  	    console_endboot(strstr(cmdline, "tty0") != NULL);
   1.149  
   1.150 +	printk("Dom0: 0x%lx\n", (u64)dom0);
   1.151 +
   1.152 +#ifdef VALIDATE_VT
   1.153  	/* VMX specific construction for Dom0, if hardware supports VMX
   1.154  	 * and Dom0 is unmodified image
   1.155  	 */
   1.156 -	printk("Dom0: 0x%lx, domain: 0x%lx\n", (u64)dom0, (u64)d);
   1.157  	if (vmx_dom0)
   1.158  	    vmx_final_setup_guest(v);
   1.159 +#endif
   1.160  
   1.161  	set_bit(_VCPUF_initialised, &v->vcpu_flags);
   1.162  
   1.163 @@ -910,11 +910,6 @@ void dummy_called(char *function)
   1.164  	while(1);
   1.165  }
   1.166  
   1.167 -void domain_pend_keyboard_interrupt(int irq)
   1.168 -{
   1.169 -	vcpu_pend_interrupt(dom0->vcpu[0],irq);
   1.170 -}
   1.171 -
   1.172  void sync_vcpu_execstate(struct vcpu *v)
   1.173  {
   1.174  //	__ia64_save_fpu(v->arch._thread.fph);
   1.175 @@ -923,53 +918,15 @@ void sync_vcpu_execstate(struct vcpu *v)
   1.176  	// FIXME SMP: Anything else needed here for SMP?
   1.177  }
   1.178  
   1.179 -// FIXME: It would be nice to print out a nice error message for bad
   1.180 -//  values of these boot-time parameters, but it seems we are too early
   1.181 -//  in the boot and attempts to print freeze the system?
   1.182 -#define abort(x...) do {} while(0)
   1.183 -#define warn(x...) do {} while(0)
   1.184 -
   1.185  static void parse_dom0_mem(char *s)
   1.186  {
   1.187 -	unsigned long bytes = parse_size_and_unit(s);
   1.188 -
   1.189 -	if (dom0_size < 4 * 1024 * 1024) {
   1.190 -		abort("parse_dom0_mem: too small, boot aborted"
   1.191 -			" (try e.g. dom0_mem=256M or dom0_mem=65536K)\n");
   1.192 -	}
   1.193 -	if (dom0_size % dom0_align) {
   1.194 -		dom0_size = ((dom0_size / dom0_align) + 1) * dom0_align;
   1.195 -		warn("parse_dom0_mem: dom0_size rounded up from"
   1.196 -			" %lx to %lx bytes, due to dom0_align=%lx\n",
   1.197 -			bytes,dom0_size,dom0_align);
   1.198 -	}
   1.199 -	else dom0_size = bytes;
   1.200 +	dom0_size = parse_size_and_unit(s);
   1.201  }
   1.202  custom_param("dom0_mem", parse_dom0_mem);
   1.203  
   1.204  
   1.205  static void parse_dom0_align(char *s)
   1.206  {
   1.207 -	unsigned long bytes = parse_size_and_unit(s);
   1.208 -
   1.209 -	if ((bytes - 1) ^ bytes) { /* not a power of two */
   1.210 -		abort("parse_dom0_align: dom0_align must be power of two, "
   1.211 -			"boot aborted"
   1.212 -			" (try e.g. dom0_align=256M or dom0_align=65536K)\n");
   1.213 -	}
   1.214 -	else if (bytes < PAGE_SIZE) {
   1.215 -		abort("parse_dom0_align: dom0_align must be >= %ld, "
   1.216 -			"boot aborted"
   1.217 -			" (try e.g. dom0_align=256M or dom0_align=65536K)\n",
   1.218 -			PAGE_SIZE);
   1.219 -	}
   1.220 -	else dom0_align = bytes;
   1.221 -	if (dom0_size % dom0_align) {
   1.222 -		dom0_size = (dom0_size / dom0_align + 1) * dom0_align;
   1.223 -		warn("parse_dom0_align: dom0_size rounded up from"
   1.224 -			" %ld to %ld bytes, due to dom0_align=%lx\n",
   1.225 -			bytes,dom0_size,dom0_align);
   1.226 -	}
   1.227 +	dom0_align = parse_size_and_unit(s);
   1.228  }
   1.229  custom_param("dom0_align", parse_dom0_align);
   1.230 -
     2.1 --- a/xen/arch/ia64/xen/irq.c	Thu Jun 15 09:10:14 2006 -0600
     2.2 +++ b/xen/arch/ia64/xen/irq.c	Thu Jun 15 09:47:19 2006 -0600
     2.3 @@ -618,10 +618,9 @@ void process_soft_irq(void)
     2.4  }
     2.5  
     2.6  // this is a temporary hack until real console input is implemented
     2.7 -extern void domain_pend_keyboard_interrupt(int irq);
     2.8  void guest_forward_keyboard_input(int irq, void *nada, struct pt_regs *regs)
     2.9  {
    2.10 -	domain_pend_keyboard_interrupt(irq);
    2.11 +	vcpu_pend_interrupt(dom0->vcpu[0],irq);
    2.12  }
    2.13  
    2.14  void serial_input_init(void)
     3.1 --- a/xen/include/asm-ia64/domain.h	Thu Jun 15 09:10:14 2006 -0600
     3.2 +++ b/xen/include/asm-ia64/domain.h	Thu Jun 15 09:47:19 2006 -0600
     3.3 @@ -64,8 +64,6 @@ struct arch_domain {
     3.4      /* SAL return point.  */
     3.5      unsigned long sal_return_addr;
     3.6  
     3.7 -    u64 xen_vastart;
     3.8 -    u64 xen_vaend;
     3.9      u64 shared_info_va;
    3.10      unsigned long initrd_start;
    3.11      unsigned long initrd_len;
    3.12 @@ -80,8 +78,6 @@ struct arch_domain {
    3.13      // protect v->itlb, v->dtlb and vhpt
    3.14      seqlock_t   vtlb_lock ____cacheline_aligned_in_smp;
    3.15  };
    3.16 -#define xen_vastart arch.xen_vastart
    3.17 -#define xen_vaend arch.xen_vaend
    3.18  #define INT_ENABLE_OFFSET(v) 		  \
    3.19      (sizeof(vcpu_info_t) * (v)->vcpu_id + \
    3.20      offsetof(vcpu_info_t, evtchn_upcall_mask))