Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752632AbdHPU32 (ORCPT ); Wed, 16 Aug 2017 16:29:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33416 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752384AbdHPU31 (ORCPT ); Wed, 16 Aug 2017 16:29:27 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1991DA9643 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jpoimboe@redhat.com Date: Wed, 16 Aug 2017 15:29:23 -0500 From: Josh Poimboeuf To: Joe Lawrence Cc: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Jessica Yu , Jiri Kosina , Miroslav Benes , Petr Mladek , Chris J Arges Subject: Re: [PATCH v3] livepatch: add (un)patch callbacks Message-ID: <20170816202923.tvtnpf6pr45cberl@treble> References: <1502911024-16143-1-git-send-email-joe.lawrence@redhat.com> <1502911024-16143-2-git-send-email-joe.lawrence@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1502911024-16143-2-git-send-email-joe.lawrence@redhat.com> User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 16 Aug 2017 20:29:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2600 Lines: 64 On Wed, Aug 16, 2017 at 03:17:04PM -0400, Joe Lawrence wrote: > Provide livepatch modules a klp_object (un)patching notification > mechanism. Pre and post-(un)patch callbacks allow livepatch modules to > setup or synchronize changes that would be difficult to support in only > patched-or-unpatched code contexts. > > Callbacks can be registered for target module or vmlinux klp_objects, > but each implementation is klp_object specific. > > - Pre-(un)patch callbacks run before any (un)patching action takes > place. > > - Post-(un)patch callbacks run once an object has been (un)patched and > the klp_patch fully transitioned to its target state. > > Example use cases include modification of global data and registration > of newly available services/handlers. > > See Documentation/livepatch/callback.txt for details. > > Signed-off-by: Joe Lawrence > --- > Documentation/livepatch/callbacks.txt | 87 ++++++++++++ > include/linux/livepatch.h | 81 ++++++++++++ > kernel/livepatch/core.c | 37 ++++-- > kernel/livepatch/patch.c | 5 +- > kernel/livepatch/transition.c | 21 ++- > samples/livepatch/Makefile | 2 + > samples/livepatch/livepatch-callbacks-demo.c | 190 +++++++++++++++++++++++++++ > samples/livepatch/livepatch-callbacks-mod.c | 53 ++++++++ > 8 files changed, 462 insertions(+), 14 deletions(-) > create mode 100644 Documentation/livepatch/callbacks.txt > create mode 100644 samples/livepatch/livepatch-callbacks-demo.c > create mode 100644 samples/livepatch/livepatch-callbacks-mod.c > > diff --git a/Documentation/livepatch/callbacks.txt b/Documentation/livepatch/callbacks.txt > new file mode 100644 > index 000000000000..e18f2678f3bb > --- /dev/null > +++ b/Documentation/livepatch/callbacks.txt > @@ -0,0 +1,87 @@ > +(Un)patching Callbacks > +====================== > + > +Livepatch (un)patch-callbacks provide a mechanism for livepatch modules > +to execute callback functions when a kernel object is (un)patched. They > +can be considered a "power feature" that extends livepatching abilities > +to include: > + > + - Safe updates to global data > + > + - "Patches" to init and probe functions > + > + - Patching otherwise unpatchable code (i.e. assembly) > + > +In most cases, (un)patch hooks will need to be used in conjunction with s/hooks/callbacks/ (though I wouldn't be opposed to changing them back to "hooks" anyway as it's one fewer syllable :-) but no strong opinion either way on that) -- Josh