new domain builder breaks compatibility
To quote xen.h:
495 * 9. There is guaranteed to be at least 512kB padding after the final 496 * bootstrap element. If necessary, the bootstrap virtual region is 497 * extended by an extra 4MB to ensure this.
The new domain builder forgot this:
763 if (dom->alloc_bootstack)
764 dom->bootstack_pfn = xc_dom_alloc_page(dom, "boot stack");
765 xc_dom_printf("%-20s: virt_alloc_end : 0x%" PRIx64 "\n",
766 __FUNCTION__, dom->virt_alloc_end);
which, predictably enough, breaks Solaris, which tries to use this area as ecratch memory during early boot.
regards
john
Quoted 8 lines · John Levon
To quote
xen.h:495 * 9. There is guaranteed to be at least 512kB padding after the final 496 * bootstrap element. If necessary, the bootstrap virtual region is 497 * extended by an extra 4MB to ensure this.which, predictably enough, breaks Solaris, which tries to use this area as ecratch memory during early boot.
The attached patch should fix this.
cheers,
Gerd
Signature · 1 line
Gerd Hoffmann <[email protected]>
libxc/xc_dom_x86.c renamed from libxc/xc_dom_x86.c~ +1 -0
@@ -66,6 +66,7 @@ extra_pages = dom->alloc_bootstack ?1 :0 ; extra_pages += dom->extra_pages; + extra_pages +=128 ;/* 512kB padding */ pages = extra_pages;for (;;) {
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 11 lines · Gerd Hoffmann
Quoted 8 lines · John Levon
To quote
xen.h:495 * 9. There is guaranteed to be at least 512kB padding after the final 496 * bootstrap element. If necessary, the bootstrap virtual region is 497 * extended by an extra 4MB to ensure this.which, predictably enough, breaks Solaris, which tries to use this area as ecratch memory during early boot.
The attached patch should fix this.
Does that ensure the 4Mb alignment too? We're expecting:
scratch_end = RNDUP((paddr_t)scratch_start + 512 * 1024, FOUR_MEG);
BTW what is dom->extra_pages intended for?
thanks,
john
Quoted 5 lines · John Levon
Quoted 3 lines · Gerd Hoffmann
Quoted 2 lines · John Levon
To quote
xen.h:
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
495 * 9. There is guaranteed to be at least 512kB padding after the final 496 * bootstrap element. If necessary, the bootstrap virtual region is 497 * extended by an extra 4MB to ensure this.which, predictably enough, breaks Solaris, which tries to use this area as ecratch memory during early boot.
The attached patch should fix this.
Does that ensure the 4Mb alignment too?
Yes. Uhm, no, depends. It completely fills the topmost L1 pagetable with entries, so you end up with an 4MB alignment for 32bit and 2MB alignment for PAE and 64bit. I think the old builder had the same behaviour, so the 4MB are actually a documentation bug ;)
Quoted 1 line
BTW what is
dom->extra_pagesintended for?
Allows allocation of some extra space. Used by the kexec bits I have in the queue, it places some code which finishes the memory layout before jumping to the new kernel entry point above the boot stack, so it needs some way to reserve memory there.
cheers,
Gerd
Signature · 1 line
Gerd Hoffmann <[email protected]>
Quoted 6 lines · Gerd Hoffmann
Quoted 1 line
Does that ensure the 4Mb alignment too?
Yes. Uhm, no, depends. It completely fills the topmost L1 pagetable with entries, so you end up with an 4MB alignment for 32bit and 2MB alignment for PAE and 64bit. I think the old builder had the same behaviour, so the 4MB are actually a documentation bug ;)
Hmm... am I misunderstanding this code:
816 /* v_end = (vstack_end + (1UL<<22)-1) & ~((1UL<<22)-1); */ 817 v_end = vstack_end; 818 if ( !increment_ulong(&v_end, (1UL<<22)-1) )
819 goto error_out;
820 v_end &= ~((1UL<<22)-1);
821
822 if ( (v_end - vstack_end) < (512UL << 10) )
823 {
824 /* Add extra 4MB to get >= 512kB padding. */
825 if ( !increment_ulong(&v_end, 1UL << 22) )
826 goto error_out;
827 }
Surely that guarantees we get at least 512Kb and it ends on a 4Mb boundary?
regards
john
Quoted 9 lines · John Levon
On Thu, Feb 01, 2007 at 04:15:16PM +0100, Gerd Hoffmann wrote:
Hmm... am I misunderstanding this code:822 if ( (
v_end-vstack_end) < (512UL << 10) )
823 {
824 /* Add extra 4MB to get >= 512kB padding. */
825 if ( !increment_ulong(&v_end, 1UL << 22) )
826 gotoerror_out;
827 }
No, you are right, it's 4MB unconditionally. Seems to have changed though since I checked last time.
Quoted 2 lines
Surely that guarantees we get at least 512Kb and it ends on a 4Mb boundary?
Yep. Is the 2MB alignment ok for Solaris? You can depend on the 512kb only anyway, so the alignment shouldn't matter much ...
cheers,
Gerd
Signature · 1 line
Gerd Hoffmann <[email protected]>
Quoted 7 lines · Gerd Hoffmann
Quoted 6 lines
822 if ( (
v_end-vstack_end) < (512UL << 10) )
823 {
824 /* Add extra 4MB to get >= 512kB padding. */
825 if ( !increment_ulong(&v_end, 1UL << 22) )
826 gotoerror_out;
827 }
Quoted 8 lines
No, you are right, it's 4MB unconditionally. Seems to have changed though since I checked last time.
Quoted 2 lines
Surely that guarantees we get at least 512Kb and it ends on a 4Mb boundary?
Yep. Is the 2MB alignment ok for Solaris? You can depend on the 512kb only anyway, so the alignment shouldn't matter much ...
I think we could probably make it 2Mb. I'll test it out with your patch. I don't see a reason why it would fail on 3.0.3 or 3.0.4 anyway.
regards
john
libxc/xc_dom_x86.c line 69
Quoted 7 lines · Gerd Hoffmann
libxc/xc_dom_x86.c renamed from libxc/xc_dom_x86.c~ +1
-0@@ -66,6 +66,7 @@ extra_pages = dom->alloc_bootstack ?1 :0 ; extra_pages += dom->extra_pages; + extra_pages +=128 ;/* 512kB padding */
I've tested this along with a kernel change to only assume 2Mb alignment, and it works on PAE and 64-bit now. Could you send a patch upstream please? And update xen.h to clarify things?
thanks,
john
Quoted 11 lines · John Levon
libxc/xc_dom_x86.c 2007-02-01 10:02:08.000000000 +0100 line 69
Quoted 7 lines
libxc/xc_dom_x86.c 2007-02-01 10:02:08.000000000 +0100 renamed from libxc/xc_dom_x86.c~ 2007-01-31 18:07:56.000000000 +0100 +1
-0@@ -66,6 +66,7 @@ extra_pages = dom->alloc_bootstack ? 1 : 0; extra_pages += dom->extra_pages; + extra_pages += 128; /* 512kB padding */I've tested this along with a kernel change to only assume 2Mb alignment, and it works on PAE and 64-bit now. Could you send a patch upstream please? And update
xen.hto clarify things?
I'll handle this and update xen.h.
Thanks,
Keir
Quoted 6 lines · Keir Fraser
Quoted 4 lines · John Levon
Quoted 4 lines
libxc/xc_dom_x86.c 2007-02-01 10:02:08.000000000 +0100 renamed from libxc/xc_dom_x86.c~ 2007-01-31 18:07:56.000000000 +0100 +0
-0@@ -66,6 +66,7 @@
Quoted 8 lines
Quoted 6 lines
libxc/xc_dom_x86.c 2007-02-01 10:02:08.000000000 +0100 line 69
Quoted 3 lines
libxc/xc_dom_x86.c 2007-02-01 10:02:08.000000000 +0100 renamed from libxc/xc_dom_x86.c~ 2007-01-31 18:07:56.000000000 +0100 +1
-0extra_pages = dom->alloc_bootstack ? 1 : 0; extra_pages += dom->extra_pages; + extra_pages += 128; /* 512kB padding */I've tested this along with a kernel change to only assume 2Mb alignment, and it works on PAE and 64-bit now. Could you send a patch upstream please? And update
xen.hto clarify things?I'll handle this and update
xen.h.
Restoring the 4MB alignment is easy too, see attached patch (which also fixes the 4MB alignment for virt_base).
cheers,
Gerd
Signature · 1 line
Gerd Hoffmann <[email protected]>
--- tools/libxc/xc_dom_x86.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/libxc/xc_dom_x86.c +5 -1
@@ -66,11 +66,12 @@ static int count_pgtables(struct xc_dom_ extra_pages = dom->alloc_bootstack ?1 :0 ; extra_pages += dom->extra_pages; + extra_pages +=128 ;/* 512kB padding */ pages = extra_pages;for (;;) { try_virt_end =round_up (dom->virt_alloc_end + pages *PAGE_SIZE_X86 , -bits_to_mask (l1_bits)); +bits_to_mask (22 ));/* 4MB alignment */ dom->pg_l4 =nr_page_tables (dom->parms.virt_base, try_virt_end, l4_bits); dom->pg_l3 =
@@ -313,6 +314,9 @@ static int alloc_magic_pages(struct xc_dif (xc_dom_feature_translated (dom)) dom->shared_info_pfn =xc_dom_alloc_page (dom,"shared info" ); dom->alloc_bootstack =1 ; + +/* 4MB align start address */ + dom->parms.virt_base &= ~(((uint64_t )1 <<22 )-1 );return 0 ; }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 4 lines · Gerd Hoffmann
Quoted 1 line
I'll handle this and update
xen.h.Restoring the 4MB alignment is easy too, see attached patch (which also fixes the 4MB alignment for
virt_base).
I suppose it is nice to stick with the guarantees described in xen.h, since it is so easy to do so.
-- Keir
Quoted 8 lines · Keir Fraser
Quoted 3 lines · Gerd Hoffmann
Quoted 1 line
I'll handle this and update
xen.h.Restoring the 4MB alignment is easy too, see attached patch (which also fixes the 4MB alignment for
virt_base).I suppose it is nice to stick with the guarantees described in
xen.h, since it is so easy to do so.
Slightly updated version of the patch, the previous one did fixup virt_base too late. This one should work in theory. It's not really tested though, the VIRT_BASE specified by linux kernels is at a 4MB border anyway, so the fixup is a no-op ...
cheers,
Gerd
Signature · 1 line
Gerd Hoffmann <[email protected]>
--- tools/libxc/xc_dom_core.c | 3 +++ tools/libxc/xc_dom_x86.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-)
tools/libxc/xc_dom_x86.c +3 -1
@@ -66,11 +66,12 @@ static int count_pgtables(struct xc_dom_ extra_pages = dom->alloc_bootstack ?1 :0 ; extra_pages += dom->extra_pages; + extra_pages +=128 ;/* 512kB padding */ pages = extra_pages;for (;;) { try_virt_end =round_up (dom->virt_alloc_end + pages *PAGE_SIZE_X86 , -bits_to_mask (l1_bits)); +bits_to_mask (22 ));/* 4MB alignment */ dom->pg_l4 =nr_page_tables (dom->parms.virt_base, try_virt_end, l4_bits); dom->pg_l3 =
@@ -313,6 +314,7 @@ static int alloc_magic_pages(struct xc_dif (xc_dom_feature_translated (dom)) dom->shared_info_pfn =xc_dom_alloc_page (dom,"shared info" ); dom->alloc_bootstack =1 ; +return 0 ; }
tools/libxc/xc_dom_core.c +3 -0
@@ -717,6 +717,9 @@ int xc_dom_build_image(struct xc_dom_ima } page_size =XC_DOM_PAGE_SIZE (dom); +/* 4MB align virtual base address */ + dom->parms.virt_base &= ~(((uint64_t )1 <<22 )-1 ); +/* load kernel */ if (0 != xc_dom_alloc_segment(dom, &dom->kernel_seg, "kernel", dom->kernel_seg.vstart,
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 4 lines · Gerd Hoffmann
Slightly updated version of the patch, the previous one did fixup
virt_basetoo late. This one should work in theory. It's not really tested though, theVIRT_BASEspecified by linux kernels is at a 4MB border anyway, so the fixup is a no-op ...
Well, we're only expecting 2Mb now anyway...
regards
john
Quoted 2 lines · John Levon
I've tested this along with a kernel change to only assume 2Mb alignment, and it works on PAE and 64-bit now.
Oh, you change the kernel for that? Hmm, why don't you simply check how many L2 entries are filled? Then you don't have to hard-code that domain builder implementation detail into the solaris kernel ...
cheers,
Gerd
Signature · 1 line
Gerd Hoffmann <[email protected]>