xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Jason Andryuk <jandryuk@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
	 Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	 Ian Jackson <iwj@xenproject.org>, Julien Grall <julien@xen.org>,
	 Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wl@xen.org>
Subject: Re: [PATCH] libelf: Handle PVH kernels lacking ENTRY elfnote
Date: Wed, 14 Oct 2020 12:27:40 -0400	[thread overview]
Message-ID: <CAKf6xpv5GNjw0pjOxEqdVj2+C6v+O5PDZG5yYkNfytDjUT_r5w@mail.gmail.com> (raw)
In-Reply-To: <6d373cae-c7dc-e109-1df3-ccbbe4bdd9c8@suse.com>

On Wed, Oct 14, 2020 at 12:02 PM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 14.10.2020 17:31, Jason Andryuk wrote:
> > Linux kernels only have an ENTRY elfnote when built with CONFIG_PV.  A
> > kernel build CONFIG_PVH=y CONFIG_PV=n lacks the note.  In this case,
> > virt_entry will be UNSET_ADDR, overwritten by the ELF header e_entry,
> > and fail the check against the virt address range.

Oh, these should be CONFIG_XEN_PVH=y and CONFIG_XEN_PV=n

> > Change the code to only check virt_entry against the virtual address
> > range if it was set upon entry to the function.
>
> Not checking at all seems wrong to me. The ELF spec anyway says
> "virtual address", so an out of bounds value is at least suspicious.
>
> > Maybe the overwriting of virt_entry could be removed, but I don't know
> > if there would be unintended consequences where (old?) kernels don't
> > have an elfnote, but do have an in-range e_entry?  The failing kernel I
> > just looked at has an e_entry of 0x1000000.
>
> And if you dropped the overwriting, what entry point would we use
> in the absence of an ELF note?

elf_xen_note_check currently has:

    /* PVH only requires one ELF note to be set */
    if ( parms->phys_entry != UNSET_ADDR32 )
    {
        elf_msg(elf, "ELF: Found PVH image\n");
        return 0;
    }

> I'd rather put up the option of adjusting the entry (or the check),
> if it looks like a valid physical address.

The function doesn't know if the image will be booted PV or PVH, so I
guess we do all the checks, but use 'parms->phys_entry != UNSET_ADDR32
&& parms->virt_entry == UNSET_ADDR' to conditionally skip checking
virt?

Regards,
Jason


  reply	other threads:[~2020-10-14 16:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-14 15:31 [PATCH] libelf: Handle PVH kernels lacking ENTRY elfnote Jason Andryuk
2020-10-14 15:52 ` Wei Liu
2020-10-14 16:02 ` Jan Beulich
2020-10-14 16:27   ` Jason Andryuk [this message]
2020-10-15  7:00     ` Jan Beulich
2020-10-15 14:50       ` Jason Andryuk
2020-10-15 15:14         ` Jan Beulich
2020-10-15 17:27           ` Andrew Cooper
2020-10-16 16:28           ` Jason Andryuk
2020-10-19  7:38             ` Jan Beulich
2020-10-19 15:26               ` Jason Andryuk
2020-10-19 15:36                 ` Jan Beulich
2020-10-15 15:03       ` Roger Pau Monné
2020-10-14 16:12 ` Jürgen Groß
2020-10-14 16:27   ` Jason Andryuk
2020-10-15  4:17     ` Jürgen Groß

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKf6xpv5GNjw0pjOxEqdVj2+C6v+O5PDZG5yYkNfytDjUT_r5w@mail.gmail.com \
    --to=jandryuk@gmail.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).