Puthiyaparambil, Aravindh
2006-May-18 18:15 UTC
[Xen-devel] Questions about VIRT_BASE and ELF_PADDR_OFFSET in __xen_guest
Keir, I was looking at your changeset: http://xenbits.xensource.com/xen-unstable.hg?cs=dbe396fd6fd8 I am finding that by making VIRT_BASE=0x0 is causing the builder to seg fault. The same thing happens when VIRT_BASE and ELF_PADDR_OFFSET is set to 0. I don''t understand why dsi->elf_paddr_offset is being set to VIRT_BASE and then overridden with ELF_PADDR_OFFSET if it is set. Does ELF_PADDR_OFFSET have any real use? Does it correlate with anything in the ELF program header? I am a little confused here :-), so could you please explain. Thanks, Aravindh Puthiyaparambil Xen Development Team Unisys, Tredyffrin PA _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2006-May-18 20:35 UTC
[Xen-devel] Re: Questions about VIRT_BASE and ELF_PADDR_OFFSET in __xen_guest
On 18 May 2006, at 19:15, Puthiyaparambil, Aravindh wrote:> I was looking at your changeset: > http://xenbits.xensource.com/xen-unstable.hg?cs=dbe396fd6fd8 > > I am finding that by making VIRT_BASE=0x0 is causing the builder to seg > fault. The same thing happens when VIRT_BASE and ELF_PADDR_OFFSET is > set > to 0. I don''t understand why dsi->elf_paddr_offset is being set to > VIRT_BASE and then overridden with ELF_PADDR_OFFSET if it is set. Does > ELF_PADDR_OFFSET have any real use? Does it correlate with anything in > the ELF program header? I am a little confused here :-), so could you > please explain.VIRT_BASE is the linear address you want your memory allocation mapped at. ELF_PADDR_OFFSET is a value subtracted from addresses in the Elf headers to produce a pseudo-physical address. We usually set it to VIRT_BASE since we write virtual (linear) addresses into those Elf header fields. The default of setting it to VIRT_BASE is simply to maintain backward compatibility with old guest images which do not explicitly define it. There is no reason really why VIRT_BASE=0 should not work. If it crashes there is presumably some underlying bug which disallowing VIRT_BASE=0 does not fix. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Puthiyaparambil, Aravindh
2006-May-19 00:57 UTC
[Xen-devel] RE: Questions about VIRT_BASE and ELF_PADDR_OFFSET in __xen_guest
> There is no reason really why VIRT_BASE=0 should not work. If it > crashes there is presumably some underlying bug which disallowing > VIRT_BASE=0 does not fix.You are right. The experiment I was trying with Mini-OS was flawed. I had forgotten to fix up the minios_x86_64.lds file to reflect 0x0 (bang head on table). Once I did that things worked fine. Do we care about the situation where there is a mismatch in ELF header and __xen_guest section? When this happens the var "pa" is calculated incorrectly causing "parray" to go out of bounds. pa = (phdr->p_paddr + done) - dsi->elf_paddr_offset; va = xc_map_foreign_range(xch, dom, PAGE_SIZE, PROT_WRITE, parray[pa>>PAGE_SHIFT]); [line 227-228 xc_load_elf.c loadelfimage()] (In my flawed test, p_addr was 0xffffffff80000000 and elf_paddr_offset was 0 due to obvious reasons) I know this is rarely possible unless someone does something stupid like I did :-) which is why I am wondering if we should test for this case. [ASIDE] Due to this I think I should fix x86_xx.S in Mini-OS so that it picks up &_text from minios_x86_xx.lds. Cheers, Aravindh _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2006-May-19 08:15 UTC
[Xen-devel] Re: Questions about VIRT_BASE and ELF_PADDR_OFFSET in __xen_guest
> > There is no reason really why VIRT_BASE=0 should not work. If it > > crashes there is presumably some underlying bug which disallowing > > VIRT_BASE=0 does not fix. > > You are right. The experiment I was trying with Mini-OS was flawed. I > had forgotten to fix up the minios_x86_64.lds file to reflect 0x0 (bang > head on table). Once I did that things worked fine. > > Do we care about the situation where there is a mismatch in ELF header > and __xen_guest section? When this happens the var "pa" is calculated > incorrectly causing "parray" to go out of bounds.Well, that''s the bug. We should perform bounds checks on indexes into parray. I would very much like to see a patch to fix this! -- Keir> pa = (phdr->p_paddr + done) - dsi->elf_paddr_offset; > va = xc_map_foreign_range(xch, dom, PAGE_SIZE, PROT_WRITE, > parray[pa>>PAGE_SHIFT]); > > [line 227-228 xc_load_elf.c loadelfimage()] > > (In my flawed test, p_addr was 0xffffffff80000000 and elf_paddr_offset > was 0 due to obvious reasons) > > I know this is rarely possible unless someone does something stupid like > I did :-) which is why I am wondering if we should test for this case. > > [ASIDE] > Due to this I think I should fix x86_xx.S in Mini-OS so that it picks up > &_text from minios_x86_xx.lds. > > Cheers, > Aravindh >-=- MIME -=-> There is no reason really why VIRT_BASE=3D0 should not work. If it > crashes there is presumably some underlying bug which disallowing > VIRT_BASE=3D0 does not fix.You are right. The experiment I was trying with Mini-OS was flawed. I had forgotten to fix up the minios_x86_64.lds file to reflect 0x0 (bang head on table). Once I did that things worked fine.=20 Do we care about the situation where there is a mismatch in ELF header and __xen_guest section? When this happens the var "pa" is calculated incorrectly causing "parray" to go out of bounds. pa =3D (phdr->p_paddr + done) - dsi->elf_paddr_offset;=20 va =3D xc_map_foreign_range(xch, dom, PAGE_SIZE, PROT_WRITE,=20 parray[pa>>PAGE_SHIFT]); [line 227-228 xc_load_elf.c loadelfimage()] (In my flawed test, p_addr was 0xffffffff80000000 and elf_paddr_offset was 0 due to obvious reasons) I know this is rarely possible unless someone does something stupid like I did :-) which is why I am wondering if we should test for this case.=20 [ASIDE] Due to this I think I should fix x86_xx.S in Mini-OS so that it picks up &_text from minios_x86_xx.lds. Cheers, Aravindh _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel