From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Ricardo Ribalda <ribalda@chromium.org>,
Ross Zwisler <zwisler@google.com>,
"Steven Rostedt (Google)" <rostedt@goodmis.org>,
Philipp Rudo <prudo@redhat.com>,
Albert Ou <aou@eecs.berkeley.edu>, Baoquan He <bhe@redhat.com>,
"Borislav Petkov (AMD)" <bp@alien8.de>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Dave Hansen <dave.hansen@linux.intel.com>,
Dave Young <dyoung@redhat.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nathan Chancellor <nathan@kernel.org>,
Nicholas Piggin <npiggin@gmail.com>,
Nick Desaulniers <ndesaulniers@google.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Palmer Dabbelt <palmer@rivosinc.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Simon Horman <horms@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>, Tom Rix <trix@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 4.19 17/49] kexec: support purgatories with .text.hot sections
Date: Mon, 19 Jun 2023 12:29:55 +0200 [thread overview]
Message-ID: <20230619102130.749126168@linuxfoundation.org> (raw)
In-Reply-To: <20230619102129.856988902@linuxfoundation.org>
From: Ricardo Ribalda <ribalda@chromium.org>
commit 8652d44f466ad5772e7d1756e9457046189b0dfc upstream.
Patch series "kexec: Fix kexec_file_load for llvm16 with PGO", v7.
When upreving llvm I realised that kexec stopped working on my test
platform.
The reason seems to be that due to PGO there are multiple .text sections
on the purgatory, and kexec does not supports that.
This patch (of 4):
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
Link: https://lkml.kernel.org/r/20230321-kexec_clang16-v7-0-b05c520b7296@chromium.org
Link: https://lkml.kernel.org/r/20230321-kexec_clang16-v7-1-b05c520b7296@chromium.org
Fixes: 930457057abe ("kernel/kexec_file.c: split up __kexec_load_puragory")
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Ross Zwisler <zwisler@google.com>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Reviewed-by: Philipp Rudo <prudo@redhat.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Baoquan He <bhe@redhat.com>
Cc: Borislav Petkov (AMD) <bp@alien8.de>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Palmer Dabbelt <palmer@rivosinc.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Simon Horman <horms@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tom Rix <trix@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/kexec_file.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -793,10 +793,22 @@ static int kexec_purgatory_setup_sechdrs
}
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;
}
next prev parent reply other threads:[~2023-06-19 10:41 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-19 10:29 [PATCH 4.19 00/49] 4.19.287-rc1 review Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 01/49] power: supply: ab8500: Fix external_power_changed race Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 02/49] power: supply: bq27xxx: Use mod_delayed_work() instead of cancel() + schedule() Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 03/49] ARM: dts: vexpress: add missing cache properties Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 04/49] power: supply: Ratelimit no data debug output Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 05/49] regulator: Fix error checking for debugfs_create_dir Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 06/49] irqchip/meson-gpio: Mark OF related data as maybe unused Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 07/49] power: supply: Fix logic checking if system is running from battery Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 08/49] parisc: Improve cache flushing for PCXL in arch_sync_dma_for_cpu() Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 09/49] MIPS: Alchemy: fix dbdma2 Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 10/49] mips: Move initrd_start check after initrd address sanitisation Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 11/49] xen/blkfront: Only check REQ_FUA for writes Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 12/49] ocfs2: fix use-after-free when unmounting read-only filesystem Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 13/49] ocfs2: check new file size on fallocate call Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 14/49] nios2: dts: Fix tse_mac "max-frame-size" property Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 15/49] nilfs2: fix incomplete buffer cleanup in nilfs_btnode_abort_change_key() Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 16/49] nilfs2: fix possible out-of-bounds segment allocation in resize ioctl Greg Kroah-Hartman
2023-06-19 10:29 ` Greg Kroah-Hartman [this message]
2023-06-19 10:29 ` [PATCH 4.19 18/49] powerpc/purgatory: remove PGO flags Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 19/49] nouveau: fix client work fence deletion race Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 20/49] RDMA/uverbs: Restrict usage of privileged QKEYs Greg Kroah-Hartman
2023-06-19 10:29 ` [PATCH 4.19 21/49] net: usb: qmi_wwan: add support for Compal RXM-G1 Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 22/49] Remove DECnet support from kernel Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 23/49] USB: serial: option: add Quectel EM061KGL series Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 24/49] usb: dwc3: gadget: Reset num TRBs before giving back the request Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 25/49] usb: gadget: f_ncm: Add OS descriptor support Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 26/49] usb: gadget: f_ncm: Fix NTP-32 support Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 27/49] netfilter: nfnetlink: skip error delivery on batch in case of ENOMEM Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 28/49] ping6: Fix send to link-local addresses with VRF Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 29/49] RDMA/rxe: Remove the unused variable obj Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 30/49] RDMA/rxe: Removed unused name from rxe_task struct Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 31/49] RDMA/rxe: Fix the use-before-initialization error of resp_pkts Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 32/49] IB/uverbs: Fix to consider event queue closing also upon non-blocking mode Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 33/49] IB/isert: Fix dead lock in ib_isert Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 34/49] IB/isert: Fix possible list corruption in CMA handler Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 35/49] IB/isert: Fix incorrect release of isert connection Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 36/49] sctp: fix an error code in sctp_sf_eat_auth() Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 37/49] igb: fix nvm.ops.read() error handling Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 38/49] drm/nouveau/dp: check for NULL nv_connector->native_mode Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 39/49] drm/nouveau/kms: Dont change EDID when it hasnt actually changed Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 40/49] drm/nouveau: add nv_encoder pointer check for NULL Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 41/49] net: lapbether: only support ethernet devices Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 42/49] net: tipc: resize nlattr array to correct size Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 43/49] selftests/ptp: Fix timestamp printf format for PTP_SYS_OFFSET Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 44/49] neighbour: Remove unused inline function neigh_key_eq16() Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 45/49] net: Remove unused inline function dst_hold_and_use() Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 46/49] neighbour: delete neigh_lookup_nodev as not used Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 47/49] drm/nouveau/kms: Fix NULL pointer dereference in nouveau_connector_detect_depth Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 48/49] powerpc: Fix defconfig choice logic when cross compiling Greg Kroah-Hartman
2023-06-19 10:30 ` [PATCH 4.19 49/49] mmc: block: ensure error propagation for non-blk Greg Kroah-Hartman
2023-06-20 9:19 ` [PATCH 4.19 00/49] 4.19.287-rc1 review Chris Paterson
2023-06-20 10:21 ` Jon Hunter
2023-06-20 10:46 ` Sudip Mukherjee (Codethink)
2023-06-20 11:04 ` Naresh Kamboju
2023-06-20 21:05 ` Shuah Khan
2023-06-21 0:37 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230619102130.749126168@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=aou@eecs.berkeley.edu \
--cc=bhe@redhat.com \
--cc=bp@alien8.de \
--cc=christophe.leroy@csgroup.eu \
--cc=dave.hansen@linux.intel.com \
--cc=dyoung@redhat.com \
--cc=ebiederm@xmission.com \
--cc=horms@kernel.org \
--cc=hpa@zytor.com \
--cc=mingo@redhat.com \
--cc=mpe@ellerman.id.au \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=npiggin@gmail.com \
--cc=palmer@dabbelt.com \
--cc=palmer@rivosinc.com \
--cc=patches@lists.linux.dev \
--cc=paul.walmsley@sifive.com \
--cc=prudo@redhat.com \
--cc=ribalda@chromium.org \
--cc=rostedt@goodmis.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=trix@redhat.com \
--cc=zwisler@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).