[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] libelf: don't attempt to parse __xen_guest for PVH
commit dec25a2cd1c8089a39900ed978c8e7ab62d2a4d4 Author: Roger Pau Monné <roger.pau@xxxxxxxxxx> AuthorDate: Fri May 28 09:13:32 2021 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Fri May 28 09:13:32 2021 +0200 libelf: don't attempt to parse __xen_guest for PVH The legacy __xen_guest section doesn't support the PHYS32_ENTRY elfnote, so it's pointless to attempt to parse the elfnotes from that section when called from an hvm container. Pass an hvm boolean parameter to the elf note parsing routine, so that the respective parsing can be suppressed in case libelf is dealing with an hvm container. Suggested-by: Jan Beulich <jbeulich@xxxxxxxx> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- tools/fuzz/libelf/libelf-fuzzer.c | 3 ++- tools/libs/guest/xg_dom_elfloader.c | 6 ++++-- tools/libs/guest/xg_dom_hvmloader.c | 2 +- xen/arch/x86/hvm/dom0_build.c | 2 +- xen/arch/x86/pv/dom0_build.c | 2 +- xen/common/libelf/libelf-dominfo.c | 8 +++----- xen/include/xen/libelf.h | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tools/fuzz/libelf/libelf-fuzzer.c b/tools/fuzz/libelf/libelf-fuzzer.c index 1ba8571711..84fb84720f 100644 --- a/tools/fuzz/libelf/libelf-fuzzer.c +++ b/tools/fuzz/libelf/libelf-fuzzer.c @@ -17,7 +17,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) return -1; elf_parse_binary(elf); - elf_xen_parse(elf, &parms); + elf_xen_parse(elf, &parms, false); + elf_xen_parse(elf, &parms, true); return 0; } diff --git a/tools/libs/guest/xg_dom_elfloader.c b/tools/libs/guest/xg_dom_elfloader.c index 0d6247db5d..f17930d98b 100644 --- a/tools/libs/guest/xg_dom_elfloader.c +++ b/tools/libs/guest/xg_dom_elfloader.c @@ -135,7 +135,8 @@ static elf_negerrnoval xc_dom_probe_elf_kernel(struct xc_dom_image *dom) * or else we might be trying to load a plain ELF. */ elf_parse_binary(&elf); - rc = elf_xen_parse(&elf, dom->parms); + rc = elf_xen_parse(&elf, dom->parms, + dom->container_type == XC_DOM_HVM_CONTAINER); if ( rc != 0 ) return rc; @@ -166,7 +167,8 @@ static elf_negerrnoval xc_dom_parse_elf_kernel(struct xc_dom_image *dom) /* parse binary and get xen meta info */ elf_parse_binary(elf); - if ( elf_xen_parse(elf, dom->parms) != 0 ) + if ( elf_xen_parse(elf, dom->parms, + dom->container_type == XC_DOM_HVM_CONTAINER) != 0 ) { rc = -EINVAL; goto out; diff --git a/tools/libs/guest/xg_dom_hvmloader.c b/tools/libs/guest/xg_dom_hvmloader.c index 4e6f30858a..ae50d98011 100644 --- a/tools/libs/guest/xg_dom_hvmloader.c +++ b/tools/libs/guest/xg_dom_hvmloader.c @@ -73,7 +73,7 @@ static elf_negerrnoval xc_dom_probe_hvm_kernel(struct xc_dom_image *dom) * else we might be trying to load a PV kernel. */ elf_parse_binary(&elf); - rc = elf_xen_parse(&elf, dom->parms); + rc = elf_xen_parse(&elf, dom->parms, true); if ( rc == 0 ) return -EINVAL; diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 878dc1d808..c24b9efdb0 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -561,7 +561,7 @@ static int __init pvh_load_kernel(struct domain *d, const module_t *image, elf_set_verbose(&elf); #endif elf_parse_binary(&elf); - if ( (rc = elf_xen_parse(&elf, &parms)) != 0 ) + if ( (rc = elf_xen_parse(&elf, &parms, true)) != 0 ) { printk("Unable to parse kernel for ELFNOTES\n"); return rc; diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index e0801a9e6d..af47615b22 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -353,7 +353,7 @@ int __init dom0_construct_pv(struct domain *d, elf_set_verbose(&elf); elf_parse_binary(&elf); - if ( (rc = elf_xen_parse(&elf, &parms)) != 0 ) + if ( (rc = elf_xen_parse(&elf, &parms, false)) != 0 ) goto out; /* compatibility check */ diff --git a/xen/common/libelf/libelf-dominfo.c b/xen/common/libelf/libelf-dominfo.c index 69c94b6f3b..bd295a9b7e 100644 --- a/xen/common/libelf/libelf-dominfo.c +++ b/xen/common/libelf/libelf-dominfo.c @@ -499,7 +499,7 @@ static elf_errorstatus elf_xen_addr_calc_check(struct elf_binary *elf, /* glue it all together ... */ elf_errorstatus elf_xen_parse(struct elf_binary *elf, - struct elf_dom_parms *parms) + struct elf_dom_parms *parms, bool hvm) { ELF_HANDLE_DECL(elf_shdr) shdr; ELF_HANDLE_DECL(elf_phdr) phdr; @@ -577,10 +577,8 @@ elf_errorstatus elf_xen_parse(struct elf_binary *elf, } - /* - * Finally fall back to the __xen_guest section. - */ - if ( xen_elfnotes == 0 ) + /* Finally fall back to the __xen_guest section for PV guests only. */ + if ( xen_elfnotes == 0 && !hvm ) { shdr = elf_shdr_by_name(elf, "__xen_guest"); if ( ELF_HANDLE_VALID(shdr) ) diff --git a/xen/include/xen/libelf.h b/xen/include/xen/libelf.h index b73998150f..be47b0cc36 100644 --- a/xen/include/xen/libelf.h +++ b/xen/include/xen/libelf.h @@ -454,7 +454,7 @@ int elf_xen_parse_note(struct elf_binary *elf, int elf_xen_parse_guest_info(struct elf_binary *elf, struct elf_dom_parms *parms); int elf_xen_parse(struct elf_binary *elf, - struct elf_dom_parms *parms); + struct elf_dom_parms *parms, bool hvm); static inline void *elf_memcpy_unchecked(void *dest, const void *src, size_t n) { return memcpy(dest, src, n); } -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |