From: Greg Kroah-Hartman Date: Tue, 7 Feb 2023 11:45:08 +0000 (+0100) Subject: 6.1-stable patches X-Git-Tag: v5.15.93~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5cce4e467794bcbeee236227e622e5d5b1caf993;p=thirdparty%2Fkernel%2Fstable-queue.git 6.1-stable patches added patches: iio-adc-twl6030-enable-measurement-of-vac.patch powerpc-64s-fix-local-irq-disable-when-pmis-are-disabled.patch powerpc-64s-radix-fix-crash-with-unaligned-relocated-kernel.patch powerpc-imc-pmu-revert-nest_init_lock-to-being-a-mutex.patch --- diff --git a/queue-6.1/iio-adc-twl6030-enable-measurement-of-vac.patch b/queue-6.1/iio-adc-twl6030-enable-measurement-of-vac.patch new file mode 100644 index 00000000000..154918ef00d --- /dev/null +++ b/queue-6.1/iio-adc-twl6030-enable-measurement-of-vac.patch @@ -0,0 +1,34 @@ +From bffb7d9d1a3dbd09e083b88aefd093b3b10abbfb Mon Sep 17 00:00:00 2001 +From: Andreas Kemnade +Date: Sat, 17 Dec 2022 23:13:05 +0100 +Subject: iio:adc:twl6030: Enable measurement of VAC + +From: Andreas Kemnade + +commit bffb7d9d1a3dbd09e083b88aefd093b3b10abbfb upstream. + +VAC needs to be wired up to produce proper measurements, +without this change only near zero values are reported. + +Reported-by: kernel test robot +Reported-by: Julia Lawall +Fixes: 1696f36482e7 ("iio: twl6030-gpadc: TWL6030, TWL6032 GPADC driver") +Signed-off-by: Andreas Kemnade +Link: https://lore.kernel.org/r/20221217221305.671117-1-andreas@kemnade.info +Signed-off-by: Jonathan Cameron +Signed-off-by: Greg Kroah-Hartman +--- + drivers/iio/adc/twl6030-gpadc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/iio/adc/twl6030-gpadc.c ++++ b/drivers/iio/adc/twl6030-gpadc.c +@@ -952,7 +952,7 @@ static int twl6030_gpadc_probe(struct pl + } + + ret = twl_i2c_write_u8(TWL6030_MODULE_ID0, +- VBAT_MEAS | BB_MEAS | BB_MEAS, ++ VBAT_MEAS | BB_MEAS | VAC_MEAS, + TWL6030_MISC1); + if (ret < 0) { + dev_err(dev, "failed to wire up inputs\n"); diff --git a/queue-6.1/powerpc-64s-fix-local-irq-disable-when-pmis-are-disabled.patch b/queue-6.1/powerpc-64s-fix-local-irq-disable-when-pmis-are-disabled.patch new file mode 100644 index 00000000000..f4e0c0492ac --- /dev/null +++ b/queue-6.1/powerpc-64s-fix-local-irq-disable-when-pmis-are-disabled.patch @@ -0,0 +1,50 @@ +From bc88ef663265676419555df2dc469a471c0add31 Mon Sep 17 00:00:00 2001 +From: Nicholas Piggin +Date: Sat, 21 Jan 2023 19:53:52 +1000 +Subject: powerpc/64s: Fix local irq disable when PMIs are disabled + +From: Nicholas Piggin + +commit bc88ef663265676419555df2dc469a471c0add31 upstream. + +When PMI interrupts are soft-masked, local_irq_save() will clear the PMI +mask bit, allowing PMIs in and causing a race condition. This causes a +deadlock in native_hpte_insert via hash_preload, which depends on PMIs +being disabled since commit 8b91cee5eadd ("powerpc/64s/hash: Make hash +faults work in NMI context"). native_hpte_insert calls local_irq_save(). +It's possible the lpar hash code is also affected when tracing is +enabled because __trace_hcall_entry() calls local_irq_save(). + +Fix this by making arch_local_irq_save() _or_ the IRQS_DISABLED bit into +the mask. + +This was found with the stress_hpt option with a kbuild workload running +together with `perf record -g`. + +Fixes: f442d004806e ("powerpc/64s: Add support to mask perf interrupts and replay them") +Fixes: 8b91cee5eadd ("powerpc/64s/hash: Make hash faults work in NMI context") +Signed-off-by: Nicholas Piggin +[mpe: Just take the fix without the new warning] +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/20230121095352.2823517-1-npiggin@gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + arch/powerpc/include/asm/hw_irq.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h +index 77fa88c2aed0..0b7d01d408ac 100644 +--- a/arch/powerpc/include/asm/hw_irq.h ++++ b/arch/powerpc/include/asm/hw_irq.h +@@ -192,7 +192,7 @@ static inline void arch_local_irq_enable(void) + + static inline unsigned long arch_local_irq_save(void) + { +- return irq_soft_mask_set_return(IRQS_DISABLED); ++ return irq_soft_mask_or_return(IRQS_DISABLED); + } + + static inline bool arch_irqs_disabled_flags(unsigned long flags) +-- +2.39.1 + diff --git a/queue-6.1/powerpc-64s-radix-fix-crash-with-unaligned-relocated-kernel.patch b/queue-6.1/powerpc-64s-radix-fix-crash-with-unaligned-relocated-kernel.patch new file mode 100644 index 00000000000..5b40b1a13e4 --- /dev/null +++ b/queue-6.1/powerpc-64s-radix-fix-crash-with-unaligned-relocated-kernel.patch @@ -0,0 +1,106 @@ +From 98d0219e043e09013e883eacde3b93e0b2bf944d Mon Sep 17 00:00:00 2001 +From: Michael Ellerman +Date: Tue, 10 Jan 2023 23:47:52 +1100 +Subject: powerpc/64s/radix: Fix crash with unaligned relocated kernel + +From: Michael Ellerman + +commit 98d0219e043e09013e883eacde3b93e0b2bf944d upstream. + +If a relocatable kernel is loaded at an address that is not 2MB aligned +and told not to relocate to zero, the kernel can crash due to +mark_rodata_ro() incorrectly changing some read-write data to read-only. + +Scenarios where the misalignment can occur are when the kernel is +loaded by kdump or using the RELOCATABLE_TEST config option. + +Example crash with the kernel loaded at 5MB: + + Run /sbin/init as init process + BUG: Unable to handle kernel data access on write at 0xc000000000452000 + Faulting instruction address: 0xc0000000005b6730 + Oops: Kernel access of bad area, sig: 11 [#1] + LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries + CPU: 1 PID: 1 Comm: init Not tainted 6.2.0-rc1-00011-g349188be4841 #166 + Hardware name: IBM pSeries (emulated by qemu) POWER9 (raw) 0x4e1202 0xf000005 of:SLOF,git-5b4c5a hv:linux,kvm pSeries + NIP: c0000000005b6730 LR: c000000000ae9ab8 CTR: 0000000000000380 + REGS: c000000004503250 TRAP: 0300 Not tainted (6.2.0-rc1-00011-g349188be4841) + MSR: 8000000000009033 CR: 44288480 XER: 00000000 + CFAR: c0000000005b66ec DAR: c000000000452000 DSISR: 0a000000 IRQMASK: 0 + ... + NIP memset+0x68/0x104 + LR zero_user_segments.constprop.0+0xa8/0xf0 + Call Trace: + ext4_mpage_readpages+0x7f8/0x830 + ext4_readahead+0x48/0x60 + read_pages+0xb8/0x380 + page_cache_ra_unbounded+0x19c/0x250 + filemap_fault+0x58c/0xae0 + __do_fault+0x60/0x100 + __handle_mm_fault+0x1230/0x1a40 + handle_mm_fault+0x120/0x300 + ___do_page_fault+0x20c/0xa80 + do_page_fault+0x30/0xc0 + data_access_common_virt+0x210/0x220 + +This happens because mark_rodata_ro() tries to change permissions on the +range _stext..__end_rodata, but _stext sits in the middle of the 2MB +page from 4MB to 6MB: + + radix-mmu: Mapped 0x0000000000000000-0x0000000000200000 with 2.00 MiB pages (exec) + radix-mmu: Mapped 0x0000000000200000-0x0000000000400000 with 2.00 MiB pages + radix-mmu: Mapped 0x0000000000400000-0x0000000002400000 with 2.00 MiB pages (exec) + +The logic that changes the permissions assumes the linear mapping was +split correctly at boot, so it marks the entire 2MB page read-only. That +leads to the write fault above. + +To fix it, the boot time mapping logic needs to consider that if the +kernel is running at a non-zero address then _stext is a boundary where +it must split the mapping. + +That leads to the mapping being split correctly, allowing the rodata +permission change to take happen correctly, with no spillover: + + radix-mmu: Mapped 0x0000000000000000-0x0000000000200000 with 2.00 MiB pages (exec) + radix-mmu: Mapped 0x0000000000200000-0x0000000000400000 with 2.00 MiB pages + radix-mmu: Mapped 0x0000000000400000-0x0000000000500000 with 64.0 KiB pages + radix-mmu: Mapped 0x0000000000500000-0x0000000000600000 with 64.0 KiB pages (exec) + radix-mmu: Mapped 0x0000000000600000-0x0000000002400000 with 2.00 MiB pages (exec) + +If the kernel is loaded at a 2MB aligned address, the mapping continues +to use 2MB pages as before: + + radix-mmu: Mapped 0x0000000000000000-0x0000000000200000 with 2.00 MiB pages (exec) + radix-mmu: Mapped 0x0000000000200000-0x0000000000400000 with 2.00 MiB pages + radix-mmu: Mapped 0x0000000000400000-0x0000000002c00000 with 2.00 MiB pages (exec) + radix-mmu: Mapped 0x0000000002c00000-0x0000000100000000 with 2.00 MiB pages + +Fixes: c55d7b5e6426 ("powerpc: Remove STRICT_KERNEL_RWX incompatibility with RELOCATABLE") +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/20230110124753.1325426-1-mpe@ellerman.id.au +Signed-off-by: Greg Kroah-Hartman +--- + arch/powerpc/mm/book3s64/radix_pgtable.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +--- a/arch/powerpc/mm/book3s64/radix_pgtable.c ++++ b/arch/powerpc/mm/book3s64/radix_pgtable.c +@@ -262,6 +262,17 @@ print_mapping(unsigned long start, unsig + static unsigned long next_boundary(unsigned long addr, unsigned long end) + { + #ifdef CONFIG_STRICT_KERNEL_RWX ++ unsigned long stext_phys; ++ ++ stext_phys = __pa_symbol(_stext); ++ ++ // Relocatable kernel running at non-zero real address ++ if (stext_phys != 0) { ++ // Start of relocated kernel text is a rodata boundary ++ if (addr < stext_phys) ++ return stext_phys; ++ } ++ + if (addr < __pa_symbol(__srwx_boundary)) + return __pa_symbol(__srwx_boundary); + #endif diff --git a/queue-6.1/powerpc-imc-pmu-revert-nest_init_lock-to-being-a-mutex.patch b/queue-6.1/powerpc-imc-pmu-revert-nest_init_lock-to-being-a-mutex.patch new file mode 100644 index 00000000000..7c5bbd8c7bd --- /dev/null +++ b/queue-6.1/powerpc-imc-pmu-revert-nest_init_lock-to-being-a-mutex.patch @@ -0,0 +1,121 @@ +From ad53db4acb415976761d7302f5b02e97f2bd097e Mon Sep 17 00:00:00 2001 +From: Michael Ellerman +Date: Mon, 30 Jan 2023 12:44:01 +1100 +Subject: powerpc/imc-pmu: Revert nest_init_lock to being a mutex + +From: Michael Ellerman + +commit ad53db4acb415976761d7302f5b02e97f2bd097e upstream. + +The recent commit 76d588dddc45 ("powerpc/imc-pmu: Fix use of mutex in +IRQs disabled section") fixed warnings (and possible deadlocks) in the +IMC PMU driver by converting the locking to use spinlocks. + +It also converted the init-time nest_init_lock to a spinlock, even +though it's not used at runtime in IRQ disabled sections or while +holding other spinlocks. + +This leads to warnings such as: + + BUG: sleeping function called from invalid context at include/linux/percpu-rwsem.h:49 + in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper/0 + preempt_count: 1, expected: 0 + CPU: 7 PID: 1 Comm: swapper/0 Not tainted 6.2.0-rc2-14719-gf12cd06109f4-dirty #1 + Hardware name: Mambo,Simulated-System POWER9 0x4e1203 opal:v6.6.6 PowerNV + Call Trace: + dump_stack_lvl+0x74/0xa8 (unreliable) + __might_resched+0x178/0x1a0 + __cpuhp_setup_state+0x64/0x1e0 + init_imc_pmu+0xe48/0x1250 + opal_imc_counters_probe+0x30c/0x6a0 + platform_probe+0x78/0x110 + really_probe+0x104/0x420 + __driver_probe_device+0xb0/0x170 + driver_probe_device+0x58/0x180 + __driver_attach+0xd8/0x250 + bus_for_each_dev+0xb4/0x140 + driver_attach+0x34/0x50 + bus_add_driver+0x1e8/0x2d0 + driver_register+0xb4/0x1c0 + __platform_driver_register+0x38/0x50 + opal_imc_driver_init+0x2c/0x40 + do_one_initcall+0x80/0x360 + kernel_init_freeable+0x310/0x3b8 + kernel_init+0x30/0x1a0 + ret_from_kernel_thread+0x5c/0x64 + +Fix it by converting nest_init_lock back to a mutex, so that we can call +sleeping functions while holding it. There is no interaction between +nest_init_lock and the runtime spinlocks used by the actual PMU routines. + +Fixes: 76d588dddc45 ("powerpc/imc-pmu: Fix use of mutex in IRQs disabled section") +Tested-by: Kajol Jain +Reviewed-by: Kajol Jain +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/20230130014401.540543-1-mpe@ellerman.id.au +Signed-off-by: Greg Kroah-Hartman +--- + arch/powerpc/perf/imc-pmu.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +--- a/arch/powerpc/perf/imc-pmu.c ++++ b/arch/powerpc/perf/imc-pmu.c +@@ -22,7 +22,7 @@ + * Used to avoid races in counting the nest-pmu units during hotplug + * register and unregister + */ +-static DEFINE_SPINLOCK(nest_init_lock); ++static DEFINE_MUTEX(nest_init_lock); + static DEFINE_PER_CPU(struct imc_pmu_ref *, local_nest_imc_refc); + static struct imc_pmu **per_nest_pmu_arr; + static cpumask_t nest_imc_cpumask; +@@ -1629,7 +1629,7 @@ static void imc_common_mem_free(struct i + static void imc_common_cpuhp_mem_free(struct imc_pmu *pmu_ptr) + { + if (pmu_ptr->domain == IMC_DOMAIN_NEST) { +- spin_lock(&nest_init_lock); ++ mutex_lock(&nest_init_lock); + if (nest_pmus == 1) { + cpuhp_remove_state(CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE); + kfree(nest_imc_refc); +@@ -1639,7 +1639,7 @@ static void imc_common_cpuhp_mem_free(st + + if (nest_pmus > 0) + nest_pmus--; +- spin_unlock(&nest_init_lock); ++ mutex_unlock(&nest_init_lock); + } + + /* Free core_imc memory */ +@@ -1796,11 +1796,11 @@ int init_imc_pmu(struct device_node *par + * rest. To handle the cpuhotplug callback unregister, we track + * the number of nest pmus in "nest_pmus". + */ +- spin_lock(&nest_init_lock); ++ mutex_lock(&nest_init_lock); + if (nest_pmus == 0) { + ret = init_nest_pmu_ref(); + if (ret) { +- spin_unlock(&nest_init_lock); ++ mutex_unlock(&nest_init_lock); + kfree(per_nest_pmu_arr); + per_nest_pmu_arr = NULL; + goto err_free_mem; +@@ -1808,7 +1808,7 @@ int init_imc_pmu(struct device_node *par + /* Register for cpu hotplug notification. */ + ret = nest_pmu_cpumask_init(); + if (ret) { +- spin_unlock(&nest_init_lock); ++ mutex_unlock(&nest_init_lock); + kfree(nest_imc_refc); + kfree(per_nest_pmu_arr); + per_nest_pmu_arr = NULL; +@@ -1816,7 +1816,7 @@ int init_imc_pmu(struct device_node *par + } + } + nest_pmus++; +- spin_unlock(&nest_init_lock); ++ mutex_unlock(&nest_init_lock); + break; + case IMC_DOMAIN_CORE: + ret = core_imc_pmu_cpumask_init(); diff --git a/queue-6.1/series b/queue-6.1/series index ba929e1d1e2..6ccf14ed7f3 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -193,3 +193,7 @@ serial-8250_dma-fix-dma-rx-completion-race.patch serial-8250_dma-fix-dma-rx-rearm-race.patch platform-x86-amd-pmc-add-config_serio-dependency.patch asoc-sof-sof-audio-prepare_widgets-check-swidget-for-null-on-sink-failure.patch +iio-adc-twl6030-enable-measurement-of-vac.patch +powerpc-64s-radix-fix-crash-with-unaligned-relocated-kernel.patch +powerpc-64s-fix-local-irq-disable-when-pmis-are-disabled.patch +powerpc-imc-pmu-revert-nest_init_lock-to-being-a-mutex.patch