Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp4635335pxb; Wed, 20 Apr 2022 07:17:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4mzfAWpOaSTujy7v0Ma4v9eh0gCcz3min0RDyJ3Plr1KbzDOrLPSxXDGl9yVfjhptLsfk X-Received: by 2002:a05:6808:14d5:b0:2da:455b:1917 with SMTP id f21-20020a05680814d500b002da455b1917mr1719405oiw.81.1650464272850; Wed, 20 Apr 2022 07:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650464272; cv=none; d=google.com; s=arc-20160816; b=zWbSG6AHpa+gQY33YVjICbTMmLQNqifOeeJ3HNBqJRMpJ200XUqdBPoq7eWYYXe5Qr R0LHGOyZtu01X6KuwRf8lEGRnRX1bzgUpKtIZJqkdfa4038GHTvIdYNWxwIuVjgiddba 3PYyyuoKmhnnX91TOh7BMu8kNQv+DIcIK49vkOeHrJeRe8gGt1VmPYvXRKWkC8aTKPRF /nN3Fw+3lvCvOH3h3UA789bo51sMb+hVh4FVRI909r9leZLXxWd3JWKPEFRQVGqkq9bJ IUrIXJznd5RtFY4L2eWsL2cF493w6pc+R23eYN1UHsp/dTOvdv8sx0oX21WWh2tMYgsS Qrug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1X1P7TWjalEM123qZYEn+EVXAidMNPjn8TgJk2XbTmY=; b=a94XZDGPnJ0/5HBG92Kre74Dp2oABKOrRSP47Z4c2M5AvS9s4z0VhZ7st8I6cxLaED ALOU0/eQv8Ybux9Ol2DW02ZEcqpoUnkFlAXE0VwsfQW/i3Ev1UYU7t1fN4Da+HaGyYYk 66aavruWtfb7Kj/O6A4rT0sYpRzMH64chIh91iPca8hf+z/EJpDTH0Iq1LhI9aq3nlD4 iDTAP9Uny1/2IFqwslq2U66rT3/wDdC1Ub5EY5ISFgt7VfjhRIDxCsSzKiNgZSQjFJEO mkvda3hyrL4uMW6UlcQx9IeWI/H5Na0LiAbZktbyaEGR3ECOx1YJOduHkYhqH6q7C+8J ttXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="c7tCX/v1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v12-20020a9d7d0c000000b006054d0a0e08si1095096otn.51.2022.04.20.07.17.32; Wed, 20 Apr 2022 07:17:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="c7tCX/v1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347352AbiDRSPR (ORCPT + 99 others); Mon, 18 Apr 2022 14:15:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbiDRSPQ (ORCPT ); Mon, 18 Apr 2022 14:15:16 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C19072DD6F for ; Mon, 18 Apr 2022 11:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650305555; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1X1P7TWjalEM123qZYEn+EVXAidMNPjn8TgJk2XbTmY=; b=c7tCX/v12VIwK/NuXj0h6W2aVl+0Z2bIdSXfZFsRFvHcptRZDvaaO6g8cLl6jxyiEs9ZOB LXJMMF8VOkXzG1Wz78lhYg3Q2lte047TZF0p0GseKx1ReTzX8ciNF9DGzEoOACIELejnjn 0eAoWdBQtC5d5MWMLj0XUKvsYtwt/UI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-534-9tjdyVQgO8K919Vc6j2rHw-1; Mon, 18 Apr 2022 14:12:29 -0400 X-MC-Unique: 9tjdyVQgO8K919Vc6j2rHw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6557C805F46; Mon, 18 Apr 2022 18:12:29 +0000 (UTC) Received: from redhat.com (unknown [10.22.8.122]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2F07200D8EF; Mon, 18 Apr 2022 18:12:28 +0000 (UTC) Date: Mon, 18 Apr 2022 14:12:27 -0400 From: Joe Lawrence To: Nicolas Schier Cc: Petr Mladek , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: Re: [RFC PATCH v6 02/12] kbuild: Support for symbols.klp creation Message-ID: References: <20220216163940.228309-1-joe.lawrence@redhat.com> <20220216163940.228309-3-joe.lawrence@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 14, 2022 at 07:59:57PM +0200, Nicolas Schier wrote: > On Thu, Apr 14, 2022 at 11:35:42AM +0200 Petr Mladek wrote: > > On Wed 2022-02-16 11:39:30, Joe Lawrence wrote: > > > From: Joao Moreira > > > > > > For automatic resolution of livepatch relocations, a file called > > > symbols.klp is used. This file maps symbols within every compiled kernel > > > object allowing the identification of symbols whose name is unique, thus > > > relocation can be automatically inferred, or providing information that > > > helps developers when code annotation is required for solving the > > > matter. > > > > > > Add support for creating symbols.klp in the main Makefile. First, ensure > > > that built-in is compiled when CONFIG_LIVEPATCH is enabled (as required > > > to achieve a complete symbols.klp file). Define the command to build > > > symbols.klp (cmd_klp_map) and hook it in the modules rule. > > > > > > As it is undesirable to have symbols from livepatch objects inside > > > symbols.klp, make livepatches discernible by modifying > > > scripts/Makefile.build to create a .livepatch file for each livepatch in > > > $(MODVERDIR). This file then used by cmd_klp_map to identify and bypass > > > livepatches. > > > > > > For identifying livepatches during the build process, a flag variable > > > LIVEPATCH_$(basetarget).o is considered in scripts/Makefile.build. This > > > way, set this flag for the livepatch sample Makefile in > > > samples/livepatch/Makefile. > > > > I do not see the related code in scripts/Makefile.build. > > > > > Finally, Add a clean rule to ensure that symbols.klp is removed during > > > clean. > > > > > > Notes: > > > > > > To achieve a correct symbols.klp file, all kernel objects must be > > > considered, thus, its construction require these objects to be priorly > > > built. On the other hand, invoking scripts/Makefile.modpost without > > > having a complete symbols.klp in place would occasionally lead to > > > in-tree livepatches being post-processed incorrectly. > > > > Honestly, I do not understand what it exactly means that "in-tree > > livepatches would occasionally be post-processed incorrectly". > > > > Is it the problem that modpost is not able to handle the unresolved > > symbols that have to be updated by klp-convert? > > > > > To prevent this > > > from becoming a circular dependency, the construction of symbols.klp > > > uses non-post-processed kernel objects and such does not cause harm as > > > the symbols normally referenced from within livepatches are visible at > > > this stage. Also due to these requirements, the spot in-between modules > > > compilation and the invocation of scripts/Makefile.modpost was picked > > > for hooking cmd_klp_map. > > > > > > The approach based on .livepatch files was proposed as an alternative to > > > using MODULE_INFO statements. This approach was originally proposed by > > > Miroslav Benes as a workaround for identifying livepathes without > > > depending on modinfo during the modpost stage. It was moved to this > > > patch as the approach also shown to be useful while building > > > symbols.klp. > > > > All the tricky code is removed in the 5th patch. My understanding is > > that the problem causing the cyclic dependency is solved by modifying > > modpost. > > > > It looks like this patch is outdated and mostly obsoleted. On the > > other hand, the commit message in 5th patch is too short. > > > > What about merging the two patches and updating the commit message? > > +1 > > Yes, please merge those patches. These '$(shell ...)' side-effect lines in the > definition of 'cmd_klp_map' are quite confusing. > Sure. Admittedly the kbuild integration is most confusing to me, so I leaned heavily on Joao's original notes and Masahiro's gracious tips and refactored code. I'll try cutting to the final version in later patches rather than providing all the (confusing) code evolution along the way. Thanks, -- Joe