stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Mark Rutland <mark.rutland@arm.com>,
	Helge Deller <deller@gmx.de>,
	"Steven Rostedt (VMware)" <rostedt@goodmis.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Torsten Duwe <duwe@suse.de>,
	Amit Daniel Kachhap <amit.kachhap@arm.com>,
	Sven Schnelle <svens@stackframe.org>,
	Ingo Molnar <mingo@redhat.com>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	Jessica Yu <jeyu@kernel.org>,
	linux-parisc@vger.kernel.org, Stephen Boyd <swboyd@chromium.org>
Subject: [PATCH 5.4 24/80] module/ftrace: handle patchable-function-entry
Date: Mon, 21 Feb 2022 09:49:04 +0100	[thread overview]
Message-ID: <20220221084916.374474220@linuxfoundation.org> (raw)
In-Reply-To: <20220221084915.554151737@linuxfoundation.org>

From: Mark Rutland <mark.rutland@arm.com>

commit a1326b17ac03a9012cb3d01e434aacb4d67a416c upstream.

When using patchable-function-entry, the compiler will record the
callsites into a section named "__patchable_function_entries" rather
than "__mcount_loc". Let's abstract this difference behind a new
FTRACE_CALLSITE_SECTION, so that architectures don't have to handle this
explicitly (e.g. with custom module linker scripts).

As parisc currently handles this explicitly, it is fixed up accordingly,
with its custom linker script removed. Since FTRACE_CALLSITE_SECTION is
only defined when DYNAMIC_FTRACE is selected, the parisc module loading
code is updated to only use the definition in that case. When
DYNAMIC_FTRACE is not selected, modules shouldn't have this section, so
this removes some redundant work in that case.

To make sure that this is keep up-to-date for modules and the main
kernel, a comment is added to vmlinux.lds.h, with the existing ifdeffery
simplified for legibility.

I built parisc generic-{32,64}bit_defconfig with DYNAMIC_FTRACE enabled,
and verified that the section made it into the .ko files for modules.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Helge Deller <deller@gmx.de>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Torsten Duwe <duwe@suse.de>
Tested-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
Tested-by: Sven Schnelle <svens@stackframe.org>
Tested-by: Torsten Duwe <duwe@suse.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Jessica Yu <jeyu@kernel.org>
Cc: linux-parisc@vger.kernel.org
Cc: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/parisc/Makefile              |    1 -
 arch/parisc/kernel/module.c       |   10 +++++++---
 arch/parisc/kernel/module.lds     |    7 -------
 include/asm-generic/vmlinux.lds.h |   14 +++++++-------
 include/linux/ftrace.h            |    5 +++++
 kernel/module.c                   |    2 +-
 6 files changed, 20 insertions(+), 19 deletions(-)
 delete mode 100644 arch/parisc/kernel/module.lds

--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -65,7 +65,6 @@ KBUILD_CFLAGS += -DCC_USING_PATCHABLE_FU
 		 -DFTRACE_PATCHABLE_FUNCTION_SIZE=$(NOP_COUNT)
 
 CC_FLAGS_FTRACE := -fpatchable-function-entry=$(NOP_COUNT),$(shell echo $$(($(NOP_COUNT)-1)))
-KBUILD_LDS_MODULE += $(srctree)/arch/parisc/kernel/module.lds
 endif
 
 OBJCOPY_FLAGS =-O binary -R .note -R .comment -S
--- a/arch/parisc/kernel/module.c
+++ b/arch/parisc/kernel/module.c
@@ -43,6 +43,7 @@
 #include <linux/elf.h>
 #include <linux/vmalloc.h>
 #include <linux/fs.h>
+#include <linux/ftrace.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/bug.h>
@@ -862,7 +863,7 @@ int module_finalize(const Elf_Ehdr *hdr,
 	const char *strtab = NULL;
 	const Elf_Shdr *s;
 	char *secstrings;
-	int err, symindex = -1;
+	int symindex = -1;
 	Elf_Sym *newptr, *oldptr;
 	Elf_Shdr *symhdr = NULL;
 #ifdef DEBUG
@@ -946,11 +947,13 @@ int module_finalize(const Elf_Ehdr *hdr,
 			/* patch .altinstructions */
 			apply_alternatives(aseg, aseg + s->sh_size, me->name);
 
+#ifdef CONFIG_DYNAMIC_FTRACE
 		/* For 32 bit kernels we're compiling modules with
 		 * -ffunction-sections so we must relocate the addresses in the
-		 *__mcount_loc section.
+		 *  ftrace callsite section.
 		 */
-		if (symindex != -1 && !strcmp(secname, "__mcount_loc")) {
+		if (symindex != -1 && !strcmp(secname, FTRACE_CALLSITE_SECTION)) {
+			int err;
 			if (s->sh_type == SHT_REL)
 				err = apply_relocate((Elf_Shdr *)sechdrs,
 							strtab, symindex,
@@ -962,6 +965,7 @@ int module_finalize(const Elf_Ehdr *hdr,
 			if (err)
 				return err;
 		}
+#endif
 	}
 	return 0;
 }
--- a/arch/parisc/kernel/module.lds
+++ /dev/null
@@ -1,7 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-
-SECTIONS {
-	__mcount_loc : {
-		*(__patchable_function_entries)
-	}
-}
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -110,17 +110,17 @@
 #endif
 
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
-#ifdef CC_USING_PATCHABLE_FUNCTION_ENTRY
-#define MCOUNT_REC()	. = ALIGN(8);				\
-			__start_mcount_loc = .;			\
-			KEEP(*(__patchable_function_entries))	\
-			__stop_mcount_loc = .;
-#else
+/*
+ * The ftrace call sites are logged to a section whose name depends on the
+ * compiler option used. A given kernel image will only use one, AKA
+ * FTRACE_CALLSITE_SECTION. We capture all of them here to avoid header
+ * dependencies for FTRACE_CALLSITE_SECTION's definition.
+ */
 #define MCOUNT_REC()	. = ALIGN(8);				\
 			__start_mcount_loc = .;			\
 			KEEP(*(__mcount_loc))			\
+			KEEP(*(__patchable_function_entries))	\
 			__stop_mcount_loc = .;
-#endif
 #else
 #define MCOUNT_REC()
 #endif
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -738,6 +738,11 @@ static inline unsigned long get_lock_par
 
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
 extern void ftrace_init(void);
+#ifdef CC_USING_PATCHABLE_FUNCTION_ENTRY
+#define FTRACE_CALLSITE_SECTION	"__patchable_function_entries"
+#else
+#define FTRACE_CALLSITE_SECTION	"__mcount_loc"
+#endif
 #else
 static inline void ftrace_init(void) { }
 #endif
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3377,7 +3377,7 @@ static int find_module_sections(struct m
 #endif
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
 	/* sechdrs[0].sh_size is always zero */
-	mod->ftrace_callsites = section_objs(info, "__mcount_loc",
+	mod->ftrace_callsites = section_objs(info, FTRACE_CALLSITE_SECTION,
 					     sizeof(*mod->ftrace_callsites),
 					     &mod->num_ftrace_callsites);
 #endif



  parent reply	other threads:[~2022-02-21  9:04 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-21  8:48 [PATCH 5.4 00/80] 5.4.181-rc1 review Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 01/80] Makefile.extrawarn: Move -Wunaligned-access to W=1 Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 02/80] HID:Add support for UGTABLET WP5540 Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 03/80] Revert "svm: Add warning message for AVIC IPI invalid target" Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 04/80] serial: parisc: GSC: fix build when IOSAPIC is not set Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 05/80] parisc: Drop __init from map_pages declaration Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 06/80] parisc: Fix data TLB miss in sba_unmap_sg Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 07/80] parisc: Fix sglist access in ccio-dma.c Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 08/80] btrfs: send: in case of IO error log it Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 09/80] platform/x86: ISST: Fix possible circular locking dependency detected Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 10/80] selftests: rtc: Increase test timeout so that all tests run Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 11/80] net: ieee802154: at86rf230: Stop leaking skbs Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 12/80] selftests/zram: Skip max_comp_streams interface on newer kernel Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 13/80] selftests/zram01.sh: Fix compression ratio calculation Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 14/80] selftests/zram: Adapt the situation that /dev/zram0 is being used Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 15/80] ax25: improve the incomplete fix to avoid UAF and NPD bugs Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 16/80] vfs: make freeze_super abort when sync_filesystem returns error Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 17/80] quota: make dquot_quota_sync return errors from ->sync_fs Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 18/80] nvme: fix a possible use-after-free in controller reset during load Greg Kroah-Hartman
2022-02-21  8:48 ` [PATCH 5.4 19/80] nvme-tcp: fix possible use-after-free in transport error_recovery work Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 20/80] nvme-rdma: " Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 21/80] drm/amdgpu: fix logic inversion in check Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 22/80] Revert "module, async: async_synchronize_full() on module init iff async is used" Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 23/80] ftrace: add ftrace_init_nop() Greg Kroah-Hartman
2022-02-21  8:49 ` Greg Kroah-Hartman [this message]
2022-02-21  8:49 ` [PATCH 5.4 25/80] arm64: module: rework special section handling Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 26/80] arm64: module/ftrace: intialize PLT at load time Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 27/80] iwlwifi: fix use-after-free Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 28/80] drm/radeon: Fix backlight control on iMac 12,1 Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 29/80] ext4: check for out-of-order index extents in ext4_valid_extent_entries() Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 30/80] ext4: check for inconsistent extents between index and leaf block Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 31/80] ext4: prevent partial update of the extent blocks Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 32/80] taskstats: Cleanup the use of task->exit_code Greg Kroah-Hartman
2022-02-21 22:46   ` Dr. Thomas Orgis
2022-02-22 23:53     ` Eric W. Biederman
2022-02-23 22:40       ` Dr. Thomas Orgis
2022-02-25  0:23         ` Eric W. Biederman
2022-02-21  8:49 ` [PATCH 5.4 33/80] dmaengine: at_xdmac: Start transfer for cyclic channels in issue_pending Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 34/80] vsock: remove vsock from connected table when connect is interrupted by a signal Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 35/80] mmc: block: fix read single on recovery logic Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 36/80] iwlwifi: pcie: fix locking when "HW not ready" Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 37/80] iwlwifi: pcie: gen2: " Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 38/80] netfilter: nft_synproxy: unregister hooks on init error path Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 39/80] net: dsa: lan9303: fix reset on probe Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 40/80] net: ieee802154: ca8210: Fix lifs/sifs periods Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 41/80] ping: fix the dif and sdif check in ping_lookup Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 42/80] bonding: force carrier update when releasing slave Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 43/80] drop_monitor: fix data-race in dropmon_net_event / trace_napi_poll_hit Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 44/80] bonding: fix data-races around agg_select_timer Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 45/80] libsubcmd: Fix use-after-free for realloc(..., 0) Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 46/80] ALSA: hda: Fix regression on forced probe mask option Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 47/80] ALSA: hda: Fix missing codec probe on Shenker Dock 15 Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 48/80] ASoC: ops: Fix stereo change notifications in snd_soc_put_volsw() Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 49/80] ASoC: ops: Fix stereo change notifications in snd_soc_put_volsw_range() Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 50/80] powerpc/lib/sstep: fix ptesync build error Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 51/80] mtd: rawnand: gpmi: dont leak PM reference in error path Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 52/80] tee: export teedev_open() and teedev_close_context() Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 53/80] optee: use driver internal tee_context for some rpc Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 54/80] block/wbt: fix negative inflight counter when remove scsi device Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 55/80] NFS: LOOKUP_DIRECTORY is also ok with symlinks Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 56/80] NFS: Do not report writeback errors in nfs_getattr() Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 57/80] mtd: rawnand: qcom: Fix clock sequencing in qcom_nandc_probe() Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 58/80] mtd: rawnand: brcmnand: Fixed incorrect sub-page ECC status Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 59/80] scsi: lpfc: Fix pt2pt NVMe PRLI reject LOGO loop Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 60/80] EDAC: Fix calculation of returned address and next offset in edac_align_ptr() Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 61/80] net: sched: limit TC_ACT_REPEAT loops Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 62/80] dmaengine: sh: rcar-dmac: Check for error num after setting mask Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 63/80] copy_process(): Move fd_install() out of sighand->siglock critical section Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 64/80] i2c: brcmstb: fix support for DSL and CM variants Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 65/80] Drivers: hv: vmbus: Fix memory leak in vmbus_add_channel_kobj Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 66/80] KVM: x86/pmu: Use AMD64_RAW_EVENT_MASK for PERF_TYPE_RAW Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 67/80] ARM: OMAP2+: hwmod: Add of_node_put() before break Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 68/80] ARM: OMAP2+: adjust the location of put_device() call in omapdss_init_of Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 69/80] irqchip/sifive-plic: Add missing thead,c900-plic match string Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 70/80] netfilter: conntrack: dont refresh sctp entries in closed state Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 71/80] arm64: dts: meson-gx: add ATF BL32 reserved-memory region Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 72/80] arm64: dts: meson-g12: " Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 73/80] arm64: dts: meson-g12: drop BL32 region from SEI510/SEI610 Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 74/80] kconfig: let shell return enough output for deep path names Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 75/80] ata: libata-core: Disable TRIM on M88V29 Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 76/80] drm/rockchip: dw_hdmi: Do not leave clock enabled in error case Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 77/80] tracing: Fix tp_printk option related with tp_printk_stop_on_boot Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 78/80] net: usb: qmi_wwan: Add support for Dell DW5829e Greg Kroah-Hartman
2022-02-21  8:49 ` [PATCH 5.4 79/80] net: macb: Align the dma and coherent dma masks Greg Kroah-Hartman
2022-02-21  8:50 ` [PATCH 5.4 80/80] kconfig: fix failing to generate auto.conf Greg Kroah-Hartman
2022-02-21 21:18 ` [PATCH 5.4 00/80] 5.4.181-rc1 review Guenter Roeck
2022-02-21 21:38 ` Shuah Khan
2022-02-22  3:19 ` Slade Watkins
2022-02-22  3:25 ` Florian Fainelli
2022-02-22  6:54 ` Naresh Kamboju
2022-02-22 12:04 ` Sudip Mukherjee
2022-02-22 12:07 ` Jon Hunter
2022-02-23  0:54 ` Samuel Zou

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=20220221084916.374474220@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=amit.kachhap@arm.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=deller@gmx.de \
    --cc=duwe@suse.de \
    --cc=jeyu@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    --cc=svens@stackframe.org \
    --cc=swboyd@chromium.org \
    /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).