From cdb05c4c8e31704884e7d500517e2630af2c1703 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Mon, 19 Sep 2022 08:26:45 -0400 Subject: [PATCH] Fixes for 5.4 Signed-off-by: Sasha Levin --- ...-pcm-oss-fix-race-at-sndctl_dsp_sync.patch | 53 +++++++++ ...15-implement-waedplinkratedatareload.patch | 95 ++++++++++++++++ ...fi-libstub-disable-shadow-call-stack.patch | 39 +++++++ ...libstub-disable-struct-randomization.patch | 56 +++++++++ ...memory-corruption-caused-by-multiple.patch | 75 ++++++++++++ ...ut-sd-flag-names-rather-than-their-v.patch | 107 ++++++++++++++++++ queue-5.4/series | 8 ++ ...k-x86-cea-force-inline-stack-helpers.patch | 53 +++++++++ ...ler_addr-to-hardirq_-enable-disable-.patch | 58 ++++++++++ 9 files changed, 544 insertions(+) create mode 100644 queue-5.4/alsa-pcm-oss-fix-race-at-sndctl_dsp_sync.patch create mode 100644 queue-5.4/drm-i915-implement-waedplinkratedatareload.patch create mode 100644 queue-5.4/efi-libstub-disable-shadow-call-stack.patch create mode 100644 queue-5.4/efi-libstub-disable-struct-randomization.patch create mode 100644 queue-5.4/sched-debug-fix-memory-corruption-caused-by-multiple.patch create mode 100644 queue-5.4/sched-debug-output-sd-flag-names-rather-than-their-v.patch create mode 100644 queue-5.4/task_stack-x86-cea-force-inline-stack-helpers.patch create mode 100644 queue-5.4/tracing-hold-caller_addr-to-hardirq_-enable-disable-.patch diff --git a/queue-5.4/alsa-pcm-oss-fix-race-at-sndctl_dsp_sync.patch b/queue-5.4/alsa-pcm-oss-fix-race-at-sndctl_dsp_sync.patch new file mode 100644 index 00000000000..3190c9b8715 --- /dev/null +++ b/queue-5.4/alsa-pcm-oss-fix-race-at-sndctl_dsp_sync.patch @@ -0,0 +1,53 @@ +From eac446e17d621bee3e6d0d19cc35eeee19a682ad Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 19 Sep 2022 08:07:54 -0400 +Subject: ALSA: pcm: oss: Fix race at SNDCTL_DSP_SYNC + +[ Upstream commit 8423f0b6d513b259fdab9c9bf4aaa6188d054c2d ] + +There is a small race window at snd_pcm_oss_sync() that is called from +OSS PCM SNDCTL_DSP_SYNC ioctl; namely the function calls +snd_pcm_oss_make_ready() at first, then takes the params_lock mutex +for the rest. When the stream is set up again by another thread +between them, it leads to inconsistency, and may result in unexpected +results such as NULL dereference of OSS buffer as a fuzzer spotted +recently. + +The fix is simply to cover snd_pcm_oss_make_ready() call into the same +params_lock mutex with snd_pcm_oss_make_ready_locked() variant. + +Reported-and-tested-by: butt3rflyh4ck +Reviewed-by: Jaroslav Kysela +Cc: +Link: https://lore.kernel.org/r/CAFcO6XN7JDM4xSXGhtusQfS2mSBcx50VJKwQpCq=WeLt57aaZA@mail.gmail.com +Link: https://lore.kernel.org/r/20220905060714.22549-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/core/oss/pcm_oss.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c +index ad4e0af2d0d0..51d2911366e9 100644 +--- a/sound/core/oss/pcm_oss.c ++++ b/sound/core/oss/pcm_oss.c +@@ -1661,13 +1661,14 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file) + runtime = substream->runtime; + if (atomic_read(&substream->mmap_count)) + goto __direct; +- if ((err = snd_pcm_oss_make_ready(substream)) < 0) +- return err; + atomic_inc(&runtime->oss.rw_ref); + if (mutex_lock_interruptible(&runtime->oss.params_lock)) { + atomic_dec(&runtime->oss.rw_ref); + return -ERESTARTSYS; + } ++ err = snd_pcm_oss_make_ready_locked(substream); ++ if (err < 0) ++ goto unlock; + format = snd_pcm_oss_format_from(runtime->oss.format); + width = snd_pcm_format_physical_width(format); + if (runtime->oss.buffer_used > 0) { +-- +2.35.1 + diff --git a/queue-5.4/drm-i915-implement-waedplinkratedatareload.patch b/queue-5.4/drm-i915-implement-waedplinkratedatareload.patch new file mode 100644 index 00000000000..2f5b846f80a --- /dev/null +++ b/queue-5.4/drm-i915-implement-waedplinkratedatareload.patch @@ -0,0 +1,95 @@ +From 36c9ca7e117d715e270e5151e4c9ecf97f565e6e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 2 Sep 2022 10:03:18 +0300 +Subject: drm/i915: Implement WaEdpLinkRateDataReload +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ville Syrjälä + +[ Upstream commit 672d6ca758651f0ec12cd0d59787067a5bde1c96 ] + +A lot of modern laptops use the Parade PS8461E MUX for eDP +switching. The MUX can operate in jitter cleaning mode or +redriver mode, the first one resulting in higher link +quality. The jitter cleaning mode needs to know the link +rate used and the MUX achieves this by snooping the +LINK_BW_SET, LINK_RATE_SELECT and SUPPORTED_LINK_RATES +DPCD accesses. + +When the MUX is powered down (seems this can happen whenever +the display is turned off) it loses track of the snooped +link rates so when we do the LINK_RATE_SELECT write it no +longer knowns which link rate we're selecting, and thus it +falls back to the lower quality redriver mode. This results +in unstable high link rates (eg. usually 8.1Gbps link rate +no longer works correctly). + +In order to avoid all that let's re-snoop SUPPORTED_LINK_RATES +from the sink at the start of every link training. + +Unfortunately we don't have a way to detect the presence of +the MUX. It looks like the set of laptops equipped with this +MUX is fairly large and contains devices from multiple +manufacturers. It may also still be growing with new models. +So a quirk doesn't seem like a very easily maintainable +option, thus we shall attempt to do this unconditionally on +all machines that use LINK_RATE_SELECT. Hopefully this extra +DPCD read doesn't cause issues for any unaffected machine. +If that turns out to be the case we'll need to convert this +into a quirk in the future. + +Cc: stable@vger.kernel.org +Cc: Jason A. Donenfeld +Cc: Ankit Nautiyal +Cc: Jani Nikula +Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/6205 +Signed-off-by: Ville Syrjälä +Link: https://patchwork.freedesktop.org/patch/msgid/20220902070319.15395-1-ville.syrjala@linux.intel.com +Tested-by: Aaron Ma +Tested-by: Jason A. Donenfeld +Reviewed-by: Jani Nikula +(cherry picked from commit 25899c590cb5ba9b9f284c6ca8e7e9086793d641) +Signed-off-by: Rodrigo Vivi +Signed-off-by: Sasha Levin +--- + .../drm/i915/display/intel_dp_link_training.c | 22 +++++++++++++++++++ + 1 file changed, 22 insertions(+) + +diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_training.c b/drivers/gpu/drm/i915/display/intel_dp_link_training.c +index 2a1130dd1ad0..774f910364ab 100644 +--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c ++++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c +@@ -142,6 +142,28 @@ intel_dp_link_training_clock_recovery(struct intel_dp *intel_dp) + intel_dp_compute_rate(intel_dp, intel_dp->link_rate, + &link_bw, &rate_select); + ++ /* ++ * WaEdpLinkRateDataReload ++ * ++ * Parade PS8461E MUX (used on varius TGL+ laptops) needs ++ * to snoop the link rates reported by the sink when we ++ * use LINK_RATE_SET in order to operate in jitter cleaning ++ * mode (as opposed to redriver mode). Unfortunately it ++ * loses track of the snooped link rates when powered down, ++ * so we need to make it re-snoop often. Without this high ++ * link rates are not stable. ++ */ ++ if (!link_bw) { ++ struct intel_connector *connector = intel_dp->attached_connector; ++ __le16 sink_rates[DP_MAX_SUPPORTED_RATES]; ++ ++ drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] Reloading eDP link rates\n", ++ connector->base.base.id, connector->base.name); ++ ++ drm_dp_dpcd_read(&intel_dp->aux, DP_SUPPORTED_LINK_RATES, ++ sink_rates, sizeof(sink_rates)); ++ } ++ + if (link_bw) + DRM_DEBUG_KMS("Using LINK_BW_SET value %02x\n", link_bw); + else +-- +2.35.1 + diff --git a/queue-5.4/efi-libstub-disable-shadow-call-stack.patch b/queue-5.4/efi-libstub-disable-shadow-call-stack.patch new file mode 100644 index 00000000000..702cb1cd7b0 --- /dev/null +++ b/queue-5.4/efi-libstub-disable-shadow-call-stack.patch @@ -0,0 +1,39 @@ +From 71eff1e8b6af8ea09df48e7f63fcb2585248bdc7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 27 Apr 2020 09:00:18 -0700 +Subject: efi/libstub: Disable Shadow Call Stack + +From: Sami Tolvanen + +[ Upstream commit cc49c71d2abe99c1c2c9bedf0693ad2d3ee4a067 ] + +Shadow stacks are not available in the EFI stub, filter out SCS flags. + +Suggested-by: James Morse +Signed-off-by: Sami Tolvanen +Reviewed-by: Kees Cook +Acked-by: Ard Biesheuvel +Signed-off-by: Will Deacon +Stable-dep-of: 1a3887924a7e ("efi: libstub: Disable struct randomization") +Signed-off-by: Sasha Levin +--- + drivers/firmware/efi/libstub/Makefile | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile +index 8c5b5529dbc0..f3540d5dd276 100644 +--- a/drivers/firmware/efi/libstub/Makefile ++++ b/drivers/firmware/efi/libstub/Makefile +@@ -31,6 +31,9 @@ KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \ + $(call cc-option,-fno-addrsig) \ + -D__DISABLE_EXPORTS + ++# remove SCS flags from all objects in this directory ++KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS)) ++ + GCOV_PROFILE := n + KASAN_SANITIZE := n + UBSAN_SANITIZE := n +-- +2.35.1 + diff --git a/queue-5.4/efi-libstub-disable-struct-randomization.patch b/queue-5.4/efi-libstub-disable-struct-randomization.patch new file mode 100644 index 00000000000..6242b944088 --- /dev/null +++ b/queue-5.4/efi-libstub-disable-struct-randomization.patch @@ -0,0 +1,56 @@ +From e519094ca4cd30a02d34ad5d4c3f518c6fb18092 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 22 Aug 2022 19:20:33 +0200 +Subject: efi: libstub: Disable struct randomization + +From: Ard Biesheuvel + +[ Upstream commit 1a3887924a7e6edd331be76da7bf4c1e8eab4b1e ] + +The EFI stub is a wrapper around the core kernel that makes it look like +a EFI compatible PE/COFF application to the EFI firmware. EFI +applications run on top of the EFI runtime, which is heavily based on +so-called protocols, which are struct types consisting [mostly] of +function pointer members that are instantiated and recorded in a +protocol database. + +These structs look like the ideal randomization candidates to the +randstruct plugin (as they only carry function pointers), but of course, +these protocols are contracts between the firmware that exposes them, +and the EFI applications (including our stubbed kernel) that invoke +them. This means that struct randomization for EFI protocols is not a +great idea, and given that the stub shares very little data with the +core kernel that is represented as a randomizable struct, we're better +off just disabling it completely here. + +Cc: # v4.14+ +Reported-by: Daniel Marth +Tested-by: Daniel Marth +Signed-off-by: Ard Biesheuvel +Acked-by: Kees Cook +Signed-off-by: Sasha Levin +--- + drivers/firmware/efi/libstub/Makefile | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile +index f3540d5dd276..34e4b31010bd 100644 +--- a/drivers/firmware/efi/libstub/Makefile ++++ b/drivers/firmware/efi/libstub/Makefile +@@ -31,6 +31,13 @@ KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \ + $(call cc-option,-fno-addrsig) \ + -D__DISABLE_EXPORTS + ++# ++# struct randomization only makes sense for Linux internal types, which the EFI ++# stub code never touches, so let's turn off struct randomization for the stub ++# altogether ++# ++KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS), $(KBUILD_CFLAGS)) ++ + # remove SCS flags from all objects in this directory + KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS)) + +-- +2.35.1 + diff --git a/queue-5.4/sched-debug-fix-memory-corruption-caused-by-multiple.patch b/queue-5.4/sched-debug-fix-memory-corruption-caused-by-multiple.patch new file mode 100644 index 00000000000..eaccc85bd90 --- /dev/null +++ b/queue-5.4/sched-debug-fix-memory-corruption-caused-by-multiple.patch @@ -0,0 +1,75 @@ +From 6e0198428dac397668410194d2f454750ee7f1d4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 29 Oct 2020 15:11:03 +0000 +Subject: sched/debug: Fix memory corruption caused by multiple small reads of + flags + +From: Colin Ian King + +[ Upstream commit 8d4d9c7b4333abccb3bf310d76ef7ea2edb9828f ] + +Reading /proc/sys/kernel/sched_domain/cpu*/domain0/flags mutliple times +with small reads causes oopses with slub corruption issues because the kfree is +free'ing an offset from a previous allocation. Fix this by adding in a new +pointer 'buf' for the allocation and kfree and use the temporary pointer tmp +to handle memory copies of the buf offsets. + +Fixes: 5b9f8ff7b320 ("sched/debug: Output SD flag names rather than their values") +Reported-by: Jeff Bastian +Signed-off-by: Colin Ian King +Signed-off-by: Peter Zijlstra (Intel) +Reviewed-by: Valentin Schneider +Link: https://lkml.kernel.org/r/20201029151103.373410-1-colin.king@canonical.com +Stable-dep-of: c2e406596571 ("sched/debug: fix dentry leak in update_sched_domain_debugfs") +Signed-off-by: Sasha Levin +--- + kernel/sched/debug.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c +index df646776b7f0..5cb097382c47 100644 +--- a/kernel/sched/debug.c ++++ b/kernel/sched/debug.c +@@ -249,7 +249,7 @@ static int sd_ctl_doflags(struct ctl_table *table, int write, + unsigned long flags = *(unsigned long *)table->data; + size_t data_size = 0; + size_t len = 0; +- char *tmp; ++ char *tmp, *buf; + int idx; + + if (write) +@@ -267,17 +267,17 @@ static int sd_ctl_doflags(struct ctl_table *table, int write, + return 0; + } + +- tmp = kcalloc(data_size + 1, sizeof(*tmp), GFP_KERNEL); +- if (!tmp) ++ buf = kcalloc(data_size + 1, sizeof(*buf), GFP_KERNEL); ++ if (!buf) + return -ENOMEM; + + for_each_set_bit(idx, &flags, __SD_FLAG_CNT) { + char *name = sd_flag_debug[idx].name; + +- len += snprintf(tmp + len, strlen(name) + 2, "%s ", name); ++ len += snprintf(buf + len, strlen(name) + 2, "%s ", name); + } + +- tmp += *ppos; ++ tmp = buf + *ppos; + len -= *ppos; + + if (len > *lenp) +@@ -292,7 +292,7 @@ static int sd_ctl_doflags(struct ctl_table *table, int write, + *lenp = len; + *ppos += len; + +- kfree(tmp); ++ kfree(buf); + + return 0; + } +-- +2.35.1 + diff --git a/queue-5.4/sched-debug-output-sd-flag-names-rather-than-their-v.patch b/queue-5.4/sched-debug-output-sd-flag-names-rather-than-their-v.patch new file mode 100644 index 00000000000..a90954b3efc --- /dev/null +++ b/queue-5.4/sched-debug-output-sd-flag-names-rather-than-their-v.patch @@ -0,0 +1,107 @@ +From d023794b6b1646ba127c98be1d86ec0bac984e5c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 17 Aug 2020 12:29:52 +0100 +Subject: sched/debug: Output SD flag names rather than their values + +From: Valentin Schneider + +[ Upstream commit 5b9f8ff7b320a34af3dbcf04edb40d9b04f22f4a ] + +Decoding the output of /proc/sys/kernel/sched_domain/cpu*/domain*/flags has +always been somewhat annoying, as one needs to go fetch the bit -> name +mapping from the source code itself. This encoding can be saved in a script +somewhere, but that isn't safe from flags being added, removed or even +shuffled around. + +What matters for debugging purposes is to get *which* flags are set in a +given domain, their associated value is pretty much meaningless. + +Make the sd flags debug file output flag names. + +Signed-off-by: Valentin Schneider +Signed-off-by: Ingo Molnar +Acked-by: Peter Zijlstra +Link: https://lore.kernel.org/r/20200817113003.20802-7-valentin.schneider@arm.com +Stable-dep-of: c2e406596571 ("sched/debug: fix dentry leak in update_sched_domain_debugfs") +Signed-off-by: Sasha Levin +--- + kernel/sched/debug.c | 56 +++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 55 insertions(+), 1 deletion(-) + +diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c +index d5f7fc7099bc..df646776b7f0 100644 +--- a/kernel/sched/debug.c ++++ b/kernel/sched/debug.c +@@ -243,6 +243,60 @@ set_table_entry(struct ctl_table *entry, + entry->proc_handler = proc_handler; + } + ++static int sd_ctl_doflags(struct ctl_table *table, int write, ++ void *buffer, size_t *lenp, loff_t *ppos) ++{ ++ unsigned long flags = *(unsigned long *)table->data; ++ size_t data_size = 0; ++ size_t len = 0; ++ char *tmp; ++ int idx; ++ ++ if (write) ++ return 0; ++ ++ for_each_set_bit(idx, &flags, __SD_FLAG_CNT) { ++ char *name = sd_flag_debug[idx].name; ++ ++ /* Name plus whitespace */ ++ data_size += strlen(name) + 1; ++ } ++ ++ if (*ppos > data_size) { ++ *lenp = 0; ++ return 0; ++ } ++ ++ tmp = kcalloc(data_size + 1, sizeof(*tmp), GFP_KERNEL); ++ if (!tmp) ++ return -ENOMEM; ++ ++ for_each_set_bit(idx, &flags, __SD_FLAG_CNT) { ++ char *name = sd_flag_debug[idx].name; ++ ++ len += snprintf(tmp + len, strlen(name) + 2, "%s ", name); ++ } ++ ++ tmp += *ppos; ++ len -= *ppos; ++ ++ if (len > *lenp) ++ len = *lenp; ++ if (len) ++ memcpy(buffer, tmp, len); ++ if (len < *lenp) { ++ ((char *)buffer)[len] = '\n'; ++ len++; ++ } ++ ++ *lenp = len; ++ *ppos += len; ++ ++ kfree(tmp); ++ ++ return 0; ++} ++ + static struct ctl_table * + sd_alloc_ctl_domain_table(struct sched_domain *sd) + { +@@ -256,7 +310,7 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd) + set_table_entry(&table[2], "busy_factor", &sd->busy_factor, sizeof(int), 0644, proc_dointvec_minmax); + set_table_entry(&table[3], "imbalance_pct", &sd->imbalance_pct, sizeof(int), 0644, proc_dointvec_minmax); + set_table_entry(&table[4], "cache_nice_tries", &sd->cache_nice_tries, sizeof(int), 0644, proc_dointvec_minmax); +- set_table_entry(&table[5], "flags", &sd->flags, sizeof(int), 0444, proc_dointvec_minmax); ++ set_table_entry(&table[5], "flags", &sd->flags, sizeof(int), 0444, sd_ctl_doflags); + set_table_entry(&table[6], "max_newidle_lb_cost", &sd->max_newidle_lb_cost, sizeof(long), 0644, proc_doulongvec_minmax); + set_table_entry(&table[7], "name", sd->name, CORENAME_MAX_SIZE, 0444, proc_dostring); + /* &table[8] is terminator */ +-- +2.35.1 + diff --git a/queue-5.4/series b/queue-5.4/series index 353e5d10f4f..5d33b3f8972 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -18,3 +18,11 @@ gpio-mpc8xxx-fix-support-for-irq_type_level_low-flow.patch drm-meson-correct-osd1-global-alpha-value.patch drm-meson-fix-osd1-rgb-to-ycbcr-coefficient.patch parisc-ccio-dma-add-missing-iounmap-in-error-path-in.patch +efi-libstub-disable-shadow-call-stack.patch +efi-libstub-disable-struct-randomization.patch +sched-debug-output-sd-flag-names-rather-than-their-v.patch +sched-debug-fix-memory-corruption-caused-by-multiple.patch +alsa-pcm-oss-fix-race-at-sndctl_dsp_sync.patch +drm-i915-implement-waedplinkratedatareload.patch +task_stack-x86-cea-force-inline-stack-helpers.patch +tracing-hold-caller_addr-to-hardirq_-enable-disable-.patch diff --git a/queue-5.4/task_stack-x86-cea-force-inline-stack-helpers.patch b/queue-5.4/task_stack-x86-cea-force-inline-stack-helpers.patch new file mode 100644 index 00000000000..29346d9ca39 --- /dev/null +++ b/queue-5.4/task_stack-x86-cea-force-inline-stack-helpers.patch @@ -0,0 +1,53 @@ +From eab9806692fe4d9f332d0d3cff36111fa7cd699e Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 23 Mar 2022 20:02:41 +0100 +Subject: task_stack, x86/cea: Force-inline stack helpers + +From: Borislav Petkov + +[ Upstream commit e87f4152e542610d0b4c6c8548964a68a59d2040 ] + +Force-inline two stack helpers to fix the following objtool warnings: + + vmlinux.o: warning: objtool: in_task_stack()+0xc: call to task_stack_page() leaves .noinstr.text section + vmlinux.o: warning: objtool: in_entry_stack()+0x10: call to cpu_entry_stack() leaves .noinstr.text section + +Signed-off-by: Borislav Petkov +Acked-by: Peter Zijlstra (Intel) +Link: https://lore.kernel.org/r/20220324183607.31717-2-bp@alien8.de +Stable-dep-of: 54c3931957f6 ("tracing: hold caller_addr to hardirq_{enable,disable}_ip") +Signed-off-by: Sasha Levin +--- + arch/x86/include/asm/cpu_entry_area.h | 2 +- + include/linux/sched/task_stack.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/arch/x86/include/asm/cpu_entry_area.h b/arch/x86/include/asm/cpu_entry_area.h +index ea866c7bf31d..0d1d37d8b279 100644 +--- a/arch/x86/include/asm/cpu_entry_area.h ++++ b/arch/x86/include/asm/cpu_entry_area.h +@@ -133,7 +133,7 @@ extern void cea_set_pte(void *cea_vaddr, phys_addr_t pa, pgprot_t flags); + + extern struct cpu_entry_area *get_cpu_entry_area(int cpu); + +-static inline struct entry_stack *cpu_entry_stack(int cpu) ++static __always_inline struct entry_stack *cpu_entry_stack(int cpu) + { + return &get_cpu_entry_area(cpu)->entry_stack_page.stack; + } +diff --git a/include/linux/sched/task_stack.h b/include/linux/sched/task_stack.h +index d10150587d81..1009b6b5ce40 100644 +--- a/include/linux/sched/task_stack.h ++++ b/include/linux/sched/task_stack.h +@@ -16,7 +16,7 @@ + * try_get_task_stack() instead. task_stack_page will return a pointer + * that could get freed out from under you. + */ +-static inline void *task_stack_page(const struct task_struct *task) ++static __always_inline void *task_stack_page(const struct task_struct *task) + { + return task->stack; + } +-- +2.35.1 + diff --git a/queue-5.4/tracing-hold-caller_addr-to-hardirq_-enable-disable-.patch b/queue-5.4/tracing-hold-caller_addr-to-hardirq_-enable-disable-.patch new file mode 100644 index 00000000000..e68440c54e7 --- /dev/null +++ b/queue-5.4/tracing-hold-caller_addr-to-hardirq_-enable-disable-.patch @@ -0,0 +1,58 @@ +From 1e024ec5ba872a134c200b147a72db3ef7ef2413 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 1 Sep 2022 18:45:14 +0800 +Subject: tracing: hold caller_addr to hardirq_{enable,disable}_ip + +From: Yipeng Zou + +[ Upstream commit 54c3931957f6a6194d5972eccc36d052964b2abe ] + +Currently, The arguments passing to lockdep_hardirqs_{on,off} was fixed +in CALLER_ADDR0. +The function trace_hardirqs_on_caller should have been intended to use +caller_addr to represent the address that caller wants to be traced. + +For example, lockdep log in riscv showing the last {enabled,disabled} at +__trace_hardirqs_{on,off} all the time(if called by): +[ 57.853175] hardirqs last enabled at (2519): __trace_hardirqs_on+0xc/0x14 +[ 57.853848] hardirqs last disabled at (2520): __trace_hardirqs_off+0xc/0x14 + +After use trace_hardirqs_xx_caller, we can get more effective information: +[ 53.781428] hardirqs last enabled at (2595): restore_all+0xe/0x66 +[ 53.782185] hardirqs last disabled at (2596): ret_from_exception+0xa/0x10 + +Link: https://lkml.kernel.org/r/20220901104515.135162-2-zouyipeng@huawei.com + +Cc: stable@vger.kernel.org +Fixes: c3bc8fd637a96 ("tracing: Centralize preemptirq tracepoints and unify their usage") +Signed-off-by: Yipeng Zou +Signed-off-by: Steven Rostedt (Google) +Signed-off-by: Sasha Levin +--- + kernel/trace/trace_preemptirq.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/kernel/trace/trace_preemptirq.c b/kernel/trace/trace_preemptirq.c +index 26b06b09c9f6..e9645f829b94 100644 +--- a/kernel/trace/trace_preemptirq.c ++++ b/kernel/trace/trace_preemptirq.c +@@ -56,14 +56,14 @@ __visible void trace_hardirqs_on_caller(unsigned long caller_addr) + this_cpu_write(tracing_irq_cpu, 0); + } + +- lockdep_hardirqs_on(CALLER_ADDR0); ++ lockdep_hardirqs_on(caller_addr); + } + EXPORT_SYMBOL(trace_hardirqs_on_caller); + NOKPROBE_SYMBOL(trace_hardirqs_on_caller); + + __visible void trace_hardirqs_off_caller(unsigned long caller_addr) + { +- lockdep_hardirqs_off(CALLER_ADDR0); ++ lockdep_hardirqs_off(caller_addr); + + if (!this_cpu_read(tracing_irq_cpu)) { + this_cpu_write(tracing_irq_cpu, 1); +-- +2.35.1 + -- 2.47.3