From: Rusty Russell paravirt_probe() and its infrastructure proved as popular as it was pretty. In anticipation of its imminent demise, this switches lguest to use a magic string to identify a different entry point. This is not the long-term solution: that will take a new bootloader rev and will hopefully be done in the next few months. Signed-off-by: Rusty Russell Signed-off-by: Andrew Morton --- Documentation/lguest/lguest.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff -puN Documentation/lguest/lguest.c~lguest-the-documentation-example-launcher-dont-use-paravirt_probe-its-dying-doc Documentation/lguest/lguest.c --- a/Documentation/lguest/lguest.c~lguest-the-documentation-example-launcher-dont-use-paravirt_probe-its-dying-doc +++ a/Documentation/lguest/lguest.c @@ -96,6 +96,19 @@ static void *map_zeroed_pages(unsigned l return (void *)addr; } +/* Find magic string marking entry point, return entry point. */ +static unsigned long entry_point(void *start, void *end, + unsigned long page_offset) +{ + void *p; + + for (p = start; p < end; p++) + if (memcmp(p, "GenuineLguest", strlen("GenuineLguest")) == 0) + return (long)p + strlen("GenuineLguest") + page_offset; + + err(1, "Is this image a genuine lguest?"); +} + /* Returns the entry point */ static unsigned long map_elf(int elf_fd, const Elf32_Ehdr *ehdr, unsigned long *page_offset) @@ -103,6 +116,7 @@ static unsigned long map_elf(int elf_fd, void *addr; Elf32_Phdr phdr[ehdr->e_phnum]; unsigned int i; + unsigned long start = -1UL, end = 0; /* Sanity checks. */ if (ehdr->e_type != ET_EXEC @@ -132,6 +146,11 @@ static unsigned long map_elf(int elf_fd, else if (*page_offset != phdr[i].p_vaddr - phdr[i].p_paddr) errx(1, "Page offset of section %i different", i); + if (phdr[i].p_paddr < start) + start = phdr[i].p_paddr; + if (phdr[i].p_paddr + phdr[i].p_filesz > end) + end = phdr[i].p_paddr + phdr[i].p_filesz; + /* We map everything private, writable. */ addr = mmap((void *)phdr[i].p_paddr, phdr[i].p_filesz, @@ -143,8 +162,7 @@ static unsigned long map_elf(int elf_fd, i, addr, (void *)phdr[i].p_paddr); } - /* Entry is physical address: convert to virtual */ - return ehdr->e_entry + *page_offset; + return entry_point((void *)start, (void *)end, *page_offset); } /* This is amazingly reliable. */ @@ -175,8 +193,7 @@ static unsigned long unpack_bzimage(int verbose("Unpacked size %i addr %p\n", len, img); *page_offset = intuit_page_offset(img, len); - /* Entry is physical address: convert to virtual */ - return (unsigned long)img + *page_offset; + return entry_point(img, img + len, *page_offset); } static unsigned long load_bzimage(int fd, unsigned long *page_offset) _