From: Sasha Levin Date: Mon, 26 Jun 2023 13:00:39 +0000 (-0400) Subject: Fixes for 6.3 X-Git-Tag: v4.14.320~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b9187e5bf358795c0203c32b501b2eecb40fc2dd;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 6.3 Signed-off-by: Sasha Levin --- diff --git a/queue-6.3/i2c-imx-lpi2c-fix-type-char-overflow-issue-when-calc.patch b/queue-6.3/i2c-imx-lpi2c-fix-type-char-overflow-issue-when-calc.patch new file mode 100644 index 00000000000..33d2641a4fa --- /dev/null +++ b/queue-6.3/i2c-imx-lpi2c-fix-type-char-overflow-issue-when-calc.patch @@ -0,0 +1,41 @@ +From a47bb6be61e2835ba2f0a6a0fcb30aa92ff97e8c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 29 May 2023 16:02:51 +0800 +Subject: i2c: imx-lpi2c: fix type char overflow issue when calculating the + clock cycle + +From: Clark Wang + +[ Upstream commit e69b9bc170c6d93ee375a5cbfd15f74c0fb59bdd ] + +Claim clkhi and clklo as integer type to avoid possible calculation +errors caused by data overflow. + +Fixes: a55fa9d0e42e ("i2c: imx-lpi2c: add low power i2c bus driver") +Signed-off-by: Clark Wang +Signed-off-by: Carlos Song +Reviewed-by: Andi Shyti +Signed-off-by: Wolfram Sang +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-imx-lpi2c.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c +index a49b14d52a986..ff12018bc2060 100644 +--- a/drivers/i2c/busses/i2c-imx-lpi2c.c ++++ b/drivers/i2c/busses/i2c-imx-lpi2c.c +@@ -201,8 +201,8 @@ static void lpi2c_imx_stop(struct lpi2c_imx_struct *lpi2c_imx) + /* CLKLO = I2C_CLK_RATIO * CLKHI, SETHOLD = CLKHI, DATAVD = CLKHI/2 */ + static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx) + { +- u8 prescale, filt, sethold, clkhi, clklo, datavd; +- unsigned int clk_rate, clk_cycle; ++ u8 prescale, filt, sethold, datavd; ++ unsigned int clk_rate, clk_cycle, clkhi, clklo; + enum lpi2c_imx_pincfg pincfg; + unsigned int temp; + +-- +2.39.2 + diff --git a/queue-6.3/series b/queue-6.3/series index 04debac0b5f..c2c22bbf31f 100644 --- a/queue-6.3/series +++ b/queue-6.3/series @@ -189,3 +189,6 @@ drm-radeon-fix-race-condition-uaf-in-radeon_gem_set_.patch tools-virtio-fix-arm64-ringtest-compilation-error.patch vhost_vdpa-tell-vqs-about-the-negotiated.patch vhost_net-revert-upend_idx-only-on-retriable-error.patch +x86-unwind-orc-add-elf-section-with-orc-version-iden.patch +x86-apic-fix-kernel-panic-when-booting-with-intremap.patch +i2c-imx-lpi2c-fix-type-char-overflow-issue-when-calc.patch diff --git a/queue-6.3/x86-apic-fix-kernel-panic-when-booting-with-intremap.patch b/queue-6.3/x86-apic-fix-kernel-panic-when-booting-with-intremap.patch new file mode 100644 index 00000000000..d2b1795c30a --- /dev/null +++ b/queue-6.3/x86-apic-fix-kernel-panic-when-booting-with-intremap.patch @@ -0,0 +1,80 @@ +From 048badc394dc493c8b89b9e013676f49548a3959 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 17 Jun 2023 02:52:36 +0530 +Subject: x86/apic: Fix kernel panic when booting with intremap=off and + x2apic_phys + +From: Dheeraj Kumar Srivastava + +[ Upstream commit 85d38d5810e285d5aec7fb5283107d1da70c12a9 ] + +When booting with "intremap=off" and "x2apic_phys" on the kernel command +line, the physical x2APIC driver ends up being used even when x2APIC +mode is disabled ("intremap=off" disables x2APIC mode). This happens +because the first compound condition check in x2apic_phys_probe() is +false due to x2apic_mode == 0 and so the following one returns true +after default_acpi_madt_oem_check() having already selected the physical +x2APIC driver. + +This results in the following panic: + + kernel BUG at arch/x86/kernel/apic/io_apic.c:2409! + invalid opcode: 0000 [#1] PREEMPT SMP NOPTI + CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.4.0-rc2-ver4.1rc2 #2 + Hardware name: Dell Inc. PowerEdge R6515/07PXPY, BIOS 2.3.6 07/06/2021 + RIP: 0010:setup_IO_APIC+0x9c/0xaf0 + Call Trace: + + ? native_read_msr + apic_intr_mode_init + x86_late_time_init + start_kernel + x86_64_start_reservations + x86_64_start_kernel + secondary_startup_64_no_verify + + +which is: + +setup_IO_APIC: + apic_printk(APIC_VERBOSE, "ENABLING IO-APIC IRQs\n"); + for_each_ioapic(ioapic) + BUG_ON(mp_irqdomain_create(ioapic)); + +Return 0 to denote that x2APIC has not been enabled when probing the +physical x2APIC driver. + + [ bp: Massage commit message heavily. ] + +Fixes: 9ebd680bd029 ("x86, apic: Use probe routines to simplify apic selection") +Signed-off-by: Dheeraj Kumar Srivastava +Signed-off-by: Borislav Petkov (AMD) +Reviewed-by: Kishon Vijay Abraham I +Reviewed-by: Vasant Hegde +Reviewed-by: Cyrill Gorcunov +Reviewed-by: Thomas Gleixner +Link: https://lore.kernel.org/r/20230616212236.1389-1-dheerajkumar.srivastava@amd.com +Signed-off-by: Sasha Levin +--- + arch/x86/kernel/apic/x2apic_phys.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c +index 6bde05a86b4ed..896bc41cb2ba7 100644 +--- a/arch/x86/kernel/apic/x2apic_phys.c ++++ b/arch/x86/kernel/apic/x2apic_phys.c +@@ -97,7 +97,10 @@ static void init_x2apic_ldr(void) + + static int x2apic_phys_probe(void) + { +- if (x2apic_mode && (x2apic_phys || x2apic_fadt_phys())) ++ if (!x2apic_mode) ++ return 0; ++ ++ if (x2apic_phys || x2apic_fadt_phys()) + return 1; + + return apic == &apic_x2apic_phys; +-- +2.39.2 + diff --git a/queue-6.3/x86-unwind-orc-add-elf-section-with-orc-version-iden.patch b/queue-6.3/x86-unwind-orc-add-elf-section-with-orc-version-iden.patch new file mode 100644 index 00000000000..b6a38e5b477 --- /dev/null +++ b/queue-6.3/x86-unwind-orc-add-elf-section-with-orc-version-iden.patch @@ -0,0 +1,181 @@ +From 915cfe9e448cf7318210f873672cfe07b704ab1f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 13 Jun 2023 14:14:56 -0700 +Subject: x86/unwind/orc: Add ELF section with ORC version identifier + +From: Omar Sandoval + +[ Upstream commit b9f174c811e3ae4ae8959dc57e6adb9990e913f4 ] + +Commits ffb1b4a41016 ("x86/unwind/orc: Add 'signal' field to ORC +metadata") and fb799447ae29 ("x86,objtool: Split UNWIND_HINT_EMPTY in +two") changed the ORC format. Although ORC is internal to the kernel, +it's the only way for external tools to get reliable kernel stack traces +on x86-64. In particular, the drgn debugger [1] uses ORC for stack +unwinding, and these format changes broke it [2]. As the drgn +maintainer, I don't care how often or how much the kernel changes the +ORC format as long as I have a way to detect the change. + +It suffices to store a version identifier in the vmlinux and kernel +module ELF files (to use when parsing ORC sections from ELF), and in +kernel memory (to use when parsing ORC from a core dump+symbol table). +Rather than hard-coding a version number that needs to be manually +bumped, Peterz suggested hashing the definitions from orc_types.h. If +there is a format change that isn't caught by this, the hashing script +can be updated. + +This patch adds an .orc_header allocated ELF section containing the +20-byte hash to vmlinux and kernel modules, along with the corresponding +__start_orc_header and __stop_orc_header symbols in vmlinux. + +1: https://github.com/osandov/drgn +2: https://github.com/osandov/drgn/issues/303 + +Fixes: ffb1b4a41016 ("x86/unwind/orc: Add 'signal' field to ORC metadata") +Fixes: fb799447ae29 ("x86,objtool: Split UNWIND_HINT_EMPTY in two") +Signed-off-by: Omar Sandoval +Signed-off-by: Peter Zijlstra (Intel) +Acked-by: Josh Poimboeuf +Link: https://lkml.kernel.org/r/aef9c8dc43915b886a8c48509a12ec1b006ca1ca.1686690801.git.osandov@osandov.com +Signed-off-by: Sasha Levin +--- + arch/x86/Makefile | 12 ++++++++++++ + arch/x86/include/asm/Kbuild | 1 + + arch/x86/include/asm/orc_header.h | 19 +++++++++++++++++++ + arch/x86/kernel/unwind_orc.c | 3 +++ + include/asm-generic/vmlinux.lds.h | 3 +++ + scripts/mod/modpost.c | 5 +++++ + scripts/orc_hash.sh | 16 ++++++++++++++++ + 7 files changed, 59 insertions(+) + create mode 100644 arch/x86/include/asm/orc_header.h + create mode 100644 scripts/orc_hash.sh + +diff --git a/arch/x86/Makefile b/arch/x86/Makefile +index b39975977c037..fdc2e3abd6152 100644 +--- a/arch/x86/Makefile ++++ b/arch/x86/Makefile +@@ -305,6 +305,18 @@ ifeq ($(RETPOLINE_CFLAGS),) + endif + endif + ++ifdef CONFIG_UNWINDER_ORC ++orc_hash_h := arch/$(SRCARCH)/include/generated/asm/orc_hash.h ++orc_hash_sh := $(srctree)/scripts/orc_hash.sh ++targets += $(orc_hash_h) ++quiet_cmd_orc_hash = GEN $@ ++ cmd_orc_hash = mkdir -p $(dir $@); \ ++ $(CONFIG_SHELL) $(orc_hash_sh) < $< > $@ ++$(orc_hash_h): $(srctree)/arch/x86/include/asm/orc_types.h $(orc_hash_sh) FORCE ++ $(call if_changed,orc_hash) ++archprepare: $(orc_hash_h) ++endif ++ + archclean: + $(Q)rm -rf $(objtree)/arch/i386 + $(Q)rm -rf $(objtree)/arch/x86_64 +diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild +index 1e51650b79d7c..4f1ce5fc4e194 100644 +--- a/arch/x86/include/asm/Kbuild ++++ b/arch/x86/include/asm/Kbuild +@@ -1,6 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + + ++generated-y += orc_hash.h + generated-y += syscalls_32.h + generated-y += syscalls_64.h + generated-y += syscalls_x32.h +diff --git a/arch/x86/include/asm/orc_header.h b/arch/x86/include/asm/orc_header.h +new file mode 100644 +index 0000000000000..07bacf3e160ea +--- /dev/null ++++ b/arch/x86/include/asm/orc_header.h +@@ -0,0 +1,19 @@ ++/* SPDX-License-Identifier: GPL-2.0-or-later */ ++/* Copyright (c) Meta Platforms, Inc. and affiliates. */ ++ ++#ifndef _ORC_HEADER_H ++#define _ORC_HEADER_H ++ ++#include ++#include ++#include ++ ++/* ++ * The header is currently a 20-byte hash of the ORC entry definition; see ++ * scripts/orc_hash.sh. ++ */ ++#define ORC_HEADER \ ++ __used __section(".orc_header") __aligned(4) \ ++ static const u8 orc_header[] = { ORC_HASH } ++ ++#endif /* _ORC_HEADER_H */ +diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c +index 37307b40f8daf..c960f250624ab 100644 +--- a/arch/x86/kernel/unwind_orc.c ++++ b/arch/x86/kernel/unwind_orc.c +@@ -7,6 +7,9 @@ + #include + #include + #include ++#include ++ ++ORC_HEADER; + + #define orc_warn(fmt, ...) \ + printk_deferred_once(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__) +diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h +index d1f57e4868ed3..7058b01e9f146 100644 +--- a/include/asm-generic/vmlinux.lds.h ++++ b/include/asm-generic/vmlinux.lds.h +@@ -839,6 +839,9 @@ + + #ifdef CONFIG_UNWINDER_ORC + #define ORC_UNWIND_TABLE \ ++ .orc_header : AT(ADDR(.orc_header) - LOAD_OFFSET) { \ ++ BOUNDED_SECTION_BY(.orc_header, _orc_header) \ ++ } \ + . = ALIGN(4); \ + .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) { \ + BOUNDED_SECTION_BY(.orc_unwind_ip, _orc_unwind_ip) \ +diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c +index 9466b6a2abae4..5b3964b39709f 100644 +--- a/scripts/mod/modpost.c ++++ b/scripts/mod/modpost.c +@@ -1985,6 +1985,11 @@ static void add_header(struct buffer *b, struct module *mod) + buf_printf(b, "#include \n"); + buf_printf(b, "#include \n"); + buf_printf(b, "\n"); ++ buf_printf(b, "#ifdef CONFIG_UNWINDER_ORC\n"); ++ buf_printf(b, "#include \n"); ++ buf_printf(b, "ORC_HEADER;\n"); ++ buf_printf(b, "#endif\n"); ++ buf_printf(b, "\n"); + buf_printf(b, "BUILD_SALT;\n"); + buf_printf(b, "BUILD_LTO_INFO;\n"); + buf_printf(b, "\n"); +diff --git a/scripts/orc_hash.sh b/scripts/orc_hash.sh +new file mode 100644 +index 0000000000000..466611aa0053f +--- /dev/null ++++ b/scripts/orc_hash.sh +@@ -0,0 +1,16 @@ ++#!/bin/sh ++# SPDX-License-Identifier: GPL-2.0-or-later ++# Copyright (c) Meta Platforms, Inc. and affiliates. ++ ++set -e ++ ++printf '%s' '#define ORC_HASH ' ++ ++awk ' ++/^#define ORC_(REG|TYPE)_/ { print } ++/^struct orc_entry {$/ { p=1 } ++p { print } ++/^}/ { p=0 }' | ++ sha1sum | ++ cut -d " " -f 1 | ++ sed 's/\([0-9a-f]\{2\}\)/0x\1,/g' +-- +2.39.2 +