Re: [PATCH] check memory descriptor over lap in dom_fw_init() (was Re: [Xen-ia64-devel] [PATCH]Fix domain0 no VGA console bug.)
Hi Alex. You're right. It could be simplified. It had also a bug. The new patch is attached. please find it. Thanks. On Thu, Jun 01, 2006 at 01:19:02PM -0600, Alex Williamson wrote: Hi Isaku, I like this idea, this should really help creating dom0s with large memory (the swiotlb doesn't like it when we don't put any memory below 4GB). I'm having trouble with the loop below though, it seems overly complicated, but maybe I'm missing something important. We're just looking for gaps in the MDT above the hypercall areas, right? Could the original be simplified as something like this (untested): for (j = 0; j num_mds; j++) { efi_memory_desc_t* next_md; unsigned long end; md = efi_memmap[j]; end = md-phys_addr + (md-num_pages EFI_PAGE_SHIFT); if (maxmem start) break; // Avoid legacy low memory addresses and the // HYPERCALL patch area. if (md-phys_addr HYPERCALL_END) { BUG_ON(end HYPERCALL_START); continue; } if (j + 1 == num_mds end maxmem) { // End of list, map memory MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, end, maxmem, 0); continue; } next_md = efi_memmap[j + 1]; if (next_md-phys_addr end) { // Found a gap, insert memory. // Should we look for some minimum sized gap? MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, end, min(next_md-phys_addr, maxmem), 0); continue; } else if (next_md-phys_addr end) { // Bad, overlapping MDT ranges BUG_ON(next_md-phys_addr end); } } The MDT we're parsing is already sorted, so there's no reason to look further than j + 1 for the next gap. I'm not sure I follow all of the tests at the end of the original loop, but I think I've captured them above. Does this look right? Thanks, Alex On Thu, 2006-06-01 at 11:46 +0900, Isaku Yamahata wrote: +#ifdef CONFIG_XEN_IA64_DOM0_VP +// simple +// MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, +// HYPERCALL_END, maxmem, 0); +// is not good. Check overlap. +sort(efi_memmap, i, sizeof(efi_memory_desc_t), efi_mdt_cmp, NULL); + +num_mds = i; +for (j = 0; j num_mds; j++) { +unsigned long start; +unsigned long end; +unsigned long next_start; +int k; + +md = efi_memmap[j]; +start = md-phys_addr; +end = md-phys_addr + (md-num_pages EFI_PAGE_SHIFT); + +if (maxmem start) +break; + +// find gap +next_start = maxmem; +for (k = j + 1; k num_mds; k++) { +efi_memory_desc_t* next_md = efi_memmap[k]; + +if (end != next_md-phys_addr) { +next_start = next_md-phys_addr; +break; +} +end = next_md-phys_addr + +(next_md-num_pages EFI_PAGE_SHIFT); +} + +if (next_start HYPERCALL_END) +continue; + +if (end HYPERCALL_END) +end = HYPERCALL_END; +if (next_start maxmem) +next_start = maxmem; +MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, +end, next_start, 0); +} +#endif -- Alex Williamson HP Open Source Linux Org. ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel -- yamahata # HG changeset patch # User [EMAIL PROTECTED] # Node ID 8036118ac7265006f683c2ae20b92d722909d0e6 # Parent 25483d9b55d4307d125f4135b609a6387f247ba8 check memory descriptor over lap in dom_fw_init() and assign page to dom0 precisely. PATCHNAME: assign_page_to_dom0_precisely Signed-off-by: Isaku Yamahata [EMAIL PROTECTED] Signed-off-by: Alex Williamson [EMAIL PROTECTED] diff -r 25483d9b55d4 -r 8036118ac726 xen/arch/ia64/xen/dom_fw.c --- a/xen/arch/ia64/xen/dom_fw.cWed May 31 16:07:47 2006 -0600 +++ b/xen/arch/ia64/xen/dom_fw.cFri Jun 02 15:26:40 2006 +0900 @@ -3,6 +3,9 @@ * Copyright (C) 2004 Hewlett-Packard Co. * Dan Magenheimer ([EMAIL PROTECTED]) * + * Copyright (c) 2006 Isaku Yamahata yamahata at valinux co jp + *VA Linux Systems Japan K.K. + *dom0 vp model support */ #include xen/config.h @@ -782,6 +785,13 @@ efi_mdt_cmp(const
RE: [Xen-ia64-devel] [PATCH]Fix domain0 no VGA console bug.
Hi Alex, The updated patch should be happy for all platforms. If EFI doesn't provide md for range(0xa-0xc) to OS. It maybe a hole or occupied by legacy vga. Therefore, I used the efi_mmio function to check it. If these pages was not mapped yet and efi_mmio return true, we can map them as MMIO safely. BTW, this patch based on Yamahata's check memory descriptor overlap patch. Please give comments. :) Thanks -Xiantao -Original Message- From: Alex Williamson [mailto:[EMAIL PROTECTED] Sent: 2006年6月1日 10:11 To: Zhang, Xiantao Cc: xen-ia64-devel@lists.xensource.com Subject: RE: [Xen-ia64-devel] [PATCH]Fix domain0 no VGA console bug. On Thu, 2006-06-01 at 09:45 +0800, Zhang, Xiantao wrote: Hi Alex, We are using tiger4 platform. I didn't find md about space: 0xa-0xc in efi memmap, maybe it was assumed EFI_MEMORY_MAPPED_IO in native OS. But dom_fw_init shouldn't neglect it to set IO space according to MDs efi provides. Seems your platform has VGA console. So this patch can enable VGA console on all platforms explicitly, maybe as you said this step is better to do in dom_fw_init :) Hi Xiantao, One of my test systems has VGA, the other does not. We cannot assume VGA in the system. If the MDT on the tiger4 doesn't describe that range, then we probably need to at least revert to the test the Linux kernel uses and test whether that range has a WB memory attribute before assuming it's VGA. Also, try not to double map the range for platforms that do describe this as type EFI_MEMORY_MAPPED_IO. Thanks, Alex -- Alex Williamson HP Open Source Linux Org. xen0_console.patch Description: xen0_console.patch ---BeginMessage--- This patch tries to check MD's overlap and tries not to assign page to non conventional area. Maybe you may want to apply this patch before VGA-related modifications. On Wed, May 31, 2006 at 08:10:42PM -0600, Alex Williamson wrote: On Thu, 2006-06-01 at 09:45 +0800, Zhang, Xiantao wrote: Hi Alex, We are using tiger4 platform. I didn't find md about space: 0xa-0xc in efi memmap, maybe it was assumed EFI_MEMORY_MAPPED_IO in native OS. But dom_fw_init shouldn't neglect it to set IO space according to MDs efi provides. Seems your platform has VGA console. So this patch can enable VGA console on all platforms explicitly, maybe as you said this step is better to do in dom_fw_init :) Hi Xiantao, One of my test systems has VGA, the other does not. We cannot assume VGA in the system. If the MDT on the tiger4 doesn't describe that range, then we probably need to at least revert to the test the Linux kernel uses and test whether that range has a WB memory attribute before assuming it's VGA. Also, try not to double map the range for platforms that do describe this as type EFI_MEMORY_MAPPED_IO. Thanks, Alex -- Alex Williamson HP Open Source Linux Org. ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel -- yamahata # HG changeset patch # User [EMAIL PROTECTED] # Node ID e3e02e227b3e8d97537c38d5cdba9959bdd05d6a # Parent f6774d15d763fead75e6320e63fa1f14fabab26a check memory descriptor over lap in dom_fw_init() and assign page to dom0 precisely. PATCHNAME: assign_page_to_dom0_precisely Signed-off-by: Isaku Yamahata [EMAIL PROTECTED] diff -r f6774d15d763 -r e3e02e227b3e xen/arch/ia64/xen/dom_fw.c --- a/xen/arch/ia64/xen/dom_fw.cThu Jun 01 11:39:04 2006 +0900 +++ b/xen/arch/ia64/xen/dom_fw.cThu Jun 01 11:39:06 2006 +0900 @@ -1017,11 +1017,16 @@ dom_fw_init (struct domain *d, const cha /* simulate 1MB free memory at physical address zero */ MAKE_MD(EFI_LOADER_DATA,EFI_MEMORY_WB,0*MB,1*MB, 0);//XXX +#else +int num_mds; +int j; #endif /* hypercall patches live here, masquerade as reserved PAL memory */ MAKE_MD(EFI_PAL_CODE,EFI_MEMORY_WB|EFI_MEMORY_RUNTIME,HYPERCALL_START,HYPERCALL_END, 0); + + +#ifndef CONFIG_XEN_IA64_DOM0_VP MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,HYPERCALL_END,maxmem-IA64_GRANULE_SIZE, 0);//XXX make sure this doesn't overlap on i/o, runtime area. -#ifndef CONFIG_XEN_IA64_DOM0_VP /* hack */ MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,last_start,last_end,1); #endif @@ -1054,6 +1059,52 @@ dom_fw_init (struct domain *d, const cha dom_fw_dom0_passthrough, arg); } else MAKE_MD(EFI_RESERVED_TYPE,0,0,0,0); + +#ifdef CONFIG_XEN_IA64_DOM0_VP +// simple +// MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, +// HYPERCALL_END, maxmem, 0); +// is not good. Check overlap. +sort(efi_memmap, i, sizeof(efi_memory_desc_t), efi_mdt_cmp
Re: [PATCH] check memory descriptor over lap in dom_fw_init() (was Re: [Xen-ia64-devel] [PATCH]Fix domain0 no VGA console bug.)
Hi Isaku, I like this idea, this should really help creating dom0s with large memory (the swiotlb doesn't like it when we don't put any memory below 4GB). I'm having trouble with the loop below though, it seems overly complicated, but maybe I'm missing something important. We're just looking for gaps in the MDT above the hypercall areas, right? Could the original be simplified as something like this (untested): for (j = 0; j num_mds; j++) { efi_memory_desc_t* next_md; unsigned long end; md = efi_memmap[j]; end = md-phys_addr + (md-num_pages EFI_PAGE_SHIFT); if (maxmem start) break; // Avoid legacy low memory addresses and the // HYPERCALL patch area. if (md-phys_addr HYPERCALL_END) { BUG_ON(end HYPERCALL_START); continue; } if (j + 1 == num_mds end maxmem) { // End of list, map memory MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, end, maxmem, 0); continue; } next_md = efi_memmap[j + 1]; if (next_md-phys_addr end) { // Found a gap, insert memory. // Should we look for some minimum sized gap? MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, end, min(next_md-phys_addr, maxmem), 0); continue; } else if (next_md-phys_addr end) { // Bad, overlapping MDT ranges BUG_ON(next_md-phys_addr end); } } The MDT we're parsing is already sorted, so there's no reason to look further than j + 1 for the next gap. I'm not sure I follow all of the tests at the end of the original loop, but I think I've captured them above. Does this look right? Thanks, Alex On Thu, 2006-06-01 at 11:46 +0900, Isaku Yamahata wrote: +#ifdef CONFIG_XEN_IA64_DOM0_VP +// simple +// MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, +// HYPERCALL_END, maxmem, 0); +// is not good. Check overlap. +sort(efi_memmap, i, sizeof(efi_memory_desc_t), efi_mdt_cmp, NULL); + +num_mds = i; +for (j = 0; j num_mds; j++) { +unsigned long start; +unsigned long end; +unsigned long next_start; +int k; + +md = efi_memmap[j]; +start = md-phys_addr; +end = md-phys_addr + (md-num_pages EFI_PAGE_SHIFT); + +if (maxmem start) +break; + +// find gap +next_start = maxmem; +for (k = j + 1; k num_mds; k++) { +efi_memory_desc_t* next_md = efi_memmap[k]; + +if (end != next_md-phys_addr) { +next_start = next_md-phys_addr; +break; +} +end = next_md-phys_addr + +(next_md-num_pages EFI_PAGE_SHIFT); +} + +if (next_start HYPERCALL_END) +continue; + +if (end HYPERCALL_END) +end = HYPERCALL_END; +if (next_start maxmem) +next_start = maxmem; +MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, +end, next_start, 0); +} +#endif -- Alex Williamson HP Open Source Linux Org. ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel
RE: [Xen-ia64-devel] [PATCH]Fix domain0 no VGA console bug.
Hi Alex, We are using tiger4 platform. I didn't find md about space: 0xa-0xc in efi memmap, maybe it was assumed EFI_MEMORY_MAPPED_IO in native OS. But dom_fw_init shouldn't neglect it to set IO space according to MDs efi provides. Seems your platform has VGA console. So this patch can enable VGA console on all platforms explicitly, maybe as you said this step is better to do in dom_fw_init :) Thanks -Xiantao -Original Message- From: Alex Williamson [mailto:[EMAIL PROTECTED] Sent: 2006年5月31日 23:32 To: Zhang, Xiantao Cc: xen-ia64-devel@lists.xensource.com Subject: Re: [Xen-ia64-devel] [PATCH]Fix domain0 no VGA console bug. On Wed, 2006-05-31 at 20:30 +0800, Zhang, Xiantao wrote: After enabling dom0_vp mode, we lost domain0's VGA console, and we have to connect it through network or serial console. The reason is that VGA frame buffer(0xa-0xc) was set to conventional memory not IO in dom0's p2m table. Attached patch fixes it. Hi Xiantao, What about systems that don't have VGA? What memory type does your system report in the EFI MDT for address 0xA? I would expect EFI_MEMORY_MAPPED_IO, but if it's something else, it probably needs to be assigned a passthrough in dom_fw_init(). Thanks, Alex -- Alex Williamson HP Open Source Linux Org. ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel
RE: [Xen-ia64-devel] [PATCH]Fix domain0 no VGA console bug.
On Thu, 2006-06-01 at 09:45 +0800, Zhang, Xiantao wrote: Hi Alex, We are using tiger4 platform. I didn't find md about space: 0xa-0xc in efi memmap, maybe it was assumed EFI_MEMORY_MAPPED_IO in native OS. But dom_fw_init shouldn't neglect it to set IO space according to MDs efi provides. Seems your platform has VGA console. So this patch can enable VGA console on all platforms explicitly, maybe as you said this step is better to do in dom_fw_init :) Hi Xiantao, One of my test systems has VGA, the other does not. We cannot assume VGA in the system. If the MDT on the tiger4 doesn't describe that range, then we probably need to at least revert to the test the Linux kernel uses and test whether that range has a WB memory attribute before assuming it's VGA. Also, try not to double map the range for platforms that do describe this as type EFI_MEMORY_MAPPED_IO. Thanks, Alex -- Alex Williamson HP Open Source Linux Org. ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel
[PATCH] check memory descriptor over lap in dom_fw_init() (was Re: [Xen-ia64-devel] [PATCH]Fix domain0 no VGA console bug.)
This patch tries to check MD's overlap and tries not to assign page to non conventional area. Maybe you may want to apply this patch before VGA-related modifications. On Wed, May 31, 2006 at 08:10:42PM -0600, Alex Williamson wrote: On Thu, 2006-06-01 at 09:45 +0800, Zhang, Xiantao wrote: Hi Alex, We are using tiger4 platform. I didn't find md about space: 0xa-0xc in efi memmap, maybe it was assumed EFI_MEMORY_MAPPED_IO in native OS. But dom_fw_init shouldn't neglect it to set IO space according to MDs efi provides. Seems your platform has VGA console. So this patch can enable VGA console on all platforms explicitly, maybe as you said this step is better to do in dom_fw_init :) Hi Xiantao, One of my test systems has VGA, the other does not. We cannot assume VGA in the system. If the MDT on the tiger4 doesn't describe that range, then we probably need to at least revert to the test the Linux kernel uses and test whether that range has a WB memory attribute before assuming it's VGA. Also, try not to double map the range for platforms that do describe this as type EFI_MEMORY_MAPPED_IO. Thanks, Alex -- Alex Williamson HP Open Source Linux Org. ___ Xen-ia64-devel mailing list Xen-ia64-devel@lists.xensource.com http://lists.xensource.com/xen-ia64-devel -- yamahata # HG changeset patch # User [EMAIL PROTECTED] # Node ID e3e02e227b3e8d97537c38d5cdba9959bdd05d6a # Parent f6774d15d763fead75e6320e63fa1f14fabab26a check memory descriptor over lap in dom_fw_init() and assign page to dom0 precisely. PATCHNAME: assign_page_to_dom0_precisely Signed-off-by: Isaku Yamahata [EMAIL PROTECTED] diff -r f6774d15d763 -r e3e02e227b3e xen/arch/ia64/xen/dom_fw.c --- a/xen/arch/ia64/xen/dom_fw.cThu Jun 01 11:39:04 2006 +0900 +++ b/xen/arch/ia64/xen/dom_fw.cThu Jun 01 11:39:06 2006 +0900 @@ -1017,11 +1017,16 @@ dom_fw_init (struct domain *d, const cha /* simulate 1MB free memory at physical address zero */ MAKE_MD(EFI_LOADER_DATA,EFI_MEMORY_WB,0*MB,1*MB, 0);//XXX +#else +int num_mds; +int j; #endif /* hypercall patches live here, masquerade as reserved PAL memory */ MAKE_MD(EFI_PAL_CODE,EFI_MEMORY_WB|EFI_MEMORY_RUNTIME,HYPERCALL_START,HYPERCALL_END, 0); + + +#ifndef CONFIG_XEN_IA64_DOM0_VP MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,HYPERCALL_END,maxmem-IA64_GRANULE_SIZE, 0);//XXX make sure this doesn't overlap on i/o, runtime area. -#ifndef CONFIG_XEN_IA64_DOM0_VP /* hack */ MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,last_start,last_end,1); #endif @@ -1054,6 +1059,52 @@ dom_fw_init (struct domain *d, const cha dom_fw_dom0_passthrough, arg); } else MAKE_MD(EFI_RESERVED_TYPE,0,0,0,0); + +#ifdef CONFIG_XEN_IA64_DOM0_VP +// simple +// MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, +// HYPERCALL_END, maxmem, 0); +// is not good. Check overlap. +sort(efi_memmap, i, sizeof(efi_memory_desc_t), efi_mdt_cmp, NULL); + +num_mds = i; +for (j = 0; j num_mds; j++) { +unsigned long start; +unsigned long end; +unsigned long next_start; +int k; + +md = efi_memmap[j]; +start = md-phys_addr; +end = md-phys_addr + (md-num_pages EFI_PAGE_SHIFT); + +if (maxmem start) +break; + +// find gap +next_start = maxmem; +for (k = j + 1; k num_mds; k++) { +efi_memory_desc_t* next_md = efi_memmap[k]; + +if (end != next_md-phys_addr) { +next_start = next_md-phys_addr; +break; +} +end = next_md-phys_addr + +(next_md-num_pages EFI_PAGE_SHIFT); +} + +if (next_start HYPERCALL_END) +continue; + +if (end HYPERCALL_END) +end = HYPERCALL_END; +if (next_start maxmem) +next_start = maxmem; +MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, +end, next_start, 0); +} +#endif } else { #ifndef CONFIG_XEN_IA64_DOM0_VP @@ -1084,11 +1135,45 @@ dom_fw_init (struct domain *d, const cha bp-console_info.orig_y = 24; bp-fpswa = dom_pa((unsigned long) fpswa_inf); if (d == dom0) { +int j; +u64 addr; + // XXX CONFIG_XEN_IA64_DOM0_VP - // initrd_start address is hard coded in start_kernel() + // initrd_start address is hard coded in construct_dom0() bp-initrd_start = (dom0_start+dom0_size) -