Bug 215587 - UBSAN: invalid-load in drivers/acpi/cppc_acpi.c:314:45 - AMD Ryzen 9 5950X
Summary: UBSAN: invalid-load in drivers/acpi/cppc_acpi.c:314:45 - AMD Ryzen 9 5950X
Status: RESOLVED ANSWERED
Alias: None
Product: ACPI
Classification: Unclassified
Component: Config-Tables (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: acpi_config-tables
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-10 19:01 UTC by Erhard F.
Modified: 2022-05-09 14:19 UTC (History)
2 users (show)

See Also:
Kernel Version: 5.17-rc3
Subsystem:
Regression: No
Bisected commit-id:


Attachments
kernel dmesg (kernel 5.17-rc3, AMD Ryzen 9 5950X) (104.13 KB, text/plain)
2022-02-10 19:01 UTC, Erhard F.
Details
kernel config (kernel 5.17-rc3, AMD Ryzen 9 5950X) (116.90 KB, text/plain)
2022-02-10 19:02 UTC, Erhard F.
Details
dmesg (kernel 5.18-rc3, AMD Ryzen 9 5950X) (67.37 KB, text/plain)
2022-04-18 11:53 UTC, Erhard F.
Details
possible patch to fix error (1.39 KB, patch)
2022-05-04 18:16 UTC, Mario Limonciello (AMD)
Details | Diff

Description Erhard F. 2022-02-10 19:01:01 UTC
Created attachment 300426 [details]
kernel dmesg (kernel 5.17-rc3, AMD Ryzen 9 5950X)

Shows up at on my Ryzen 5950X when UBSAN is enabled.

[...]
UBSAN: invalid-load in drivers/acpi/cppc_acpi.c:314:45
load of value 107 is not a valid value for type 'bool' (aka '_Bool')
CPU: 12 PID: 1 Comm: swapper/0 Tainted: G        W         5.17.0-rc3-Zen3 #1
Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./B450M Steel Legend, BIOS P4.20 08/03/2021
Call Trace:
 <TASK>
 dump_stack_lvl+0x16c/0x218
 ? extent_err+0x43f/0x43f
 ? panic+0x5ba/0x5ba
 ? usleep_range_state+0xe5/0x146
 ? schedule_timeout_idle+0x52/0x52
 ubsan_epilogue+0x5/0x44
 __ubsan_handle_load_invalid_value+0x9e/0xa0
 send_pcc_cmd+0xb79/0xc1f
 ? cppc_get_perf_caps+0x1300/0x1300
 ? __lock_acquire+0x1344/0x20af
 cppc_get_perf_caps+0x49c/0x1300
 ? cppc_get_nominal_perf+0xd/0xd
 ? __mutex_trylock_common+0x1f6/0x344
 ? rcu_report_qs_rdp+0x3d6/0x3d6
 ? atomic_dec_and_mutex_lock+0x117/0x117
 ? kernfs_get+0x3d/0x5c
 ? kobject_add_internal+0x433/0x76a
 init_freq_invariance+0x2b0/0x3b2
 ? arch_disable_smp_support+0x5/0x5
 init_freq_invariance_cppc+0x1f/0x32
 acpi_cppc_processor_probe+0xd9b/0xff6
 ? __mutex_unlock_slowpath+0x24d/0x853
 ? acpi_get_psd_map+0x6ad/0x6ad
 ? kernfs_create_link+0x126/0x1a5
 __acpi_processor_start+0x6e/0x2a3
 acpi_processor_start+0x4c/0x5e
 really_probe+0x32d/0x738
 __driver_probe_device+0x147/0x22f
 driver_probe_device+0x44/0xb8
 __driver_attach+0x17b/0x1ba
 ? driver_attach+0x3a/0x3a
 bus_for_each_dev+0x157/0x1af
 ? bus_remove_file+0x98/0x98
 ? do_raw_spin_unlock+0x46/0x23c
 bus_add_driver+0x2b7/0x477
 driver_register+0x173/0x29c
 acpi_processor_driver_init+0x3c/0xf6
 ? acpi_initialize_objects+0x61/0x61
 do_one_initcall+0x181/0x384
 ? __kmalloc+0x277/0x351
 ? do_initcalls+0x23/0x76
 ? acpi_initialize_objects+0x61/0x61
 ? efi_enabled+0x48/0x48
 ? rcu_read_lock_sched_held+0xc2/0x1a7
 ? perf_trace_rcu_stall_warning+0x34c/0x34c
 do_initcall_level+0x136/0x1bf
 do_initcalls+0x46/0x76
 kernel_init_freeable+0x399/0x4e6
 ? _raw_spin_unlock_irq+0x1f/0x29
 ? report_meminit+0x4a/0x4a
 ? lockdep_hardirqs_on_prepare+0x22e/0x4cd
 ? print_irqtrace_events+0x214/0x214
 ? finish_task_switch+0x116/0x4e0
 ? rest_init+0x23d/0x23d
 kernel_init+0x14/0x150
 ? rest_init+0x23d/0x23d
 ret_from_fork+0x22/0x30
 </TASK>
[...}

Some data about the machine:
System:    Kernel: 5.17.0-rc3-Zen3 x86_64 bits: 64 Console: pty pts/0
           Distro: Gentoo Base System release 2.7
Machine:   Type: Desktop Mobo: ASRock model: B450M Steel Legend
           UEFI: American Megatrends v: P4.20 date: 08/03/2021
CPU:       Info: 16-Core AMD Ryzen 9 5950X [MT MCP] speed: 2878 MHz min/max: 2200/3400 MHz
Graphics:  Device-1: AMD RV370 [Radeon X600/X600 SE] driver: radeon v: kernel
           Display: server: X.org 1.21.1.3 driver: loaded: radeon tty: 104x57
Network:   Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet driver: r8169

 # lspci 
00:00.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Root Complex
00:00.2 IOMMU: Advanced Micro Devices, Inc. [AMD] Starship/Matisse IOMMU
00:01.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
00:01.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse GPP Bridge
00:01.3 PCI bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse GPP Bridge
00:02.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
00:03.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
00:03.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse GPP Bridge
00:04.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
00:05.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
00:07.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
00:07.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Internal PCIe GPP Bridge 0 to bus[E:B]
00:08.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Host Bridge
00:08.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Internal PCIe GPP Bridge 0 to bus[E:B]
00:14.0 SMBus: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller (rev 61)
00:14.3 ISA bridge: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge (rev 51)
00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 0
00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 1
00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 2
00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 3
00:18.4 Host bridge: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 4
00:18.5 Host bridge: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 5
00:18.6 Host bridge: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 6
00:18.7 Host bridge: Advanced Micro Devices, Inc. [AMD] Matisse/Vermeer Data Fabric: Device 18h; Function 7
01:00.0 Non-Volatile memory controller: Sandisk Corp WD Blue SN550 NVMe SSD (rev 01)
02:00.0 USB controller: Advanced Micro Devices, Inc. [AMD] 400 Series Chipset USB 3.1 XHCI Controller (rev 01)
02:00.1 SATA controller: Advanced Micro Devices, Inc. [AMD] 400 Series Chipset SATA Controller (rev 01)
02:00.2 PCI bridge: Advanced Micro Devices, Inc. [AMD] 400 Series Chipset PCIe Bridge (rev 01)
03:00.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] 400 Series Chipset PCIe Port (rev 01)
03:01.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] 400 Series Chipset PCIe Port (rev 01)
03:04.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] 400 Series Chipset PCIe Port (rev 01)
05:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)
07:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] RV370 [Radeon X600/X600 SE]
07:00.1 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] RV380 [Radeon X300/X550/X1050 Series] (Secondary)
08:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Starship/Matisse PCIe Dummy Function
09:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Reserved SPP
09:00.1 Encryption controller: Advanced Micro Devices, Inc. [AMD] Starship/Matisse Cryptographic Coprocessor PSPCPP
09:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Matisse USB 3.0 Host Controller
Comment 1 Erhard F. 2022-02-10 19:02:39 UTC
Created attachment 300427 [details]
kernel config (kernel 5.17-rc3, AMD Ryzen 9 5950X)
Comment 2 Erhard F. 2022-04-18 11:53:32 UTC
Created attachment 300773 [details]
dmesg (kernel 5.18-rc3, AMD Ryzen 9 5950X)

5.18-rc3 still affected.
[...]
UBSAN: invalid-load in drivers/acpi/cppc_acpi.c:314:45
load of value 107 is not a valid value for type 'bool' (aka '_Bool')
CPU: 13 PID: 1 Comm: swapper/0 Not tainted 5.18.0-rc3-Zen3 #1
Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./B450M Steel Legend, BIOS P4.20 08/03/2021
Call Trace:
 <TASK>
 dump_stack_lvl+0xe5/0x154
 __ubsan_handle_load_invalid_value+0xd2/0x110
 send_pcc_cmd+0x995/0xa40
 cppc_get_perf_caps+0x410/0x1220
 amd_set_max_freq_ratio+0x42/0x120
 init_freq_invariance+0xd5/0x150
 init_freq_invariance_cppc+0x1f/0x40
 acpi_cppc_processor_probe+0xeba/0x11a0
 ? acpi_processor_start+0x44/0x60
 __acpi_processor_start+0x6d/0x320
 acpi_processor_start+0x4c/0x60
 really_probe+0x3fb/0x820
 __driver_probe_device+0x147/0x240
 driver_probe_device+0x4b/0x320
 __driver_attach+0x263/0x4f0
 ? driver_attach+0x40/0x40
 bus_for_each_dev+0xff/0x140
 bus_add_driver+0x2b7/0x480
 driver_register+0x1f5/0x330
 acpi_processor_driver_init+0x3c/0xf6
 ? acpi_initialize_objects+0x61/0x61
 do_one_initcall+0x12b/0x2d0
 ? acpi_initialize_objects+0x61/0x61
 do_initcall_level+0x136/0x1bf
 ? kernel_init+0x14/0x1d0
 do_initcalls+0x46/0x76
 kernel_init_freeable+0x334/0x456
 ? rest_init+0x240/0x240
 kernel_init+0x14/0x1d0
 ? rest_init+0x240/0x240
 ret_from_fork+0x22/0x30
 </TASK>
Comment 3 Mario Limonciello (AMD) 2022-05-04 18:14:52 UTC
Can you please have a try with this:


diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index ed18936b8ce6..ebfa33a40fce 100644
--- a/drivers/mailbox/pcc.c
+++ b/drivers/mailbox/pcc.c
@@ -654,7 +654,7 @@ static int pcc_mbox_probe(struct platform_device *pdev)
                goto err;
        }

-       pcc_mbox_ctrl = devm_kmalloc(dev, sizeof(*pcc_mbox_ctrl), GFP_KERNEL);
+       pcc_mbox_ctrl = devm_kzalloc(dev, sizeof(*pcc_mbox_ctrl), GFP_KERNEL);
        if (!pcc_mbox_ctrl) {
                rc = -ENOMEM;
                goto err;
Comment 4 Mario Limonciello (AMD) 2022-05-04 18:16:00 UTC
Created attachment 300877 [details]
possible patch to fix error
Comment 5 Erhard F. 2022-05-09 10:58:51 UTC
Just applied your patch on top of v5.18-rc6 and can confirm the error is fixed. Thanks!

I'll close here as soon as it lands in -rc.
Comment 6 Mario Limonciello (AMD) 2022-05-09 14:19:31 UTC
I submitted it here: https://lore.kernel.org/linux-acpi/20220509141716.1270-1-mario.limonciello@amd.com/T/#u

Note You need to log in before you can comment on or make changes to this bug.