From nobody Fri May 17 03:54:53 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 header.i=@amazon.com; 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=quarantine dis=none) header.from=amazon.com ARC-Seal: i=1; a=rsa-sha256; t=1674123325; cv=none; d=zohomail.com; s=zohoarc; b=RFkfBTZod8wxn37WvaAUZG21THFau2rvv6BMTQuPDKAa303yNZWmNhS4dvQWtd4SIfIqepMhdVDXF7bd9Bnv/DWeVSoh1yZ4quGDmIujo2UQCbvgMPMFQrlrYusLApORWiRJEHzGfGuD+xWl5VGx9t6nWGzrHwrq91EzCF0TSEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674123325; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4hf1x7Xe4bXRLb6h+Ksi8ZE8+Xk4HBnSsvCu7j+CUQ4=; b=HPvei8IMlqTn9io69Dxd0x56I0Uohbcyuc9OrSkUXYp4EBJ9otdBxKfjCKCXgy/BF5nxIi7618ESWujzBgH5CBxHhBAe4cxilK2JhbtEfs0gRxclbEPvqMBXwbbf0aSGHziNZnozPxFgvKuCuJ9aNmJW39j01tWHe9EYMfimtyQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.com; 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1674123325724671.6263701771435; Thu, 19 Jan 2023 02:15:25 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.480911.745567 (Exim 4.92) (envelope-from ) id 1pIRwf-0000Tp-N0; Thu, 19 Jan 2023 10:14:57 +0000 Received: by outflank-mailman (output) from mailman id 480911.745567; Thu, 19 Jan 2023 10:14:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pIRwf-0000TX-Jn; Thu, 19 Jan 2023 10:14:57 +0000 Received: by outflank-mailman (input) for mailman id 480911; Thu, 19 Jan 2023 10:14:22 +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 1pIRw6-0007Sb-Sz for xen-devel@lists.xenproject.org; Thu, 19 Jan 2023 10:14:22 +0000 Received: from smtp-fw-80007.amazon.com (smtp-fw-80007.amazon.com [99.78.197.218]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0985ffd9-97e2-11ed-91b6-6bf2151ebd3b; Thu, 19 Jan 2023 11:14:21 +0100 (CET) Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-m6i4x-7dc0ecf1.us-east-1.amazon.com) ([10.25.36.214]) by smtp-border-fw-80007.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2023 10:14:17 +0000 Received: from EX13D45EUA003.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1e-m6i4x-7dc0ecf1.us-east-1.amazon.com (Postfix) with ESMTPS id AFD1B83352 for ; Thu, 19 Jan 2023 10:14:15 +0000 (UTC) Received: from EX19D039EUA004.ant.amazon.com (10.252.50.95) by EX13D45EUA003.ant.amazon.com (10.43.165.71) with Microsoft SMTP Server (TLS) id 15.0.1497.45; Thu, 19 Jan 2023 10:14:13 +0000 Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX19D039EUA004.ant.amazon.com (10.252.50.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.7; Thu, 19 Jan 2023 10:14:13 +0000 Received: from dev-dsk-mstrasun-1c-15417e94.eu-west-1.amazon.com (172.19.92.214) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.45 via Frontend Transport; Thu, 19 Jan 2023 10:14:12 +0000 Received: by dev-dsk-mstrasun-1c-15417e94.eu-west-1.amazon.com (Postfix, from userid 17415739) id 8126F21426; Thu, 19 Jan 2023 10:14:12 +0000 (UTC) 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 Sender: "Xen-devel" X-Inumbo-ID: 0985ffd9-97e2-11ed-91b6-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1674123262; x=1705659262; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4hf1x7Xe4bXRLb6h+Ksi8ZE8+Xk4HBnSsvCu7j+CUQ4=; b=nUKTLNs6VsJLVg0yLiH7j7Q9MHx6dzSiqZmmGoJxY8FxPds9AhAFBV4l qRSCRlKVGoO8rDABdOJf74K5UZ+prgZBd1rZ3uymNR3ZsRG+MWIwhDVTU TC7NmyI6qGtoLWWE+HVn6VS8L+I/3l+bLLOCr7QnWrJkPg9B+l1wjY+Xf s=; X-IronPort-AV: E=Sophos;i="5.97,228,1669075200"; d="scan'208";a="172738134" From: Mihails Strasuns To: CC: , Michael Kurth Subject: [PATCH v1 1/4] common.h: Flush stdout before writing to stderr Date: Thu, 19 Jan 2023 10:13:02 +0000 Message-ID: <2e89973f61bbd6e6ebb423ec6fe7a025d5404235.1673623880.git.mstrasun@amazon.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @amazon.com) X-ZM-MESSAGEID: 1674123326487100001 Content-Type: text/plain; charset="utf-8" Flush existing debug messages before writing an error to stderr. stderr is usually unbuffered and stdout is usually buffered. This results in odd looking output when an error occurs and both stderr/stdout are printed on the same console/file. More precisely, the error message is printed in the middle of previously emitted debug messages. Signed-off-by: Michael Kurth Reviewed-by: Ross Lagerwall --- common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common.h b/common.h index 02c9b7b..9a9da79 100644 --- a/common.h +++ b/common.h @@ -10,6 +10,7 @@ extern char *childobj; =20 #define DIFF_FATAL(format, ...) \ ({ \ + fflush(stdout); \ fprintf(stderr, "ERROR: %s: " format "\n", childobj, ##__VA_ARGS__); \ error(2, 0, "unreconcilable difference"); \ }) --=20 2.38.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 From nobody Fri May 17 03:54:53 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 header.i=@amazon.com; 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=quarantine dis=none) header.from=amazon.com ARC-Seal: i=1; a=rsa-sha256; t=1674123309; cv=none; d=zohomail.com; s=zohoarc; b=jCVQjXDnsIJtYJsgQ0yB4URBY6y5lCWY3jOj7BrMzFV06TY+IzGvzVEKTAp5gbyBLcNTrLfHQU6hDg/8ySGvqgyKpwq2GHoN3Wz0bUNFI5JZRD1pykAFovlrEsnAEdPfD846NitTy/SPt4SGLJiGkskUdLCSjm/NPJ28l1Js4Mk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674123309; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2xU/uBcWEWbfzk2TqLk64mpRRkZpjZZO7FkjawvYQC8=; b=NsevsM+9JzmuNBlUq23aYgRQRz94Ex1bw/8DKMHbjT6k9vmPo9+Z8CJezZXRKDVoSJftqDolWDnQ6PSs9RTq1UCfZgMTJIqfMsAUL6X5zrcGCSOoXeRyI+PtSCnJIwkFSCVd0CH2RpuYbQcSsredBhltnyPXIvIUWSvec0diNNA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.com; 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1674123309429751.3542078670455; Thu, 19 Jan 2023 02:15:09 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.480913.745537 (Exim 4.92) (envelope-from ) id 1pIRwP-0007lT-RG; Thu, 19 Jan 2023 10:14:41 +0000 Received: by outflank-mailman (output) from mailman id 480913.745537; Thu, 19 Jan 2023 10:14:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pIRwP-0007lK-NZ; Thu, 19 Jan 2023 10:14:41 +0000 Received: by outflank-mailman (input) for mailman id 480913; Thu, 19 Jan 2023 10:14:40 +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 1pIRwO-0007kn-DI for xen-devel@lists.xenproject.org; Thu, 19 Jan 2023 10:14:40 +0000 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 140a99f7-97e2-11ed-b8d1-410ff93cb8f0; Thu, 19 Jan 2023 11:14:38 +0100 (CET) Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1a-m6i4x-96feee09.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2023 10:14:34 +0000 Received: from EX13D50EUA002.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1a-m6i4x-96feee09.us-east-1.amazon.com (Postfix) with ESMTPS id 3D6C842F0E for ; Thu, 19 Jan 2023 10:14:34 +0000 (UTC) Received: from EX19D003EUA004.ant.amazon.com (10.252.50.128) by EX13D50EUA002.ant.amazon.com (10.43.165.201) with Microsoft SMTP Server (TLS) id 15.0.1497.45; Thu, 19 Jan 2023 10:14:33 +0000 Received: from EX13MTAUEE002.ant.amazon.com (10.43.62.24) by EX19D003EUA004.ant.amazon.com (10.252.50.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.7; Thu, 19 Jan 2023 10:14:33 +0000 Received: from dev-dsk-mstrasun-1c-15417e94.eu-west-1.amazon.com (172.19.92.214) by mail-relay.amazon.com (10.43.62.224) with Microsoft SMTP Server id 15.0.1497.45 via Frontend Transport; Thu, 19 Jan 2023 10:14:32 +0000 Received: by dev-dsk-mstrasun-1c-15417e94.eu-west-1.amazon.com (Postfix, from userid 17415739) id 19BEB21426; Thu, 19 Jan 2023 10:14:32 +0000 (UTC) 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 Sender: "Xen-devel" X-Inumbo-ID: 140a99f7-97e2-11ed-b8d1-410ff93cb8f0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1674123278; x=1705659278; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2xU/uBcWEWbfzk2TqLk64mpRRkZpjZZO7FkjawvYQC8=; b=XwJ0oRAz/IEfDDBcyv6oPOgWj5WE8hqfb1DuEJZdQM2/DDx+iUhyJvVH 6G3VC0pnt37F1kgwwhmQ1MbihMrhGpI8aEDhooo8sbzOpGE3FuKDE7Fl7 bWHJXDm53j4046GY3cLLilt9HmAdlkWatYBtFz4L1QHhshjX2UUSr0UAO k=; X-IronPort-AV: E=Sophos;i="5.97,228,1669075200"; d="scan'208";a="284332618" From: Mihails Strasuns To: CC: , Raphael Ning , Bjoern Doebel , Martin Pohlack Subject: [PATCH v1 2/4] livepatch-build: Allow a patch to introduce new subdirs Date: Thu, 19 Jan 2023 10:13:04 +0000 Message-ID: <472bfbf92aba6d3409b2a101798f04a50c97f6e9.1673623880.git.mstrasun@amazon.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @amazon.com) X-ZM-MESSAGEID: 1674123310325100001 Content-Type: text/plain; charset="utf-8" From: Raphael Ning Fix a bug in create_patch() where cp, strip, etc. will fail if the new object file introduced by the patch is located in a new subdirectory: DEBUG: cp: cannot create regular file `output/xen/common/lu/lu.o': No such= file or directory DEBUG: strip: 'output/xen/common/lu/lu.o': No such file In this example, xen/common/lu/ does not exist in the original (unpatched) Xen source tree. It needs to be created in output/ as well. Signed-off-by: Raphael Ning Reviewed-by: Bjoern Doebel Reviewed-by: Martin Pohlack Reviewed-by: Ross Lagerwall --- livepatch-build | 1 + 1 file changed, 1 insertion(+) diff --git a/livepatch-build b/livepatch-build index f7d6471..444daa9 100755 --- a/livepatch-build +++ b/livepatch-build @@ -232,6 +232,7 @@ function create_patch() =20 NEW_FILES=3D$(comm -23 <(cd patched/xen && find . -type f -name '*.o' = | sort) <(cd original/xen && find . -type f -name '*.o' | sort)) for i in $NEW_FILES; do + mkdir -p "output/$(dirname "$i")" cp "patched/$i" "output/$i" [[ $STRIP -eq 1 ]] && strip --strip-unneeded "output/$i" CHANGED=3D1 --=20 2.38.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 From nobody Fri May 17 03:54:53 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 header.i=@amazon.com; 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=quarantine dis=none) header.from=amazon.com ARC-Seal: i=1; a=rsa-sha256; t=1674123314; cv=none; d=zohomail.com; s=zohoarc; b=RjCWmXBuSGpJdRa4hNUuMjsoM8fauiWfCzmuWIkqpEMWqtHPLthgF1XWOFm7I/UGClhlnOa+O0yqqDm2W8Pghq4FvrBqe5T8Xb1XQ6Jyy35R6h/ao3SFAwvMDQVS+5QpTPSlDQlLYTgF5s8c3AiRq20PDZyPhIEsOhNiEFXpxIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674123314; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7xjJSEeZVrQKBcQS6rbLeHu3TkZB46tvdM9kg8Ho5tM=; b=mld80LX6CNZgkvd1i96yb/zCOu/igRhr7rdk8g61DRPocnduw6qGIpqaRf0/OsoAfpswXUMA2eh2sewoaiB8s8Un4I1oHd0NlXTXRuGR5GEORZtQ/QxTCJ7TZWsKaMLE9NNi/BrtbM32nfWS6jTnUvEfO6GFD5PZCgMDp+ksiZ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.com; 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1674123314163737.8092876953493; Thu, 19 Jan 2023 02:15:14 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.480914.745547 (Exim 4.92) (envelope-from ) id 1pIRwX-00089y-2p; Thu, 19 Jan 2023 10:14:49 +0000 Received: by outflank-mailman (output) from mailman id 480914.745547; Thu, 19 Jan 2023 10:14: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 1pIRwW-00089r-VI; Thu, 19 Jan 2023 10:14:48 +0000 Received: by outflank-mailman (input) for mailman id 480914; Thu, 19 Jan 2023 10:14:47 +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 1pIRwV-0007Sb-Ka for xen-devel@lists.xenproject.org; Thu, 19 Jan 2023 10:14:47 +0000 Received: from smtp-fw-33001.amazon.com (smtp-fw-33001.amazon.com [207.171.190.10]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 18968994-97e2-11ed-91b6-6bf2151ebd3b; Thu, 19 Jan 2023 11:14:46 +0100 (CET) Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1d-m6i4x-d7759ebe.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-33001.sea14.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2023 10:14:39 +0000 Received: from EX13D51EUB004.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1d-m6i4x-d7759ebe.us-east-1.amazon.com (Postfix) with ESMTPS id 7BB8B43948 for ; Thu, 19 Jan 2023 10:14:37 +0000 (UTC) Received: from EX19D029EUB004.ant.amazon.com (10.252.61.53) by EX13D51EUB004.ant.amazon.com (10.43.166.217) with Microsoft SMTP Server (TLS) id 15.0.1497.45; Thu, 19 Jan 2023 10:14:37 +0000 Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX19D029EUB004.ant.amazon.com (10.252.61.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.7; Thu, 19 Jan 2023 10:14:36 +0000 Received: from dev-dsk-mstrasun-1c-15417e94.eu-west-1.amazon.com (172.19.92.214) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.45 via Frontend Transport; Thu, 19 Jan 2023 10:14:35 +0000 Received: by dev-dsk-mstrasun-1c-15417e94.eu-west-1.amazon.com (Postfix, from userid 17415739) id D06FE21426; Thu, 19 Jan 2023 10:14:35 +0000 (UTC) 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 Sender: "Xen-devel" X-Inumbo-ID: 18968994-97e2-11ed-91b6-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1674123287; x=1705659287; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7xjJSEeZVrQKBcQS6rbLeHu3TkZB46tvdM9kg8Ho5tM=; b=aNgiJynxj0bg3dDNDMgoWCjqWlJ0A/jbpo9W64C5Nk6+ybwbUuUIzkpl G2Wa6lQiLtBGqJqRMuHwUzIwwRIaNdQdA8eD0d4HPhOTFT5saVtPfQWFe N6KRDO2F7+5FS+iUMPVMA7d4/QTUVSrwYt8SDd1BsZYnFrsbZwsdcdnKu 8=; X-IronPort-AV: E=Sophos;i="5.97,228,1669075200"; d="scan'208";a="256252891" From: Mihails Strasuns To: CC: , Raphael Ning , Bjoern Doebel , Martin Pohlack Subject: [PATCH v1 3/4] livepatch-gcc: Ignore buildid.o Date: Thu, 19 Jan 2023 10:13:05 +0000 Message-ID: <477a6e0f0b0088c54f3f048bf2b4593eb4df18af.1673623880.git.mstrasun@amazon.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @amazon.com) X-ZM-MESSAGEID: 1674123314511100001 Content-Type: text/plain; charset="utf-8" From: Raphael Ning Not all .o files generated by the Xen build need to be passed to create-diff-object for analysis. The latest example is: Run create-diff-object on xen/arch/x86/efi/buildid.o Open base /usr/libexec/livepatch-build-tools/create-diff-object: ERROR: buildid.o: k= patch_create_section_list: 77: elf_getshdrnum This file is special, as it does not contain any sections. It is generated by objcopy from a magic string of bytes (see Xen commit eee5909e9d1e x86/EFI: use less crude a way of generating the build ID), which probably will never change. Therefore, livepatch-gcc should not copy it to the output directory. Signed-off-by: Raphael Ning Reviewed-by: Bjoern Doebel Reviewed-by: Martin Pohlack CR: https://code.amazon.com/reviews/CR-63147772 Reviewed-by: Ross Lagerwall --- livepatch-gcc | 1 + 1 file changed, 1 insertion(+) diff --git a/livepatch-gcc b/livepatch-gcc index 91333d5..e72cc8d 100755 --- a/livepatch-gcc +++ b/livepatch-gcc @@ -65,6 +65,7 @@ elif [[ "$TOOLCHAINCMD" =3D~ $OBJCOPY_RE ]] ; then version.o|\ debug.o|\ efi/check.o|\ + buildid.o|\ .*.o) ;; *.o) --=20 2.38.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 From nobody Fri May 17 03:54:53 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 header.i=@amazon.com; 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=quarantine dis=none) header.from=amazon.com ARC-Seal: i=1; a=rsa-sha256; t=1674123316; cv=none; d=zohomail.com; s=zohoarc; b=JYJX36apC4Q/FPolOxmbIO5gavh+NqtwFphNT62/NqNj3KtyexSdewok7IyUgc3nQvx7V4i8ZRGtyNNH1gshKZbgky4zDfEhPZq96hbVv8H9vts0fD5YHnRJE6PEpH/7swMBZnHw0nXmHhg5OcQ5EQuY4DjRLPbGvTmLhrZf1ZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674123316; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gXy2lSCqzAzPVhs9Pixrebyr+33aF5wrQ+8+7LICdlw=; b=VhoResdpvnxsdROAaSo+1r1pqw4kCL6TxNZ6eUd4n7CcBYHOAPjb4gX3LCNBnamxukOoNRmPnM/Jt0ssbjPQiTGdyYZTtzHLGvVXqOgaispUU3rZBIEeQQUtg76Yb3TKQhXPGQADc2paxmSqgEUeGtMN0JgvWeCIGeBNSy/gsvU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.com; 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1674123316813395.2775009152399; Thu, 19 Jan 2023 02:15:16 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.480915.745557 (Exim 4.92) (envelope-from ) id 1pIRwY-0008R9-9b; Thu, 19 Jan 2023 10:14:50 +0000 Received: by outflank-mailman (output) from mailman id 480915.745557; Thu, 19 Jan 2023 10:14:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pIRwY-0008Qs-6q; Thu, 19 Jan 2023 10:14:50 +0000 Received: by outflank-mailman (input) for mailman id 480915; Thu, 19 Jan 2023 10:14:49 +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 1pIRwW-0007Sb-VV for xen-devel@lists.xenproject.org; Thu, 19 Jan 2023 10:14:49 +0000 Received: from smtp-fw-33001.amazon.com (smtp-fw-33001.amazon.com [207.171.190.10]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 19f1060f-97e2-11ed-91b6-6bf2151ebd3b; Thu, 19 Jan 2023 11:14:47 +0100 (CET) Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2a-m6i4x-8a14c045.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-33001.sea14.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2023 10:14:44 +0000 Received: from EX13D48EUA002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-pdx-2a-m6i4x-8a14c045.us-west-2.amazon.com (Postfix) with ESMTPS id 3F2A383120 for ; Thu, 19 Jan 2023 10:14:42 +0000 (UTC) Received: from EX19D042EUA004.ant.amazon.com (10.252.50.16) by EX13D48EUA002.ant.amazon.com (10.43.165.27) with Microsoft SMTP Server (TLS) id 15.0.1497.45; Thu, 19 Jan 2023 10:14:40 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX19D042EUA004.ant.amazon.com (10.252.50.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.7; Thu, 19 Jan 2023 10:14:40 +0000 Received: from dev-dsk-mstrasun-1c-15417e94.eu-west-1.amazon.com (172.19.92.214) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1497.45 via Frontend Transport; Thu, 19 Jan 2023 10:14:38 +0000 Received: by dev-dsk-mstrasun-1c-15417e94.eu-west-1.amazon.com (Postfix, from userid 17415739) id CB9DE21426; Thu, 19 Jan 2023 10:14:38 +0000 (UTC) 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 Sender: "Xen-devel" X-Inumbo-ID: 19f1060f-97e2-11ed-91b6-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1674123288; x=1705659288; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gXy2lSCqzAzPVhs9Pixrebyr+33aF5wrQ+8+7LICdlw=; b=RxuYz8n7hbLoIRnhaMyplwEpnpFgya/QnJazk6905YwuO7DvgY7yhpZG 8/czkV+UicRU/2zHvrwZ6SC8CoO0BlJ2WwNIjSi1FGRhLubPUKnMdvDcb HjQQWqpT2CVHlQ+pw3dPIrnbuGnFeZKn/IOQ5uQbLmflomVU+td5/p099 E=; X-IronPort-AV: E=Sophos;i="5.97,228,1669075200"; d="scan'208";a="256252906" From: Mihails Strasuns To: CC: , Stanislav Uschakow , "Bjoern Doebel" , Martin Pohlack Subject: [PATCH v1 4/4] create-diff-object: Add new symbols for relocation aliases Date: Thu, 19 Jan 2023 10:13:06 +0000 Message-ID: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @amazon.com) X-ZM-MESSAGEID: 1674123318476100001 Content-Type: text/plain; charset="utf-8" From: Stanislav Uschakow This fixes an issue when stacking multiple hotpatches modifying the same function when there is also an internal call to that function within these patches. Two hotpatches touching the same subset of functions can result in a situation where the second hotpatch is loaded but the code is never executed. This happens when the symbol resolution of the first hotpatch calculates the target address for the relocation entries based on the hotpach instead of the original function. The resulting address for the relocation-target will become the patched function instead of the original one (A' -> B' instead of A' -> B). In this case the trampoline in the original function is not used. Patching this function again (B'') re-sets the trampoline to the newly patched method. Since callq points to the first patched function it never reaches the second version. 2nd patch | B'' 1st patch | A' -> B' original | A -> B This fix provides a solution for this problem by resolving the symbols during patch generation using xen-syms. The patch iterates over all relocation entries, and creates duplicates of all referenced symbols with the scope set to SHN_ABS and the address to the one resolved from xen-syms. This new symbol is prefixed with a unique string to generate a new name. This forces all calls to be directed to the original function which contains the trampoline. Signed-off-by: Stanislav Uschakow Signed-off-by: Mihails Strasuns Reviewed-by: Bjoern Doebel Reviewed-by: Martin Pohlack --- create-diff-object.c | 132 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/create-diff-object.c b/create-diff-object.c index a516670..808b288 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -1878,6 +1878,25 @@ static char *mangle_local_symbol(char *filename, cha= r *symname) return s; } =20 +/* + * For a given mangled symbol name allocates a copy with the filename and = the + * unmangled symbol separated by a null terminator. + */ +static bool unmangle_local_symbol(const char *mangled, char **filename, + char **symname) +{ + if (filename =3D=3D NULL || symname =3D=3D NULL) + ERROR("Malformed output arguments passed to 'unmangle_local_symbol'"); + char *sep =3D strchr(mangled, '#'); + if (!sep) + return false; + int i =3D sep - mangled; + *filename =3D strdup(mangled); + (*filename)[i] =3D '\0'; + *symname =3D *filename + i + 1; + return true; +} + /* * Rename local symbols to the filename#symbol format used by Xen's "speci= al" * symbol table. @@ -2290,6 +2309,116 @@ static error_t parse_opt (int key, char *arg, struc= t argp_state *state) return 0; } =20 +/* + * For a given elf output target add a new entry to the symbol table + * which duplicates the provided source symbol. + */ +static struct symbol *insert_symbol_copy(struct kpatch_elf *elf, + struct symbol *src, int index, + char *new_name) +{ + struct symbol *new_sym; + ALLOC_LINK(new_sym, &elf->symbols); + new_sym->index =3D index; + new_sym->twin =3D NULL; + new_sym->sec =3D NULL; + new_sym->bind =3D src->bind; + new_sym->type =3D src->type; + new_sym->status =3D NEW; + new_sym->strip =3D 0; + new_sym->name =3D new_name; + /* The copy here will keep referring to the original symbol + name which is fine - it will be updated later during the final elf + generation. */ + new_sym->sym =3D src->sym; + return new_sym; +} + +/* + * In certain cases when 2 hotpatches are loaded patching the same subset = of + * functions calling each other, the topmost hotpatch can become unreachab= le. + * This is caused by the loader when resolving symbols. If a symbol is both + * to be relocated and loaded (foo calls bar and both are patched to foo' = and + * bar'), the callq target in foo' is set to bar' instead of the original = bar. + * Patching bar again (bar'') cannot be reached from foo' because foo' doe= s not + * use the trampoline in bar. + * + * This post-processing function fixes the problem by updating all + * non-livepatch relocation entries (i.e. originally created by a compiler= ) to + * be based on a special SHN_ABS with a fixed value resolved from xen-syms. + * These new symbols are not used by livepatch loader itself and only exis= t as + * a named constant for the relevant function address in the host process. + * + * All new symbols are prefixed with a scalpel-specific prefix string. As = they + * are not used outside of a specific livepatch linking/relocation proces= s, + * the prefix can be the same across multiple livepatches. + */ +void add_absolute_symbol_aliases(struct kpatch_elf *elf, + struct lookup_table *lookup) +{ + const char *prefix =3D "__livepatch_unique_"; + + int sym_count =3D 0; + struct symbol *sym; + list_for_each_entry (sym, &elf->symbols, list) + sym_count++; + + struct section *sec; + list_for_each_entry (sec, &elf->sections, list) { + if (!is_rela_section(sec)) + continue; + /* Ignore any relocation sections that are not related to a symbol + text sections: */ + if (strncmp(sec->name, ".rela.text.", 11) !=3D 0) + continue; + + struct rela *rel; + list_for_each_entry (rel, &sec->relas, list) { + if ((rel->sym->type !=3D STT_FUNC) && + (rel->sym->type !=3D STT_OBJECT) && + (rel->sym->type !=3D STT_NOTYPE)) + continue; + if (strlen(rel->sym->name) =3D=3D 0) + ERROR("Unnamed symbol used in relocation"); + + struct lookup_result res =3D {0}; + bool found =3D false; + /* Static/local symbols are mangled to include a filename prefix, + thus need a special treatment for xen-syms lookup: */ + if (rel->sym->bind =3D=3D STB_LOCAL) { + char *filename, *symname; + if (!unmangle_local_symbol(rel->sym->name, &filename, &symname)) + continue; + found =3D !lookup_local_symbol(lookup, symname, filename, &res); + } else + found =3D !lookup_global_symbol(lookup, rel->sym->name, &res); + + if (found) { + char *buf =3D malloc(strlen(prefix) + strlen(rel->sym->name) + 1); + if (!buf) + ERROR("Failed to allocate buffer\n"); + strcpy(buf, prefix); + strcpy(buf + strlen(prefix), rel->sym->name); + + struct symbol *new_sym =3D + insert_symbol_copy(elf, rel->sym, sym_count++, buf); + /* Override key fields after copying. GLOBAL/LOCAL binding + most likely doesn't matter here but forcing GLOBAL in case + linker tries to do something smart: */ + new_sym->bind =3D STB_GLOBAL; + new_sym->sym.st_value =3D res.value; + new_sym->sym.st_shndx =3D SHN_ABS; + new_sym->sym.st_info =3D GELF_ST_INFO(new_sym->bind, new_sym->type); +=20 + /* TODO: translate X86_64_PC32 rel type to X86_64_64 and + validate that the relocation is still correvtly computed. */ + log_debug("Added '%s' alias for '%s'\n", buf, rel->sym->name); + rel->sym =3D new_sym; + } + } + } +} + static struct argp argp =3D { options, parse_opt, args_doc, 0 }; =20 int main(int argc, char *argv[]) @@ -2434,6 +2563,9 @@ int main(int argc, char *argv[]) log_debug("Rename local symbols\n"); livepatch_rename_local_symbols(kelf_out, hint); =20 + log_debug("Add absolute symbol aliases for internal calls\n"); + add_absolute_symbol_aliases(kelf_out, lookup); + /* * At this point, the set of output sections and symbols is * finalized. Reorder the symbols into linker-compliant --=20 2.38.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879