Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2240877rdf; Mon, 6 Nov 2023 08:26:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFiwvcSQoqc+z5xpLwdAb6y2EWyDL4Lvol6If/zmIwNTmqe7fAciaqaBB7O+sp8VcSdPtK X-Received: by 2002:a17:90a:7527:b0:27d:4b6e:b405 with SMTP id q36-20020a17090a752700b0027d4b6eb405mr25808463pjk.33.1699287967627; Mon, 06 Nov 2023 08:26:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699287967; cv=none; d=google.com; s=arc-20160816; b=GttiW8m41JsidOUZd4iy7F2fEPwUqcEjY0s797u6+5OpwVbpfo5w5niJPpIPCMEt5E y58g5ypVw9dCvdsnkJjUIXMLuRtpGIqyc0XtUhD60ojM/CwidRh73Tj658IIp5uWbWh1 oMKn9W72CwK1rDPHTob+bvNeZyVCbX6gVOlP/QSPATz+sUxhGVo/os45ikGSnh9GxA1A gBE6YA+oxJs5G0YTqTxEsJdiwAFNvqNnjmbs8aUKrOReEzKiYq6x5xl9rDrNpkz4n9Cg 5ZrMaQGP1+Tt2EhXbUR6eiSFrU3jPAiXiL+En2ixu2pOjjQ3sQg+j+6BkF5oZsxUFJSv lBCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=ob/3KR5vtw053vP6IAp0IYpjgIdHRPjmD1sNZvpeql0=; fh=vZ6WhgrPPTeFSs0fWRWCKnl4FbJkrfyiREmhm+x1VlA=; b=BjLt+1WqYGAIhaygxqWD4XWt5chA7XBTi+ShZ8sTWt12e+AL3qpWQZcbZ5HnHXkjA1 ipKzevqWrmWV5Arr8F2AhGgcY87FxsdExBPJlcokB0Q26B48nW7tBeKjEL8FisnDJden cNwfJeR/bigKrdmRO6fL1s4iK1JNN3200FJtHjbzRKSSIzFzipVwxwPLXbwUd/Upg7Fw Z0/rz7SuaTRQRnXZSRz4kykI/72wGA2ThEERiV9rP3I1FLtXrOgKYI3QdvedSDxzzFXe ZkGHDcAkzfiSHg//+LTwxX//ngkgvXNId4IiGMLUUXVQRHYRR08XrnrRMJw0177yZdgj vU1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=mi0IHoKw; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id lx1-20020a17090b4b0100b0026b31ed4895si9580618pjb.29.2023.11.06.08.26.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 08:26:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=mi0IHoKw; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 55ACA808E8CD; Mon, 6 Nov 2023 08:26:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232345AbjKFQZu (ORCPT + 99 others); Mon, 6 Nov 2023 11:25:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232536AbjKFQZs (ORCPT ); Mon, 6 Nov 2023 11:25:48 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C7881BF; Mon, 6 Nov 2023 08:25:45 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id A21FD20068; Mon, 6 Nov 2023 16:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1699287943; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ob/3KR5vtw053vP6IAp0IYpjgIdHRPjmD1sNZvpeql0=; b=mi0IHoKw5riU85/0sf6qaNa3jS2PNV4ug2EA+CCnutY6KPZQV6dTb4Xksq75570q8Jb3km oxDxxEH7yiTDcwFQt4c6qkcrhFxh9jRMOEz4T092ogvEyOOMCYUtBGt0w1ksnA+fLL8yL9 ix+xQ+OksjB5ZSJA/1WIB/EmhA/n8sE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1699287943; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ob/3KR5vtw053vP6IAp0IYpjgIdHRPjmD1sNZvpeql0=; b=sFVp2uUDhufFOXyNbCdYdXLvAFvLiW31KQPhmoQrNMoola6hV9DCxWebYU0kYU09tqI4zL ErLs8L3wmQp4RnDA== Received: from localhost.cz (lhruska.udp.ovpn2.prg.suse.de [10.100.204.118]) by relay2.suse.de (Postfix) with ESMTP id 3CB9A2CD83; Mon, 6 Nov 2023 16:25:43 +0000 (UTC) From: Lukas Hruska To: Petr Mladek , Miroslav Benes , Josh Poimboeuf Cc: Joe Lawrence , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Marcos Paulo de Souza , Lukas Hruska Subject: [PATCH v1 0/5] livepatch: klp-convert tool - Minimal version Date: Mon, 6 Nov 2023 17:25:08 +0100 Message-ID: <20231106162513.17556-1-lhruska@suse.cz> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 08:26:04 -0800 (PST) Summary ------- This is a significantly simplified version of the original klp-convert tool. The klp-convert code has never got a proper review and also clean ups were not easy. The last version was v7, see https://lore.kernel.org/r/20230306140824.3858543-1-joe.lawrence@redhat.com The main change is that the tool does not longer search for the symbols which would need the livepatch specific relocation entry. Also klp.symbols file is not longer needed. Instead, the needed information is appended to the symbol declaration via a new macro KLP_RELOC_SYMBOL(). It creates symbol with all needed metadata. For example: extern char *saved_command_line \ KLP_RELOC_SYMBOL(vmlinux, vmlinux, saved_command_line, 0); would create symbol $>readelf -r -W : Relocation section '.rela.text' at offset 0x32e60 contains 10 entries: Offset Info Type Symbol's Value Symbol's Name + Addend [...] 0000000000000068 0000003c00000002 R_X86_64_PC32 0000000000000000 .klp.sym.rela.vmlinux.vmlinux.saved_command_line,0 - 4 [...] The simplified klp-convert tool just transforms symbols created by KLP_RELOC_SYMBOL() to object specific rela sections and rela entries which would later be proceed when the livepatch or the livepatched object is loaded. For example, klp-convert would replace the above symbols with: $> readelf -r -W Relocation section '.klp.rela.vmlinux.text' at offset 0x5cb60 contains 1 entry: Offset Info Type Symbol's Value Symbol's Name + Addend 0000000000000068 0000003c00000002 R_X86_64_PC32 0000000000000000 .klp.sym.vmlinux.saved_command_line,0 - 4 Note that similar macro was needed also in the original version to handle more symbols of the same name (sympos). Given the above, add klp-convert tool; integrate klp-convert tool into kbuild; add data-structure and macros to enable users to annotate livepatch source code; make modpost stage compatible with livepatches; update livepatch-sample and update documentation. Testing ------- The patchset selftests build and execute on x86_64, s390x, and ppc64le for both default config (with added livepatch dependencies) and a larger SLE-15-ish config. Summary of changes in this minimal version ------------------------ - rebase for v6.5 - cleaned-up SoB chains (suggested by pmladek) - klp-convert: remove the symbol map auto-resolving solution - klp-convert: add macro for flagging variables inside a LP src to be resolved by this tool - klp-convert: code simplification Previous versions ----------------- RFC: https://lore.kernel.org/lkml/cover.1477578530.git.jpoimboe@redhat.com/ v2: https://lore.kernel.org/lkml/f52d29f7-7d1b-ad3d-050b-a9fa8878faf2@redhat.com/ v3: https://lore.kernel.org/lkml/20190410155058.9437-1-joe.lawrence@redhat.com/ v4: https://lore.kernel.org/lkml/20190509143859.9050-1-joe.lawrence@redhat.com/ v5: (not posted) https://github.com/joe-lawrence/klp-convert-tree/tree/klp-convert-v5-devel v6: https://lore.kernel.org/live-patching/20220216163940.228309-1-joe.lawrence@redhat.com/ v7: https://lore.kernel.org/all/20230306140824.3858543-1-joe.lawrence@redhat.com/