From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Ross Lagerwall <ross.lagerwall@cloud.com>
Cc: xen-devel@lists.xenproject.org,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>
Subject: Re: [PATCH 1/5] xen/livepatch: register livepatch regions when loaded
Date: Fri, 23 Feb 2024 15:55:58 +0100 [thread overview]
Message-ID: <Zdix_iZFYnvweQuR@macbook> (raw)
In-Reply-To: <CAG7k0Eq+G7w8M2JFTnikv10SNocfCBGwvbEwz-pbR9v99uStGg@mail.gmail.com>
On Fri, Feb 23, 2024 at 09:45:15AM +0000, Ross Lagerwall wrote:
> On Thu, Nov 30, 2023 at 2:30 PM Roger Pau Monne <roger.pau@citrix.com> wrote:
> >
> > Currently livepatch regions are registered as virtual regions only after the
> > livepatch has been applied.
> >
> > This can lead to issues when using the pre-apply or post-revert hooks, as at
> > the point the livepatch is not in the virtual regions list. If a livepatch
> > pre-apply hook contains a WARN() it would trigger an hypervisor crash, as the
> > code to handle the bug frame won't be able to find the instruction pointer that
> > triggered the #UD in any of the registered virtual regions, and hence crash.
> >
> > Fix this by adding the livepatch payloads as virtual regions as soon as loaded,
> > and only remove them once the payload is unloaded. This requires some changes
> > to the virtual regions code, as the removal of the virtual regions is no longer
> > done in stop machine context, and hence an RCU barrier is added in order to
> > make sure there are no users of the virtual region after it's been removed from
> > the list.
> >
> > Fixes: 8313c864fa95 ('livepatch: Implement pre-|post- apply|revert hooks')
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > ---
> > xen/common/livepatch.c | 5 +++--
> > xen/common/virtual_region.c | 40 +++++++++++--------------------------
> > 2 files changed, 15 insertions(+), 30 deletions(-)
> >
> > diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
> > index 1209fea2566c..3199432f11f5 100644
> > --- a/xen/common/livepatch.c
> > +++ b/xen/common/livepatch.c
> > @@ -942,6 +942,8 @@ static int prepare_payload(struct payload *payload,
> > }
> > }
> >
> > + register_virtual_region(region);
> > +
> > return 0;
> > }
> >
>
> The region is registered in prepare_payload() but if e.g. the build id
> check in load_payload_data() fails, it won't unregister the region
> since the failure path calls free_payload_data(), not free_payload().
> Perhaps the call to register_virtual_region() could be done as the last
> thing in load_payload_data()?
I've moved it to livepatch_upload(), as I think it's more natural to
be done together with the addition to the list of livepatches. Thanks
for spotting it, I guess I got confused between free_payload_data()
free_payload().
Roger.
next prev parent reply other threads:[~2024-02-23 14:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-30 14:29 [PATCH 0/5] xen/livepatch: fixes for the pre-apply / post-revert hooks Roger Pau Monne
2023-11-30 14:29 ` [PATCH 1/5] xen/livepatch: register livepatch regions when loaded Roger Pau Monne
2023-12-05 13:47 ` Jan Beulich
2023-12-05 15:04 ` Roger Pau Monné
2023-12-05 15:16 ` Jan Beulich
2024-02-23 9:45 ` Ross Lagerwall
2024-02-23 14:55 ` Roger Pau Monné [this message]
2023-11-30 14:29 ` [PATCH 2/5] xen/livepatch: search for symbols in all loaded payloads Roger Pau Monne
2024-02-23 10:11 ` Ross Lagerwall
2023-11-30 14:29 ` [PATCH 3/5] xen/livepatch: fix norevert test attempt to open-code revert Roger Pau Monne
2024-02-23 10:10 ` Ross Lagerwall
2024-02-26 8:16 ` Roger Pau Monné
2023-11-30 14:29 ` [PATCH 4/5] xen/livepatch: fix norevert test hook setup typo Roger Pau Monne
2024-02-23 10:13 ` Ross Lagerwall
2023-11-30 14:29 ` [PATCH 5/5] xen/livepatch: properly build the noapply and norevert tests Roger Pau Monne
2024-02-23 10:30 ` Ross Lagerwall
2024-02-23 10:48 ` [PATCH 0/5] xen/livepatch: fixes for the pre-apply / post-revert hooks Jan Beulich
2024-02-26 8:40 ` Roger Pau Monné
2024-02-26 9:26 ` Jan Beulich
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=Zdix_iZFYnvweQuR@macbook \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=konrad.wilk@oracle.com \
--cc=ross.lagerwall@cloud.com \
--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 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.