Received: by 10.223.185.116 with SMTP id b49csp4911244wrg; Tue, 27 Feb 2018 04:53:13 -0800 (PST) X-Google-Smtp-Source: AH8x225mIg3C/cCf4PBdE8Vuu3d+TZkF64sTqS8Z+X/GMD9LWFEDuuK9cS1OFZYXey7T5xXVKwDt X-Received: by 10.99.109.70 with SMTP id i67mr11307494pgc.190.1519735993787; Tue, 27 Feb 2018 04:53:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519735993; cv=none; d=google.com; s=arc-20160816; b=u33eWmuPuAJ16Ov+gLxYJPQ1eI3gWiFPKDy69y5DppDXDF/SLj6FTcDdmzNLXCKX2V TlTjtFHUvE1UlPMnSoLYqd+MuXxXT4WWFIPwK9EchEOU7OBnUNvuQ497gC5J38zVXDuY vyh6M8UIG+uzn+mIgyu/1benaNeXY5gnL4z4AkMAMBW35dHvLOgTR6xeRZBhxJEIhkZS baoFjge1hJqjzb69M1vVuerfB4XQo7Lqix1AZKhTcfitZBeEtz1WykvVVyuc5sxECcU3 aGlpkUlFNQT6zljUl3SxHlNS7sE3IZG0x6EK84BE5qm8kzkwYBrDEoy2Nmkpv1qtVNu/ 0C8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=bQXA91rREgty+eBc7jjkA8jQC66PFAkpQ+7kCVjzgDU=; b=D89Nug97KNtHsL+YpAuVLmfdt4tWcVYrLN24qNgs41XlKqPQ87fC5ILxWvPZDtRZe+ JuRpdd2zi3ts5hZRPzI25HwmhBh2AQUb4NcvYMNb2E5uWP8Odq3N7QQSOFMQsxYAiy6j /op9E+l+rQrkRdQpCJTsPcevRrERGbbkC+ON0CBWxWBtrhHZMhcmIH4XAOgW/wPDZYMD hzolVZVepQ3SqJULxoFRfRYjfhd/Bg2ZYaEsSB4lOIsuOpY1wOtfinkObEEzChrCFCGW jEqSMjHH66L325pAWzlP5/zXdfQgC5/MND2cn/kyNaBdQkszGAv+9Yv7itlqtfvvXF0k +7bA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u137si6979743pgc.630.2018.02.27.04.52.57; Tue, 27 Feb 2018 04:53:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752621AbeB0Mgq (ORCPT + 99 others); Tue, 27 Feb 2018 07:36:46 -0500 Received: from mx2.suse.de ([195.135.220.15]:49701 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752107AbeB0Mgp (ORCPT ); Tue, 27 Feb 2018 07:36:45 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DFE2BAE60; Tue, 27 Feb 2018 12:36:43 +0000 (UTC) Date: Tue, 27 Feb 2018 13:36:42 +0100 (CET) From: Miroslav Benes To: Joe Lawrence cc: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Josh Poimboeuf , Jessica Yu , Jiri Kosina , Petr Mladek , Jason Baron , Evgenii Shatokhin Subject: Re: [PATCH v0 2/3] livepatch: update documentation/samples for callbacks In-Reply-To: <1519421630-12025-3-git-send-email-joe.lawrence@redhat.com> Message-ID: References: <1519421630-12025-1-git-send-email-joe.lawrence@redhat.com> <1519421630-12025-3-git-send-email-joe.lawrence@redhat.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 23 Feb 2018, Joe Lawrence wrote: > Update livepatch callback documentation and samples with respect to new > atomic replace / cumulative patch functionality. > > Signed-off-by: Joe Lawrence > --- > Documentation/livepatch/callbacks.txt | 102 ++++++++++++++++ > samples/livepatch/Makefile | 1 + > samples/livepatch/livepatch-callbacks-demo2.c | 162 ++++++++++++++++++++++++++ > 3 files changed, 265 insertions(+) > create mode 100644 samples/livepatch/livepatch-callbacks-demo2.c > > diff --git a/Documentation/livepatch/callbacks.txt b/Documentation/livepatch/callbacks.txt > index c9776f48e458..b5e67975c5a9 100644 > --- a/Documentation/livepatch/callbacks.txt > +++ b/Documentation/livepatch/callbacks.txt > @@ -86,6 +86,13 @@ If the object did successfully patch, but the patch transition never > started for some reason (e.g., if another object failed to patch), > only the post-unpatch callback will be called. > > +If a livepatch is replaced by a cumulative patch, then only the > +callbacks belonging to the cumulative patch will be executed. This > +simplifies the livepatching core for it is the responsibility of the > +cumulative patch to safely revert whatever needs to be reverted. See > +Documentation/livepatch/cumulative.txt for more information on such > +patches. s/cumulative/atomic replace/ almost everywhere? 'Documentation/livepatch/cumulative.txt' should be 'Documentation/livepatch/cumulative-patches.txt' and we may rename it atomic-replace-patches.txt. I don't know. Cumulative patches forms a subset of atomic replace patches in my understanding. The feature itself is more general. Even if practically used for cumulative patches only. But it is for you and Petr to decide. > Example Use-cases > ================= > @@ -603,3 +610,98 @@ pre-unpatch callbacks are skipped: > % rmmod samples/livepatch/livepatch-callbacks-busymod.ko > [ 141.279111] livepatch_callbacks_busymod: busymod_work_func exit > [ 141.279760] livepatch_callbacks_busymod: livepatch_callbacks_mod_exit > + > + > +Test 10 > +------- > + > +Test loading multiple livepatch modules containing callback routines. > +The livepatching core executes callbacks for all modules. > + > +- load livepatch > +- load second livepatch > +- disable livepatch > +- disable second livepatch > +- unload livepatch > +- unload second livepatch > + > + % insmod samples/livepatch/livepatch-callbacks-demo.ko > + [ 216.448208] livepatch: enabling patch 'livepatch_callbacks_demo' > + [ 216.448211] livepatch: 'livepatch_callbacks_demo': initializing patching transition > + [ 216.448330] livepatch_callbacks_demo: pre_patch_callback: vmlinux > + [ 216.448341] livepatch: 'livepatch_callbacks_demo': starting patching transition > + [ 218.720099] livepatch: 'livepatch_callbacks_demo': completing patching transition > + [ 218.720179] livepatch_callbacks_demo: post_patch_callback: vmlinux > + [ 218.720180] livepatch: 'livepatch_callbacks_demo': patching complete > + > + % insmod samples/livepatch/livepatch-callbacks-demo2.ko > + [ 220.126552] livepatch: enabling patch 'livepatch_callbacks_demo2' > + [ 220.126554] livepatch: 'livepatch_callbacks_demo2': initializing patching transition > + [ 220.126592] livepatch_callbacks_demo2: pre_patch_callback: vmlinux > + [ 220.126593] livepatch: 'livepatch_callbacks_demo2': starting patching transition > + [ 221.728091] livepatch: 'livepatch_callbacks_demo2': completing patching transition > + [ 221.728254] livepatch_callbacks_demo2: post_patch_callback: vmlinux > + [ 221.728255] livepatch: 'livepatch_callbacks_demo2': patching complete > + > + % echo 0 > /sys/kernel/livepatch/livepatch_callbacks_demo2/enabled > + [ 223.434556] livepatch: 'livepatch_callbacks_demo2': initializing unpatching transition > + [ 223.434616] livepatch_callbacks_demo2: pre_unpatch_callback: vmlinux > + [ 223.434617] livepatch: 'livepatch_callbacks_demo2': starting unpatching transition > + [ 224.736159] livepatch: 'livepatch_callbacks_demo2': completing unpatching transition > + [ 224.736660] livepatch_callbacks_demo2: post_unpatch_callback: vmlinux > + [ 224.736662] livepatch: 'livepatch_callbacks_demo2': unpatching complete > + > + % echo 0 > /sys/kernel/livepatch/livepatch_callbacks_demo/enabled > + [ 227.284070] livepatch: 'livepatch_callbacks_demo': initializing unpatching transition > + [ 227.284111] livepatch_callbacks_demo: pre_unpatch_callback: vmlinux > + [ 227.284112] livepatch: 'livepatch_callbacks_demo': starting unpatching transition > + [ 228.704142] livepatch: 'livepatch_callbacks_demo': completing unpatching transition > + [ 228.704215] livepatch_callbacks_demo: post_unpatch_callback: vmlinux > + [ 228.704216] livepatch: 'livepatch_callbacks_demo': unpatching complete > + > + % rmmod samples/livepatch/livepatch-callbacks-demo2.ko > + % rmmod samples/livepatch/livepatch-callbacks-demo.ko > + > + > +Test 11 > +------- > + > +A similar test as the previous one, except this time load the second > +callback demo module as a cumulative (ie, replacement) patch. The > +livepatching core will only execute klp_object callbacks for the latest > +cumulative patch on the patch stack. > + > +- load livepatch > +- load second livepatch (atomic replace) > +- disable livepatch Not needed. Miroslav > +- disable second livepatch > +- unload livepatch > +- unload second livepatch > + > + % insmod samples/livepatch/livepatch-callbacks-demo.ko > + [16435.711175] livepatch: enabling patch 'livepatch_callbacks_demo' > + [16435.711185] livepatch: 'livepatch_callbacks_demo': initializing patching transition > + [16435.711271] livepatch_callbacks_demo: pre_patch_callback: vmlinux > + [16435.711297] livepatch: 'livepatch_callbacks_demo': starting patching transition > + [16436.704092] livepatch: 'livepatch_callbacks_demo': completing patching transition > + [16436.704363] livepatch_callbacks_demo: post_patch_callback: vmlinux > + [16436.704364] livepatch: 'livepatch_callbacks_demo': patching complete > + > + % insmod samples/livepatch/livepatch-callbacks-demo2.ko replace=1 > + [16442.760963] livepatch: enabling patch 'livepatch_callbacks_demo2' > + [16442.760966] livepatch: 'livepatch_callbacks_demo2': initializing patching transition > + [16442.761018] livepatch_callbacks_demo2: pre_patch_callback: vmlinux > + [16442.761018] livepatch: 'livepatch_callbacks_demo2': starting patching transition > + [16444.704092] livepatch: 'livepatch_callbacks_demo2': completing patching transition > + [16444.704181] livepatch_callbacks_demo2: post_patch_callback: vmlinux > + [16444.704181] livepatch: 'livepatch_callbacks_demo2': patching complete > + > + % echo 0 > /sys/kernel/livepatch/livepatch_callbacks_demo2/enabled > + [16448.434672] livepatch: 'livepatch_callbacks_demo2': initializing unpatching transition > + [16448.434712] livepatch: 'livepatch_callbacks_demo2': starting unpatching transition > + [16449.760134] livepatch: 'livepatch_callbacks_demo2': completing unpatching transition > + [16449.760338] livepatch: 'livepatch_callbacks_demo2': unpatching complete > + ** TODO ** where are the demo2 unpatch callbacks? > + > + % rmmod samples/livepatch/livepatch-callbacks-demo2.ko > + % rmmod samples/livepatch/livepatch-callbacks-demo.ko