All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Ryo Takakura <takakura@valinux.co.jp>
Cc: andrew.cooper3@citrix.com, xen-devel@lists.xenproject.org,
	ross.lagerwall@citrix.com, sstabellini@kernel.org,
	julien@xen.org, bertrand.marquis@arm.com, michal.orzel@amd.com,
	Volodymyr_Babchuk@epam.com, anthony.perard@vates.tech,
	jbeulich@suse.com, taka@valinux.co.jp, den@valinux.co.jp
Subject: Re: [RFC] xen/arm64: livepatch: enable attaching callbacks
Date: Wed, 1 Jul 2026 15:50:59 +0200	[thread overview]
Message-ID: <akUbQyNy-Rj1oOkJ@macbook.local> (raw)
In-Reply-To: <20260701090908.15204-1-takakura@valinux.co.jp>

On Wed, Jul 01, 2026 at 06:09:08PM +0900, Ryo Takakura wrote:
> Hi Roger and Andrew,
> 
> On Tue, 30 Jun 2026 08:47:14 +0000, Roger Pau Monné wrote:
> >On Mon, Jun 29, 2026 at 11:01:28AM +0900, Ryo Takakura wrote:
> >> Linux ftrace allows registering callbacks which is useful
> >> for debugging and tracing events. On Linux, it is done by
> >> reserving function entry points at compile time which can
> >> later be patched to branch to a trampoline.
> >> 
> >> This patch implements similar callback feature, but with
> >> different approach using existing livepatch infrastructure.
> >> Instead of reserving function entry points at compile time,
> >> the traced function will be livepatched so that it branches
> >> to the trampoline.
> >
> >While this is an interesting usage of the livepatch logic in new ways,
> >may I ask why not do as Linux and add an empty function preamble that
> >can be replaced at run-time with calls to hooks?
> >
> >You could still re-use most of the livepatch logic for handling the
> >addition of the hook calls, but it would be nicer in that we won't
> >need to move the original function.
> 
> I agree that we can reuse a lot of livepatch logic.
> 
> >> The role of the trampoline(illustrated below) is to preserve
> >> the context while jumping to the tracer function, and return
> >> back to the traced function with its context restored.
> >
> >Alternatively - why not use livepatch-build-tools against a build with
> >the added hooks to generate a proper livepatch?  This looks a bit
> >fragile to me (see the question from Andrew about fixing up
> >instruction pointer relative references).
> 
> Yes, I think proper livepatching would still be preferred
> given all the concerns Andrew and Roger raised.
> 
> >On x86 at least we would also need to adjust the bug frames and
> >exception table contents, and the contents of the symbol table to
> >account for the function being moved.
> >
> >IOW: it looks like overall this is a lot more work than possibly
> >reserving a function preamble to add hook calls?
> 
> Yes, I agree.
> (I wasn't aware of this additional work when I replied
> to Andrew yesterday, thanks!)
> 
> And if I were to summarize the discussion so far, assuming we
> still want to add a tracing-feature, I think we are in agreement
> adding an empty function preamble like Linux.
> (I personally would still like to see a framework on Xen
> that is more convenient and tracing-friendly which can be used
> reliably at the same time)
> 
> If this sounds reasonable, I will try preparing one based on
> the feedbacks I was given so far:
> - Use of Linux-like reserved function preamble
> - Use of __attribute__((no_caller_saved_registers))
> - Split replacement and preamble-hook handling in common code
> 
> Let me know your thoughts!

I think the above approach is easier to implement, and more reliable
than the current proposal.

Do you also have the intention to integrate this with existing tracing
tools used by Linux or other OSes?  That would be very useful IMO.

Thanks, Roger.


  reply	other threads:[~2026-07-01 13:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29  2:01 [RFC] xen/arm64: livepatch: enable attaching callbacks Ryo Takakura
2026-06-29 16:33 ` Andrew Cooper
2026-06-30 10:43   ` Ryo Takakura
2026-06-30 10:57     ` Andrew Cooper
2026-07-01  9:11       ` Ryo Takakura
2026-06-30  8:46 ` Roger Pau Monné
2026-07-01  9:09   ` Ryo Takakura
2026-07-01 13:50     ` Roger Pau Monné [this message]
2026-07-02  2:14       ` Ryo Takakura

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=akUbQyNy-Rj1oOkJ@macbook.local \
    --to=roger.pau@citrix.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=bertrand.marquis@arm.com \
    --cc=den@valinux.co.jp \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=ross.lagerwall@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=taka@valinux.co.jp \
    --cc=takakura@valinux.co.jp \
    --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.