580.178.04: oops in rm_acpi_notify on kernel 6.8+ (ACPI notify handlers now run in parallel), crash on every boot on battery

Since moving from kernel 5.15 to 6.8 (Ubuntu 22.04 to 24.04), my laptop crashes on every boot on battery power, between about 10 and 126 seconds after the kernel starts. Every crash is a page fault or NULL pointer dereference inside nvidia.ko, reached through rm_acpi_notify ← nv_acpi_notify_event on the kacpi_notify workqueue. One crash also happened on mains power after a day of uptime, through the same path.

I believe the cause is a change in kernel 6.8 that lets ACPI notify handlers run in parallel, while the driver’s notify handlers are not reentrant. Serialising them with a mutex in nv-acpi.c stops the crashes (patch below).

System

  • Acer Aspire VN7-791G, BIOS V1.14 (08/06/2015), Optimus: Intel i915 + GeForce GTX 960M (Maxwell)
  • Ubuntu 24.04.5 LTS, kernels 6.8.0-139-generic and 6.8.0-146-generic
  • Driver 580.178.04, proprietary kernel module (Ubuntu nvidia-driver-580 580.178.04-0ubuntu0.24.04.1, DKMS)
  • Other out-of-tree modules loaded: VirtualBox 7.0.16 (vboxdrv, vboxnetadp, vboxnetflt)

History

Kernel Driver Result
5.15.0-181 535.309.01 2 boots on battery, no crash (July)
5.15.0-190 580.173.02 2 boots on battery, no crash (September, one ran 5 days)
6.8.0-139 580.178.04 booted on mains, crashed after about 24 h (19 Sep)
6.8.0-146 580.178.04 4 of 4 boots on battery failed within about 2 minutes (12 Oct)
6.8.0-146 580.178.04 + patch below boot on battery and two plug/unplug cycles, no crash (14 Oct)

5.15 with 580.178.04 was never started on battery, so the history alone does not separate kernel from driver version. The analysis below points at the kernel change.

Analysis

  1. Kernel 6.8 changed how ACPI Notify() handlers run (commit e2ffcda16290, “ACPI: OSL: Allow Notify () handlers to run on all CPUs”). In 6.7, drivers/acpi/osl.c queues them with queue_work_on(0, …) on alloc_workqueue("kacpi_notify", 0, 1), so they run one at a time on CPU 0. In 6.8 they are queued with queue_work(kacpi_notify_wq, …) on alloc_workqueue("kacpi_notify", 0, 0), so several can run at once on different CPUs.
  2. nv_acpi_notify_event() in nvidia/nv-acpi.c calls rm_acpi_notify(pNvAcpiObject->sp, …). sp is a single nvidia_stack_t, allocated once in nv_install_notifier() and shared by every call of that handler. nv_acpi_powersource_hotplug_event() and nv_acpi_nvpcf_event() work the same way. None of them takes a lock, and kernel-open/nvidia/nv-acpi.c on GitHub (main) still has none.
  3. On battery the firmware notifies the GPU often enough that two handlers overlap. In the 12 Oct log below, two kacpi_notify workers (CPU 0, PID 10 and CPU 4, PID 89) both fault inside rm_acpi_notify, 0.16 s apart. With the 6.7 workqueue they could not have run at the same time.

Workaround (tested)

The patch puts one mutex around the three RM entry points, which restores the one-at-a-time behaviour of kernels before 6.8. The handlers run on a workqueue (process context), so a mutex is allowed. With it, a boot on battery ran well past all earlier crash times, and plugging and unplugging the charger twice caused no crash. Before, 4 of 4 boots on battery crashed. I have only shown that serialising removes the crash; a proper fix may belong inside RM or use a stack per call.

--- a/nvidia/nv-acpi.c
+++ b/nvidia/nv-acpi.c
@@ -74,6 +74,14 @@
 static acpi_handle nvpcf_device_handle = NULL;
 static nv_acpi_t  *nvpcf_nv_acpi_object = NULL;
 
+/*
+ * Since Linux 6.8 (commit e2ffcda16290) ACPI Notify() handlers run concurrently
+ * on all CPUs instead of one at a time on CPU 0. The RM entry points below share
+ * one nvidia_stack_t per notifier and are not reentrant, so serialise them again
+ * (oops in rm_acpi_notify on two CPUs at once when booting on battery).
+ */
+static DEFINE_MUTEX(nv_acpi_notify_lock);
+
 #define ACPI_NVPCF_EVENT_CHANGE    0xC0
 
 /*
@@ -149,7 +157,9 @@
         if (nv_acpi_get_powersource(&ac_plugged) != NV_OK)
             return;
 
+        mutex_lock(&nv_acpi_notify_lock);
         rm_power_source_change_event(pNvAcpiObject->sp, !ac_plugged);
+        mutex_unlock(&nv_acpi_notify_lock);
     }
 }
 
@@ -159,7 +169,9 @@
 
     if (event_type == ACPI_NVPCF_EVENT_CHANGE)
     {
+        mutex_lock(&nv_acpi_notify_lock);
         rm_acpi_nvpcf_notify(pNvAcpiObject->sp);
+        mutex_unlock(&nv_acpi_notify_lock);
     }
     else
     {
@@ -266,7 +278,9 @@
      * Function to handle device specific ACPI events such as display hotplug,
      * GPS and D-notifier events.
      */
+    mutex_lock(&nv_acpi_notify_lock);
     rm_acpi_notify(pNvAcpiObject->sp, NV_STATE_PTR(nvl), event_type);
+    mutex_unlock(&nv_acpi_notify_lock);
 }
 
 void nv_acpi_register_notifier(nv_linux_state_t *nvl)

Logs

12 Oct: two oopses on CPU 0 and CPU 4 (6.8.0-146, started on battery)
[125.960872] BUG: unable to handle page fault for address: 000056d400000018
[125.960890] #PF: supervisor read access in kernel mode
[125.960896] #PF: error_code(0x0000) - not-present page
[125.960903] PGD 0 P4D 0 
[125.960913] Oops: 0000 [#1] PREEMPT SMP PTI
[125.960923] CPU: 0 PID: 10 Comm: kworker/0:1 Tainted: P           OE      6.8.0-146-generic #146-Ubuntu
[125.960932] Hardware name: Acer Aspire VN7-791G/Aspire VN7-791G, BIOS V1.14 08/06/2015
[125.960938] Workqueue: kacpi_notify acpi_os_execute_deferred
[125.960956] RIP: 0010:os_free_mem+0xa/0x40 [nvidia]
[125.962325] Code: cc cc cc cc 66 66 2e 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 55 48 8d 47 f8 <f6> 47 f8 01 48 89 c7 48 89 e5 74 0f e8 35 43 86 c1 5d 31 c0 31 ff
[125.962333] RSP: 0018:ffffcf038009bc50 EFLAGS: 00010202
[125.962342] RAX: 000056d400000018 RBX: ffff8dccf9cf5db0 RCX: 0000000000000020
[125.962348] RDX: 0000000000000001 RSI: 000056d400000020 RDI: 000056d400000020
[125.962354] RBP: ffff8dccf9cf5d50 R08: 0000000000000000 R09: 0000000000000000
[125.962360] R10: 0000000000000000 R11: 0000000000000000 R12: ffff8dccf9820c08
[125.962365] R13: ffffffffc2c56d80 R14: ffff8dccf9e98820 R15: ffff8dccf9cf5ea8
[125.962371] FS:  0000000000000000(0000) GS:ffff8dd00f000000(0000) knlGS:0000000000000000
[125.962378] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[125.962384] CR2: 000056d400000018 CR3: 000000006323c003 CR4: 00000000001706f0
[125.962390] Call Trace:
[125.962396]  <TASK>
[125.962404]  ? _nv056328rm+0x2d/0x50 [nvidia]
[125.963609]  ? _nv054057rm+0xfa/0x1b0 [nvidia]
[125.964260]  ? _nv056303rm+0x3f5/0x500 [nvidia]
[125.964839]  ? _nv015942rm+0x424/0x680 [nvidia]
[125.965205]  ? _nv054203rm+0x29/0x30 [nvidia]
[125.965576]  ? _nv056306rm+0x60/0x60 [nvidia]
[125.965925]  ? rm_acpi_notify+0x126/0x280 [nvidia]
[125.966261]  ? up+0x58/0xa0
[125.966266]  ? nv_acpi_notify_event+0x1a/0x30 [nvidia]
[125.966532]  ? acpi_ev_notify_dispatch+0x59/0xa0
[125.966535]  ? acpi_os_execute_deferred+0x1a/0x40
[125.966538]  ? process_one_work+0x184/0x3a0
[125.966541]  ? worker_thread+0x18b/0x330
[125.966544]  ? __pfx_worker_thread+0x10/0x10
[125.966546]  ? kthread+0xf2/0x120
[125.966548]  ? __pfx_kthread+0x10/0x10
[125.966550]  ? ret_from_fork+0x47/0x70
[125.966553]  ? __pfx_kthread+0x10/0x10
[125.966555]  ? ret_from_fork_asm+0x1b/0x30
[125.966559]  </TASK>
[125.966660] CR2: 000056d400000018
[125.966662] ---[ end trace 0000000000000000 ]---
[126.124230] pstore: backend (efi_pstore) writing error (-5)
[126.124238] RIP: 0010:os_free_mem+0xa/0x40 [nvidia]
[126.124623] Code: cc cc cc cc 66 66 2e 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 55 48 8d 47 f8 <f6> 47 f8 01 48 89 c7 48 89 e5 74 0f e8 35 43 86 c1 5d 31 c0 31 ff
[126.124626] RSP: 0018:ffffcf038009bc50 EFLAGS: 00010202
[126.124629] RAX: 000056d400000018 RBX: ffff8dccf9cf5db0 RCX: 0000000000000020
[126.124631] RDX: 0000000000000001 RSI: 000056d400000020 RDI: 000056d400000020
[126.124633] RBP: ffff8dccf9cf5d50 R08: 0000000000000000 R09: 0000000000000000
[126.124635] R10: 0000000000000000 R11: 0000000000000000 R12: ffff8dccf9820c08
[126.124636] R13: ffffffffc2c56d80 R14: ffff8dccf9e98820 R15: ffff8dccf9cf5ea8
[126.124638] FS:  0000000000000000(0000) GS:ffff8dd00f000000(0000) knlGS:0000000000000000
[126.124640] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[126.124642] CR2: 000056d400000018 CR3: 000000012ccd8006 CR4: 00000000001706f0
[126.124644] note: kworker/0:1[10] exited with irqs disabled
[126.124764] BUG: unable to handle page fault for address: 00003f6da7171963
[126.124770] #PF: supervisor read access in kernel mode
[126.124773] #PF: error_code(0x0000) - not-present page
[126.124776] PGD 0 P4D 0 
[126.124780] Oops: 0000 [#2] PREEMPT SMP PTI
[126.124785] CPU: 4 PID: 89 Comm: kworker/4:1 Tainted: P      D    OE      6.8.0-146-generic #146-Ubuntu
[126.124789] Hardware name: Acer Aspire VN7-791G/Aspire VN7-791G, BIOS V1.14 08/06/2015
[126.124792] Workqueue: kacpi_notify acpi_os_execute_deferred
[126.124800] RIP: 0010:_nv014055rm+0x3c/0x310 [nvidia]
[126.125534] Code: 48 63 47 08 48 01 c2 48 8b 07 48 85 c0 75 1b e9 2b 02 00 00 66 2e 0f 1f 84 00 00 00 00 00 48 8b 48 10 48 85 c9 74 17 48 89 c8 <48> 39 30 77 ef 0f 83 f9 01 00 00 48 8b 48 18 48 85 c9 75 e9 48 89
[126.125536] RSP: 0018:ffffcf0380373ce8 EFLAGS: 00010006
[126.125539] RAX: 00003f6da7171963 RBX: ffffffffc2966fed RCX: 00003f6da7171963
[126.125541] RDX: ffffcf0380373d90 RSI: 0000000000000059 RDI: ffffffffc2c50cd8
[126.125542] RBP: ffff8dccf9cf6000 R08: 0000000000000000 R09: 0000000000000000
[126.125544] R10: 0000000000000000 R11: 0000000000000000 R12: ffffcf0380373d40
[126.125545] R13: 0000000000000000 R14: 0000000000004001 R15: 0000000000000000
[126.125547] FS:  0000000000000000(0000) GS:ffff8dd00f200000(0000) knlGS:0000000000000000
[126.125548] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[126.125550] CR2: 00003f6da7171963 CR3: 000000006323c006 CR4: 00000000001706f0
[126.125552] Call Trace:
[126.125554]  <TASK>
[126.125555]  ? _nv016372rm+0xbc/0x170 [nvidia]
[126.125872]  ? _nv000848rm+0x1d/0x70 [nvidia]
[126.126271]  ? rm_acpi_notify+0xf1/0x280 [nvidia]
[126.126604]  ? nv_acpi_notify_event+0x1a/0x30 [nvidia]
[126.126870]  ? acpi_ev_notify_dispatch+0x59/0xa0
[126.126873]  ? acpi_os_execute_deferred+0x1a/0x40
[126.126876]  ? process_one_work+0x184/0x3a0
[126.126879]  ? worker_thread+0x18b/0x330
[126.126881]  ? __pfx_worker_thread+0x10/0x10
[126.126884]  ? kthread+0xf2/0x120
[126.126886]  ? __pfx_kthread+0x10/0x10
[126.126887]  ? ret_from_fork+0x47/0x70
[126.126890]  ? __pfx_kthread+0x10/0x10
[126.126892]  ? ret_from_fork_asm+0x1b/0x30
[126.126895]  </TASK>
[126.126995] CR2: 00003f6da7171963
[126.126997] ---[ end trace 0000000000000000 ]---

After this: hard LOCKUP on CPU 1 at 141.8 s and on CPU 0 at 156.0 s, an RCU stall at 186.1 s, then the machine hung.

19 Sep: same path on mains power after about 24 h (6.8.0-139)
19:06:46.094748 BUG: kernel NULL pointer dereference, address: 000000000000007d
19:06:46.094952 #PF: supervisor read access in kernel mode
19:06:46.097473 #PF: error_code(0x0000) - not-present page
19:06:46.097556 PGD 0 P4D 0 
19:06:46.097616 Oops: 0000 [#1] PREEMPT SMP PTI
19:06:46.097642 CPU: 2 PID: 118853 Comm: kworker/2:1 Tainted: P           OE      6.8.0-139-generic #139-Ubuntu
19:06:46.097666 Hardware name: Acer Aspire VN7-791G/Aspire VN7-791G, BIOS V1.14 08/06/2015
19:06:46.097683 Workqueue: kacpi_notify acpi_os_execute_deferred
19:06:46.097703 RIP: 0010:_nv015914rm+0x2a4/0xab0 [nvidia]
19:06:46.097728 Code: 41 81 ff ff 00 00 00 0f 84 a1 00 00 00 44 3b 7d 18 74 13 41 83 c7 01 41 83 ff ff 0f 85 ad fe ff ff 0f 1f 44 00 00 48 8b 45 20 <80> 78 7d 00 0f 85 c2 06 00 00 8b 45 28 8b 0d 51 6f 03 01 09 05 43
19:06:46.097757 RSP: 0018:ffffcf4cce397c80 EFLAGS: 00010046
19:06:46.097788 RAX: 0000000000000000 RBX: ffffffffc27afee0 RCX: 000f9bdf5a05c640
19:06:46.097813 RDX: 0000000000000015 RSI: 0000000000000000 RDI: 0000000000000000
19:06:46.097830 RBP: ffff8d1de2daaf50 R08: 0000000000000001 R09: 0000000000000000
19:06:46.097847 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000001
19:06:46.097864 R13: 0000000000000000 R14: ffff8d1df9268008 R15: 0000000000000000
19:06:46.097881 FS:  0000000000000000(0000) GS:ffff8d210f100000(0000) knlGS:0000000000000000
19:06:46.097901 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
19:06:46.097917 CR2: 000000000000007d CR3: 000000012043c004 CR4: 00000000001706f0
19:06:46.097934 Call Trace:
19:06:46.097953  <TASK>
19:06:46.097973  ? _nv054103rm+0x118/0x190 [nvidia]
19:06:46.098001  ? _nv016371rm+0x108/0x1c0 [nvidia]
19:06:46.098029  ? _nv059473rm+0x98/0x1d0 [nvidia]
19:06:46.098047  ? rm_acpi_notify+0x147/0x280 [nvidia]
19:06:46.098064  ? up+0x58/0xa0
19:06:46.098083  ? nv_acpi_notify_event+0x1a/0x30 [nvidia]
19:06:46.098100  ? acpi_ev_notify_dispatch+0x59/0xa0
19:06:46.098119  ? acpi_os_execute_deferred+0x1a/0x40
19:06:46.098144  ? process_one_work+0x184/0x3a0
19:06:46.098166  ? worker_thread+0x18b/0x330
19:06:46.098186  ? __pfx_worker_thread+0x10/0x10
19:06:46.098202  ? kthread+0xf2/0x120
19:06:46.098224  ? __pfx_kthread+0x10/0x10
19:06:46.098249  ? ret_from_fork+0x47/0x70
19:06:46.098277  ? __pfx_kthread+0x10/0x10
19:06:46.098294  ? ret_from_fork_asm+0x1b/0x30
19:06:46.098320  </TASK>
19:06:46.098441 CR2: 000000000000007d
19:06:46.098462 ---[ end trace 0000000000000000 ]---

Two further boots on battery on 12 Oct stopped 10 s and 11.5 s after kernel start with BUG: kernel NULL pointer dereference, address: 0000000000000097 and …0000000000000047; their traces did not reach the disk. The fourth stopped logging 30 s after kernel start, without a trace.

Possibly the same bug on current hardware: this Arch Linux thread reports a page fault in rm_acpi_notify, triggered by ACPI, on an RTX 4060 Mobile with 580.82.07 and kernel 6.12.

I can provide nvidia-bug-report.log.gz on request.

Probably the same bug on current hardware: Driver crashes early after boot (even in text mode) on laptop with RTX 4070 (RTX 4070 laptop, Arch, kernel 6.13.7, driver 570.124.04, March 2025, no replies). Its call trace follows the same path as the CPU 4 oops above: the faulting RM function at +0x3c/0x310, called through rm_acpi_notify+0xf1/0x280 from acpi_ev_notify_dispatch / acpi_os_execute_deferred. Only the obfuscated symbol numbers differ between driver versions. So this is not limited to Maxwell and goes back to at least 570.

A LLM led me here. I’m highly dubious it’s the same issue, but I’ve experienced oopses in nv_acpi_dsm_method.

Modprobing options NVreg_RegisterForACPIEvents=0 and similar had no effect, prolly because those values are not already found in /proc/driver/nvidia/params for this version of driver.

In the end, removing kernel boot parameter slab_debug=PZ did the trick for me. I’d just like to encourage everyone to revise boot args when running boxes “configured”.