From patchwork Fri May 19 14:47:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 96476 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1297935vqo; Fri, 19 May 2023 07:59:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ63FTLojx3bfp167mYgrE81zDcYz1nzHshxHcpyKJLYLPG1CFlJqf9K+h46vrvc0x4SL/Cc X-Received: by 2002:a17:902:e803:b0:1ae:4:da8b with SMTP id u3-20020a170902e80300b001ae0004da8bmr3785642plg.1.1684508380348; Fri, 19 May 2023 07:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684508380; cv=none; d=google.com; s=arc-20160816; b=uQlnHSCT8O9QT0hTGu10E0xSyXhVxd/59wTMY5mMxs7OmY5bRgrIJzrjYboP/1p1Vq lXFdzOHZNGdP6ChMAwx8kXTg3qeHFeVFS1JXNomwmykuJtmmI9Wc63BPk86W70TMW3Bt 9lH2xZZ1Cq9O19nYwaKwLlO7iVF+4eXBY+eHizXmeDV2sh6dzE3pVJplhR6MZ1hOO4hA khPstDXmfnFj8C+tXJwc0W9ead/jDdMvWwDX6MWD5EDT0zI+OlpIQX+ZKpKmU1IFOkM+ 5AAF9g7QmL8ikG7LKIKam0vg0SsNoVQ0/ZkRQp4ed2eVU4kF60JXC16bfZeuDpxASwNG akbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ELGoOCRLTJ4MHn8fGeUgbOupJ2+8dwbN21sm7VIhXso=; b=QRQUVrvG6EivTuwG3IjNQluiLGTz89JMF/4vhjlfL6nHdw18Rt25hYnp2BbM6crmmB 0uSA3lNnbGJkvsaQB30nVVo01Cw5ZBUfi8HQZTpVQRklPHOu+T2s2w+p2OX4ZMquEpbK MKESSERd/XflAYD47WkH2oBfOYI83WhbuihjKyMMfOUf6UVt1Gld2r1bBTLIXvPszIgz AkEMwYTKPRJS3N3mDuiA8Ff0v14EjVakhGeOVI1dJNtQDa1LVn2RNU+wx3AXImylLZwv qLU08AcnGeAUlsrDQ6knoQqWupIDqle/KpA2KzTMWDPRgwfDH0kGWpX6dyxiKUDiF6Rd paEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=D4g+JOjE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a170903024d00b001a6db2bef14si3910665plh.157.2023.05.19.07.59.20; Fri, 19 May 2023 07:59:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=D4g+JOjE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232045AbjESOsh (ORCPT + 99 others); Fri, 19 May 2023 10:48:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231937AbjESOs1 (ORCPT ); Fri, 19 May 2023 10:48:27 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 283A818C for ; Fri, 19 May 2023 07:48:26 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-96f6e83e12fso99183266b.1 for ; Fri, 19 May 2023 07:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1684507704; x=1687099704; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ELGoOCRLTJ4MHn8fGeUgbOupJ2+8dwbN21sm7VIhXso=; b=D4g+JOjETqBP2MNsVxzuMqgSzr8YRIXXqXUsFsUs+pP7Oau99Qe5QVR8UVcOTLFbYr 2mBKTdNoSjWjKYbSfJFKKxoLxwL2nUiC9vdnjZqrfUxyhqBpQTfo92kIGosmAzfxZkc7 /gFY2ugyiRu/EN9empIUDCr0miK+PQYdw14+w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684507704; x=1687099704; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ELGoOCRLTJ4MHn8fGeUgbOupJ2+8dwbN21sm7VIhXso=; b=VcxTrcRczfM9cdfmabUd9UMeKG6BnKkX6xE9dICN5BGWM0QSxJb/PgTD3IGpIj+Rc1 OYT+Iz9Q1s5m1gpk1qmE2omcbsX1nS/xfITL8KqQcyyWFEBS81WU1J401OhyQuN6k5Bk /ljHMvC1VMYkacD4AxjVJwXgmxinM28tIKnVj4hpVgZzr8oymYukXHeU2+S2ipqLb+VS KpGGn3SDyqgnJR8GQkwuWE5a48NWYe/i1s+0MjdisCIbqFJY+IpS6KknLD+lOm8ZrrVn +ZxDLSGbP/wJ6qmLffzJ8UkXCrVYJESocK8RUoalog5UTlYYWv28e/45JfvtRhMetdOg XpVw== X-Gm-Message-State: AC+VfDwvrb8yt2KsQovnSZ31uVy5JWuG54zaRtF7qqGQmieWWkmgoLKN TeJZe8RaEcTGMabc0A0iRGL9mWMwYu1GiNX7KqY= X-Received: by 2002:a17:906:da8d:b0:96a:2b4:eb65 with SMTP id xh13-20020a170906da8d00b0096a02b4eb65mr1967680ejb.9.1684507704586; Fri, 19 May 2023 07:48:24 -0700 (PDT) Received: from alco.roam.corp.google.com ([2620:0:1059:10:62fd:274b:c2ab:69bb]) by smtp.gmail.com with ESMTPSA id a2-20020a17090680c200b0096a68648329sm2349437ejx.214.2023.05.19.07.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 07:48:24 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 May 2023 16:47:36 +0200 Subject: [PATCH v7 1/4] kexec: Support purgatories with .text.hot sections MIME-Version: 1.0 Message-Id: <20230321-kexec_clang16-v7-1-b05c520b7296@chromium.org> References: <20230321-kexec_clang16-v7-0-b05c520b7296@chromium.org> In-Reply-To: <20230321-kexec_clang16-v7-0-b05c520b7296@chromium.org> To: Eric Biederman , Philipp Rudo , Dave Young , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Nathan Chancellor , Tom Rix , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: Baoquan He , Philipp Rudo , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Ross Zwisler , Steven Rostedt , Simon Horman , Nick Desaulniers , llvm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, Ricardo Ribalda , stable@vger.kernel.org X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2610; i=ribalda@chromium.org; h=from:subject:message-id; bh=CXKb/XxwO+TeE2qMZ4maPIDzkElWqU54WhfDNIzg1OA=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBkZ4wvbWRlFkwwm7hPC34OsXUHzyGG/L3qcdTaQ ESqu7FBeJOJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCZGeMLwAKCRDRN9E+zzrE iGRwD/0as+nZeAaB8OCCvreoh9SZpvQ6HI+sFQ8wcjwVDbNr4u/AX48ru5mvUvQkXZoW997MbsV a9jsKvwYE378RIjLevvwuaw7lXR+z1QCf0pDGsFS9/1Qkgpnm5MFRGtuEJjqfU4opKZZTyG3+52 PULBlFYQ+CO3naQLwyzrl6R1wxhDznz9okZI+/eZEBjbTUPPG1JVqNbj+voFWFhrSME3gCGl0od tiMu8KOz8glAw78ATlp/ZyhTMvncR1OcGXRhZ5TVlundBnvi+XxEn0D9kMjn9D03/hpkGJ9w0ob O/BvrYhGpJ6tkMS0vW0L5KmvnKN0y+PjE4Knwzrpk5JmH2kLXI7N1H19wMT1ic8un9ioYq+TAQ0 piiLFkEgR0PJ+TKJsP5MtYNhJUucIksvHaz0fso54li1MpHNPwGZeJ8ixj34l+G5L+mHfScdWJo aZ8306S/qymzgdbngVq2LU2kkf9t1A0MXbBoVeAwgk4K4Te2i1WCF1vE4A4dxLojWktksv2lEX9 DT+Ht5dp0m/id7BEVxuTBt9RIAcbqNXxhc/mIOJ8nzGIz3M7y3uyX6epnnvRkQAE8xFIXdESvLF 5xvWaykmWjyl+XRYp94K3OvPDAwVjfqWHtlSeHy2A2Bg6adMdcQO5tqfln3HOq48lkIrpqzg+F1 2N3gY3Zhf2lxlRg== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766335059706226362?= X-GMAIL-MSGID: =?utf-8?q?1766335059706226362?= Clang16 links the purgatory text in two sections when PGO is in use: [ 1] .text PROGBITS 0000000000000000 00000040 00000000000011a1 0000000000000000 AX 0 0 16 [ 2] .rela.text RELA 0000000000000000 00003498 0000000000000648 0000000000000018 I 24 1 8 ... [17] .text.hot. PROGBITS 0000000000000000 00003220 000000000000020b 0000000000000000 AX 0 0 1 [18] .rela.text.hot. RELA 0000000000000000 00004428 0000000000000078 0000000000000018 I 24 17 8 And both of them have their range [sh_addr ... sh_addr+sh_size] on the area pointed by `e_entry`. This causes that image->start is calculated twice, once for .text and another time for .text.hot. The second calculation leaves image->start in a random location. Because of this, the system crashes immediately after: kexec_core: Starting new kernel Cc: stable@vger.kernel.org Fixes: 930457057abe ("kernel/kexec_file.c: split up __kexec_load_puragory") Reviewed-by: Ross Zwisler Reviewed-by: Steven Rostedt (Google) Reviewed-by: Philipp Rudo Signed-off-by: Ricardo Ribalda --- kernel/kexec_file.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index f989f5f1933b..69ee4a29136f 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -901,10 +901,22 @@ static int kexec_purgatory_setup_sechdrs(struct purgatory_info *pi, } offset = ALIGN(offset, align); + + /* + * Check if the segment contains the entry point, if so, + * calculate the value of image->start based on it. + * If the compiler has produced more than one .text section + * (Eg: .text.hot), they are generally after the main .text + * section, and they shall not be used to calculate + * image->start. So do not re-calculate image->start if it + * is not set to the initial value, and warn the user so they + * have a chance to fix their purgatory's linker script. + */ if (sechdrs[i].sh_flags & SHF_EXECINSTR && pi->ehdr->e_entry >= sechdrs[i].sh_addr && pi->ehdr->e_entry < (sechdrs[i].sh_addr - + sechdrs[i].sh_size)) { + + sechdrs[i].sh_size) && + !WARN_ON(kbuf->image->start != pi->ehdr->e_entry)) { kbuf->image->start -= sechdrs[i].sh_addr; kbuf->image->start += kbuf->mem + offset; } From patchwork Fri May 19 14:47:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 96475 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1295662vqo; Fri, 19 May 2023 07:55:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ebuF9/l1AdwZgTq+abyZnlVV/pNvvoZv8ZZjeRUG8/x92wBfZxi5mWy/Wf2N0yz2oS7R9 X-Received: by 2002:a17:90a:f686:b0:24e:688:30f8 with SMTP id cl6-20020a17090af68600b0024e068830f8mr1982577pjb.49.1684508128342; Fri, 19 May 2023 07:55:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684508128; cv=none; d=google.com; s=arc-20160816; b=mBNowWmGtVq1vDa0ETnt9IExV+lhbu9K4C7zkhfx1k20M+FHo3GGZOZq1VRrKCSH49 pr654PRMpuXnrY+LcXcywv15BQoW3iqStMY9Xh3ggL+CC8Epb6QWyhPo2L6HV5MK2gQ2 /hHxBwOyuR6aYdgof43H1tPOyK6Y6lHZgUgnp/XaERqP6vx4Yr/Z3qgX2gPvYmSjacFy JcD1iODTEe/Mk2Qm8stw36LbU8lS6Mqdnvlzkg8NDXhjwkpqIblZv96/iaLGLgInvUeY DrtXAaWxl8eQJPAMDEgQY7dh5ll6DzmQk/cV/p8ldvHa2Uu+BdLm0m2uqCqP3HlI0mVT SmiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=BD6qB7twnufisotyY5nBfpaakG3WUms/sLLcs5/qPcg=; b=nGEFbWueAIrqXAf7kpsTImTcR+kEW6TicT4BMhrX/uuF5yGOV60+tiDALHVOHT2Hk/ ewz6mkgUErMccg4x/b2FLKDLDs9hmffsk5v4eUwJfOC7Vav6BAmLAIXG2jp8JKlvMN9x j6jlXc25CxAVJvALlKCm8HMxqr7l3f6p8vkDHVhlTtzSf2w+aroTaa7kKNapFG9VE16L uGeKMyh3ESW1oQn2/F4jOZrTqwOxWS+0zTrws3+fGl9fXuu6R0PlhEE2+iM6lnd2hCcC +khoqG0RdF6FDd1Zvn02V8Hc6f2/r2q8nc2VkDNgv7yw2F8WJ0QAary/48bSdnejbOlN 49bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JDuBiVDj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d127-20020a633685000000b0053486f3dcc2si2205293pga.629.2023.05.19.07.55.15; Fri, 19 May 2023 07:55:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JDuBiVDj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232151AbjESOsm (ORCPT + 99 others); Fri, 19 May 2023 10:48:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232026AbjESOsc (ORCPT ); Fri, 19 May 2023 10:48:32 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF48D1A7 for ; Fri, 19 May 2023 07:48:27 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-96f588bc322so181697566b.1 for ; Fri, 19 May 2023 07:48:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1684507706; x=1687099706; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=BD6qB7twnufisotyY5nBfpaakG3WUms/sLLcs5/qPcg=; b=JDuBiVDj8o8HaMzkIB840oZkGv5wJJi7TNtUIrYqKhMie/96QidOGQDjQXE7b5+5S9 tK8GWP5SEiIeHDVPjC3T2ENDFCeYqLi5SHh6A0hgK/rjIefTVUgKtRZiA8w7MSYtyRXh R0aHFCTNuZeLm/jFjl0vcQ1z/eRP+0aN//K8c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684507706; x=1687099706; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BD6qB7twnufisotyY5nBfpaakG3WUms/sLLcs5/qPcg=; b=h5A6njbIS6ZQ1xC3K+SgXnNVPrpZI13vscDc55i61oOudhgENDksjys82RPBN0UFwH fKsciqv2g7AJo2/a07HIUYt46+4ltmPvV2hhfu0sLBKe3ShljuUItYvmdkD+K324Jtbx I9cPkaOEdfkTq9pvo+wlCRFwWf9HP6eEP3Vu1KEmX4nzQ3UZEAGPJSotn8FZ5couNgaX gj0wZUTMJi72v4CiQ65VnwQ5YR7sQNqoNWhtcnp1ij0JxPAGvY8rIuuiDoyTm0bib791 RI5vhkgC8UkJO3b9vFKp8qQzXNg7jqfY884p1FkjlLZjtQqAv0Kp5X3Dm3LY2MtMpcnx C1lA== X-Gm-Message-State: AC+VfDwkrm9gEaoWb7GlHuc4aSiVW4XFmlWY5NkjpMoeZYeLuPhKI7PX CsSp7H7e2KAzNy9wpINuXCHwTg== X-Received: by 2002:a17:907:1609:b0:94f:1c90:cb71 with SMTP id hb9-20020a170907160900b0094f1c90cb71mr2302378ejc.65.1684507706237; Fri, 19 May 2023 07:48:26 -0700 (PDT) Received: from alco.roam.corp.google.com ([2620:0:1059:10:62fd:274b:c2ab:69bb]) by smtp.gmail.com with ESMTPSA id a2-20020a17090680c200b0096a68648329sm2349437ejx.214.2023.05.19.07.48.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 07:48:25 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 May 2023 16:47:37 +0200 Subject: [PATCH v7 2/4] x86/purgatory: Remove PGO flags MIME-Version: 1.0 Message-Id: <20230321-kexec_clang16-v7-2-b05c520b7296@chromium.org> References: <20230321-kexec_clang16-v7-0-b05c520b7296@chromium.org> In-Reply-To: <20230321-kexec_clang16-v7-0-b05c520b7296@chromium.org> To: Eric Biederman , Philipp Rudo , Dave Young , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Nathan Chancellor , Tom Rix , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: Baoquan He , Philipp Rudo , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Ross Zwisler , Steven Rostedt , Simon Horman , Nick Desaulniers , llvm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, Ricardo Ribalda , stable@vger.kernel.org X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1218; i=ribalda@chromium.org; h=from:subject:message-id; bh=ZdKmKWLc9TEOfphmrnN/WwYYNZStN7R/TxB0+Zjd8HY=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBkZ4wxpLapFX/30sji37lAIaagKHpP8BO2TaX+/ sJHabfFQk2JAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCZGeMMQAKCRDRN9E+zzrE iBOhEACRW3xOCPLHp71KLmHTYNCd71GtWrKjkfxklAL33OghFmTvUpYrsF9LpYB/m7hEcL/ThHl hL85+iGqortM23o+IHkavb1dGe2lPjzhRrAlOP3VRhZdMb4Z30GB9soPtsVB1wTkIHAffgMXlXl OX9TTvAAdTwiK3QpxHsQTI7Zrwd7j4F5PLFwLvF1EJ5B9vHk24k8qUliTckaIUupc8s90pL+blD 76ekelf8r6J/OuHnqjwfBNPIN+L5PKM1Qnvc+nhDbVClbug/NZoYEOQncnJUQzy4+pPlgWMhh1n jSBpPsZLhRFaaAvgOmnCFcJ4QK855FrYlgSZ62gNGa18oujDvo8M/P3rMJl+ZptFWkJHg4ftqjk d2p50qqwa36cAZSdv5xiIorPYJAvQcKnfbLTa/33NmhdJsRmYKEIBmzoJJMVV1WM2GQ1GoS3iqQ xsIbbnRtyfu5Oj+092A0UrmjBv44l9VFL0GioJ/h1dybPyj/xRudpeipiBI5UHl+PsrthS0eXyR BEhiiCDkPPQVspdv9HGVTw7RtC+jrD2P59F2ZJdHKAj43rczvbjLU1aFhLmXOsvEzExQ7jdyhrD dtwIMAsWCKWuA82FW3a1RMjpQzwZn57XSc6vVKzBJhtayoAZ/RnFP3+dNNhzAJAuESXOXu/+Yc9 KoQnpw6oiVlAnVA== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766334795492031251?= X-GMAIL-MSGID: =?utf-8?q?1766334795492031251?= If profile-guided optimization is enabled, the purgatory ends up with multiple .text sections. This is not supported by kexec and crashes the system. Cc: stable@vger.kernel.org Fixes: 930457057abe ("kernel/kexec_file.c: split up __kexec_load_puragory") Signed-off-by: Ricardo Ribalda --- arch/x86/purgatory/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile index 82fec66d46d2..42abd6af1198 100644 --- a/arch/x86/purgatory/Makefile +++ b/arch/x86/purgatory/Makefile @@ -14,6 +14,11 @@ $(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE CFLAGS_sha256.o := -D__DISABLE_EXPORTS +# When profile-guided optimization is enabled, llvm emits two different +# overlapping text sections, which is not supported by kexec. Remove profile +# optimization flags. +KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS)) + # When linking purgatory.ro with -r unresolved symbols are not checked, # also link a purgatory.chk binary without -r to check for unresolved symbols. PURGATORY_LDFLAGS := -e purgatory_start -z nodefaultlib From patchwork Fri May 19 14:47:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 96477 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1302410vqo; Fri, 19 May 2023 08:04:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Bos6QCA65t1aIoGao3mCeWTgEErmw0JYnEqgnaWRr1TYRkVmPefbT/OX31HSuojl5iCDf X-Received: by 2002:a17:90b:1050:b0:24e:507:7408 with SMTP id gq16-20020a17090b105000b0024e05077408mr2316409pjb.37.1684508639841; Fri, 19 May 2023 08:03:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684508639; cv=none; d=google.com; s=arc-20160816; b=UkAh64mdAcK5i7TIz6KIeghMlkKVGmbB9cR8t2/7juLedUHprJbDMj3zboa/PEuenQ d3ISiqfEAYN2mRCuT17Ys7GMIsfopDdJT7jSDcQ5dsX2NWii2QyghzAlybUnQuZ9+rfb Sq/TJ3aW10d4lg+MKcbVCCk84zfwvtV9eTK3gUHp+FWjwY9YUIcABiNqs+J1NZeKegj8 2LIz94BrV4vyeQ5qayKnb39PlHZHQaPtGK3ltXFG9hi7nNf7//MjMFLigH+prHmAukSR 6d4BaNq4YSSYq7KhCwu3R+Xpjr9OwZqy5BFoIdNnIvrnkTjd6yzmXUgFD0VaYmBgJZRO ybGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=tXwbVblZO4SjZiyR2RJlU+1lPwt65C7sEIHn8p960bg=; b=nlPiuY6mcMvcXS/hjk6iYWPBndpigVah04jt/ZfHrekaIoW/L5vom6GCYH4HhNqm3c J/GdWyqxTjw17C0nQO6NRFE8+cypuqftP8G0rk2NRpRPlXN0bag0Nz2OGI7jUNasvmUJ K4yspufY0EQr0JXCOsiD9GyX/rCwgRKSZKBc6OSvaEBrm2GM8UUM7x6LCDMna5qH9i66 46TB+YsAVbi484ncBYjZi3xY0zG7a9Uus2Wr84mVXYdJa21Ztmgofiu+3c5SAO5bYOaJ LMt+wqHjwnLL0ukaACGt6cotOMzqPoqybYqstLxBtwDpHxWQgTLUVsYwnQsi2NZTeT2K BnbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VaD18pva; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g4-20020a633744000000b005303a7ca052si3832424pgn.491.2023.05.19.08.03.45; Fri, 19 May 2023 08:03:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VaD18pva; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232181AbjESOso (ORCPT + 99 others); Fri, 19 May 2023 10:48:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232086AbjESOsc (ORCPT ); Fri, 19 May 2023 10:48:32 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 426B91B4 for ; Fri, 19 May 2023 07:48:29 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-94a342f7c4cso636589966b.0 for ; Fri, 19 May 2023 07:48:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1684507708; x=1687099708; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=tXwbVblZO4SjZiyR2RJlU+1lPwt65C7sEIHn8p960bg=; b=VaD18pvaYOrPW92cQcoX/NEFyAia0fIgR3ptOsuxx7KqL2m3/Fogz3ohdrjtw8jIAf /EDDCPYx2T0p21USc97DaVoXS6yaR7TsMgEpNMeajTXb8D6rWvFbDapW+nC79TBs8v+N rMi14ZDfRFVBtp/DNGdIPfZ3+MAQ50UYsHPYQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684507708; x=1687099708; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tXwbVblZO4SjZiyR2RJlU+1lPwt65C7sEIHn8p960bg=; b=jKWHiTri4FYvKaUdsK2Yun5LzVMq0hR5qdiz2n7Tp0ed+WQpXWXu7X/WCPQ+QMjdUR kaUh8ljQgwpZGj91GOBTQs3kCZNgsxd4KjKHTxjkRnVTbwZExlUtGxq3mTbvtV6NgHRB pAUj8IEpUda/Ok4kpWQMOVjEvTz/RdSNjEKCwCVpku+ke8XNQId2JJshk1QMqxrGspOQ xwYDABIFWCTdYlZpFx99a07cmUZp4nXOul+8f3zE3Em+aeP3c+cgrr2meGFopfOBQnwq RDow317G15ebnowMY7TcjN7UWy6ymllKiA3nuXNAQa0S1FKWxOjoiWFtlhTLSFU4OWAT jxvw== X-Gm-Message-State: AC+VfDxLSxE8esDhhqe0rpQq+YGk578BZTPMh+viM2bkgoiCM5/QSD50 v9eL/WoZFEmZh/Wqr+WygyQcUg== X-Received: by 2002:a17:906:5d09:b0:948:a1ae:b2c4 with SMTP id g9-20020a1709065d0900b00948a1aeb2c4mr2454616ejt.6.1684507708255; Fri, 19 May 2023 07:48:28 -0700 (PDT) Received: from alco.roam.corp.google.com ([2620:0:1059:10:62fd:274b:c2ab:69bb]) by smtp.gmail.com with ESMTPSA id a2-20020a17090680c200b0096a68648329sm2349437ejx.214.2023.05.19.07.48.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 07:48:27 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 May 2023 16:47:38 +0200 Subject: [PATCH v7 3/4] powerpc/purgatory: Remove PGO flags MIME-Version: 1.0 Message-Id: <20230321-kexec_clang16-v7-3-b05c520b7296@chromium.org> References: <20230321-kexec_clang16-v7-0-b05c520b7296@chromium.org> In-Reply-To: <20230321-kexec_clang16-v7-0-b05c520b7296@chromium.org> To: Eric Biederman , Philipp Rudo , Dave Young , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Nathan Chancellor , Tom Rix , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: Baoquan He , Philipp Rudo , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Ross Zwisler , Steven Rostedt , Simon Horman , Nick Desaulniers , llvm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, Ricardo Ribalda , stable@vger.kernel.org X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1118; i=ribalda@chromium.org; h=from:subject:message-id; bh=nWZ2BYP6i2Y8oRo+uF2PHambNY95ZiGn4TiaTAGbKto=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBkZ4wyHkNCHhezyfivzJzrNGMs0K4vUNQRc3pJJ kWHuaNU3qOJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCZGeMMgAKCRDRN9E+zzrE iP+cEACcWHC3j1LmIzpKx/SEOuyu+T8juc3Qsp240gztvu/viz42y8/iBia84BlsRwErLK2OL0F 3ajW94BvdF+hTyHozZEgIagItfSauWAbew6wVa0Qzfv2fr5mU42KfHptzq1l42en7K2rPbcBmLI I2P1/oqo/f6jOgRfm+rkNph26o3SqzcGwOrNJxLkICIjOt2ryabXBD6m79TkrzdPaB9SoChGJac O79LnGL81Pw+Yncu0mYsV4I5Rjw5ZeyFHdpQ7Fz5EA8wvSDDG6odoFxcqf4yE6+bmUv/49AELSz 4dxJdTvbEKZro9lHA0iSPkRPv/S0GQJu/n8ilKFXAYPfqAfDYAN86mjt4xRWsDrK/m2U5bJyQDO y1Bsea8Nuec1BFMA7YRXUDVC9wxgK6i5U1QYeDdEOWjG8KsrN7aDk6FT7Vs5HVZVFlpaYzxI1Qy OuCwULJN4OB++Blq1pndCgv3Enk4iWEnD3tV8M5ZGZEkwnZmi1PxTzTAUZrdHBuiBcGUJURHEal /D5/1Q6A+bUxW980Yzwcu1tPuxwKe1lCW0boDcrNi3inwoNG0wyymcZvtfl/+IKzenjCXxuZ8c4 54evV8xE1nlppSTiE5EscgwFuFxb6elq+Frz99s4912olrL9bjc84OFEQ1brCORAnz/ZbTuENqO ZuH2pEvCDHPT0rw== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766335331921025286?= X-GMAIL-MSGID: =?utf-8?q?1766335331921025286?= If profile-guided optimization is enabled, the purgatory ends up with multiple .text sections. This is not supported by kexec and crashes the system. Cc: stable@vger.kernel.org Fixes: 930457057abe ("kernel/kexec_file.c: split up __kexec_load_puragory") Signed-off-by: Ricardo Ribalda Acked-by: Michael Ellerman (powerpc) --- arch/powerpc/purgatory/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/powerpc/purgatory/Makefile b/arch/powerpc/purgatory/Makefile index 6f5e2727963c..78473d69cd2b 100644 --- a/arch/powerpc/purgatory/Makefile +++ b/arch/powerpc/purgatory/Makefile @@ -5,6 +5,11 @@ KCSAN_SANITIZE := n targets += trampoline_$(BITS).o purgatory.ro +# When profile-guided optimization is enabled, llvm emits two different +# overlapping text sections, which is not supported by kexec. Remove profile +# optimization flags. +KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS)) + LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined $(obj)/purgatory.ro: $(obj)/trampoline_$(BITS).o FORCE From patchwork Fri May 19 14:47:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 96478 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1303180vqo; Fri, 19 May 2023 08:04:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4rO6DvIKvmmSNy1E9/wVrW1SmhtCsYEhWlu/5SeBSAWO2xnRuELt8w0YA+GvcbAi5m+gPr X-Received: by 2002:a17:902:d48e:b0:1ac:8835:b881 with SMTP id c14-20020a170902d48e00b001ac8835b881mr2902804plg.17.1684508692206; Fri, 19 May 2023 08:04:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684508692; cv=none; d=google.com; s=arc-20160816; b=Zy7NKMiq5/8oW+sQwdTn2cC3AdDXsj2LebW386fCzneVw6uGO8Qd4pfsbgIos5B80u 1yB8ZSPZ1ypcgJGPmJJfFaf65S2hZ6EiMZ4OHEzHMQUvGIcPyfc8YYl+WpQW4BUHJs04 4U/7fB0xJQ3/1pszuOjrok0OsjOnJbNN5j8jchGG4d5NEtBwBTHDByut9Qddz12is+R5 1IUazVsjhlMHH1RU/jh4eCZqruV5NpJnwdYlEwMAtVI8I/sac3/le+dpqiMVpBnSzvOo fj765CTZDQqItpaFX/Ld/7MkS6cm9NZOdMjo/NAHvOEChVvwAbtoeJ/nsxs9qF2XLMd6 KhuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=osK35APNMHUOM/vspbNmY4dm4o7cSGGXI42PTW0uu8s=; b=kp+5tGAAK6s7vGWEq2OnyaRSP+FxUwFRwoHhc2k8RTvPSpKVmyHGJd4hL4OcmQwiHT P+SsItdV0WTE78pvJw9i2OtKMs53HVRALnUU/tQLrbKvRJ2woLQSLJPSrqr43jRnkw75 obROl1rjkTuAXrVMyuS2NXALVDfwRJIQiyKiDzGiVAYRxynNGVI5Wg/WUT7iGe5sWB+w Z3+2dRkBDoUvN/qi3qQbd6bLgjtvheoPdd1NXESPY87aFs6LlIgpF1NCTTp8Mb3Uy+v0 w/U233Wlg6uq8CrlZAAit/lyEZ/FpaE0WjuIGBnbmChyqgMRg7j1yLqCszJ+NGxfODkA gwoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZYjh30K7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a170903024d00b001a6db2bef14si3910665plh.157.2023.05.19.08.04.38; Fri, 19 May 2023 08:04:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZYjh30K7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232168AbjESOsr (ORCPT + 99 others); Fri, 19 May 2023 10:48:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232098AbjESOsc (ORCPT ); Fri, 19 May 2023 10:48:32 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6572C1B5 for ; Fri, 19 May 2023 07:48:31 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-96649b412easo532763666b.0 for ; Fri, 19 May 2023 07:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1684507711; x=1687099711; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=osK35APNMHUOM/vspbNmY4dm4o7cSGGXI42PTW0uu8s=; b=ZYjh30K7khuwsHmxdTGgS+WoY9zJgx6/9/pcc1JbuvgcIEsldCdXXJbEp4NACjCKaD LMW1h53HHwQnKpmODQx7uXNQn0+JuBNgZS2Zh/7IejB20vSK2D1Unr6kMSuPVMXAFhiZ 9ZeWiBl87aFZW9wBv1Nh3DLuN2movq9+fC554= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684507711; x=1687099711; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=osK35APNMHUOM/vspbNmY4dm4o7cSGGXI42PTW0uu8s=; b=UokvlmPWXs1gY0jEEhuTpAya1J18aYOAr2fyxevhbeOJByHS2sfsKQlrEyId4TTeRZ GVZ+i/rZo2vxv2pNhq/tpXcaXC/ajhlFmYEXxv+LaSqX/krAonV23GxgNOUB1Ae0SDEo W0G4L/L7eNp9NmFS/x3+AJpsXHShA/F1y4Cj9OX6Btv8pc6v3cTeJtNhrfinFYUFbG+o COYx10yuY+29xwgDipX2zN+3P4CoRfELDTaD/q3gx2XZrP3WY4xymTjRtB9TTPKHfEZ+ MkUBRbKXdUGqjN8qFiuGceTomsOu4yvsWGmsjV5sujgrNCVKo/5snBIT8qIDnlI9geeI OVpA== X-Gm-Message-State: AC+VfDyTiDo8dF+JvVX360tJxMl5Ox75uZNgETI5/wxCu2kGraaEevTo 0jTb6NE/adZ+UiSXu4uP9EQGow== X-Received: by 2002:a17:906:d54a:b0:94e:f738:514f with SMTP id cr10-20020a170906d54a00b0094ef738514fmr2090904ejc.13.1684507710607; Fri, 19 May 2023 07:48:30 -0700 (PDT) Received: from alco.roam.corp.google.com ([2620:0:1059:10:62fd:274b:c2ab:69bb]) by smtp.gmail.com with ESMTPSA id a2-20020a17090680c200b0096a68648329sm2349437ejx.214.2023.05.19.07.48.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 07:48:30 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 19 May 2023 16:47:39 +0200 Subject: [PATCH v7 4/4] riscv/purgatory: Remove PGO flags MIME-Version: 1.0 Message-Id: <20230321-kexec_clang16-v7-4-b05c520b7296@chromium.org> References: <20230321-kexec_clang16-v7-0-b05c520b7296@chromium.org> In-Reply-To: <20230321-kexec_clang16-v7-0-b05c520b7296@chromium.org> To: Eric Biederman , Philipp Rudo , Dave Young , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Nathan Chancellor , Tom Rix , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: Baoquan He , Philipp Rudo , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Ross Zwisler , Steven Rostedt , Simon Horman , Nick Desaulniers , llvm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, Ricardo Ribalda , stable@vger.kernel.org, Palmer Dabbelt X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1298; i=ribalda@chromium.org; h=from:subject:message-id; bh=wdnk6GxBa5T/HIlvuq8XoXYQQFQFk4mx9eVuJiQf83M=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBkZ4wzePFk89/IBhUZr9SWcIl2QkwFBFu2gEcYe /5y+YTRvGqJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCZGeMMwAKCRDRN9E+zzrE iEJ9EACWgKvSdCRvRA4/lyxhvVHQgJQ0PCNnOhH3hpa3YJPoHyQLHQ8AWvcvBMla51KPtthYLTN RttNdzciI8SyWtWAc62LCy0wqaKDS+qbrbvVnUEYDgzqyCjq/gSxRky4clrjmFzUvY2wNCRfWMt yFLtWzm5iYd4N7d07L87XEKmPRitblqcy/VsPL9EMUutCQ5OQlaaSRto36SmkRf9nkrMPPzCH+2 qNNS8PY2lNeGzUvTDAi7F00EDf/PLWQ7pXaKeJeU56IsYS8v1VUoNdkx04R/AIO8TBdqwsDZhhD UqPLLPRwecZmAks5n575AFj+ZFRtUPueG6J2aQ1ndVzS+8/OTyW1xxwogq6fkwr44uXalhe3YxJ aUOnvtCxh06L48mQLfdlx1JhUTlhZ1AtVysiezFN9EedPP27rIgxpSSgnEwsjDWJny3YJfbGJQN Zk7DDEwAQLAN3GaT+i/K2X8PEHG6+A5SkFE+wZe5WKERCdPLVGgWjIYwaqXDAvGK/5DfORHun85 2qC2ReqZtGwpWhUfg6jJ4cFTsiNbkYy31b1T5/9BqXT5dBqfAuVU/QKYqg5qb4ciKtKesTLLV1H ZydnfO9MMJNG6tjvelUtgGQRPqf1ea9Lob19/0XoQrWh8oifHm8eWWisKYfQY/1ExftAFpZCeA5 BmR9KbCqwO2lwOg== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766335386499510827?= X-GMAIL-MSGID: =?utf-8?q?1766335386499510827?= If profile-guided optimization is enabled, the purgatory ends up with multiple .text sections. This is not supported by kexec and crashes the system. Cc: stable@vger.kernel.org Fixes: 930457057abe ("kernel/kexec_file.c: split up __kexec_load_puragory") Acked-by: Palmer Dabbelt Signed-off-by: Ricardo Ribalda --- arch/riscv/purgatory/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/riscv/purgatory/Makefile b/arch/riscv/purgatory/Makefile index 5730797a6b40..bd2e27f82532 100644 --- a/arch/riscv/purgatory/Makefile +++ b/arch/riscv/purgatory/Makefile @@ -35,6 +35,11 @@ CFLAGS_sha256.o := -D__DISABLE_EXPORTS CFLAGS_string.o := -D__DISABLE_EXPORTS CFLAGS_ctype.o := -D__DISABLE_EXPORTS +# When profile-guided optimization is enabled, llvm emits two different +# overlapping text sections, which is not supported by kexec. Remove profile +# optimization flags. +KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS)) + # When linking purgatory.ro with -r unresolved symbols are not checked, # also link a purgatory.chk binary without -r to check for unresolved symbols. PURGATORY_LDFLAGS := -e purgatory_start -z nodefaultlib