direct-io.hg

changeset 8419:545ba1b126ca

Important domU/vbd fix. Reserve top granule of machine memory for dom0.
author djm@kirby.fc.hp.com
date Tue Dec 20 14:11:17 2005 -0600 (2005-12-20)
parents 9a72d15cc3a5
children 72f51528d55a
files xen/arch/ia64/xen/dom_fw.c xen/arch/ia64/xen/xensetup.c
line diff
     1.1 --- a/xen/arch/ia64/xen/dom_fw.c	Mon Dec 19 15:18:54 2005 -0600
     1.2 +++ b/xen/arch/ia64/xen/dom_fw.c	Tue Dec 20 14:11:17 2005 -0600
     1.3 @@ -13,6 +13,7 @@
     1.4  #include <asm/io.h>
     1.5  #include <asm/pal.h>
     1.6  #include <asm/sal.h>
     1.7 +#include <asm/meminit.h>
     1.8  #include <xen/compile.h>
     1.9  #include <xen/acpi.h>
    1.10  
    1.11 @@ -95,12 +96,7 @@ unsigned long dom_fw_setup(struct domain
    1.12  #define MB	(1024*1024UL)
    1.13  
    1.14  #define NUM_EFI_SYS_TABLES 6
    1.15 -#define PASS_THRU_IOPORT_SPACE
    1.16 -#ifdef PASS_THRU_IOPORT_SPACE
    1.17 -# define NUM_MEM_DESCS	4
    1.18 -#else
    1.19 -# define NUM_MEM_DESCS	3
    1.20 -#endif
    1.21 +# define NUM_MEM_DESCS	5
    1.22  
    1.23  
    1.24  #define SECS_PER_HOUR   (60 * 60)
    1.25 @@ -806,30 +802,53 @@ dom_fw_init (struct domain *d, char *arg
    1.26  
    1.27  	sal_systab->checksum = -checksum;
    1.28  
    1.29 -	/* simulate 1MB free memory at physical address zero */
    1.30  	i = 0;
    1.31 -	MAKE_MD(EFI_BOOT_SERVICES_DATA,EFI_MEMORY_WB,0*MB,1*MB, 0);
    1.32 -	/* hypercall patches live here, masquerade as reserved PAL memory */
    1.33 -	MAKE_MD(EFI_PAL_CODE,EFI_MEMORY_WB,HYPERCALL_START,HYPERCALL_END, 0);
    1.34 -	MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,HYPERCALL_END,maxmem, 0);
    1.35 -#ifdef PASS_THRU_IOPORT_SPACE
    1.36 -	if (d == dom0 && !running_on_sim) {
    1.37 +	if (d == dom0) {
    1.38 +		/*
    1.39 +		 * This is a bad hack.  Dom0 may share other domains' memory
    1.40 +		 * through a dom0 physical address.  Unfortunately, this
    1.41 +		 * address may be used in phys_to_page (e.g. in the loopback
    1.42 +		 * driver) but when Linux initializes memory it only creates
    1.43 +		 * page structs for the physical memory it knows about.  And
    1.44 +		 * on ia64, only for full writeback granules.  So, we reserve
    1.45 +		 * the last full granule of Xen's memory for dom0 (in
    1.46 +		 * start_kernel) to ensure dom0 creates a large enough memmap
    1.47 +		 */
    1.48 +		unsigned long last_start = max_page << PAGE_SHIFT;
    1.49 +		unsigned long last_end = last_start + IA64_GRANULE_SIZE;
    1.50 +
    1.51 +		/* simulate 1MB free memory at physical address zero */
    1.52 +		MAKE_MD(EFI_LOADER_DATA,EFI_MEMORY_WB,0*MB,1*MB, 0);
    1.53 +		/* hypercall patches live here, masquerade as reserved PAL memory */
    1.54 +		MAKE_MD(EFI_PAL_CODE,EFI_MEMORY_WB,HYPERCALL_START,HYPERCALL_END, 0);
    1.55 +		MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,HYPERCALL_END,maxmem-IA64_GRANULE_SIZE, 0);
    1.56 +/* hack */	MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,last_start,last_end,1);
    1.57 +
    1.58  		/* pass through the I/O port space */
    1.59 -		efi_memory_desc_t *efi_get_io_md(void);
    1.60 -		efi_memory_desc_t *ia64_efi_io_md = efi_get_io_md();
    1.61 -		u32 type;
    1.62 -		u64 iostart, ioend, ioattr;
    1.63 -		
    1.64 -		type = ia64_efi_io_md->type;
    1.65 -		iostart = ia64_efi_io_md->phys_addr;
    1.66 -		ioend = ia64_efi_io_md->phys_addr +
    1.67 -			(ia64_efi_io_md->num_pages << 12);
    1.68 -		ioattr = ia64_efi_io_md->attribute;
    1.69 -		MAKE_MD(type,ioattr,iostart,ioend, 1);
    1.70 +		if (!running_on_sim) {
    1.71 +			efi_memory_desc_t *efi_get_io_md(void);
    1.72 +			efi_memory_desc_t *ia64_efi_io_md;
    1.73 +			u32 type;
    1.74 +			u64 iostart, ioend, ioattr;
    1.75 +
    1.76 +			ia64_efi_io_md = efi_get_io_md();
    1.77 +			type = ia64_efi_io_md->type;
    1.78 +			iostart = ia64_efi_io_md->phys_addr;
    1.79 +			ioend = ia64_efi_io_md->phys_addr +
    1.80 +				(ia64_efi_io_md->num_pages << 12);
    1.81 +			ioattr = ia64_efi_io_md->attribute;
    1.82 +			MAKE_MD(type,ioattr,iostart,ioend, 1);
    1.83 +		}
    1.84 +		else MAKE_MD(EFI_RESERVED_TYPE,0,0,0,0);
    1.85  	}
    1.86 -	else
    1.87 +	else {
    1.88 +		MAKE_MD(EFI_LOADER_DATA,EFI_MEMORY_WB,0*MB,1*MB, 1);
    1.89 +		/* hypercall patches live here, masquerade as reserved PAL memory */
    1.90 +		MAKE_MD(EFI_PAL_CODE,EFI_MEMORY_WB,HYPERCALL_START,HYPERCALL_END, 1);
    1.91 +		MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,HYPERCALL_END,maxmem, 1);
    1.92  		MAKE_MD(EFI_RESERVED_TYPE,0,0,0,0);
    1.93 -#endif
    1.94 +		MAKE_MD(EFI_RESERVED_TYPE,0,0,0,0);
    1.95 +	}
    1.96  
    1.97  	bp->efi_systab = dom_pa(fw_mem);
    1.98  	bp->efi_memmap = dom_pa(efi_memmap);
     2.1 --- a/xen/arch/ia64/xen/xensetup.c	Mon Dec 19 15:18:54 2005 -0600
     2.2 +++ b/xen/arch/ia64/xen/xensetup.c	Tue Dec 20 14:11:17 2005 -0600
     2.3 @@ -247,6 +247,11 @@ void start_kernel(void)
     2.4      max_page = 0;
     2.5      efi_memmap_walk(find_max_pfn, &max_page);
     2.6      printf("find_memory: efi_memmap_walk returns max_page=%lx\n",max_page);
     2.7 +    /* this is a bad hack.  see dom_fw.c creation of EFI map for dom0 */
     2.8 +    max_page = (GRANULEROUNDDOWN(max_page << PAGE_SHIFT)
     2.9 +	- IA64_GRANULE_SIZE) >> PAGE_SHIFT;
    2.10 +    printf("find_memory: last granule reserved for dom0; xen max_page=%lx\n",
    2.11 +	max_page);
    2.12  
    2.13      heap_start = memguard_init(ia64_imva(&_end));
    2.14      printf("Before heap_start: 0x%lx\n", heap_start);