* [PATCH 0/2] Fix BSD symtab/strtab loading
@ 2015-06-11 16:05 Roger Pau Monne
2015-06-11 16:05 ` [PATCH 1/2] libelf: fix elf_parse_bsdsyms call Roger Pau Monne
2015-06-11 16:05 ` [PATCH 2/2] libxc: fix xc_dom_load_elf_symtab Roger Pau Monne
0 siblings, 2 replies; 5+ messages in thread
From: Roger Pau Monne @ 2015-06-11 16:05 UTC (permalink / raw)
To: xen-devel
This two patches fix BSD symtab/strtab loading when
XEN_ELFNOTE_PADDR_OFFSET is different than XEN_ELFNOTE_VIRT_BASE. They are
fairly small fixes, which I hope can be backported to stable branches once
accepted.
Thanks, Roger.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] libelf: fix elf_parse_bsdsyms call
2015-06-11 16:05 [PATCH 0/2] Fix BSD symtab/strtab loading Roger Pau Monne
@ 2015-06-11 16:05 ` Roger Pau Monne
2015-06-11 16:05 ` [PATCH 2/2] libxc: fix xc_dom_load_elf_symtab Roger Pau Monne
1 sibling, 0 replies; 5+ messages in thread
From: Roger Pau Monne @ 2015-06-11 16:05 UTC (permalink / raw)
To: xen-devel
Cc: Tim Deegan, Ian Jackson, Ian Campbell, Jan Beulich,
Roger Pau Monne
elf_parse_bsdsyms expects the second paramater to be a physical address, not
a virtual one.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Tim Deegan <tim@xen.org>
---
xen/common/libelf/libelf-dominfo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xen/common/libelf/libelf-dominfo.c b/xen/common/libelf/libelf-dominfo.c
index 6120dd4..86403b9 100644
--- a/xen/common/libelf/libelf-dominfo.c
+++ b/xen/common/libelf/libelf-dominfo.c
@@ -438,7 +438,7 @@ static elf_errorstatus elf_xen_addr_calc_check(struct elf_binary *elf,
if ( parms->bsd_symtab )
{
- elf_parse_bsdsyms(elf, parms->virt_kend);
+ elf_parse_bsdsyms(elf, elf->pend);
if ( elf->bsd_symtab_pend )
parms->virt_kend = elf->bsd_symtab_pend + parms->virt_offset;
}
--
1.9.5 (Apple Git-50.3)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] libxc: fix xc_dom_load_elf_symtab
2015-06-11 16:05 [PATCH 0/2] Fix BSD symtab/strtab loading Roger Pau Monne
2015-06-11 16:05 ` [PATCH 1/2] libelf: fix elf_parse_bsdsyms call Roger Pau Monne
@ 2015-06-11 16:05 ` Roger Pau Monne
2015-06-17 9:56 ` Wei Liu
1 sibling, 1 reply; 5+ messages in thread
From: Roger Pau Monne @ 2015-06-11 16:05 UTC (permalink / raw)
To: xen-devel
Cc: Wei Liu, Stefano Stabellini, Ian Jackson, Ian Campbell,
Roger Pau Monne
xc_dom_load_elf_symtab was incorrectly trying to perform the same
calculations already done in elf_parse_bsdsyms when load == 0 is used.
Instead of trying to repeat the calculations, just trust what
elf_parse_bsdsyms has already accounted for.
This also simplifies the code by allowing the non-load case to return
earlier.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
tools/libxc/xc_dom_elfloader.c | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/tools/libxc/xc_dom_elfloader.c b/tools/libxc/xc_dom_elfloader.c
index 9843b1f..6ce1062 100644
--- a/tools/libxc/xc_dom_elfloader.c
+++ b/tools/libxc/xc_dom_elfloader.c
@@ -128,6 +128,8 @@ static elf_errorstatus xc_dom_load_elf_symtab(struct xc_dom_image *dom,
return 0;
}
+ size = elf->bsd_symtab_pend - elf->bsd_symtab_pstart;
+
if ( load )
{
char *hdr_ptr;
@@ -135,11 +137,10 @@ static elf_errorstatus xc_dom_load_elf_symtab(struct xc_dom_image *dom,
if ( !dom->bsd_symtab_start )
return 0;
- size = dom->kernel_seg.vend - dom->bsd_symtab_start;
hdr_ptr = xc_dom_vaddr_to_ptr(dom, dom->bsd_symtab_start, &allow_size);
if ( hdr_ptr == NULL )
{
- DOMPRINTF("%s/load: xc_dom_vaddr_to_ptr(dom,dom->bsd_symtab_start"
+ DOMPRINTF("%s: xc_dom_vaddr_to_ptr(dom,dom->bsd_symtab_start"
" => NULL", __FUNCTION__);
return -1;
}
@@ -152,8 +153,6 @@ static elf_errorstatus xc_dom_load_elf_symtab(struct xc_dom_image *dom,
{
char *hdr_ptr;
- size = sizeof(unsigned) + elf_size(elf, elf->ehdr) +
- elf_shdr_count(elf) * elf_size(elf, shdr);
hdr_ptr = xc_dom_malloc(dom, size);
if ( hdr_ptr == NULL )
return 0;
@@ -161,6 +160,8 @@ static elf_errorstatus xc_dom_load_elf_symtab(struct xc_dom_image *dom,
elf->caller_xdest_size = size;
hdr = ELF_REALPTR2PTRVAL(hdr_ptr);
dom->bsd_symtab_start = elf_round_up(elf, dom->kernel_seg.vend);
+ dom->kernel_seg.vend = elf_round_up(elf, dom->bsd_symtab_start + size);
+ return 0;
}
elf_memcpy_safe(elf, hdr + sizeof(unsigned),
@@ -189,9 +190,8 @@ static elf_errorstatus xc_dom_load_elf_symtab(struct xc_dom_image *dom,
}
if ( elf->caller_xdest_size < sizeof(unsigned) )
{
- DOMPRINTF("%s/%s: header size %"PRIx64" too small",
- __FUNCTION__, load ? "load" : "parse",
- (uint64_t)elf->caller_xdest_size);
+ DOMPRINTF("%s: header size %"PRIx64" too small",
+ __FUNCTION__, (uint64_t)elf->caller_xdest_size);
return -1;
}
if ( elf_init(&syms, elf->caller_xdest_base + sizeof(unsigned),
@@ -219,10 +219,9 @@ static elf_errorstatus xc_dom_load_elf_symtab(struct xc_dom_image *dom,
maxaddr = elf_round_up(&syms, symtab + elf_size(&syms, syms.ehdr) +
elf_shdr_count(&syms) * elf_size(&syms, shdr));
- DOMPRINTF("%s/%s: bsd_symtab_start=%" PRIx64 ", kernel.end=0x%" PRIx64
+ DOMPRINTF("%s: bsd_symtab_start=%" PRIx64 ", kernel.end=0x%" PRIx64
" -- symtab=0x%" PRIx64 ", maxaddr=0x%" PRIx64 "",
- __FUNCTION__, load ? "load" : "parse",
- dom->bsd_symtab_start, dom->kernel_seg.vend,
+ __FUNCTION__, dom->bsd_symtab_start, dom->kernel_seg.vend,
symtab, maxaddr);
count = elf_shdr_count(&syms);
@@ -279,13 +278,10 @@ static elf_errorstatus xc_dom_load_elf_symtab(struct xc_dom_image *dom,
type == SHT_SYMTAB ? "symtab" : "strtab",
size, maxaddr);
- if ( load )
- {
- shdr2 = elf_shdr_by_index(elf, h);
- elf_memcpy_safe(elf, elf_section_start(&syms, shdr),
- elf_section_start(elf, shdr2),
- size);
- }
+ shdr2 = elf_shdr_by_index(elf, h);
+ elf_memcpy_safe(elf, elf_section_start(&syms, shdr),
+ elf_section_start(elf, shdr2),
+ size);
}
/* Name is NULL. */
@@ -308,8 +304,7 @@ static elf_errorstatus xc_dom_load_elf_symtab(struct xc_dom_image *dom,
dom->bsd_symtab_start = 0;
return 0;
}
- if ( !load )
- dom->kernel_seg.vend = maxaddr;
+
return 0;
}
--
1.9.5 (Apple Git-50.3)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] libxc: fix xc_dom_load_elf_symtab
2015-06-11 16:05 ` [PATCH 2/2] libxc: fix xc_dom_load_elf_symtab Roger Pau Monne
@ 2015-06-17 9:56 ` Wei Liu
2015-06-17 11:14 ` Ian Campbell
0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2015-06-17 9:56 UTC (permalink / raw)
To: Roger Pau Monne
Cc: xen-devel, Wei Liu, Ian Jackson, Ian Campbell, Stefano Stabellini
On Thu, Jun 11, 2015 at 06:05:20PM +0200, Roger Pau Monne wrote:
> xc_dom_load_elf_symtab was incorrectly trying to perform the same
> calculations already done in elf_parse_bsdsyms when load == 0 is used.
> Instead of trying to repeat the calculations, just trust what
> elf_parse_bsdsyms has already accounted for.
>
> This also simplifies the code by allowing the non-load case to return
> earlier.
>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Cc: Ian Campbell <ian.campbell@citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] libxc: fix xc_dom_load_elf_symtab
2015-06-17 9:56 ` Wei Liu
@ 2015-06-17 11:14 ` Ian Campbell
0 siblings, 0 replies; 5+ messages in thread
From: Ian Campbell @ 2015-06-17 11:14 UTC (permalink / raw)
To: Wei Liu; +Cc: xen-devel, Stefano Stabellini, Ian Jackson, Roger Pau Monne
On Wed, 2015-06-17 at 10:56 +0100, Wei Liu wrote:
> On Thu, Jun 11, 2015 at 06:05:20PM +0200, Roger Pau Monne wrote:
> > xc_dom_load_elf_symtab was incorrectly trying to perform the same
> > calculations already done in elf_parse_bsdsyms when load == 0 is used.
> > Instead of trying to repeat the calculations, just trust what
> > elf_parse_bsdsyms has already accounted for.
> >
> > This also simplifies the code by allowing the non-load case to return
> > earlier.
> >
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > Cc: Ian Campbell <ian.campbell@citrix.com>
> > Cc: Wei Liu <wei.liu2@citrix.com>
>
> Acked-by: Wei Liu <wei.liu2@citrix.com>
Applied, thanks (#1 was committed by Jan already).
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-06-17 11:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-11 16:05 [PATCH 0/2] Fix BSD symtab/strtab loading Roger Pau Monne
2015-06-11 16:05 ` [PATCH 1/2] libelf: fix elf_parse_bsdsyms call Roger Pau Monne
2015-06-11 16:05 ` [PATCH 2/2] libxc: fix xc_dom_load_elf_symtab Roger Pau Monne
2015-06-17 9:56 ` Wei Liu
2015-06-17 11:14 ` Ian Campbell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.