From: Greg Kroah-Hartman Date: Fri, 3 Feb 2023 08:18:25 +0000 (+0100) Subject: 5.15-stable patches X-Git-Tag: v4.14.305~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e553efaae0cfa06f69f129a72870a8873266ea41;p=thirdparty%2Fkernel%2Fstable-queue.git 5.15-stable patches added patches: acpi-processor-idle-practically-limit-dummy-wait-workaround-to-old-intel-systems.patch bluetooth-fix-null-ptr-deref-on-hci_sync_conn_complete_evt.patch selftests-provide-local-define-of-__cpuid_count.patch selftests-vm-remove-array_size-define-from-individual-tests.patch tools-fix-array_size-defines-in-tools-and-selftests-hdrs.patch --- diff --git a/queue-5.15/acpi-processor-idle-practically-limit-dummy-wait-workaround-to-old-intel-systems.patch b/queue-5.15/acpi-processor-idle-practically-limit-dummy-wait-workaround-to-old-intel-systems.patch new file mode 100644 index 00000000000..3530288b3f3 --- /dev/null +++ b/queue-5.15/acpi-processor-idle-practically-limit-dummy-wait-workaround-to-old-intel-systems.patch @@ -0,0 +1,77 @@ +From e400ad8b7e6a1b9102123c6240289a811501f7d9 Mon Sep 17 00:00:00 2001 +From: Dave Hansen +Date: Thu, 22 Sep 2022 11:47:45 -0700 +Subject: ACPI: processor idle: Practically limit "Dummy wait" workaround to old Intel systems + +From: Dave Hansen + +commit e400ad8b7e6a1b9102123c6240289a811501f7d9 upstream. + +Old, circa 2002 chipsets have a bug: they don't go idle when they are +supposed to. So, a workaround was added to slow the CPU down and +ensure that the CPU waits a bit for the chipset to actually go idle. +This workaround is ancient and has been in place in some form since +the original kernel ACPI implementation. + +But, this workaround is very painful on modern systems. The "inl()" +can take thousands of cycles (see Link: for some more detailed +numbers and some fun kernel archaeology). + +First and foremost, modern systems should not be using this code. +Typical Intel systems have not used it in over a decade because it is +horribly inferior to MWAIT-based idle. + +Despite this, people do seem to be tripping over this workaround on +AMD system today. + +Limit the "dummy wait" workaround to Intel systems. Keep Modern AMD +systems from tripping over the workaround. Remotely modern Intel +systems use intel_idle instead of this code and will, in practice, +remain unaffected by the dummy wait. + +Reported-by: K Prateek Nayak +Suggested-by: Rafael J. Wysocki +Signed-off-by: Dave Hansen +Reviewed-by: Mario Limonciello +Tested-by: K Prateek Nayak +Link: https://lore.kernel.org/all/20220921063638.2489-1-kprateek.nayak@amd.com/ +Link: https://lkml.kernel.org/r/20220922184745.3252932-1-dave.hansen@intel.com +Signed-off-by: Guilherme G. Piccoli +Signed-off-by: Greg Kroah-Hartman +--- + drivers/acpi/processor_idle.c | 23 ++++++++++++++++++++--- + 1 file changed, 20 insertions(+), 3 deletions(-) + +--- a/drivers/acpi/processor_idle.c ++++ b/drivers/acpi/processor_idle.c +@@ -531,10 +531,27 @@ static void wait_for_freeze(void) + /* No delay is needed if we are in guest */ + if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) + return; ++ /* ++ * Modern (>=Nehalem) Intel systems use ACPI via intel_idle, ++ * not this code. Assume that any Intel systems using this ++ * are ancient and may need the dummy wait. This also assumes ++ * that the motivating chipset issue was Intel-only. ++ */ ++ if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) ++ return; + #endif +- /* Dummy wait op - must do something useless after P_LVL2 read +- because chipsets cannot guarantee that STPCLK# signal +- gets asserted in time to freeze execution properly. */ ++ /* ++ * Dummy wait op - must do something useless after P_LVL2 read ++ * because chipsets cannot guarantee that STPCLK# signal gets ++ * asserted in time to freeze execution properly ++ * ++ * This workaround has been in place since the original ACPI ++ * implementation was merged, circa 2002. ++ * ++ * If a profile is pointing to this instruction, please first ++ * consider moving your system to a more modern idle ++ * mechanism. ++ */ + inl(acpi_gbl_FADT.xpm_timer_block.address); + } + diff --git a/queue-5.15/bluetooth-fix-null-ptr-deref-on-hci_sync_conn_complete_evt.patch b/queue-5.15/bluetooth-fix-null-ptr-deref-on-hci_sync_conn_complete_evt.patch new file mode 100644 index 00000000000..74499fa73dc --- /dev/null +++ b/queue-5.15/bluetooth-fix-null-ptr-deref-on-hci_sync_conn_complete_evt.patch @@ -0,0 +1,45 @@ +From 3afee2118132e93e5f6fa636dfde86201a860ab3 Mon Sep 17 00:00:00 2001 +From: Soenke Huster +Date: Fri, 14 Jan 2022 17:44:02 +0100 +Subject: Bluetooth: fix null ptr deref on hci_sync_conn_complete_evt + +From: Soenke Huster + +commit 3afee2118132e93e5f6fa636dfde86201a860ab3 upstream. + +This event is just specified for SCO and eSCO link types. +On the reception of a HCI_Synchronous_Connection_Complete for a BDADDR +of an existing LE connection, LE link type and a status that triggers the +second case of the packet processing a NULL pointer dereference happens, +as conn->link is NULL. + +Signed-off-by: Soenke Huster +Signed-off-by: Luiz Augusto von Dentz +Signed-off-by: Ovidiu Panait +Signed-off-by: Greg Kroah-Hartman +--- + net/bluetooth/hci_event.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +--- a/net/bluetooth/hci_event.c ++++ b/net/bluetooth/hci_event.c +@@ -4415,6 +4415,19 @@ static void hci_sync_conn_complete_evt(s + struct hci_ev_sync_conn_complete *ev = (void *) skb->data; + struct hci_conn *conn; + ++ switch (ev->link_type) { ++ case SCO_LINK: ++ case ESCO_LINK: ++ break; ++ default: ++ /* As per Core 5.3 Vol 4 Part E 7.7.35 (p.2219), Link_Type ++ * for HCI_Synchronous_Connection_Complete is limited to ++ * either SCO or eSCO ++ */ ++ bt_dev_err(hdev, "Ignoring connect complete event for invalid link type"); ++ return; ++ } ++ + BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); + + hci_dev_lock(hdev); diff --git a/queue-5.15/selftests-provide-local-define-of-__cpuid_count.patch b/queue-5.15/selftests-provide-local-define-of-__cpuid_count.patch new file mode 100644 index 00000000000..b3ef609c765 --- /dev/null +++ b/queue-5.15/selftests-provide-local-define-of-__cpuid_count.patch @@ -0,0 +1,60 @@ +From a23039c7306f53416ba35d230201398ea34f4640 Mon Sep 17 00:00:00 2001 +From: Reinette Chatre +Date: Mon, 25 Apr 2022 14:01:11 -0700 +Subject: selftests: Provide local define of __cpuid_count() + +From: Reinette Chatre + +commit a23039c7306f53416ba35d230201398ea34f4640 upstream. + +Some selftests depend on information provided by the CPUID instruction. +To support this dependency the selftests implement private wrappers for +CPUID. + +Duplication of the CPUID wrappers should be avoided. + +Both gcc and clang/LLVM provide __cpuid_count() macros but neither +the macro nor its header file are available in all the compiler +versions that need to be supported by the selftests. __cpuid_count() +as provided by gcc is available starting with gcc v4.4, so it is +not available if the latest tests need to be run in all the +environments required to support kernels v4.9 and v4.14 that +have the minimal required gcc v3.2. + +Duplicate gcc's __cpuid_count() macro to provide a centrally defined +macro for __cpuid_count() to help eliminate the duplicate CPUID wrappers +while continuing to compile in older environments. + +Suggested-by: Shuah Khan +Signed-off-by: Reinette Chatre +Signed-off-by: Shuah Khan +Cc: Kyle Huey +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/kselftest.h | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +--- a/tools/testing/selftests/kselftest.h ++++ b/tools/testing/selftests/kselftest.h +@@ -52,6 +52,21 @@ + #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + #endif + ++/* ++ * gcc cpuid.h provides __cpuid_count() since v4.4. ++ * Clang/LLVM cpuid.h provides __cpuid_count() since v3.4.0. ++ * ++ * Provide local define for tests needing __cpuid_count() because ++ * selftests need to work in older environments that do not yet ++ * have __cpuid_count(). ++ */ ++#ifndef __cpuid_count ++#define __cpuid_count(level, count, a, b, c, d) \ ++ __asm__ __volatile__ ("cpuid\n\t" \ ++ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ ++ : "0" (level), "2" (count)) ++#endif ++ + /* define kselftest exit codes */ + #define KSFT_PASS 0 + #define KSFT_FAIL 1 diff --git a/queue-5.15/selftests-vm-remove-array_size-define-from-individual-tests.patch b/queue-5.15/selftests-vm-remove-array_size-define-from-individual-tests.patch new file mode 100644 index 00000000000..bdb7455b97e --- /dev/null +++ b/queue-5.15/selftests-vm-remove-array_size-define-from-individual-tests.patch @@ -0,0 +1,66 @@ +From e89908201e2509354c40158b517945bf3d645812 Mon Sep 17 00:00:00 2001 +From: Shuah Khan +Date: Thu, 9 Dec 2021 16:35:02 -0700 +Subject: selftests/vm: remove ARRAY_SIZE define from individual tests + +From: Shuah Khan + +commit e89908201e2509354c40158b517945bf3d645812 upstream. + +ARRAY_SIZE is defined in several selftests. Remove definitions from +individual test files and include header file for the define instead. +ARRAY_SIZE define is added in a separate patch to prepare for this +change. + +Remove ARRAY_SIZE from vm tests and pickup the one defined in +kselftest.h. + +Signed-off-by: Shuah Khan +Cc: Kyle Huey +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/vm/mremap_test.c | 1 - + tools/testing/selftests/vm/pkey-helpers.h | 3 ++- + tools/testing/selftests/vm/va_128TBswitch.c | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +--- a/tools/testing/selftests/vm/mremap_test.c ++++ b/tools/testing/selftests/vm/mremap_test.c +@@ -22,7 +22,6 @@ + #define VALIDATION_DEFAULT_THRESHOLD 4 /* 4MB */ + #define VALIDATION_NO_THRESHOLD 0 /* Verify the entire region */ + +-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + #define MIN(X, Y) ((X) < (Y) ? (X) : (Y)) + + struct config { +--- a/tools/testing/selftests/vm/pkey-helpers.h ++++ b/tools/testing/selftests/vm/pkey-helpers.h +@@ -13,6 +13,8 @@ + #include + #include + ++#include "../kselftest.h" ++ + /* Define some kernel-like types */ + #define u8 __u8 + #define u16 __u16 +@@ -175,7 +177,6 @@ static inline void __pkey_write_allow(in + dprintf4("pkey_reg now: %016llx\n", read_pkey_reg()); + } + +-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) + #define ALIGN_UP(x, align_to) (((x) + ((align_to)-1)) & ~((align_to)-1)) + #define ALIGN_DOWN(x, align_to) ((x) & ~((align_to)-1)) + #define ALIGN_PTR_UP(p, ptr_align_to) \ +--- a/tools/testing/selftests/vm/va_128TBswitch.c ++++ b/tools/testing/selftests/vm/va_128TBswitch.c +@@ -9,7 +9,7 @@ + #include + #include + +-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) ++#include "../kselftest.h" + + #ifdef __powerpc64__ + #define PAGE_SIZE (64 << 10) diff --git a/queue-5.15/series b/queue-5.15/series index 33b0f5293a9..fec1903ebbe 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -11,3 +11,8 @@ dmaengine-imx-sdma-fix-a-possible-memory-leak-in-sdm.patch cifs-fix-return-of-uninitialized-rc-in-dfs_cache_upd.patch ext4-fix-bad-checksum-after-online-resize.patch extcon-usbc-tusb320-fix-kernel-doc-warning.patch +acpi-processor-idle-practically-limit-dummy-wait-workaround-to-old-intel-systems.patch +bluetooth-fix-null-ptr-deref-on-hci_sync_conn_complete_evt.patch +tools-fix-array_size-defines-in-tools-and-selftests-hdrs.patch +selftests-vm-remove-array_size-define-from-individual-tests.patch +selftests-provide-local-define-of-__cpuid_count.patch diff --git a/queue-5.15/tools-fix-array_size-defines-in-tools-and-selftests-hdrs.patch b/queue-5.15/tools-fix-array_size-defines-in-tools-and-selftests-hdrs.patch new file mode 100644 index 00000000000..ae8b515a8d8 --- /dev/null +++ b/queue-5.15/tools-fix-array_size-defines-in-tools-and-selftests-hdrs.patch @@ -0,0 +1,66 @@ +From 066b34aa5461f6072dbbecb690f4fe446b736ebf Mon Sep 17 00:00:00 2001 +From: Shuah Khan +Date: Wed, 8 Dec 2021 10:47:42 -0700 +Subject: tools: fix ARRAY_SIZE defines in tools and selftests hdrs + +From: Shuah Khan + +commit 066b34aa5461f6072dbbecb690f4fe446b736ebf upstream. + +tools/include/linux/kernel.h and kselftest_harness.h are missing +ifndef guard around ARRAY_SIZE define. Fix them to avoid duplicate +define errors during compile when another file defines it. This +problem was found when compiling selftests that include a header +with ARRAY_SIZE define. + +ARRAY_SIZE is defined in several selftests. There are about 25+ +duplicate defines in various selftests source and header files. +Add ARRAY_SIZE to kselftest.h in preparation for removing duplicate +ARRAY_SIZE defines from individual test files. + +Signed-off-by: Shuah Khan +Cc: Kyle Huey +Signed-off-by: Greg Kroah-Hartman +--- + tools/include/linux/kernel.h | 2 ++ + tools/testing/selftests/kselftest.h | 4 ++++ + tools/testing/selftests/kselftest_harness.h | 2 ++ + 3 files changed, 8 insertions(+) + +--- a/tools/include/linux/kernel.h ++++ b/tools/include/linux/kernel.h +@@ -108,7 +108,9 @@ int vscnprintf(char *buf, size_t size, c + int scnprintf(char * buf, size_t size, const char * fmt, ...); + int scnprintf_pad(char * buf, size_t size, const char * fmt, ...); + ++#ifndef ARRAY_SIZE + #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) ++#endif + + /* + * This looks more complex than it should be. But we need to +--- a/tools/testing/selftests/kselftest.h ++++ b/tools/testing/selftests/kselftest.h +@@ -48,6 +48,10 @@ + #include + #include + ++#ifndef ARRAY_SIZE ++#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) ++#endif ++ + /* define kselftest exit codes */ + #define KSFT_PASS 0 + #define KSFT_FAIL 1 +--- a/tools/testing/selftests/kselftest_harness.h ++++ b/tools/testing/selftests/kselftest_harness.h +@@ -671,7 +671,9 @@ + #define EXPECT_STRNE(expected, seen) \ + __EXPECT_STR(expected, seen, !=, 0) + ++#ifndef ARRAY_SIZE + #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) ++#endif + + /* Support an optional handler after and ASSERT_* or EXPECT_*. The approach is + * not thread-safe, but it should be fine in most sane test scenarios.