From patchwork Mon Apr 29 14:56:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13647085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A148C19F53 for ; Mon, 29 Apr 2024 15:01:01 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.714125.1115147 (Exim 4.92) (envelope-from ) id 1s1SUi-000647-TJ; Mon, 29 Apr 2024 15:00:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 714125.1115147; Mon, 29 Apr 2024 15:00:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SUi-00063k-Or; Mon, 29 Apr 2024 15:00:40 +0000 Received: by outflank-mailman (input) for mailman id 714125; Mon, 29 Apr 2024 15:00:39 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SUh-00061u-Du for xen-devel@lists.xenproject.org; Mon, 29 Apr 2024 15:00:39 +0000 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [2607:f8b0:4864:20::72b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3d391801-0639-11ef-909b-e314d9c70b13; Mon, 29 Apr 2024 17:00:38 +0200 (CEST) Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-790f4650f93so114417085a.2 for ; Mon, 29 Apr 2024 08:00:38 -0700 (PDT) Received: from localhost ([213.195.114.223]) by smtp.gmail.com with ESMTPSA id oo14-20020a05620a530e00b00790f6f8b03csm807879qkn.55.2024.04.29.08.00.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:00:36 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3d391801-0639-11ef-909b-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1714402837; x=1715007637; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CiR1avLNZwB2iaSZsLj5E6HA1txC8l+NaDpKGNZUIvI=; b=QqgEUupfH79KQGHsJaIJcWPjJCo+uJ04B+Pe+Ai/U1rJ1G4SBWpubL5jee4MGm/w7L i+7vYvCL5OsI2PwxZeIGYZU0E5lkAoLR12sTFAEsfX0A1pmRooHejk5QJskWF1gTfORL 9bMMiUepGimMcVUUwwLorhEpSRxg1XSyepMds= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714402837; x=1715007637; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CiR1avLNZwB2iaSZsLj5E6HA1txC8l+NaDpKGNZUIvI=; b=AQZ4oEAG/LlJr7tFo7UbiQjvdt3m/H7JoPGHt0WrryjxyICGRTB5Ehy2rT+D1UrCEs jD26MEYEOgbco8LhknRUmfsVIGXRlRHvFZ9iSSryfhviANCZfjIxeAsri1hX7MOvKtTy 7BjaTKnM0zN8Vf3PBd0ZUsGK/D7Y7LYmVUemSLyr/u/WBV/u4wRykRCS9MiKLvNSMFzf QXTLwP2TYL5SBV+Zcbe8hXMA5AtOs9TIePCC5E8lgcxInmr3Z7UEdpG6buujc8AMIh58 WpxfhR04E+vwOJdShbIvSEC/dEA29nm4CE5fs2/R0YE8pj1Lypx9lA9CVUwiEbDLun31 RPhQ== X-Gm-Message-State: AOJu0YxcQwYNXu6CGYVI7jNp8o57O/gGf+oYqq63Fs192usAp3Clrq3I hj6ndO3A0QpESUpsNUeREwnjLdPXRXJi/s6LyTpxI+78JRey9R2fU9Rcsxmfv0Ogefv/MCweSq3 S X-Google-Smtp-Source: AGHT+IHE66QaziwrLZLcC+gNcKROz5NfYV0txx1zAAT6J8hMJhKzbk7ohPvn/82BVbBB1YE+GHAibA== X-Received: by 2002:a05:620a:a92:b0:790:96d4:7a5e with SMTP id v18-20020a05620a0a9200b0079096d47a5emr10944592qkg.12.1714402837340; Mon, 29 Apr 2024 08:00:37 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: konrad.wilk@oracle.com, ross.lagerwall@citrix.com, Roger Pau Monne Subject: [PATCH 1/9] livepatch-build-tools: allow patch file name sizes up to 127 characters Date: Mon, 29 Apr 2024 16:56:46 +0200 Message-ID: <20240429145654.71669-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429145654.71669-1-roger.pau@citrix.com> References: <20240429145654.71669-1-roger.pau@citrix.com> MIME-Version: 1.0 XenServer uses quite long Xen version names, and encode such in the livepatch filename, and it's currently running out of space in the file name. Bump max filename size to 127, so it also matches the patch name length in the hypervisor interface. Note the size of the buffer is 128 character, and the last one is reserved for the null terminator. Signed-off-by: Roger Pau Monné --- Changes since v1: - Take into account the null terminator. --- livepatch-build | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/livepatch-build b/livepatch-build index 948b2acfc2f6..f3ca9399d149 100755 --- a/livepatch-build +++ b/livepatch-build @@ -72,8 +72,9 @@ function make_patch_name() fi # Only allow alphanumerics and '_' and '-' in the patch name. Everything - # else is replaced with '-'. Truncate to 48 chars. - echo ${PATCHNAME//[^a-zA-Z0-9_-]/-} |cut -c 1-48 + # else is replaced with '-'. Truncate to 127 chars + # (XEN_LIVEPATCH_NAME_SIZE - 1). + echo ${PATCHNAME//[^a-zA-Z0-9_-]/-} |cut -c -127 } # Do a full normal build From patchwork Mon Apr 29 14:56:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13647082 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3503C4345F for ; Mon, 29 Apr 2024 15:00:52 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.714126.1115162 (Exim 4.92) (envelope-from ) id 1s1SUn-0006XM-8r; Mon, 29 Apr 2024 15:00:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 714126.1115162; Mon, 29 Apr 2024 15:00:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SUn-0006XF-5j; Mon, 29 Apr 2024 15:00:45 +0000 Received: by outflank-mailman (input) for mailman id 714126; Mon, 29 Apr 2024 15:00:44 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SUl-0006Ve-Vo for xen-devel@lists.xenproject.org; Mon, 29 Apr 2024 15:00:43 +0000 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [2607:f8b0:4864:20::72d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3f2b3c33-0639-11ef-b4bb-af5377834399; Mon, 29 Apr 2024 17:00:42 +0200 (CEST) Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-790605809cbso420317085a.3 for ; Mon, 29 Apr 2024 08:00:42 -0700 (PDT) Received: from localhost ([213.195.114.223]) by smtp.gmail.com with ESMTPSA id pa2-20020a05620a830200b0078ede2e9125sm10422151qkn.57.2024.04.29.08.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:00:39 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3f2b3c33-0639-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1714402840; x=1715007640; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SiQeSFoT/wXbOVQjeXcAWBiOE9S9/ogSwfjl5ofYfjE=; b=UJMh97+hl4Old0cahbYH5d+r4/9LYzJy9lgZ+VkqVojsktRGxB8PnHuTGbAWJsRr5S X2VEE6BqRmFR9Ns9R4Domwt3I4YfNrOGoKoRzwH6KnDURslxny8/iNoTVwnW6YpQBqap GR5UedV+qlLgu9rsN6hUVF/aU/ypHiG6759K8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714402840; x=1715007640; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SiQeSFoT/wXbOVQjeXcAWBiOE9S9/ogSwfjl5ofYfjE=; b=cPydUbqrl3h/nBY97pEFSGgAfRwiwTOZyae4ivdTbjpnDCmoQiPI8mEK2QMoyI2ur1 LTi8IjTHuULg7iwYA9SEpOgcWwt3EnyURcWpE+iIrZ8ftZgVp2gxsYknim3X9V+ofimz LAdM1Uzz3z7PnRGLcqV8y/fvHPUd2Ftd+4zNpSld8km3v/5n32XPBVwxh1f+Jyp+ZCFK d8UvOCEgh+BsyP/Tp4mi4pklKkLwJp89jfzjfyGYdw8qxifYLZzCRL464Fcy4i7Xxsa/ F58WrnY4v9MyzTUfBVrBOSKQriUylItwU+76dnJLtyzEyGaLx9zxzq8NlAdv3z2togF5 e3cA== X-Gm-Message-State: AOJu0YwMpJaV9xj9bV7lByctIW1ZttVTYu1dyRnGdjWlhu3jlKteW9Id E6U6UcLTUijYZG7/rwYFqSoPgxOz1IFwm/utYJjCNb7JRer6NbV7e985bVcgXTJmw/9y1TTDg5R 4 X-Google-Smtp-Source: AGHT+IGyzndRvqqRSoKqlx/mXjkWwqb7cfTC/no9JTMWUvvtw0nuLVnO4nxSXwkIu/HziZUgZD6Gxg== X-Received: by 2002:a05:620a:1a16:b0:790:8926:a69e with SMTP id bk22-20020a05620a1a1600b007908926a69emr12973353qkb.74.1714402840107; Mon, 29 Apr 2024 08:00:40 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: konrad.wilk@oracle.com, ross.lagerwall@citrix.com, Roger Pau Monne Subject: [PATCH 2/9] create-diff-object: update default alt_instr size Date: Mon, 29 Apr 2024 16:56:47 +0200 Message-ID: <20240429145654.71669-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429145654.71669-1-roger.pau@citrix.com> References: <20240429145654.71669-1-roger.pau@citrix.com> MIME-Version: 1.0 The size of the alt_instr structure in Xen is 14 instead of 12 bytes, adjust it. Signed-off-by: Roger Pau Monné --- create-diff-object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create-diff-object.c b/create-diff-object.c index fed360a9aa68..d8a2afbf2774 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -1000,7 +1000,7 @@ static int altinstructions_group_size(struct kpatch_elf *kelf, int offset) char *str; if (!size) { str = getenv("ALT_STRUCT_SIZE"); - size = str ? atoi(str) : 12; + size = str ? atoi(str) : 14; } log_debug("altinstr_size=%d\n", size); From patchwork Mon Apr 29 14:56:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13647086 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D4950C04FFE for ; Mon, 29 Apr 2024 15:01:01 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.714127.1115171 (Exim 4.92) (envelope-from ) id 1s1SUo-0006my-GV; Mon, 29 Apr 2024 15:00:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 714127.1115171; Mon, 29 Apr 2024 15:00:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SUo-0006mp-Dd; Mon, 29 Apr 2024 15:00:46 +0000 Received: by outflank-mailman (input) for mailman id 714127; Mon, 29 Apr 2024 15:00:44 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SUm-00061u-Ic for xen-devel@lists.xenproject.org; Mon, 29 Apr 2024 15:00:44 +0000 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [2607:f8b0:4864:20::82d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 404a482c-0639-11ef-909b-e314d9c70b13; Mon, 29 Apr 2024 17:00:43 +0200 (CEST) Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-4376e3fd7e4so26387901cf.2 for ; Mon, 29 Apr 2024 08:00:43 -0700 (PDT) Received: from localhost ([213.195.114.223]) by smtp.gmail.com with ESMTPSA id k3-20020ac81403000000b00434b1f4e371sm10390572qtj.13.2024.04.29.08.00.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:00:42 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 404a482c-0639-11ef-909b-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1714402842; x=1715007642; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tIQL44q1facCYinF0oLLBfEQhZ81h9VJYnFL1TS4smQ=; b=ocfhCp3Eg4E1PPDLGCmfEtk61vZtapxxszL+gR/9/p6og6tIz1RMiQCFbqUbfV8Uri sMs/VaEzOWphg0kxzE1Ckw2s23BEsqp9Pieq/ZrUi7/9WfZekl54lE4ZgEbtBwAwFZvp Ok4Renic0ShephJOHlfTrNm9UJt/i1GMyYNOY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714402842; x=1715007642; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tIQL44q1facCYinF0oLLBfEQhZ81h9VJYnFL1TS4smQ=; b=s/2hw6fjjNh0O431fPqeAkmT7fVTx/JkrLnb5Of6aBojDeCcdL+a/ZkV5iDXDDWRE5 cQDPN0OpVr+4l83xtF00U5sfNVhu3RvdsISo8t58oUCXVPlQlIbQ5gP8fFFdSZQZWQNS jUgyOAzp9PTTJmwAdC0yz8avlVp7bu4DOR5xETLqZiXiRkBhPUd7HJ0mvkc7ZjfxLjjQ 2UJdnKZ6AaVpp1aknr23dMyXgsnUJmBz2MkrQR4Y6gwW8SBiEprh46mfoyuqzF+X5HtL L4xGATUEVJoW0qXukc6wZevOXZmUte/9laBQwMxYkeRTjocVk1YPgqc6ZZ6suEIfNVld o9dg== X-Gm-Message-State: AOJu0YzPDjNdlRgfuiMGDUZnDEUTYLJ/7IXS6qZF/PIFZTtQtKNJDr20 8Lj8Rwj6SyeJ217Wz9IX+cHNQgHHciPes52t0rzelS0XHrdXzevRRJrQl0UwRfhVp5K8WBT+dqt C X-Google-Smtp-Source: AGHT+IE7GahoqRxCd3aGn0U1XCVeiA/KWYl/oQDUK2088DWFjxKaP1VEXT07v9R6T974NWvCaqkJhw== X-Received: by 2002:a05:622a:1921:b0:437:bcac:a770 with SMTP id w33-20020a05622a192100b00437bcaca770mr14426957qtc.55.1714402842435; Mon, 29 Apr 2024 08:00:42 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: konrad.wilk@oracle.com, ross.lagerwall@citrix.com, Roger Pau Monne Subject: [PATCH 3/9] livepatch-build: fix detection of structure sizes Date: Mon, 29 Apr 2024 16:56:48 +0200 Message-ID: <20240429145654.71669-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429145654.71669-1-roger.pau@citrix.com> References: <20240429145654.71669-1-roger.pau@citrix.com> MIME-Version: 1.0 The current runes assume that in the list of DWARF tags DW_AT_byte_size will come after DW_AT_name, but that's not always the case. On one of my builds I've seen: DW_AT_name : (indirect string, offset: 0x3c45): exception_table_entry DW_AT_declaration : 1 <1>: Abbrev Number: 5 (DW_TAG_const_type) DW_AT_type : <0xb617> <1>: Abbrev Number: 14 (DW_TAG_pointer_type) DW_AT_byte_size : 8 Instead of assuming such order, explicitly search for the DW_AT_byte_size tag when a match in the DW_AT_name one is found. Signed-off-by: Roger Pau Monné --- All this ad hoc parsing of DWARF data seems very fragile. This is an improvement over the current logic, but I would still prefer if we could find a more reliable way to obtain the struct sizes we need. --- livepatch-build | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/livepatch-build b/livepatch-build index f3ca9399d149..aad9849f2ba9 100755 --- a/livepatch-build +++ b/livepatch-build @@ -427,9 +427,16 @@ if [ "${SKIP}" != "build" ]; then SPECIAL_VARS=$(readelf -wi "$OUTPUT/xen-syms" | awk ' BEGIN { a = b = e = 0 } + # Ensure no fall through to the next tag without getting the size + (a == 1 || b == 1 || e == 1) && /DW_AT_name/ \ + {print "can not get special structure size" > "/dev/stderr"; exit 1} a == 0 && /DW_AT_name.* alt_instr/ {a = 1; next} b == 0 && /DW_AT_name.* bug_frame/ {b = 1; next} e == 0 && /DW_AT_name.* exception_table_entry/ {e = 1; next} + # Seek the line that contains the size + a == 1 && !/DW_AT_byte_size/ {next} + b == 1 && !/DW_AT_byte_size/ {next} + e == 1 && !/DW_AT_byte_size/ {next} # Use shell printf to (possibly) convert from hex to decimal a == 1 {printf("export ALT_STRUCT_SIZE=`printf \"%%d\" \"%s\"`\n", $4); a = 2} b == 1 {printf("export BUG_STRUCT_SIZE=`printf \"%%d\" \"%s\"`\n", $4); b = 2} From patchwork Mon Apr 29 14:56:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13647084 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 833F9C4345F for ; Mon, 29 Apr 2024 15:00:59 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.714128.1115181 (Exim 4.92) (envelope-from ) id 1s1SUr-00075K-PU; Mon, 29 Apr 2024 15:00:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 714128.1115181; Mon, 29 Apr 2024 15:00:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SUr-00075D-Ly; Mon, 29 Apr 2024 15:00:49 +0000 Received: by outflank-mailman (input) for mailman id 714128; Mon, 29 Apr 2024 15:00:47 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SUp-0006Ve-OF for xen-devel@lists.xenproject.org; Mon, 29 Apr 2024 15:00:47 +0000 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [2607:f8b0:4864:20::72d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 41a33aa5-0639-11ef-b4bb-af5377834399; Mon, 29 Apr 2024 17:00:46 +0200 (CEST) Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-79100a90868so29299685a.2 for ; Mon, 29 Apr 2024 08:00:46 -0700 (PDT) Received: from localhost ([213.195.114.223]) by smtp.gmail.com with ESMTPSA id sq18-20020a05620a4ad200b0078d5f7b9a2dsm10320819qkn.15.2024.04.29.08.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:00:44 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 41a33aa5-0639-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1714402845; x=1715007645; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TeOl9O7LDZ2iZGM+JQTgtPA8a4JFNTC4N89WNpXHObE=; b=AbX4Z1ySumGuZa8+qCmNrsXjCpHAlnA1/CDpcPoOjauCw+5v7kyIV52gXIfPHGfw9O ojMIAyZasCHDzKf/QwjlXILlRgXSONSlf6g9EmmmUUpj00qiwcpWRFLUAkHjzzE2w5j+ PS5ACDHCoyZ04aD5Lkcuyg432mosTkTwkLgKQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714402845; x=1715007645; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TeOl9O7LDZ2iZGM+JQTgtPA8a4JFNTC4N89WNpXHObE=; b=UUYHOcYT6SR2J4mAazNsJW0z9IN8OYt3fD5ZUn/v7Ei1dpDNZp+TtkbwdO+bqlkdeY +CfHkYNVnFAAk0l0dQrXoyOirJ/F/69LSkUaP38HuYclhi2cm8WRdv7Y5LkgItOmA651 f0imXalOvMXWw4FX92Chv43/RMAnE8YeLXGSD50M/zxlAFzDI7YcdGPBVMpNnevmDU/k S6ldTgB8sxOCqUDAtFJAUZDnawRpL7Q1j2NyYU4Dw9BMnIxbRcC1nNEEzyK16tx10xUX MDQSEZyn22hj91QJbDWb9enjPOUVMMITyq1qKIMoAOonOSCjOXksxC51lbuymuT4Vn0e awsQ== X-Gm-Message-State: AOJu0YzTivCrEpapfnUZEjHszPX1y71lvFvrrQxGu3e1AWopAi85VaC+ zlaSAZJzUF/wcMsGusOtCU1mmnlKdoftCz2fiuJZVNb6D0CCvm3Wni8CcRpsXqDjWgugU2ooBH8 w X-Google-Smtp-Source: AGHT+IEQTaracmximP7j2sbFjK4X6UAk8BGjawiXJbZvQU35r2lCSidN0qLlCOK94Lpv7HSFuOQ2FA== X-Received: by 2002:a05:620a:414b:b0:790:c677:545d with SMTP id k11-20020a05620a414b00b00790c677545dmr8130046qko.68.1714402844493; Mon, 29 Apr 2024 08:00:44 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: konrad.wilk@oracle.com, ross.lagerwall@citrix.com, Roger Pau Monne Subject: [PATCH 4/9] create-diff-object: document kpatch_regenerate_special_section() behavior Date: Mon, 29 Apr 2024 16:56:49 +0200 Message-ID: <20240429145654.71669-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429145654.71669-1-roger.pau@citrix.com> References: <20240429145654.71669-1-roger.pau@citrix.com> MIME-Version: 1.0 The purpose of kpatch_regenerate_special_section() is fairly opaque without spending a good amount of time and having quite a lot of knowledge about what the special sections contains. Introduce some comments in order to give context and describe the expected functionality. Signed-off-by: Roger Pau Monné --- create-diff-object.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/create-diff-object.c b/create-diff-object.c index d8a2afbf2774..6a751bf3b789 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -1210,6 +1210,12 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf, src_offset = 0; dest_offset = 0; + + /* + * Special sections processed here are array objects, hence in order to + * detect whether a special section needs processing attempt to get the + * element size. Returning a size of 0 means no processing required. + */ group_size = special->group_size(kelf, src_offset); if (group_size == 0) { log_normal("Skipping regeneration of a special section: %s\n", @@ -1246,6 +1252,33 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf, if (src_offset + group_size > sec->base->sh.sh_size) group_size = sec->base->sh.sh_size - src_offset; + /* + * Special sections handled perform a bunch of different tasks, + * but they all have something in common: they are array like + * sections that reference functions in the object file being + * processed. + * + * .bug_frames.* relocations reference the symbol (plus offset) + * where the exception is triggered from. + * + * .altinstructions relocations contain references to + * coordinates where the alternatives are to be applied, plus + * coordinates that point to the replacement code in + * .altinstr_replacement. + * + * .ex_table relocations contain references to the coordinates + * where the fixup code should be executed, plus relocation + * coordinates that point to the text code to execte living in + * the .fixup section. + * + * .livepatch.hooks.* relocations point to the hook + * functions. + * + * Such dependencies allow to make a decision on whether an + * element in the array needs including in the livepatch: if + * the symbol pointed by the relocation is new or has changed + * the array element needs including. + */ include = should_keep_rela_group(sec, src_offset, group_size); if (!include) From patchwork Mon Apr 29 14:56:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13647088 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2AC6EC25B5C for ; Mon, 29 Apr 2024 15:01:02 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.714129.1115191 (Exim 4.92) (envelope-from ) id 1s1SUu-0007OP-1j; Mon, 29 Apr 2024 15:00:52 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 714129.1115191; Mon, 29 Apr 2024 15:00:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SUt-0007O7-VC; Mon, 29 Apr 2024 15:00:51 +0000 Received: by outflank-mailman (input) for mailman id 714129; Mon, 29 Apr 2024 15:00:50 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SUs-0006Ve-Mh for xen-devel@lists.xenproject.org; Mon, 29 Apr 2024 15:00:50 +0000 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [2607:f8b0:4864:20::f2a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 435b60d9-0639-11ef-b4bb-af5377834399; Mon, 29 Apr 2024 17:00:49 +0200 (CEST) Received: by mail-qv1-xf2a.google.com with SMTP id 6a1803df08f44-6a0b68733f5so17121996d6.1 for ; Mon, 29 Apr 2024 08:00:49 -0700 (PDT) Received: from localhost ([213.195.114.223]) by smtp.gmail.com with ESMTPSA id mg22-20020a056214561600b006a0cd4c2d9bsm1081568qvb.28.2024.04.29.08.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:00:46 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 435b60d9-0639-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1714402847; x=1715007647; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RQz1eJLG5RTUbfOfXgpL5NrHKeTAiJtLKKFiPXfVznk=; b=WB/hh2C8gS8Z/CsJQadz2EmKNa0AWHuIp4F4l2ReRO0KshtHSkwq8yWCGPXJQMyKZu QkTnoCd3BpxcqzcAWfUjCP9/UsAw6eZtBEbL8stee84kl1PhU0QLqydtw4l6vkKDigxz f065T72fguBaQG3LXRZIZFTi9n+UP+UTF8sa8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714402847; x=1715007647; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RQz1eJLG5RTUbfOfXgpL5NrHKeTAiJtLKKFiPXfVznk=; b=jpMWCzd+5zncRVuHC4cMPhhTEH2r6fNX6hhOS7yC588xGAbeZwrS5hjngMK5QLxC6V a8SgLTQz7KeTgFVhaL58HzbldSCrljzxhBAHhgucBxXCxhYa2Tkgw2JsORsylgJqrmP0 WSAqKLo9xF156qlS9wTrdFarL33lWXYo4+rr5Xg+ipGACYM6AiVDIVLvUDpGyEFe1VHB /yMxpsKmysxd54iftMG12QoDeN4jgLUyH+P0TnyAB3Jk/F1aXgFxhobEjdAO1EoP9z/+ EsmXEJ3opA80lcQhHrr36/DAor4r3iFpO1X8x9hlubviLeaKZHHw+fic9AbxaBEdwQG/ PRBg== X-Gm-Message-State: AOJu0Yz6Ko6cz8BeWqmTNWvnAhTKvu11HNLS/qRYP4P7o7E1bomiuKEL 1xbbkvnUKmrpolgQs1a95vogojI3YrX8MQWcIFhN7fs5OIAE7buMgdj0gMzElqJdBM2kISwU5ma r X-Google-Smtp-Source: AGHT+IEXBtTgAfpV3p39ATbcVjeU7BTkltXUUJMbnqzj2OpTZpuakYk2/N+6I2Nt2geVhKOHwwNukA== X-Received: by 2002:a05:6214:250a:b0:6a0:c9eb:25db with SMTP id gf10-20020a056214250a00b006a0c9eb25dbmr4996306qvb.8.1714402846918; Mon, 29 Apr 2024 08:00:46 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: konrad.wilk@oracle.com, ross.lagerwall@citrix.com, Roger Pau Monne Subject: [PATCH 5/9] create-diff-object: move kpatch_include_symbol() Date: Mon, 29 Apr 2024 16:56:50 +0200 Message-ID: <20240429145654.71669-6-roger.pau@citrix.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429145654.71669-1-roger.pau@citrix.com> References: <20240429145654.71669-1-roger.pau@citrix.com> MIME-Version: 1.0 So it can be used by kpatch_process_special_sections() in further changes. Non functional change. Signed-off-by: Roger Pau Monné --- create-diff-object.c | 74 ++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/create-diff-object.c b/create-diff-object.c index 6a751bf3b789..7674d972e301 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -1198,6 +1198,43 @@ void kpatch_update_ex_table_addend(struct kpatch_elf *kelf, } } +#define inc_printf(fmt, ...) \ + log_debug("%*s" fmt, recurselevel, "", ##__VA_ARGS__); + +static void kpatch_include_symbol(struct symbol *sym, int recurselevel) +{ + struct rela *rela; + struct section *sec; + + inc_printf("start include_symbol(%s)\n", sym->name); + sym->include = 1; + inc_printf("symbol %s is included\n", sym->name); + /* + * Check if sym is a non-local symbol (sym->sec is NULL) or + * if an unchanged local symbol. This a base case for the + * inclusion recursion. + */ + if (!sym->sec || sym->sec->include || + (sym->type != STT_SECTION && sym->status == SAME)) + goto out; + sec = sym->sec; + sec->include = 1; + inc_printf("section %s is included\n", sec->name); + if (sec->secsym && sec->secsym != sym) { + sec->secsym->include = 1; + inc_printf("section symbol %s is included\n", sec->secsym->name); + } + if (!sec->rela) + goto out; + sec->rela->include = 1; + inc_printf("section %s is included\n", sec->rela->name); + list_for_each_entry(rela, &sec->rela->relas, list) + kpatch_include_symbol(rela->sym, recurselevel+1); +out: + inc_printf("end include_symbol(%s)\n", sym->name); + return; +} + static void kpatch_regenerate_special_section(struct kpatch_elf *kelf, struct special_section *special, struct section *sec) @@ -1455,43 +1492,6 @@ static void kpatch_include_standard_string_elements(struct kpatch_elf *kelf) } } -#define inc_printf(fmt, ...) \ - log_debug("%*s" fmt, recurselevel, "", ##__VA_ARGS__); - -static void kpatch_include_symbol(struct symbol *sym, int recurselevel) -{ - struct rela *rela; - struct section *sec; - - inc_printf("start include_symbol(%s)\n", sym->name); - sym->include = 1; - inc_printf("symbol %s is included\n", sym->name); - /* - * Check if sym is a non-local symbol (sym->sec is NULL) or - * if an unchanged local symbol. This a base case for the - * inclusion recursion. - */ - if (!sym->sec || sym->sec->include || - (sym->type != STT_SECTION && sym->status == SAME)) - goto out; - sec = sym->sec; - sec->include = 1; - inc_printf("section %s is included\n", sec->name); - if (sec->secsym && sec->secsym != sym) { - sec->secsym->include = 1; - inc_printf("section symbol %s is included\n", sec->secsym->name); - } - if (!sec->rela) - goto out; - sec->rela->include = 1; - inc_printf("section %s is included\n", sec->rela->name); - list_for_each_entry(rela, &sec->rela->relas, list) - kpatch_include_symbol(rela->sym, recurselevel+1); -out: - inc_printf("end include_symbol(%s)\n", sym->name); - return; -} - static int kpatch_include_changed_functions(struct kpatch_elf *kelf) { struct symbol *sym; From patchwork Mon Apr 29 14:56:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13647087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E2875C25B10 for ; Mon, 29 Apr 2024 15:01:01 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.714130.1115201 (Exim 4.92) (envelope-from ) id 1s1SUv-0007eN-9D; Mon, 29 Apr 2024 15:00:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 714130.1115201; Mon, 29 Apr 2024 15:00:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SUv-0007dd-5p; Mon, 29 Apr 2024 15:00:53 +0000 Received: by outflank-mailman (input) for mailman id 714130; Mon, 29 Apr 2024 15:00:52 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SUu-00061u-Ad for xen-devel@lists.xenproject.org; Mon, 29 Apr 2024 15:00:52 +0000 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [2607:f8b0:4864:20::72b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 44fcd359-0639-11ef-909b-e314d9c70b13; Mon, 29 Apr 2024 17:00:51 +0200 (CEST) Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-790c36dcee9so177920385a.2 for ; Mon, 29 Apr 2024 08:00:51 -0700 (PDT) Received: from localhost ([213.195.114.223]) by smtp.gmail.com with ESMTPSA id k17-20020a0cc791000000b0069b5672bab8sm2931726qvj.134.2024.04.29.08.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:00:48 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 44fcd359-0639-11ef-909b-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1714402850; x=1715007650; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xd4lZ7/Bfmvxjs4M6E3w4HW0FfqXGJAqEEwuT6BA+iE=; b=rbVFcPHsOSAbgLMMImyT1StCMuT3dmIt2kVVFVVpzUMgkq4+bKr84gB7SM9AOQQOyk CFmDA1Q4bw1bR6lPRQ/Tnwz2MxSUHe887FHOwwSwG7/wYZagNENBLHOfWOgPgnb+oMBh 34KacTHBopA14ENa1l5GBIVQizmPAIVT5NmZM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714402850; x=1715007650; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xd4lZ7/Bfmvxjs4M6E3w4HW0FfqXGJAqEEwuT6BA+iE=; b=JFcgGoRwIieaJQ66zftqCmFbnlxz7CY8LBYsRKdZ6Fz4c1ryd/S69BbgwKJwnKARRl SyrWWynBohogeBlF/2agEMyMfS42XfaiZbBebn5Wf0+linxu/MBct8OAhetacp7oLjMi 8Eh+z2SkYwHN3vi6N3uGZiTZuXfsPAyYyjNrKryU8xtH2GKZTrhRcfYsmvfLTgpx2OP5 wY7NW+GqBJ9ueIs2PKkbJPJ8o1FiiGQ+vnvW6hXTE5/gM1CvO5Lk0vWvmjSxjuEDk+DC osyBf04myMpUa9/xGJcFSqlVKnoAxCg238Hh/g8YiWpfzXCMo6Th76gfeOuCGgTG7nbd d72w== X-Gm-Message-State: AOJu0YzpsiUnvJciHju3oiD65Bsauw2yMvlAFktLH0GXuqIiZ3iFBtBD 31N+z3NQmx5R0XglKifZpOKBz+3mN9xjhjTykPnl0c5Oz3VtwZvGsD82oC8ptjkCFGUXFC+B9aW 6 X-Google-Smtp-Source: AGHT+IHOmO2lrGeD523koRfftzGmX4T+JaFhJC/d9cTRx7FnHPaxJ98Q386J+pdqp5gySJa2j/zeVw== X-Received: by 2002:a05:6214:2625:b0:6a0:ccc4:9c9b with SMTP id gv5-20020a056214262500b006a0ccc49c9bmr4326861qvb.44.1714402850284; Mon, 29 Apr 2024 08:00:50 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: konrad.wilk@oracle.com, ross.lagerwall@citrix.com, Roger Pau Monne Subject: [PATCH 6/9] create-diff-object: detect changes in .altinstr_replacement and .fixup sections Date: Mon, 29 Apr 2024 16:56:51 +0200 Message-ID: <20240429145654.71669-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429145654.71669-1-roger.pau@citrix.com> References: <20240429145654.71669-1-roger.pau@citrix.com> MIME-Version: 1.0 The current logic to detect changes in special sections elements will only include group elements that reference function symbols that need including (either because they have changed or are new). This works fine in order to detect when a special section element needs including because of the function is points has changed or is newly introduced, but doesn't detect changes to the replacement code in .altinstr_replacement or .fixup sections, as the relocations in that case are against STT_SECTION symbols. Fix this by also including the special section group if the symbol the relocations points to is of type section. Signed-off-by: Roger Pau Monné --- create-diff-object.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/create-diff-object.c b/create-diff-object.c index 7674d972e301..f4e4da063d0a 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -1158,11 +1158,21 @@ static int should_keep_rela_group(struct section *sec, int start, int size) struct rela *rela; int found = 0; - /* check if any relas in the group reference any changed functions */ + /* + * Check if any relas in the group reference any changed functions. + * + * Relocations in the .altinstructions and .ex_table special sections + * can also reference changed section symbols, since the replacement + * text in both cases resides on a section that has no function symbols + * (.altinstr_replacement and .fixup respectively). Account for that + * and also check whether the referenced symbols are section ones in + * order to decide whether the relocation group needs including. + */ list_for_each_entry(rela, &sec->relas, list) { if (rela->offset >= start && rela->offset < start + size && - rela->sym->type == STT_FUNC && + (rela->sym->type == STT_FUNC || + rela->sym->type == STT_SECTION) && rela->sym->sec->include) { found = 1; log_debug("new/changed symbol %s found in special section %s\n", @@ -1338,6 +1348,21 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf, rela->sym->include = 1; + /* + * Changes that cause only the + * .altinstr_replacement or .fixup sections to + * be modified need the target function of the + * replacement to also be marked as CHANGED, + * otherwise livepatch won't replace the + * function, and the new replacement code won't + * take effect. + */ + if (rela->sym->type == STT_FUNC && + rela->sym->status == SAME) { + rela->sym->status = CHANGED; + kpatch_include_symbol(rela->sym, 0); + } + if (!strcmp(special->name, ".fixup")) kpatch_update_ex_table_addend(kelf, special, src_offset, From patchwork Mon Apr 29 14:56:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13647090 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48958C4345F for ; Mon, 29 Apr 2024 15:01:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.714131.1115212 (Exim 4.92) (envelope-from ) id 1s1SV0-00087Y-O6; Mon, 29 Apr 2024 15:00:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 714131.1115212; Mon, 29 Apr 2024 15:00:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SV0-00087M-Jw; Mon, 29 Apr 2024 15:00:58 +0000 Received: by outflank-mailman (input) for mailman id 714131; Mon, 29 Apr 2024 15:00:56 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SUy-0006Ve-Rp for xen-devel@lists.xenproject.org; Mon, 29 Apr 2024 15:00:56 +0000 Received: from mail-oo1-xc33.google.com (mail-oo1-xc33.google.com [2607:f8b0:4864:20::c33]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 46fbe4fa-0639-11ef-b4bb-af5377834399; Mon, 29 Apr 2024 17:00:55 +0200 (CEST) Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-5ac8c73cf88so3212412eaf.2 for ; Mon, 29 Apr 2024 08:00:55 -0700 (PDT) Received: from localhost ([213.195.114.223]) by smtp.gmail.com with ESMTPSA id d17-20020a0cf0d1000000b006a04769b5a7sm10441892qvl.110.2024.04.29.08.00.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:00:52 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 46fbe4fa-0639-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1714402853; x=1715007653; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IFbDmju5IjTA9HMoPxU+gJubSBkYzhzZZat8pMJw8AU=; b=ckv782+AXekPtMhi+DR01PJTWQCWGOkV6os/hAANCqBmLRorqpcFu8mK6jg/QgHyKk tNXENyJ+cx6kq901C3aXjmXMlTkWfrUpVD7jculei/Olv/s5bj2Dg/sucCUVAfOMZRM9 wAYaBwP3dLtbG+h6id1ySXwA/UIonqef70gG0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714402853; x=1715007653; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IFbDmju5IjTA9HMoPxU+gJubSBkYzhzZZat8pMJw8AU=; b=Rhd4/QqvUG1PmegseSJKeKmF7dZ0x55ZR0AqGnoLCCgBB5Hbean3cNd6w4JccfFWUL qnEV4WQXwIxwn99mqhLFicIGCmvB/BJT73X+hxJ386dJbi6iN+piu60UEyBm8u/GmEnX /WgjH75nsRrpY/C53UWWfojpdOfpdhF6rbNSj2Yu7GXEcIj3aAXyVykG1vKIzcQ8ZEYx wiKEVVlJkNqmoYS0CdYYlvLSqFiPFK/2jZhZvxLxsHYI269RJEOLk2460AFd/TICzczP xdgjHjrNc4nYBADPSDHponxii1xvtM2+L22KmXbg6BOx9drQKdJDftJZCrl/hwdzMKdm MlrQ== X-Gm-Message-State: AOJu0YwdroKmz6L8yaLaQR1ejuchUV444+8TVmJcFOUiSTCba5YUyjUs GluQY+HIfBYn1uu5Vr/2B4IvShkb/xfH6Y0sWqAszRJFxEXub98/i7Q/JEAd7yQQjeQw4lep0P/ n X-Google-Smtp-Source: AGHT+IH61EQ/4nlaImXeAg5mlusaibvWGRzYoiVkr/DIS2WKP+Xnc4BLJE3V92IGdcm2d2Yz1gEuoA== X-Received: by 2002:a05:6358:1913:b0:18e:3ec:94cb with SMTP id w19-20020a056358191300b0018e03ec94cbmr12307398rwm.14.1714402853326; Mon, 29 Apr 2024 08:00:53 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: konrad.wilk@oracle.com, ross.lagerwall@citrix.com, Roger Pau Monne Subject: [PATCH 7/9] create-diff-object: don't account for changes to .bug_frame.? sections Date: Mon, 29 Apr 2024 16:56:52 +0200 Message-ID: <20240429145654.71669-8-roger.pau@citrix.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429145654.71669-1-roger.pau@citrix.com> References: <20240429145654.71669-1-roger.pau@citrix.com> MIME-Version: 1.0 bug_frame related sections exclusively contain addresses that reference back to the address where the BUG_INSTR is executed. As such, any change to the contents of bug_frame sections (or it's relocations) will necessarily require a change in the caller function, as the placement of the BUG_INSTR must have changed. Take advantage of this relocation, and unconditionally mark the bug_frame sections themselves as not having changed, the logic in kpatch_regenerate_special_section() will already take care of including any bug_frame element group that references a function that has changed. This should be a non functional change in the payload generated by create-diff-object, but needs doing so that we can take into account changes to .altinstructions and .ex_table sections themselves without unnecessarily also pulling .bug_frame sections. Signed-off-by: Roger Pau Monné --- create-diff-object.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/create-diff-object.c b/create-diff-object.c index f4e4da063d0a..d1b1477be1cd 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -1284,6 +1284,17 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf, } } + /* + * For bug_frame sections don't care if the section itself or the + * relocations have changed, as any change in the bug_frames will be + * accompanied by a change in the caller function text, as the + * BUG_INSTR will have a different placement in the caller. + */ + if (!strncmp(special->name, ".bug_frames.", strlen(".bug_frames."))) { + sec->status = SAME; + sec->base->status = SAME; + } + for ( ; src_offset < sec->base->sh.sh_size; src_offset += group_size) { group_size = special->group_size(kelf, src_offset); From patchwork Mon Apr 29 14:56:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13647089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5549C4345F for ; Mon, 29 Apr 2024 15:01:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.714132.1115222 (Exim 4.92) (envelope-from ) id 1s1SV2-0008RC-1a; Mon, 29 Apr 2024 15:01:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 714132.1115222; Mon, 29 Apr 2024 15:00:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SV1-0008QM-Sb; Mon, 29 Apr 2024 15:00:59 +0000 Received: by outflank-mailman (input) for mailman id 714132; Mon, 29 Apr 2024 15:00:57 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SUz-00061u-Nc for xen-devel@lists.xenproject.org; Mon, 29 Apr 2024 15:00:57 +0000 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [2607:f8b0:4864:20::829]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 48213e23-0639-11ef-909b-e314d9c70b13; Mon, 29 Apr 2024 17:00:57 +0200 (CEST) Received: by mail-qt1-x829.google.com with SMTP id d75a77b69052e-4365c1451d4so31256561cf.2 for ; Mon, 29 Apr 2024 08:00:57 -0700 (PDT) Received: from localhost ([213.195.114.223]) by smtp.gmail.com with ESMTPSA id h5-20020ac85485000000b00439cccb91b2sm6612689qtq.73.2024.04.29.08.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:00:55 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 48213e23-0639-11ef-909b-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1714402856; x=1715007656; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bJJy5gubMnJaNx3BJ2gbPZ/DdC5mFYTQDBpTvDsIrfk=; b=Z5H15jZQky0Gux1WB9koyK6gFqtIZrc3cBNDrPvCxDPatbZ1tF+NviCWuR0KNTuWsM xPEujhloHRLDG47Xq5GxZD6McfeE7B5tdGMSxJRJZcInL9buc5/4Z6dKLg6SJrhyAPZO Yf0WWvlZIMC+3XGWumULngAuzs4fFiPAB1hBA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714402856; x=1715007656; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bJJy5gubMnJaNx3BJ2gbPZ/DdC5mFYTQDBpTvDsIrfk=; b=Q47uPIBq/q3RqzaHIiswayxKbcoDeQmk/6pPY9aU+C2XPm63HD1Hm0pi2hnutthFsR j/U7N7gMaufsoSqQxv/kW6nJ6TrnQtjMOPmzb8EzmxOhxaPep2nAmQz4qrfZPg+W5pIf JLtweLXwt9wKnSYZD3VncrRmkXmpouuoGm4hfnL6/Zb8yeSqJDFzOh+U1yW24kyNsta0 dPydjG5hwtv7vm28esJUfOxTqmQIeyCNZokLclHX2eu27j1JWvFKhmnTkDWF4lQwVQXV hs/V30AYyjmTUXugyw0O6xr5o3EfhTXeUX8JUNvHDM1cc2FkoNqYNcNYrtZFuR7DCRNC rNNQ== X-Gm-Message-State: AOJu0YwmGO87wRKrgVeziJby6JxPfOSS/ZD8cU3Ah0UhSjt0SxerAVpg qP+LxJP8Nx6mXXOFGdURlOmRnvEHDn9Mmo8DPvP/Xn3PfYOv1Ce8FmVDrtbxrNK3q065Ksn5OnB o X-Google-Smtp-Source: AGHT+IF7Kt4rVMpOZTBkwfNyqexlYmDJuCJB7gQOo9oZubbbFgketoMH7REOTY+yQPwhgpfUnURAkw== X-Received: by 2002:a05:622a:298d:b0:43a:bd5b:2c33 with SMTP id hd13-20020a05622a298d00b0043abd5b2c33mr7519212qtb.3.1714402855678; Mon, 29 Apr 2024 08:00:55 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: konrad.wilk@oracle.com, ross.lagerwall@citrix.com, Roger Pau Monne Subject: [PATCH 8/9] create-diff-object: account for changes in the special section itself Date: Mon, 29 Apr 2024 16:56:53 +0200 Message-ID: <20240429145654.71669-9-roger.pau@citrix.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429145654.71669-1-roger.pau@citrix.com> References: <20240429145654.71669-1-roger.pau@citrix.com> MIME-Version: 1.0 Changes to special sections are not accounted for right now. For example a change that only affects .altinstructions or .ex_table won't be included in the livepatch payload, if none of the symbols referenced by those sections have also changed. Since it's not possible to know which elements in the special group have changed if we detect a change in the special section the whole group (minus elements that have references to init section symbols) must be included. Signed-off-by: Roger Pau Monné --- create-diff-object.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/create-diff-object.c b/create-diff-object.c index d1b1477be1cd..8bfb6bf92a1b 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -1170,13 +1170,32 @@ static int should_keep_rela_group(struct section *sec, int start, int size) */ list_for_each_entry(rela, &sec->relas, list) { if (rela->offset >= start && - rela->offset < start + size && - (rela->sym->type == STT_FUNC || - rela->sym->type == STT_SECTION) && - rela->sym->sec->include) { - found = 1; - log_debug("new/changed symbol %s found in special section %s\n", - rela->sym->name, sec->name); + rela->offset < start + size) + { + /* + * Avoid including groups with relocations against + * symbols living in init sections, those are never + * included in livepatches. + */ + if (is_init_section(rela->sym->sec)) + return 0; + + /* + * If the base section has changed, always include all + * groups (except those pointing to .init section + * symbols), as we have no way to differentiate which + * groups have changed. + */ + if (sec->status != SAME || sec->base->status != SAME) + found = 1; + else if ((rela->sym->type == STT_FUNC || + rela->sym->type == STT_SECTION) && + rela->sym->sec->include) { + found = 1; + log_debug( + "new/changed symbol %s found in special section %s\n", + rela->sym->name, sec->name); + } } } From patchwork Mon Apr 29 14:56:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13647091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A223AC19F53 for ; Mon, 29 Apr 2024 15:01:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.714136.1115232 (Exim 4.92) (envelope-from ) id 1s1SV4-0000NK-C1; Mon, 29 Apr 2024 15:01:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 714136.1115232; Mon, 29 Apr 2024 15:01:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SV4-0000MQ-6t; Mon, 29 Apr 2024 15:01:02 +0000 Received: by outflank-mailman (input) for mailman id 714136; Mon, 29 Apr 2024 15:01:00 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s1SV2-00061u-O3 for xen-devel@lists.xenproject.org; Mon, 29 Apr 2024 15:01:00 +0000 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [2607:f8b0:4864:20::f30]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 499c070b-0639-11ef-909b-e314d9c70b13; Mon, 29 Apr 2024 17:00:59 +0200 (CEST) Received: by mail-qv1-xf30.google.com with SMTP id 6a1803df08f44-69b6c2e9ed9so21091906d6.1 for ; Mon, 29 Apr 2024 08:00:59 -0700 (PDT) Received: from localhost ([213.195.114.223]) by smtp.gmail.com with ESMTPSA id t10-20020a0cef0a000000b006a040cdd805sm392396qvr.92.2024.04.29.08.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:00:57 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 499c070b-0639-11ef-909b-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1714402858; x=1715007658; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ABIMao/S3hzX29QxYYcWMCOhcIr5YSs4nbEkZAC6ppk=; b=ESvZdTEfYhOldho+Qeoi7BKH6MkOsqdG9R6iwAdt81dt6fE15zkk4wkga7Tuk3ZmlH H7j42bXg5Knvabwlscjiv9tMoeysK7pTWXQf0dAps1m6DyMpKur4zJ6BNtOV8yJESadF i1jdgMUX0oh+XFr5Q64pAfxNV5/9Ycn8LQk9g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714402858; x=1715007658; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ABIMao/S3hzX29QxYYcWMCOhcIr5YSs4nbEkZAC6ppk=; b=Q1oh/ouC/3WalvjBgDA1ar602mkQQrQaUuUz9pYgU1OXpJ9L8vzqfOgyoLntFTmnNu 5K6wbbkhVikh1fztaQ/kf5XhBU9OglrDYo/g4Jv2CgLNCXtQSjvMSv6amgh/RplZq7M7 UIIMVxo7yfqOUfkqBZ3TiQzf/5ZWde8yBFTSS9mqlrZAkbaTsPO/q0zwrYX2nxu/U5o7 8maAVd7hesYzLxpuf0+W9kJh79CPi0hJPC3vtnVP7CxrOgXuPue1S+Q6q/U/T/8d022z /2tgc8qlkBa8+BcfSoNNS9FQsxlyEF1VbuT9VR2dthxC5N+j1r6+W2bPoPPVgnEzpH7d BcPA== X-Gm-Message-State: AOJu0Yxjmg4mR7tzyL2jTcWc6bhFjE5QC30JMGENDVVuQYs5K6Yfph15 1jEggLOL8IqJQypoPBWa2VSGEAAdMnIluMpLUQa4mHbm8xM58kDD9cOwrX1sDmr6TfGqrF4pKNZ w X-Google-Smtp-Source: AGHT+IGxPcDT9IwGTWGDL4oYzCXrDmSIbNhuvzGMF891BclHIsi0n3Dih5B5TyYh4tZ1b0v0ecwWcg== X-Received: by 2002:a05:6214:130d:b0:6a0:5528:9594 with SMTP id pn13-20020a056214130d00b006a055289594mr11828763qvb.64.1714402858002; Mon, 29 Apr 2024 08:00:58 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: konrad.wilk@oracle.com, ross.lagerwall@citrix.com, Roger Pau Monne Subject: [PATCH 9/9] create-diff-object: account for special section changes Date: Mon, 29 Apr 2024 16:56:54 +0200 Message-ID: <20240429145654.71669-10-roger.pau@citrix.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429145654.71669-1-roger.pau@citrix.com> References: <20240429145654.71669-1-roger.pau@citrix.com> MIME-Version: 1.0 When deciding whether there's content to generate a payload also take into account whether special sections have changed. Initially account for changes to alternative related section to cause the generation of a livepatch. Note that accounting for hook sections is already done by kpatch_include_hook_elements() when deciding whether there's changed content in the object file. .bugframe sections are also not accounted for since any section in a bugframe section will be accompanied by a change in the function the bugframe references (the placement of the BUG_INSTR will change in the caller function). Signed-off-by: Roger Pau Monné --- create-diff-object.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/create-diff-object.c b/create-diff-object.c index 8bfb6bf92a1b..957631097b8a 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -1663,6 +1663,28 @@ static int kpatch_include_hook_elements(struct kpatch_elf *kelf) return num_new_functions; } +static unsigned int include_special_sections(const struct kpatch_elf *kelf) +{ + const struct section *sec; + unsigned int nr = 0; + + /* + * Only account for changes in alternatives and exception table related + * sections. Hooks are already taken care of separately, and changes + * in bug_frame sections always go along with changes in the caller + * functions. + */ + list_for_each_entry(sec, &kelf->sections, list) + if (sec->status != SAME && + (!strcmp(sec->name, ".altinstructions") || + !strcmp(sec->name, ".altinstr_replacement") || + !strcmp(sec->name, ".ex_table") || + !strcmp(sec->name, ".fixup"))) + nr++; + + return nr; +} + static int kpatch_include_new_globals(struct kpatch_elf *kelf) { struct symbol *sym; @@ -2469,6 +2491,8 @@ int main(int argc, char *argv[]) kpatch_include_debug_sections(kelf_patched); log_debug("Include hook elements\n"); num_changed += kpatch_include_hook_elements(kelf_patched); + log_debug("Include special sections\n"); + num_changed += include_special_sections(kelf_patched); log_debug("num_changed = %d\n", num_changed); log_debug("Include new globals\n"); new_globals_exist = kpatch_include_new_globals(kelf_patched);