From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754809AbcHSIcX (ORCPT ); Fri, 19 Aug 2016 04:32:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:58780 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754603AbcHSIcV (ORCPT ); Fri, 19 Aug 2016 04:32:21 -0400 Date: Fri, 19 Aug 2016 10:32:18 +0200 From: Petr Mladek To: Jessica Yu Cc: Josh Poimboeuf , Miroslav Benes , Jiri Kosina , Chris J Arges , Eugene Shatokhin , live-patching@vger.kernel.org, x86@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: livepatch/x86: apply alternatives and paravirt patches after relocations Message-ID: <20160819083218.GQ13300@pathway.suse.cz> References: <1471481911-5003-1-git-send-email-jeyu@redhat.com> <1471481911-5003-3-git-send-email-jeyu@redhat.com> <20160818095153.GM13300@pathway.suse.cz> <20160818180313.GA8272@packer-debian-8-amd64.digitalocean.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160818180313.GA8272@packer-debian-8-amd64.digitalocean.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2016-08-18 14:03:13, Jessica Yu wrote: > +++ Petr Mladek [18/08/16 11:51 +0200]: > >On Wed 2016-08-17 20:58:29, Jessica Yu wrote: > >>Implement arch_klp_init_object_loaded() for x86, which applies > >>alternatives/paravirt patches. This fixes the order in which relocations > >>and alternatives/paravirt patches are applied. > >> > >>--- /dev/null > >>+++ b/arch/x86/kernel/livepatch.c > >>+ for (s = info->sechdrs; s < info->sechdrs + info->hdr.e_shnum; s++) { > >>+ /* Apply per-object .klp.arch sections */ > >>+ cnt = sscanf(info->secstrings + s->sh_name, > >>+ ".klp.arch.%55[^.].%127s", > >>+ sec_objname, secname); > >>+ if (cnt != 2) > >>+ continue; > >>+ if (strcmp(sec_objname, objname)) > >>+ continue; > >>+ if (!strcmp(".altinstructions", secname)) > > > >The previous version of the patch compared against "altinstructions" > >(without the dot). I admit that I haven't tested it but the dot > >looks suspicious here. > > Good eye, I should have explained why the dot is needed in the strcmp.. > So, the new documentation states that any arch-specific sections to > be applied by livepatch are to be prefixed with the string > ".klp.arch.$objname.", note the required dot at the end of this prefix. > > So for example, if we have a .parainstructions section with a patch > for the kvm module, the prefixed section name would look like: > > .klp.arch.kvm..parainstructions > ^ prefix ^^ original name ^ > > That extra dot looks weird, but it is needed when we have section names > like "__ftr_fixup" on powerpc. Without the extra dot at the end of > ".klp.arch.$objname." We'd get names like ".klp.arch.$objname__ftr_fixup", > and we wouldn't be able to tell where the objname ends and where the > section name begins. But with ".klp.arch.$objname.__ftr_fixup", we > have a hard delimeter and know that after the dot after $objname comes > the original section name. That is a bit unfortunate but it makes perfect sense. Thanks a lot for explanation. Best Regards, Petr