[PW_SID:1147259] iommu/riscv: Fix command queue publishing races - #2483
[PW_SID:1147259] iommu/riscv: Fix command queue publishing races#2483linux-riscv-bot wants to merge 6 commits into
Conversation
…_RWX When CONFIG_STRICT_MODULE_RWX is not set, execmem cannot create temporary writable mappings for read-only executable pages. In this case, the execmem ranges must already have writable permissions. Currently EXECMEM_KPROBES unconditionally uses PAGE_KERNEL_READ_EXEC, which causes kprobe instruction slot writes to trigger page faults on systems where CONFIG_STRICT_MODULE_RWX is not enabled. Fix this by using PAGE_KERNEL_EXEC when CONFIG_STRICT_MODULE_RWX is not available. Signed-off-by: Xiaofeng Yuan <xiaofengmian@163.com> Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Nam Cao <namcao@linutronix.de> Link: https://patch.msgid.link/20260814082742.148403-2-xiaofengmian@163.com Signed-off-by: Paul Walmsley <pjw@kernel.org>
patch_map() always creates a temporary writable mapping via fixmap for kernel text addresses, even when CONFIG_STRICT_KERNEL_RWX is disabled and the kernel text is already mapped with _PAGE_WRITE. This is unnecessary overhead at best, and on minimal configurations it can cause page faults. Skip the fixmap path for kernel text when CONFIG_STRICT_KERNEL_RWX is not enabled, since the text pages are already writable in that case. The module text path is already gated on CONFIG_STRICT_MODULE_RWX and is kept unchanged. Reported-by: Klara Modin <klara@kasm.eu> Closes: https://lore.kernel.org/all/ant_8TaBbov_GS4i@soda.int.kasm.eu/ Reported-by: Lad Prabhakar <prabhakar.csengg@gmail.com> Closes: https://lore.kernel.org/all/CA+V-a8tQK8rih9SGGTyqrEBGpNkx4H0eX2YccCRrgkVAPr+EBg@mail.gmail.com/ Tested-by: Klara Modin <klarasmodin@gmail.com> Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Link: https://patch.msgid.link/20260814082742.148403-3-xiaofengmian@163.com Signed-off-by: Paul Walmsley <pjw@kernel.org>
Add a raw spinlock to the RISC-V IOMMU queue state so command queue publishing can be serialized by a later change. Fixes: 856c0cf ("iommu/riscv: Command and fault queue support") Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Serialize command queue publishing so software producer state advances only after a command is written and the hardware tail is updated. Wait for hardware consumption outside the queue lock when the command queue is full so other CPUs are not blocked behind a long poll. Fixes: 856c0cf ("iommu/riscv: Command and fault queue support") Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Do not wait for IOFENCE.C completion when the command failed to enter the queue. The command was not published to hardware, so waiting for its producer index can only report a misleading execution timeout. Fixes: 856c0cf ("iommu/riscv: Command and fault queue support") Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[1/3] iommu/riscv: Add command queue lock" |
|
Patch 1: "[1/3] iommu/riscv: Add command queue lock" |
|
Patch 1: "[1/3] iommu/riscv: Add command queue lock" |
|
Patch 1: "[1/3] iommu/riscv: Add command queue lock" |
|
Patch 1: "[1/3] iommu/riscv: Add command queue lock" |
|
Patch 1: "[1/3] iommu/riscv: Add command queue lock" |
|
Patch 1: "[1/3] iommu/riscv: Add command queue lock" |
|
Patch 1: "[1/3] iommu/riscv: Add command queue lock" |
|
Patch 1: "[1/3] iommu/riscv: Add command queue lock" |
|
Patch 1: "[1/3] iommu/riscv: Add command queue lock" |
|
Patch 1: "[1/3] iommu/riscv: Add command queue lock" |
|
Patch 1: "[1/3] iommu/riscv: Add command queue lock" |
|
Patch 2: "[2/3] iommu/riscv: Serialize command queue publishing" |
|
Patch 2: "[2/3] iommu/riscv: Serialize command queue publishing" |
|
Patch 2: "[2/3] iommu/riscv: Serialize command queue publishing" |
|
Patch 2: "[2/3] iommu/riscv: Serialize command queue publishing" |
|
Patch 2: "[2/3] iommu/riscv: Serialize command queue publishing" |
|
Patch 2: "[2/3] iommu/riscv: Serialize command queue publishing" |
|
Patch 2: "[2/3] iommu/riscv: Serialize command queue publishing" |
|
Patch 2: "[2/3] iommu/riscv: Serialize command queue publishing" |
|
Patch 2: "[2/3] iommu/riscv: Serialize command queue publishing" |
|
Patch 2: "[2/3] iommu/riscv: Serialize command queue publishing" |
|
Patch 2: "[2/3] iommu/riscv: Serialize command queue publishing" |
|
Patch 2: "[2/3] iommu/riscv: Serialize command queue publishing" |
|
Patch 3: "[3/3] iommu/riscv: Avoid waiting on failed command enqueue" |
|
Patch 3: "[3/3] iommu/riscv: Avoid waiting on failed command enqueue" |
|
Patch 3: "[3/3] iommu/riscv: Avoid waiting on failed command enqueue" |
|
Patch 3: "[3/3] iommu/riscv: Avoid waiting on failed command enqueue" |
|
Patch 3: "[3/3] iommu/riscv: Avoid waiting on failed command enqueue" |
|
Patch 3: "[3/3] iommu/riscv: Avoid waiting on failed command enqueue" |
|
Patch 3: "[3/3] iommu/riscv: Avoid waiting on failed command enqueue" |
|
Patch 3: "[3/3] iommu/riscv: Avoid waiting on failed command enqueue" |
|
Patch 3: "[3/3] iommu/riscv: Avoid waiting on failed command enqueue" |
|
Patch 3: "[3/3] iommu/riscv: Avoid waiting on failed command enqueue" |
|
Patch 3: "[3/3] iommu/riscv: Avoid waiting on failed command enqueue" |
|
Patch 3: "[3/3] iommu/riscv: Avoid waiting on failed command enqueue" |
bb1a926 to
6f6f7c0
Compare
PR for series 1147259 applied to workflow__riscv__fixes
Name: iommu/riscv: Fix command queue publishing races
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1147259
Version: 1