From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756818AbcA2UPh (ORCPT ); Fri, 29 Jan 2016 15:15:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36475 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752578AbcA2UPg (ORCPT ); Fri, 29 Jan 2016 15:15:36 -0500 Date: Fri, 29 Jan 2016 14:15:34 -0600 From: Josh Poimboeuf To: Steven Rostedt Cc: Miroslav Benes , Jessica Yu , Seth Jennings , Jiri Kosina , Vojtech Pavlik , Ingo Molnar , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Rusty Russell Subject: Re: [PATCH 1/2] livepatch: Implement separate coming and going module notifiers Message-ID: <20160129201534.GE19101@treble.redhat.com> References: <1454049827-3726-1-git-send-email-jeyu@redhat.com> <1454049827-3726-2-git-send-email-jeyu@redhat.com> <20160129173010.GA19101@treble.redhat.com> <20160129124014.204020ed@gandalf.local.home> <20160129175834.GB19101@treble.redhat.com> <20160129142950.0f6a6e62@gandalf.local.home> <20160129194715.GD19101@treble.redhat.com> <20160129150823.14a5d17e@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160129150823.14a5d17e@gandalf.local.home> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 29, 2016 at 03:08:23PM -0500, Steven Rostedt wrote: > On Fri, 29 Jan 2016 13:47:15 -0600 > Josh Poimboeuf wrote: > > > > > Although, I have to admit, if live kernel patching is configured in, > > > it's not always needed to be called here, does it? With ftrace, the > > > call has to be done when ftrace is configured in regardless if tracing > > > is used or not. > > > > For live patching it actually does need to be called for every module. > > We need to check if any previously loaded patches have any modifications > > which affect the module. > > > > But only if you are using the live kernel patching facility. My point > is, if I never use live kernel patching (which 99.9% of Linux users do > no use), then the call will basically be a nop. > > With ftrace, that's not the story. Even if you don't ever use the > facility (like 99.8% of Linux users do not use ;-) the function is > still not a nop. There's three calls needed for each module. > > 1) convert all the calls to mcount/fentry into a nop, and save > those locations in a table. They are all marked as disabled (not to be > used) > > 2) After module setup (where the notifiers are called), the locations > need to be enabled, otherwise ftrace would never work for that module. > > 3) On module exit, the locations must be removed, otherwise ftrace may > still try to write to non-existing code which could brick specific > network cards. > > These are done if ftrace is configured regardless if it is every > actually used by a user. > > Thus, my question is, what does live kernel patching need to do if I > never add a patch? Right, as you say it's basically a nop 99.99% of the time. But we still need to do the "are any patches loaded" check, so we still need the call into a livepatch function to do that. -- Josh