[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC] xen/arm64: livepatch: enable attaching callbacks


  • To: roger.pau@xxxxxxxxxx, andrew.cooper3@xxxxxxxxxx
  • From: Ryo Takakura <takakura@xxxxxxxxxxxxx>
  • Date: Thu, 2 Jul 2026 11:14:20 +0900
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JEQYCUB/AsrZes5fX6l4h5HMkIT20KsBaBAhAmYHYJ0=; b=ZI+8zQv3pvn8roMYreM9rPaDU2KVm446+yEJo8sgxx8gTYnmluOQlI9pj/APFG/WtCJouBHPlUcOzdDrDJ4lrzomar6qvyVJyf8FZdenP0csuULtpNovhRnBiunboeXWwGXqNRbupo/oXy7ORHD9axwhRYkG+0vmyHnoDCcj7yV/5qoW43Y9CMAl6mhf0ub1ng9Q93M/+oi9AKBOR2uCKr+pOdD4rNFKclljURIXHevqiVM0z3wFDi6Y/8/GcQZzNHJM0DMjx1qielDI9giCHVc4DVM+WJjd0c5zOrVdo6B5PIYRv9OOwqfRgKVMvCUhI6naOEGf2rrdhcRQuuRbXA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LRLVcnxTu4EsiAxj0UY1pQ22TKBvWitIEdbnqJuFLFFqmugxOeP+LS7aM6DIeQ+JqO9cELfNaWLIBPFzqhxHAnko4iJfr05qxX/AIK1tTiYRuXX6PrvfrRmuTBXsWU8GfLrlzd6k57lhtvNm3VSzeNZNNE/W23Zuar5DKTVfKwbk+7hSmJzzxqP46LzBN/s7U7xzf18HodDPsw+yPtZOOJiuHiSRNmeFL8/c3rySUmxwbdN37KNl2w/oITBPXJl8ebnwDMaLM8+QmMoHoOgudbH/OE3++zE4IXGe4rBGhD4TrOYLGx+jel7T2wBDo2Y2UeIJRhJ05qsf7vjBY5QcNA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-Id:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, ross.lagerwall@xxxxxxxxxx, sstabellini@xxxxxxxxxx, julien@xxxxxxx, bertrand.marquis@xxxxxxx, michal.orzel@xxxxxxx, Volodymyr_Babchuk@xxxxxxxx, anthony.perard@xxxxxxxxxx, jbeulich@xxxxxxxx, taka@xxxxxxxxxxxxx, den@xxxxxxxxxxxxx
  • Delivery-date: Thu, 02 Jul 2026 02:14:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, 1 Jul 2026 15:50:59 +0200, Roger Pau Monné wrote:
>On Wed, Jul 01, 2026 at 06:09:08PM +0900, Ryo Takakura wrote:
>> 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.

Good!

>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.

Although I don't have anything specific in mind yet,
I also hope for more tools to be integrated in the future :-)

Sincerely,
Ryo Takakura



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.