Alexandre Ghiti
6f796a6a39
riscv: Fix IPIs usage in kfence_protect_page()
commit b3431a8bb3 upstream.
flush_tlb_kernel_range() may use IPIs to flush the TLBs of all the
cores, which triggers the following warning when the irqs are disabled:
[ 3.455330] WARNING: CPU: 1 PID: 0 at kernel/smp.c:815 smp_call_function_many_cond+0x452/0x520
[ 3.456647] Modules linked in:
[ 3.457218] CPU: 1 UID: 0 PID: 0 Comm: swapper/1 Not tainted 6.12.0-rc7-00010-g91d3de7240b8 #1
[ 3.457416] Hardware name: QEMU QEMU Virtual Machine, BIOS
[ 3.457633] epc : smp_call_function_many_cond+0x452/0x520
[ 3.457736] ra : on_each_cpu_cond_mask+0x1e/0x30
[ 3.457786] epc : ffffffff800b669a ra : ffffffff800b67c2 sp : ff2000000000bb50
[ 3.457824] gp : ffffffff815212b8 tp : ff6000008014f080 t0 : 000000000000003f
[ 3.457859] t1 : ffffffff815221e0 t2 : 000000000000000f s0 : ff2000000000bc10
[ 3.457920] s1 : 0000000000000040 a0 : ffffffff815221e0 a1 : 0000000000000001
[ 3.457953] a2 : 0000000000010000 a3 : 0000000000000003 a4 : 0000000000000000
[ 3.458006] a5 : 0000000000000000 a6 : ffffffffffffffff a7 : 0000000000000000
[ 3.458042] s2 : ffffffff815223be s3 : 00fffffffffff000 s4 : ff600001ffe38fc0
[ 3.458076] s5 : ff600001ff950d00 s6 : 0000000200000120 s7 : 0000000000000001
[ 3.458109] s8 : 0000000000000001 s9 : ff60000080841ef0 s10: 0000000000000001
[ 3.458141] s11: ffffffff81524812 t3 : 0000000000000001 t4 : ff60000080092bc0
[ 3.458172] t5 : 0000000000000000 t6 : ff200000000236d0
[ 3.458203] status: 0000000200000100 badaddr: ffffffff800b669a cause: 0000000000000003
[ 3.458373] [<ffffffff800b669a>] smp_call_function_many_cond+0x452/0x520
[ 3.458593] [<ffffffff800b67c2>] on_each_cpu_cond_mask+0x1e/0x30
[ 3.458625] [<ffffffff8000e4ca>] __flush_tlb_range+0x118/0x1ca
[ 3.458656] [<ffffffff8000e6b2>] flush_tlb_kernel_range+0x1e/0x26
[ 3.458683] [<ffffffff801ea56a>] kfence_protect+0xc0/0xce
[ 3.458717] [<ffffffff801e9456>] kfence_guarded_free+0xc6/0x1c0
[ 3.458742] [<ffffffff801e9d6c>] __kfence_free+0x62/0xc6
[ 3.458764] [<ffffffff801c57d8>] kfree+0x106/0x32c
[ 3.458786] [<ffffffff80588cf2>] detach_buf_split+0x188/0x1a8
[ 3.458816] [<ffffffff8058708c>] virtqueue_get_buf_ctx+0xb6/0x1f6
[ 3.458839] [<ffffffff805871da>] virtqueue_get_buf+0xe/0x16
[ 3.458880] [<ffffffff80613d6a>] virtblk_done+0x5c/0xe2
[ 3.458908] [<ffffffff8058766e>] vring_interrupt+0x6a/0x74
[ 3.458930] [<ffffffff800747d8>] __handle_irq_event_percpu+0x7c/0xe2
[ 3.458956] [<ffffffff800748f0>] handle_irq_event+0x3c/0x86
[ 3.458978] [<ffffffff800786cc>] handle_simple_irq+0x9e/0xbe
[ 3.459004] [<ffffffff80073934>] generic_handle_domain_irq+0x1c/0x2a
[ 3.459027] [<ffffffff804bf87c>] imsic_handle_irq+0xba/0x120
[ 3.459056] [<ffffffff80073934>] generic_handle_domain_irq+0x1c/0x2a
[ 3.459080] [<ffffffff804bdb76>] riscv_intc_aia_irq+0x24/0x34
[ 3.459103] [<ffffffff809d0452>] handle_riscv_irq+0x2e/0x4c
[ 3.459133] [<ffffffff809d923e>] call_on_irq_stack+0x32/0x40
So only flush the local TLB and let the lazy kfence page fault handling
deal with the faults which could happen when a core has an old protected
pte version cached in its TLB. That leads to potential inaccuracies which
can be tolerated when using kfence.
Fixes: 47513f243b ("riscv: Enable KFENCE for riscv64")
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20241209074125.52322-1-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-12-19 18:11:22 +01:00
..
2023-11-28 17:20:13 +00:00
2023-06-01 08:45:01 -07:00
2023-08-02 13:49:43 -07:00
2023-08-02 13:49:07 -07:00
2023-09-08 11:24:34 -07:00
2023-06-14 07:17:45 -07:00
2023-11-28 17:19:47 +00:00
2024-08-29 17:33:33 +02:00
2023-04-29 11:25:13 -07:00
2023-06-05 09:57:14 +02:00
2022-07-21 17:17:29 -07:00
2023-08-23 14:22:00 -07:00
2024-02-16 19:10:52 +01:00
2023-08-23 14:16:39 -07:00
2023-04-29 09:08:44 +02:00
2022-08-11 13:46:51 -07:00
2022-08-11 13:06:47 -07:00
2023-06-01 08:45:01 -07:00
2023-09-01 09:06:25 -07:00
2023-08-08 17:25:40 +05:30
2023-09-01 09:08:57 -07:00
2023-09-08 11:25:13 -07:00
2023-08-31 00:18:36 -07:00
2023-03-23 08:47:00 -07:00
2024-07-11 12:49:06 +02:00
2023-06-14 07:17:45 -07:00
2023-04-13 18:14:26 -07:00
2024-03-06 14:48:41 +00:00
2022-10-02 10:17:58 +05:30
2024-03-06 14:48:37 +00:00
2024-02-23 09:24:47 +01:00
2023-11-28 17:19:49 +00:00
2023-03-14 21:26:06 -07:00
2024-07-05 09:33:53 +02:00
2022-12-08 15:43:58 -08:00
2023-06-22 10:38:35 -07:00
2024-02-05 20:14:17 +00:00
2023-06-09 17:44:16 -07:00
2024-02-23 09:24:47 +01:00
2022-12-05 10:59:51 -08:00
2024-12-19 18:11:22 +01:00
2023-09-20 06:45:27 -07:00
2023-06-18 21:24:36 +05:30
2023-06-18 21:24:34 +05:30
2023-06-19 22:27:58 +05:30
2023-08-09 12:15:25 +05:30
2022-07-29 17:14:11 +05:30
2022-07-29 17:14:53 +05:30
2024-10-04 16:28:51 +02:00
2023-06-19 22:28:00 +05:30
2022-10-21 11:52:45 +05:30
2023-08-08 17:26:05 +05:30
2024-09-12 11:11:45 +02:00
2023-08-08 15:28:37 -07:00
2023-08-23 14:17:43 -07:00
2023-01-31 23:29:39 -08:00
2024-05-02 16:32:49 +02:00
2023-09-06 06:26:06 -07:00
2022-08-06 15:04:48 -07:00
2023-06-01 10:09:22 -07:00
2023-08-21 13:37:57 -07:00
2024-09-12 11:11:40 +02:00
2023-02-02 22:33:09 -08:00
2024-09-12 11:11:40 +02:00
2024-01-31 16:18:55 -08:00
2023-03-23 08:47:00 -07:00
2024-10-17 15:24:11 +02:00
2024-01-25 15:35:50 -08:00
2023-01-19 14:58:19 +01:00
2023-04-19 07:46:28 -07:00
2023-01-24 22:13:15 -08:00
2023-05-15 13:44:59 +02:00
2024-10-17 15:24:17 +02:00
2022-11-18 02:18:10 +01:00
2024-02-16 19:10:53 +01:00
2023-01-31 11:43:23 -08:00
2023-04-29 11:25:13 -07:00
2023-06-08 07:16:43 -07:00
2024-01-20 11:51:46 +01:00
2023-08-23 14:16:36 -07:00
2024-10-17 15:24:08 +02:00
2023-06-09 17:44:16 -07:00
2024-02-16 19:10:53 +01:00
2024-07-11 12:49:06 +02:00
2023-04-19 07:47:45 -07:00
2024-04-10 16:36:04 +02:00
2022-06-01 21:46:36 -07:00
2023-09-20 06:45:27 -07:00
2023-01-31 23:29:42 -08:00
2023-08-22 13:55:12 -07:00
2023-09-01 09:08:55 -07:00
2024-03-06 14:48:38 +00:00
2024-01-25 15:35:50 -08:00