From nobody Sat Nov 23 16:19:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1701163375; cv=none; d=zohomail.com; s=zohoarc; b=jFTegj6sMYi8yilbM0IT20/C+xUTKEFnpTt5FgVPcyQMzsGC8UL4lfX90MEnERYVdHrb0dCbRx/NjABEi3SoBQ3nibUPcP7FbBHFQyiwrvbJcTGvN2Bau9BQV7uYc3uBuDd5WckR6mKMAhsNnWuPSFpH+uTp4ndgCv00DBU4CO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701163375; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OgDIL9w5jx+UxCwj2sM5xrPgOrkinlsQKkLBTFvRxoc=; b=nnv/RWWzFAe6kQY3Zb26w6wF/FuD1svvM9nFTMxyLrltP7VIbQNV7n5t3nLXsUGOkmJ3NhfAAtTSqnXyoNEmA6GqOWEtR0yBlfaQ/cWq+VRCBDpEi/ej4TG/fO/mTuTAO8qxsd1RMlgoAbuWoazzCOKlHjf1g6JIz/6op6hXgco= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1701163375832653.5307860462831; Tue, 28 Nov 2023 01:22:55 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.642822.1002549 (Exim 4.92) (envelope-from ) id 1r7uIT-0004u4-UN; Tue, 28 Nov 2023 09:22:25 +0000 Received: by outflank-mailman (output) from mailman id 642822.1002549; Tue, 28 Nov 2023 09:22:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r7uIT-0004tx-Rg; Tue, 28 Nov 2023 09:22:25 +0000 Received: by outflank-mailman (input) for mailman id 642822; Tue, 28 Nov 2023 09:22:24 +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 1r7uIS-0004tq-Sj for xen-devel@lists.xenproject.org; Tue, 28 Nov 2023 09:22:24 +0000 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [2a00:1450:4864:20::332]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a32bb506-8dcf-11ee-98e3-6d05b1d4d9a1; Tue, 28 Nov 2023 10:22:23 +0100 (CET) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40b31232bf0so42186155e9.1 for ; Tue, 28 Nov 2023 01:22:23 -0800 (PST) Received: from localhost ([213.195.113.99]) by smtp.gmail.com with ESMTPSA id p34-20020a05600c1da200b00406408dc788sm17535442wms.44.2023.11.28.01.22.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 01:22:22 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: a32bb506-8dcf-11ee-98e3-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1701163343; x=1701768143; 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=OgDIL9w5jx+UxCwj2sM5xrPgOrkinlsQKkLBTFvRxoc=; b=Yr1o+KfN8zJHB4DoKfB2Nc7tjtBMcDQfRoT6R5TmvS+4oOSj8sAT9OJFyfpZkj5XfQ Lly9EKEXkvWBriy6UyAb3EOw1uN9R3ebGwYotkG+DvUDRVNO4X0M2viV/p+uxcpoiPDH fDmBqj2O/cLfDaAyjA2y9d0JKVndAFCHd/cfY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701163343; x=1701768143; 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=OgDIL9w5jx+UxCwj2sM5xrPgOrkinlsQKkLBTFvRxoc=; b=FINwW9i5TzdJ6Qe73HB4UJ0OAyYmnG7A0hlF/bLFU8V/IpQld46IhR5d1qMG1L3ChU sVH55Gqo3Oasi92gG6VwkTNbX52yLRvD6YcNhTIPl8IDfQZfyG/n6UBqZu2eWcNayiFL x9QnNSRTjgflMgOQtW+bgd/RzEuJ1XfXpd5Z5A9xlRnzBq+ylPi97QwLIMsAgc4IkMI2 InIMq/q4uE83/MygRTid0m52BRLwB/P85Xm+HDH2uvru9D/fyPsVEn1Bl4Iy2Z/xrcta QyvsXvQmeckl6TIPFvZt5eF8sLcMmP2Z2GzcM2IG8fyO7nV1Zs+CL8m12z2tLUMVE/fG ByFw== X-Gm-Message-State: AOJu0YyD+XwaPsNslqQ5vJBCaHLG0hYU7lcK+EmdcJhWSJQtwvcU/1Sy BQz2gEU8m4YZcuU7C4igJwLBOh/DapZlabi+6Qc= X-Google-Smtp-Source: AGHT+IERTa201gF0CHZeOAYrIVyvM0E4oJr0RIksH0nF29I7usiI6qaKzScDtaVOuV+0vNMPsuXnYg== X-Received: by 2002:a05:600c:4f16:b0:40b:3857:12f9 with SMTP id l22-20020a05600c4f1600b0040b385712f9mr9408150wmq.5.1701163342885; Tue, 28 Nov 2023 01:22:22 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Konrad Rzeszutek Wilk , Ross Lagerwall , Roger Pau Monne Subject: [PATCH v2 1/3] livepatch-build-tools: do not use readlink -m option Date: Tue, 28 Nov 2023 10:21:50 +0100 Message-ID: <20231128092152.35039-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231128092152.35039-1-roger.pau@citrix.com> References: <20231128092152.35039-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1701163376414000001 Busybox readlink implementation only supports the -f option to follow symli= nks, so adjust the logic in order to keep the same behaviour without using the -m option. Singed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Ross Lagerwall --- livepatch-build | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/livepatch-build b/livepatch-build index 91d203bda0eb..305644037ee7 100755 --- a/livepatch-build +++ b/livepatch-build @@ -336,8 +336,8 @@ while [[ $# -gt 0 ]]; do ;; --xen-syms) shift - XENSYMS=3D"$(readlink -m -- "$1")" - [ -f "$XENSYMS" ] || die "xen-syms file does not exist" + [ -f "$1" ] || die "xen-syms file does not exist" + XENSYMS=3D"$(readlink -f -- "$1")" shift ;; --depends) @@ -366,22 +366,20 @@ while [[ $# -gt 0 ]]; do done =20 [ -z "$srcarg" ] && die "Xen directory not given" +[ -d "$srcarg" ] || die "Xen directory does not exist" [ -z "$patcharg" ] && die "Patchfile not given" +[ -f "$patcharg" ] || die "Patchfile does not exist" [ -z "$configarg" ] && die ".config not given" +[ -f "$configarg" ] || die ".config does not exist" [ -z "$outputarg" ] && die "Output directory not given" [ -z "$DEPENDS" ] && die "Build-id dependency not given" [ -z "$XEN_DEPENDS" ] && die "Xen Build-id dependency not given" =20 -SRCDIR=3D"$(readlink -m -- "$srcarg")" +SRCDIR=3D"$(readlink -f -- "$srcarg")" # We need an absolute path because we move around, but we need to # retain the name of the symlink (=3D realpath -s) PATCHFILE=3D"$(readlink -f "$(dirname "$patcharg")")/$(basename "$patcharg= ")" -CONFIGFILE=3D"$(readlink -m -- "$configarg")" -OUTPUT=3D"$(readlink -m -- "$outputarg")" - -[ -d "${SRCDIR}" ] || die "Xen directory does not exist" -[ -f "${PATCHFILE}" ] || die "Patchfile does not exist" -[ -f "${CONFIGFILE}" ] || die ".config does not exist" +CONFIGFILE=3D"$(readlink -f -- "$configarg")" =20 PATCHNAME=3D$(make_patch_name "${PATCHFILE}") =20 @@ -390,17 +388,20 @@ echo echo "Xen directory: ${SRCDIR}" echo "Patch file: ${PATCHFILE}" echo ".config file: ${CONFIGFILE}" -echo "Output directory: ${OUTPUT}" +echo "Output directory: $outputarg" echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D" echo =20 if [ "${SKIP}" !=3D "build" ]; then - [ -e "${OUTPUT}" ] && die "Output directory exists" + # Make sure output directory doesn't exist, and create it. + [ -e "$outputarg" ] && die "Output directory exists" + mkdir -p "$outputarg" || die + OUTPUT=3D"$(readlink -f -- "$outputarg")" + grep -q 'CONFIG_LIVEPATCH=3Dy' "${CONFIGFILE}" || die "CONFIG_LIVEPATC= H must be enabled" cd "$SRCDIR" || die patch -s -N -p1 -f --fuzz=3D0 --dry-run < "$PATCHFILE" || die "Source = patch file failed to apply" =20 - mkdir -p "${OUTPUT}" || die cp -f "${CONFIGFILE}" "${OUTPUT}/.config" cp -f "${OUTPUT}/.config" "xen/.config" =20 @@ -453,7 +454,9 @@ if [ "${SKIP}" !=3D "build" ]; then fi =20 if [ "${SKIP}" !=3D "diff" ]; then - [ -d "${OUTPUT}" ] || die "Output directory does not exist" + cd "${SCRIPTDIR}" || die + [ -d "$outputarg" ] || die "Output directory does not exist" + OUTPUT=3D"$(readlink -f -- "$outputarg")" =20 cd "${OUTPUT}" || die create_patch base-commit: e588b7914e7afa3abb64b15a32fc2fdb57ded341 --=20 2.43.0 From nobody Sat Nov 23 16:19:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1701163370; cv=none; d=zohomail.com; s=zohoarc; b=HwD//qVprZSBS6nDyxm9yjqawtrzlXffAaEjXrrZ+RI1AHKX9hnFoBUKWMc2lGwth4s4IfYWsDYOTrc5FskuSS9CIGfb3f2MwlbjdcqpKC7KIbyNE4FNGe7dNKkzeSrFn7lXY/wVq0aGDQw2hlAWDcPS+VK7hZwew/SbBXsmkcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701163370; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h5HPry0cHVXYa7E65UlZUEhBkm420RlLl9/gqlG+ArQ=; b=BEf/Mmkc/EIcs62gJN/ECG019X07Rxdf+zUJ7mGNc7+5uqw8jhAtABLrLztnmLiwtZIOLgEIGYPsT7Qn3lnRGvJqHEci1uJI/MnoT7X5BJFDVP8ANJk1rz31j65dcQcidIwrSHsNxuFRS8B1cXsbwYr+MRZ9T5iyicjAG310fIE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1701163370777515.2913431708956; Tue, 28 Nov 2023 01:22:50 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.642825.1002578 (Exim 4.92) (envelope-from ) id 1r7uIW-0005cP-Kd; Tue, 28 Nov 2023 09:22:28 +0000 Received: by outflank-mailman (output) from mailman id 642825.1002578; Tue, 28 Nov 2023 09:22:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r7uIW-0005cI-HU; Tue, 28 Nov 2023 09:22:28 +0000 Received: by outflank-mailman (input) for mailman id 642825; Tue, 28 Nov 2023 09:22:26 +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 1r7uIU-0004tr-Kw for xen-devel@lists.xenproject.org; Tue, 28 Nov 2023 09:22:26 +0000 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [2a00:1450:4864:20::42a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a3ccb24d-8dcf-11ee-9b0e-b553b5be7939; Tue, 28 Nov 2023 10:22:24 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3316bb1303bso3233170f8f.0 for ; Tue, 28 Nov 2023 01:22:25 -0800 (PST) Received: from localhost ([213.195.113.99]) by smtp.gmail.com with ESMTPSA id b7-20020adfe307000000b00332fbf7ab21sm6834899wrj.60.2023.11.28.01.22.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 01:22:23 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: a3ccb24d-8dcf-11ee-9b0e-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1701163344; x=1701768144; 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=h5HPry0cHVXYa7E65UlZUEhBkm420RlLl9/gqlG+ArQ=; b=BKFwDsMvtefl2dhVlXZFUuughPuwhabDvJjl8vY5hQCWU3R+dHFu/GgCQ3iqn20iHz xHYT9WQ617iOMTkRXDZp6cTauItHg7A33DRHiTnwAlF51qh+XKDYyH/4MrsK1j5pw07n u2ikulgVxRh4P0D1IpNHlq0kG35r8Ht5H/dK0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701163344; x=1701768144; 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=h5HPry0cHVXYa7E65UlZUEhBkm420RlLl9/gqlG+ArQ=; b=gdIE698slba8G89/W7bDN1d2ykemlqLjeKlPLoz4d2NDWKpE7L8c9mGJCrohxbB6jD sSvNv4qeYm4M/2RKR9DB2Hw4eZ7nc8GxlIckWeJFdLusgmJbbvNvcM+FU7oh3TYUC0XL rLqc7tTqYxOEXKmEK5GAj9ImzXLIZxWSqAIq3lPtYXv4MN3Yts02FVKdwMBfiN7Pv8+H UbYTDXNpUUeBVwgcX8vxKwpKyH1M0cZZnH6yl+2PYDqzrXDXzPim6J+asZMQsM8DIbJT 6L0PXO5xPEM5iKkZ11boC3mYqSgv8r7UlmJEbC3E5MMhrp4CWJwXzEi/WSPaKhY20ONm dtiQ== X-Gm-Message-State: AOJu0YwEcNK+ChUOrn9wNc/40pwSTWDgZ1BUxw0HmVC9JOLc+42U7McD 9eFGn8DWTgtOktf+KHUJR5wIxmRzZ395XiUQXUk= X-Google-Smtp-Source: AGHT+IEQiMZYddsFFj7Vr/s1dpjiADp3UuvyPpdn8nKI0utkQ7+Yp9K9ye8K+CxyXt8skoTiuCjdFg== X-Received: by 2002:adf:f349:0:b0:333:ed:82ed with SMTP id e9-20020adff349000000b0033300ed82edmr4459304wrp.66.1701163343894; Tue, 28 Nov 2023 01:22:23 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Konrad Rzeszutek Wilk , Ross Lagerwall , Roger Pau Monne Subject: [PATCH v2 2/3] livepatch-build-tools: remove usage of gawk Date: Tue, 28 Nov 2023 10:21:51 +0100 Message-ID: <20231128092152.35039-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231128092152.35039-1-roger.pau@citrix.com> References: <20231128092152.35039-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1701163372323000002 And instead use plain awk. Since plain awk cannot do the conversion from hex to decimal, use the shell (bash) printf to convert the (maybe) hexadecimal output of readelf. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Ross Lagerwall --- Changes since v1: - Use shell printf to convert. --- livepatch-build | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/livepatch-build b/livepatch-build index 305644037ee7..e2ccce4f7fd7 100755 --- a/livepatch-build +++ b/livepatch-build @@ -423,14 +423,15 @@ if [ "${SKIP}" !=3D "build" ]; then echo "Reading special section data" # Using xen-syms built in the previous step by build_full(). SPECIAL_VARS=3D$(readelf -wi "$OUTPUT/xen-syms" | - gawk --non-decimal-data ' + awk ' BEGIN { a =3D b =3D e =3D 0 } a =3D=3D 0 && /DW_AT_name.* alt_instr/ {a =3D 1; next} b =3D=3D 0 && /DW_AT_name.* bug_frame/ {b =3D 1; next} e =3D=3D 0 && /DW_AT_name.* exception_table_entry/ {e =3D 1= ; next} - a =3D=3D 1 {printf("export ALT_STRUCT_SIZE=3D%d\n", $4); a = =3D 2} - b =3D=3D 1 {printf("export BUG_STRUCT_SIZE=3D%d\n", $4); b = =3D 2} - e =3D=3D 1 {printf("export EX_STRUCT_SIZE=3D%d\n", $4); e = =3D 2} + # Use shell printf to (possibly) convert from hex to decimal + a =3D=3D 1 {printf("export ALT_STRUCT_SIZE=3D`printf \"%%d\= " \"%s\"`\n", $4); a =3D 2} + b =3D=3D 1 {printf("export BUG_STRUCT_SIZE=3D`printf \"%%d\= " \"%s\"`\n", $4); b =3D 2} + e =3D=3D 1 {printf("export EX_STRUCT_SIZE=3D`printf \"%%d\"= \"%s\"`\n", $4); e =3D 2} a =3D=3D 2 && b =3D=3D 2 && e =3D=3D 2 {exit}') [[ -n $SPECIAL_VARS ]] && eval "$SPECIAL_VARS" if [[ -z $ALT_STRUCT_SIZE ]] || [[ -z $BUG_STRUCT_SIZE ]] || [[ -z $EX= _STRUCT_SIZE ]]; then --=20 2.43.0 From nobody Sat Nov 23 16:19:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1701163377; cv=none; d=zohomail.com; s=zohoarc; b=FkbZ+qcYk9TDvrgy1Us3nVwN4zbUPDjC0Tcp53qvdeEFTe/A+A83uYY17fjAC5UK1ghMcKayRkAPomg2kQj93bbaOu6V+SaFWvZ+f663KTOscmJP/v9d0X9lhrjClKdPjWtZzvj0syTSiRyiMv/+J1239lreg+5oFVFY0U1FPsg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701163377; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nloFbZsR0n5o1gFMfsRypOwTdPPhgWOtMQCBf1lcPX8=; b=VFc6u2HIJa+QIvVbuzQNvMUTUmoXGyNtCH4hKXWIOw9vRqvnyVuhbJrIutQQQ2y6Rlenq3RBwBjEkp4XEnErEXQUZGYUHQ7YEqXrWU0mzl+09ERKUtD4bpk5Y0ooIz7gnmd2ZLJ4DQIDslv1kL6hJvsmWMmKqh7skdCE01BYqo8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 170116337736153.39377061575942; Tue, 28 Nov 2023 01:22:57 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.642824.1002563 (Exim 4.92) (envelope-from ) id 1r7uIV-0005C3-Dj; Tue, 28 Nov 2023 09:22:27 +0000 Received: by outflank-mailman (output) from mailman id 642824.1002563; Tue, 28 Nov 2023 09:22:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r7uIV-0005At-9F; Tue, 28 Nov 2023 09:22:27 +0000 Received: by outflank-mailman (input) for mailman id 642824; Tue, 28 Nov 2023 09:22:26 +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 1r7uIU-0004tq-C2 for xen-devel@lists.xenproject.org; Tue, 28 Nov 2023 09:22:26 +0000 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [2a00:1450:4864:20::32a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a472df4c-8dcf-11ee-98e3-6d05b1d4d9a1; Tue, 28 Nov 2023 10:22:25 +0100 (CET) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40b4c2ef58aso4187555e9.0 for ; Tue, 28 Nov 2023 01:22:25 -0800 (PST) Received: from localhost ([213.195.113.99]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c3b8800b0040b398f0585sm14323367wms.9.2023.11.28.01.22.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 01:22:24 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: a472df4c-8dcf-11ee-98e3-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1701163345; x=1701768145; 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=nloFbZsR0n5o1gFMfsRypOwTdPPhgWOtMQCBf1lcPX8=; b=eX4ePTQEiWinhG61NI8NtbC0pSmWTfp4G1zG3TASMY4PNT4MQ1ybL9nLc6OHVw+NkR eBhKvXVKN23VRTwND5PLx9jYXmw43eigkuSu42AvxidIoBkCJnIWP8v01msJ5biTlfaM zJz4MaWKjRBSG741CWN9qSyKj3ZlCUh9MGi/U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701163345; x=1701768145; 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=nloFbZsR0n5o1gFMfsRypOwTdPPhgWOtMQCBf1lcPX8=; b=Zu15x3k9uipQ4EdIaNoh4Is5bJnFyzq2FqMWCkPLETuuDkZO5p/yMJTo6v+P6+sqGl XuqtNFfBAw3+Ej36fo3qu+SivNAH0ro/+rDNFjzBFtu6QGe3DtBBlmbWNxFFqYrY80Yh 6petiGvPkwC/WlXtd7RbRYyWbwlV0eglPZw2NXiD5rWvAGLP2WJVQb6DZUk5u/RuF6I+ x7IpXOXShfyTw01f5oFJOdga3WF5E+ct8XCQ5r+JFrf5HMviJczvNsc1BhcgFfZ1eCGW D76Gxry7XxC0Ehh55reXc7PvaUU97i/uO7Kr2rJH47cuSMU12USv9UgrdE2k0ZWUeueT lhiw== X-Gm-Message-State: AOJu0YzlHDp4qza2KReYyR7hZqtPUpZJ5VThXrdrLWz0l8WAvacaOAoG sbjgPNRcYZJZNXnig+0RxGprw9pu+pc6/umuOjI= X-Google-Smtp-Source: AGHT+IG3Eo5ZvV3iidJ+LL4lIRYVlc0WvPm8MgpcybdntPPVgNd0KKSy77sIYN1+0k2yHT3X4/QGCA== X-Received: by 2002:a05:600c:198a:b0:40b:448b:f711 with SMTP id t10-20020a05600c198a00b0040b448bf711mr4835936wmq.18.1701163345041; Tue, 28 Nov 2023 01:22:25 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Konrad Rzeszutek Wilk , Ross Lagerwall , Roger Pau Monne Subject: [PATCH v2 3/3] livepatch-build-tools: account for section alignment when calculating function size Date: Tue, 28 Nov 2023 10:21:52 +0100 Message-ID: <20231128092152.35039-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231128092152.35039-1-roger.pau@citrix.com> References: <20231128092152.35039-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1701163378284000003 Forcing function section alignment at the compiler level ensures that enough space is present in the text section so that at least a jump can be encoded= in the old function body to switch to the newly loaded code payload. Modify create-diff-object to account for any section alignment when calcula= ting the size of the old function. When used with a suitable -falign-function compiler parameter on the Xen hypervisor build this ensures that all functions have enough space to accommodate for any control flow instructions plus a jump. Note that while the rounding could be applied to all (text) symbols, it's n= ot required, as the size is only relevant for functions that are live patched,= and hence only do the rounding when calculating the old (previous) function siz= e. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Ross Lagerwall --- Changes since v2: - New in this version. --- common.h | 2 ++ create-diff-object.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/common.h b/common.h index 0d3e5f1dd3b5..5ff9ef6ca8e9 100644 --- a/common.h +++ b/common.h @@ -37,6 +37,8 @@ extern char *childobj; list_add_tail(&(_new)->list, (_list)); \ } =20 +#define ROUNDUP(x, a) (((x) + (a) - 1) & ~((a) - 1)) + enum loglevel { DEBUG, NORMAL diff --git a/create-diff-object.c b/create-diff-object.c index d0e14e3a62bb..fed360a9aa68 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -2015,6 +2015,11 @@ static void livepatch_create_patches_sections(struct= kpatch_elf *kelf, ERROR("lookup_global_symbol %s", sym->name); } + + /* Take into account section alignment for padding. */ + result.size =3D ROUNDUP(result.size, + sym->sec->sh.sh_addralign); + log_debug("lookup for %s @ 0x%016lx len %lu\n", sym->name, result.value, result.size); =20 --=20 2.43.0