From: Sasha Levin Date: Mon, 27 Mar 2023 01:40:36 +0000 (-0400) Subject: Fixes for 6.1 X-Git-Tag: v5.15.105~68 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=260ae2a908afa0e15445dd9db96351d1187de1c5;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 6.1 Signed-off-by: Sasha Levin --- diff --git a/queue-6.1/entry-fix-noinstr-warning-in-__enter_from_user_mode.patch b/queue-6.1/entry-fix-noinstr-warning-in-__enter_from_user_mode.patch new file mode 100644 index 00000000000..4a69e01c86e --- /dev/null +++ b/queue-6.1/entry-fix-noinstr-warning-in-__enter_from_user_mode.patch @@ -0,0 +1,79 @@ +From f72d900ddcc0f26d1471c2b8a759d0f292dbcdaa Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 25 Feb 2023 16:01:36 -0800 +Subject: entry: Fix noinstr warning in __enter_from_user_mode() + +From: Josh Poimboeuf + +[ Upstream commit f87d28673b71b35b248231a2086f9404afbb7f28 ] + +__enter_from_user_mode() is triggering noinstr warnings with +CONFIG_DEBUG_PREEMPT due to its call of preempt_count_add() via +ct_state(). + +The preemption disable isn't needed as interrupts are already disabled. +And the context_tracking_enabled() check in ct_state() also isn't needed +as that's already being done by the CT_WARN_ON(). + +Just use __ct_state() instead. + +Fixes the following warnings: + + vmlinux.o: warning: objtool: enter_from_user_mode+0xba: call to preempt_count_add() leaves .noinstr.text section + vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0xf9: call to preempt_count_add() leaves .noinstr.text section + vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0xc7: call to preempt_count_add() leaves .noinstr.text section + vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0xba: call to preempt_count_add() leaves .noinstr.text section + +Fixes: 171476775d32 ("context_tracking: Convert state to atomic_t") +Signed-off-by: Josh Poimboeuf +Signed-off-by: Thomas Gleixner +Link: https://lore.kernel.org/r/d8955fa6d68dc955dda19baf13ae014ae27926f5.1677369694.git.jpoimboe@kernel.org +Signed-off-by: Sasha Levin +--- + include/linux/context_tracking.h | 1 + + include/linux/context_tracking_state.h | 2 ++ + kernel/entry/common.c | 2 +- + 3 files changed, 4 insertions(+), 1 deletion(-) + +diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h +index d4afa8508a806..3a7909ed54980 100644 +--- a/include/linux/context_tracking.h ++++ b/include/linux/context_tracking.h +@@ -96,6 +96,7 @@ static inline void user_exit_irqoff(void) { } + static inline int exception_enter(void) { return 0; } + static inline void exception_exit(enum ctx_state prev_ctx) { } + static inline int ct_state(void) { return -1; } ++static inline int __ct_state(void) { return -1; } + static __always_inline bool context_tracking_guest_enter(void) { return false; } + static inline void context_tracking_guest_exit(void) { } + #define CT_WARN_ON(cond) do { } while (0) +diff --git a/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h +index 4a4d56f771802..fdd537ea513ff 100644 +--- a/include/linux/context_tracking_state.h ++++ b/include/linux/context_tracking_state.h +@@ -46,7 +46,9 @@ struct context_tracking { + + #ifdef CONFIG_CONTEXT_TRACKING + DECLARE_PER_CPU(struct context_tracking, context_tracking); ++#endif + ++#ifdef CONFIG_CONTEXT_TRACKING_USER + static __always_inline int __ct_state(void) + { + return arch_atomic_read(this_cpu_ptr(&context_tracking.state)) & CT_STATE_MASK; +diff --git a/kernel/entry/common.c b/kernel/entry/common.c +index 846add8394c41..1314894d2efad 100644 +--- a/kernel/entry/common.c ++++ b/kernel/entry/common.c +@@ -21,7 +21,7 @@ static __always_inline void __enter_from_user_mode(struct pt_regs *regs) + arch_enter_from_user_mode(regs); + lockdep_hardirqs_off(CALLER_ADDR0); + +- CT_WARN_ON(ct_state() != CONTEXT_USER); ++ CT_WARN_ON(__ct_state() != CONTEXT_USER); + user_exit_irqoff(); + + instrumentation_begin(); +-- +2.39.2 + diff --git a/queue-6.1/entry-rcu-check-tif_resched-_after_-delayed-rcu-wake.patch b/queue-6.1/entry-rcu-check-tif_resched-_after_-delayed-rcu-wake.patch new file mode 100644 index 00000000000..fe6d6db40e6 --- /dev/null +++ b/queue-6.1/entry-rcu-check-tif_resched-_after_-delayed-rcu-wake.patch @@ -0,0 +1,56 @@ +From e2ff2a83cdea5d1058a6678a3ceb7aaab369be96 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 15 Mar 2023 19:43:43 +0000 +Subject: entry/rcu: Check TIF_RESCHED _after_ delayed RCU wake-up + +From: Frederic Weisbecker + +[ Upstream commit b416514054810cf2d2cc348ae477cea619b64da7 ] + +RCU sometimes needs to perform a delayed wake up for specific kthreads +handling offloaded callbacks (RCU_NOCB). These wakeups are performed +by timers and upon entry to idle (also to guest and to user on nohz_full). + +However the delayed wake-up on kernel exit is actually performed after +the thread flags are fetched towards the fast path check for work to +do on exit to user. As a result, and if there is no other pending work +to do upon that kernel exit, the current task will resume to userspace +with TIF_RESCHED set and the pending wake up ignored. + +Fix this with fetching the thread flags _after_ the delayed RCU-nocb +kthread wake-up. + +Fixes: 47b8ff194c1f ("entry: Explicitly flush pending rcuog wakeup before last rescheduling point") +Signed-off-by: Frederic Weisbecker +Signed-off-by: Paul E. McKenney +Signed-off-by: Joel Fernandes (Google) +Signed-off-by: Thomas Gleixner +Link: https://lore.kernel.org/r/20230315194349.10798-3-joel@joelfernandes.org +Signed-off-by: Sasha Levin +--- + kernel/entry/common.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/kernel/entry/common.c b/kernel/entry/common.c +index 1314894d2efad..be61332c66b54 100644 +--- a/kernel/entry/common.c ++++ b/kernel/entry/common.c +@@ -192,13 +192,14 @@ static unsigned long exit_to_user_mode_loop(struct pt_regs *regs, + + static void exit_to_user_mode_prepare(struct pt_regs *regs) + { +- unsigned long ti_work = read_thread_flags(); ++ unsigned long ti_work; + + lockdep_assert_irqs_disabled(); + + /* Flush pending rcuog wakeup before the last need_resched() check */ + tick_nohz_user_enter_prepare(); + ++ ti_work = read_thread_flags(); + if (unlikely(ti_work & EXIT_TO_USER_MODE_WORK)) + ti_work = exit_to_user_mode_loop(regs, ti_work); + +-- +2.39.2 + diff --git a/queue-6.1/hwmon-fix-potential-sensor-registration-fail-if-of_n.patch b/queue-6.1/hwmon-fix-potential-sensor-registration-fail-if-of_n.patch new file mode 100644 index 00000000000..674ef6db844 --- /dev/null +++ b/queue-6.1/hwmon-fix-potential-sensor-registration-fail-if-of_n.patch @@ -0,0 +1,58 @@ +From 45bf3a3ae83bfbb313adecb70ca356766d844f32 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 21 Mar 2023 14:02:23 +0800 +Subject: hwmon: fix potential sensor registration fail if of_node is missing + +From: Phinex Hung + +[ Upstream commit 2315332efcbe7124252f080e03b57d3d2f1f4771 ] + +It is not sufficient to check of_node in current device. +In some cases, this would cause the sensor registration to fail. + +This patch looks for device's ancestors to find a valid of_node if any. + +Fixes: d560168b5d0f ("hwmon: (core) New hwmon registration API") +Signed-off-by: Phinex Hung +Link: https://lore.kernel.org/r/20230321060224.3819-1-phinex@realtek.com +Signed-off-by: Guenter Roeck +Signed-off-by: Sasha Levin +--- + drivers/hwmon/hwmon.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c +index 4218750d5a66b..9ed34b2e1f499 100644 +--- a/drivers/hwmon/hwmon.c ++++ b/drivers/hwmon/hwmon.c +@@ -756,6 +756,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, + struct hwmon_device *hwdev; + const char *label; + struct device *hdev; ++ struct device *tdev = dev; + int i, err, id; + + /* Complain about invalid characters in hwmon name attribute */ +@@ -825,7 +826,9 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, + hwdev->name = name; + hdev->class = &hwmon_class; + hdev->parent = dev; +- hdev->of_node = dev ? dev->of_node : NULL; ++ while (tdev && !tdev->of_node) ++ tdev = tdev->parent; ++ hdev->of_node = tdev ? tdev->of_node : NULL; + hwdev->chip = chip; + dev_set_drvdata(hdev, drvdata); + dev_set_name(hdev, HWMON_ID_FORMAT, id); +@@ -837,7 +840,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, + + INIT_LIST_HEAD(&hwdev->tzdata); + +- if (dev && dev->of_node && chip && chip->ops->read && ++ if (hdev->of_node && chip && chip->ops->read && + chip->info[0]->type == hwmon_chip && + (chip->info[0]->config[0] & HWMON_C_REGISTER_TZ)) { + err = hwmon_thermal_register_sensors(hdev); +-- +2.39.2 + diff --git a/queue-6.1/hwmon-it87-fix-voltage-scaling-for-chips-with-10.9mv.patch b/queue-6.1/hwmon-it87-fix-voltage-scaling-for-chips-with-10.9mv.patch new file mode 100644 index 00000000000..05ba60c68d6 --- /dev/null +++ b/queue-6.1/hwmon-it87-fix-voltage-scaling-for-chips-with-10.9mv.patch @@ -0,0 +1,47 @@ +From 1b510ef48dad66908700e5de638158586d57919f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 18 Mar 2023 19:05:42 +1100 +Subject: hwmon (it87): Fix voltage scaling for chips with 10.9mV ADCs + +From: Frank Crawford + +[ Upstream commit 968b66ffeb7956acc72836a7797aeb7b2444ec51 ] + +Fix voltage scaling for chips that have 10.9mV ADCs, where scaling was +not performed. + +Fixes: ead8080351c9 ("hwmon: (it87) Add support for IT8732F") +Signed-off-by: Frank Crawford +Link: https://lore.kernel.org/r/20230318080543.1226700-2-frank@crawford.emu.id.au +[groeck: Update subject and description to focus on bug fix] +Signed-off-by: Guenter Roeck +Signed-off-by: Sasha Levin +--- + drivers/hwmon/it87.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c +index 7bd154ba351b9..b45bd3aa5a653 100644 +--- a/drivers/hwmon/it87.c ++++ b/drivers/hwmon/it87.c +@@ -486,6 +486,8 @@ static const struct it87_devices it87_devices[] = { + #define has_pwm_freq2(data) ((data)->features & FEAT_PWM_FREQ2) + #define has_six_temp(data) ((data)->features & FEAT_SIX_TEMP) + #define has_vin3_5v(data) ((data)->features & FEAT_VIN3_5V) ++#define has_scaling(data) ((data)->features & (FEAT_12MV_ADC | \ ++ FEAT_10_9MV_ADC)) + + struct it87_sio_data { + int sioaddr; +@@ -3098,7 +3100,7 @@ static int it87_probe(struct platform_device *pdev) + "Detected broken BIOS defaults, disabling PWM interface\n"); + + /* Starting with IT8721F, we handle scaling of internal voltages */ +- if (has_12mv_adc(data)) { ++ if (has_scaling(data)) { + if (sio_data->internal & BIT(0)) + data->in_scaled |= BIT(3); /* in3 is AVCC */ + if (sio_data->internal & BIT(1)) +-- +2.39.2 + diff --git a/queue-6.1/perf-x86-amd-core-always-clear-status-for-idx.patch b/queue-6.1/perf-x86-amd-core-always-clear-status-for-idx.patch new file mode 100644 index 00000000000..601be0559c5 --- /dev/null +++ b/queue-6.1/perf-x86-amd-core-always-clear-status-for-idx.patch @@ -0,0 +1,57 @@ +From 849094aab00b592ae150dac8d12cf51bfba3dfb5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 21 Mar 2023 04:33:38 -0700 +Subject: perf/x86/amd/core: Always clear status for idx + +From: Breno Leitao + +[ Upstream commit 263f5ecaf7080513efc248ec739b6d9e00f4129f ] + +The variable 'status' (which contains the unhandled overflow bits) is +not being properly masked in some cases, displaying the following +warning: + + WARNING: CPU: 156 PID: 475601 at arch/x86/events/amd/core.c:972 amd_pmu_v2_handle_irq+0x216/0x270 + +This seems to be happening because the loop is being continued before +the status bit being unset, in case x86_perf_event_set_period() +returns 0. This is also causing an inconsistency because the "handled" +counter is incremented, but the status bit is not cleaned. + +Move the bit cleaning together above, together when the "handled" +counter is incremented. + +Fixes: 7685665c390d ("perf/x86/amd/core: Add PerfMonV2 overflow handling") +Signed-off-by: Breno Leitao +Signed-off-by: Peter Zijlstra (Intel) +Reviewed-by: Sandipan Das +Link: https://lore.kernel.org/r/20230321113338.1669660-1-leitao@debian.org +Signed-off-by: Sasha Levin +--- + arch/x86/events/amd/core.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c +index 4386b10682ce4..8ca5e827f30b2 100644 +--- a/arch/x86/events/amd/core.c ++++ b/arch/x86/events/amd/core.c +@@ -923,6 +923,7 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs) + + /* Event overflow */ + handled++; ++ status &= ~mask; + perf_sample_data_init(&data, 0, hwc->last_period); + + if (!x86_perf_event_set_period(event)) +@@ -935,8 +936,6 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs) + + if (perf_event_overflow(event, &data, regs)) + x86_pmu_stop(event, 0); +- +- status &= ~mask; + } + + /* +-- +2.39.2 + diff --git a/queue-6.1/series b/queue-6.1/series index 3ee5735f763..c815ce0e302 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -95,3 +95,8 @@ bluetooth-btsdio-fix-use-after-free-bug-in-btsdio_re.patch bluetooth-mgmt-fix-mgmt-add-advmon-with-rssi-command.patch bluetooth-hci-fix-global-out-of-bounds.patch platform-chrome-cros_ec_chardev-fix-kernel-data-leak.patch +entry-fix-noinstr-warning-in-__enter_from_user_mode.patch +perf-x86-amd-core-always-clear-status-for-idx.patch +entry-rcu-check-tif_resched-_after_-delayed-rcu-wake.patch +hwmon-fix-potential-sensor-registration-fail-if-of_n.patch +hwmon-it87-fix-voltage-scaling-for-chips-with-10.9mv.patch