* [PATCH RFC 00/19] riscv: Add initial support for Espressif ESP32-P4
@ 2026-11-25 23:30 Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 14/19] riscv: Synchronize instructions written to ESP32-P4 PSRAM Vítor Hugo Silva
0 siblings, 1 reply; 3+ messages in thread
From: Vítor Hugo Silva @ 2026-11-25 23:30 UTC (permalink / raw)
To: linux-riscv
Cc: devicetree, linux-kernel, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Alexandre Ghiti, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thomas Gleixner, Daniel Lezcano, Greg Kroah-Hartman,
Jiri Slaby, linux-serial, Christian Brauner, Kees Cook,
David Hildenbrand, linux-fsdevel, linux-mm
Hello,
This series of patches adds the initial support for the Espressif's
ESP32-P4 on the Waveshare ESP32-P4-Module-DEV-KIT. It boots in M-mode on
a RV32 NOMMU kernel with one HP hart.
The series adds CLIC trap handling, drivers for clic and for interrupt
matrix, and extends the CLINT timer driver. It restores a previously
removed ESP32 UART driver with ESP32-P4 UART support and early console
support. It also synchronizes the instructions written to the PSRAM,
aligns the init data to the ESP32-P4 PMP granularity, and it adds DT
bindings and the board devicetree.
The boot firmware initializes PSRAM, loads the kernel, DTB and the
initramfs from the microSD, and it supplies the timebase-frequency
before jumping into the kernel.
The bootloader source and microSD boot instructions are available at:
https://github.com/pushdword/waveshare-esp32-p4-bootloader/blob/390880e881208ab16aa16eb520b3e5ea0c63c0a2/README.md
I tested this series on the hardware, the Waveshare
ESP32-P4-Module-DEV-KIT with the ESP32-P4 revision v3.2 with 32MB of
PSRAM. The kernel booted to the UART shell from the initramfs. The
/proc/interrupts showed the CLINT IRQ's increased, UART0 interrupts were
routed through the interrupts matrix.
It would be nice to you all send feedback on restoring the interrupted
CLIC level before irq_exit_rcu() and the interface for propagating
instruction-cache sync failures to NOMMU executable loading, and signal
setup.
AI disclaimer: I have used 6.2-Sol to assist development and to assist
debug/troubleshoot some ongoing issues. I have used Codex's 6-Sol
with Daybreak Blue enabled to generate peer-review-like report to
pinpoint potential security issues regarding the patches. I manually
reviewed and validated each change, including the AI-assisted changes.
I also manually tested each change on the hardware as described above.
Vítor Hugo Silva (19):
riscv: Prepare ESP32-P4 early CLIC trap vectors
riscv: Handle ESP32-P4 CLIC trap context
dt-bindings: interrupt-controller: Add Espressif ESP32-P4 CLIC
irqchip: Add Espressif ESP32-P4 CLIC support
dt-bindings: interrupt-controller: Add Espressif ESP32-P4 interrupt
matrix
irqchip: Add Espressif ESP32-P4 interrupt matrix support
dt-bindings: timer: Add Espressif ESP32-P4 CLINT
clocksource/drivers/timer-clint: Add Espressif ESP32-P4 support
dt-bindings: serial: Add Espressif ESP32-P4 UART
serial: esp32: Restore the ESP32 UART driver
serial: esp32: Add support for the ESP32-P4 UART
serial: esp32: Rearm TX interrupts when the FIFO is full
serial: esp32: Add early console support for ESP32-P4
riscv: Synchronize instructions written to ESP32-P4 PSRAM
riscv: Align init data to the ESP32-P4 PMP granularity
dt-bindings: riscv: Add Waveshare ESP32-P4-Module-DEV-KIT
dt-bindings: riscv: cpus: Document Espressif ESP32-P4 HP harts
riscv: dts: Add Waveshare ESP32-P4-Module-DEV-KIT
MAINTAINERS: Add the Espressif ESP32-P4 platform
.../esp,esp32p4-clic.yaml | 53 +
.../esp,esp32p4-intmtx.yaml | 67 ++
.../devicetree/bindings/riscv/cpus.yaml | 17 +-
.../devicetree/bindings/riscv/espressif.yaml | 22 +
.../bindings/serial/esp,esp32-uart.yaml | 4 +-
.../bindings/timer/sifive,clint.yaml | 28 +
MAINTAINERS | 14 +
arch/riscv/Kconfig.socs | 9 +
arch/riscv/boot/dts/Makefile | 1 +
arch/riscv/boot/dts/espressif/Makefile | 2 +
.../esp32p4-waveshare-module-dev-kit.dts | 46 +
arch/riscv/boot/dts/espressif/esp32p4.dtsi | 64 ++
arch/riscv/include/asm/asm-prototypes.h | 4 +
arch/riscv/include/asm/cacheflush.h | 6 +
arch/riscv/include/asm/ptrace.h | 4 +
arch/riscv/kernel/asm-offsets.c | 3 +
arch/riscv/kernel/entry.S | 67 ++
arch/riscv/kernel/head.S | 13 +
arch/riscv/kernel/patch.c | 132 ++-
arch/riscv/kernel/signal.c | 6 +-
arch/riscv/kernel/traps.c | 4 +
arch/riscv/kernel/vmlinux.lds.S | 4 +
drivers/clocksource/timer-clint.c | 57 +-
drivers/irqchip/Makefile | 2 +
drivers/irqchip/irq-esp32p4-clic.c | 178 ++++
drivers/irqchip/irq-esp32p4-intmtx.c | 139 +++
drivers/tty/serial/Kconfig | 15 +
drivers/tty/serial/Makefile | 1 +
drivers/tty/serial/esp32_uart.c | 940 ++++++++++++++++++
fs/binfmt_flat.c | 6 +-
fs/exec.c | 10 +-
include/linux/cacheflush.h | 7 +
32 files changed, 1910 insertions(+), 15 deletions(-)
create mode 100644 Documentation/devicetree/bindings/interrupt-controller/esp,esp32p4-clic.yaml
create mode 100644 Documentation/devicetree/bindings/interrupt-controller/esp,esp32p4-intmtx.yaml
create mode 100644 Documentation/devicetree/bindings/riscv/espressif.yaml
create mode 100644 arch/riscv/boot/dts/espressif/Makefile
create mode 100644 arch/riscv/boot/dts/espressif/esp32p4-waveshare-module-dev-kit.dts
create mode 100644 arch/riscv/boot/dts/espressif/esp32p4.dtsi
create mode 100644 drivers/irqchip/irq-esp32p4-clic.c
create mode 100644 drivers/irqchip/irq-esp32p4-intmtx.c
create mode 100644 drivers/tty/serial/esp32_uart.c
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
--
2.56.1
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH RFC 14/19] riscv: Synchronize instructions written to ESP32-P4 PSRAM 2026-11-25 23:30 [PATCH RFC 00/19] riscv: Add initial support for Espressif ESP32-P4 Vítor Hugo Silva @ 2026-11-25 23:30 ` Vítor Hugo Silva 2026-11-26 23:32 ` sashiko-bot 0 siblings, 1 reply; 3+ messages in thread From: Vítor Hugo Silva @ 2026-11-25 23:30 UTC (permalink / raw) To: linux-riscv Cc: devicetree, linux-kernel, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Alexander Viro, Christian Brauner, Jan Kara, Kees Cook, David Hildenbrand, linux-fsdevel, linux-mm On ESP32-P4, a load can observe new instruction bytes in the data cache while the instruction fetch path still sees old bytes. The runtime constant patching code can then execute stale instructions and use an invalid address during boot. Write back the L1 data and L2 caches for the modified PSRAM range, invalidate the local L1 instruction cache for that range and issue fence.i before executing the modified instructions. Apply the same sequence to NOMMU userspace code, including FLAT binaries and the signal return trampoline. Split the aligned range into 32 KiB chunks and restore the caller's IRQ state after each chunk. In instrumented measurements on the Waveshare board, the longest observed IRQ-disabled window fell from 2.69 ms with 128 KiB chunks to 1.13 ms with 32 KiB chunks. Bound cache synchronization by a fixed number of reads per command. After a timeout, stop issuing commands because the controller may still be busy. Propagate failures through executable loading and signal setup. Treat a failure to synchronize patched kernel text as fatal. The ESP32-P4 board probe observed stale instructions after fence.i alone. Combining data writeback and instruction cache invalidation made the modified instructions visible. Verified boot to the UART shell on a Waveshare ESP32-P4-Module-DEV-KIT with SDMMC disabled in Linux. The shell handled SIGUSR1 and resumed execution. With CLIC disabled, the RV32 NOMMU patch.o and signal.o matched the reference byte for byte. AI assisted with isolating the cache synchronization change from the rest of the ESP32-P4 port. Link: https://docs.espressif.com/projects/esp-idf/en/stable/esp32p4/api-reference/system/mm_sync.html Signed-off-by: Vítor Hugo Silva <vitorhg20080@gmail.com> --- arch/riscv/include/asm/cacheflush.h | 6 ++ arch/riscv/kernel/patch.c | 132 +++++++++++++++++++++++++++- arch/riscv/kernel/signal.c | 6 +- fs/binfmt_flat.c | 6 +- fs/exec.c | 10 ++- include/linux/cacheflush.h | 7 ++ 6 files changed, 160 insertions(+), 7 deletions(-) diff --git a/arch/riscv/include/asm/cacheflush.h b/arch/riscv/include/asm/cacheflush.h index c2b0a2928f06..a5c20d7d1c9d 100644 --- a/arch/riscv/include/asm/cacheflush.h +++ b/arch/riscv/include/asm/cacheflush.h @@ -85,6 +85,12 @@ static inline void flush_icache_range(unsigned long start, unsigned long end) flush_icache_all(); } +#ifdef CONFIG_RISCV_ESP32P4_CLIC +int esp32p4_sync_user_text(unsigned long start, unsigned long end); + +#define flush_icache_user_range_checked esp32p4_sync_user_text +#endif + extern unsigned int riscv_cbom_block_size; extern unsigned int riscv_cboz_block_size; extern unsigned int riscv_cbop_block_size; diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c index 2b5adf01c550..e0687c943358 100644 --- a/arch/riscv/kernel/patch.c +++ b/arch/riscv/kernel/patch.c @@ -3,6 +3,13 @@ * Copyright (C) 2020 SiFive */ +#ifdef CONFIG_RISCV_ESP32P4_CLIC +#include <linux/align.h> +#include <linux/io.h> +#include <linux/irqflags.h> +#include <linux/panic.h> +#include <linux/sizes.h> +#endif #include <linux/spinlock.h> #include <linux/mm.h> #include <linux/memory.h> @@ -173,9 +180,132 @@ static int __patch_insn_set(void *addr, u8 c, size_t len) } NOKPROBE_SYMBOL(__patch_insn_set); +#ifdef CONFIG_RISCV_ESP32P4_CLIC +#define ESP32P4_CACHE_BASE 0x3ff10000 +#define ESP32P4_CACHE_SYNC_CTRL 0x98 +#define ESP32P4_CACHE_SYNC_MAP 0x9c +#define ESP32P4_CACHE_SYNC_ADDR 0xa0 +#define ESP32P4_CACHE_SYNC_SIZE 0xa4 + +#define ESP32P4_CACHE_INVALIDATE BIT(0) +#define ESP32P4_CACHE_WRITEBACK BIT(2) +#define ESP32P4_CACHE_SYNC_DONE BIT(4) +#define ESP32P4_CACHE_SYNC_MAX_POLLS 1000000 + +#define ESP32P4_CACHE_L1_I0 BIT(0) +#define ESP32P4_CACHE_L1_D BIT(4) +#define ESP32P4_CACHE_L2 BIT(5) + +#define ESP32P4_PSRAM_START 0x48000000UL +#define ESP32P4_PSRAM_END 0x4c000000UL +#define ESP32P4_CACHE_MAX_LINE 128 + +static int esp32p4_cache_sync(u32 map, u32 start, u32 size, u32 op, + unsigned int count) +{ + /* The caller holds local IRQs disabled on the single supported hart. */ + static bool sync_failed; + void __iomem *base = (void __iomem *)ESP32P4_CACHE_BASE; + unsigned int polls; + + if (sync_failed) + return -EIO; + + writel(map, base + ESP32P4_CACHE_SYNC_MAP); + writel(start, base + ESP32P4_CACHE_SYNC_ADDR); + writel(size, base + ESP32P4_CACHE_SYNC_SIZE); + + while (count--) { + writel(op, base + ESP32P4_CACHE_SYNC_CTRL); + /* Order the sync command before reading its completion status. */ + mb(); + for (polls = 0; polls < ESP32P4_CACHE_SYNC_MAX_POLLS; polls++) { + if (readl(base + ESP32P4_CACHE_SYNC_CTRL) & ESP32P4_CACHE_SYNC_DONE) + break; + cpu_relax(); + } + if (polls == ESP32P4_CACHE_SYNC_MAX_POLLS) { + sync_failed = true; + return -ETIMEDOUT; + } + } + + return 0; +} + +static int esp32p4_cache_writeback(u32 start, u32 size) +{ + int ret; + + /* Repeat writeback to avoid losing a sync with conflicting writes. */ + ret = esp32p4_cache_sync(ESP32P4_CACHE_L1_D, start, size, ESP32P4_CACHE_WRITEBACK, 2); + if (ret) + return ret; + + return esp32p4_cache_sync(ESP32P4_CACHE_L2, start, size, ESP32P4_CACHE_WRITEBACK, 2); +} + +static int esp32p4_sync_text(void *addr, size_t len, bool fatal) +{ + unsigned long start = (unsigned long)addr; + unsigned long first, end, flags; + + if (start < ESP32P4_PSRAM_START || start >= ESP32P4_PSRAM_END || + !len || len > ESP32P4_PSRAM_END - start) + return 0; + + first = ALIGN_DOWN(start, ESP32P4_CACHE_MAX_LINE); + end = ALIGN(start + len, ESP32P4_CACHE_MAX_LINE); + + /* Allow interrupts between chunks if they were enabled on entry. */ + while (first < end) { + u32 size = min_t(u32, end - first, SZ_32K); + int ret; + + local_irq_save(flags); + ret = esp32p4_cache_writeback(first, size); + if (!ret) + ret = esp32p4_cache_sync(ESP32P4_CACHE_L1_I0, first, size, + ESP32P4_CACHE_INVALIDATE, 1); + if (ret) { + if (fatal) + panic("ESP32-P4 text cache sync failed: %d\n", ret); + local_irq_restore(flags); + return ret; + } + + local_flush_icache_all(); + local_irq_restore(flags); + first += size; + } + + return 0; +} + +int esp32p4_sync_user_text(unsigned long start, unsigned long end) +{ + int ret; + + if (end > start) { + ret = esp32p4_sync_text((void *)start, end - start, false); + if (ret) + return ret; + } + + flush_icache_range(start, end); + return 0; +} +#endif + static int __patch_insn_write(void *addr, const void *insn, size_t len) { - return copy_to_kernel_nofault(addr, insn, len); + int ret = copy_to_kernel_nofault(addr, insn, len); + +#ifdef CONFIG_RISCV_ESP32P4_CLIC + if (!ret) + esp32p4_sync_text(addr, len, true); +#endif + return ret; } NOKPROBE_SYMBOL(__patch_insn_write); #endif /* CONFIG_MMU */ diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c index 59784dc117e4..05266d7c1466 100644 --- a/arch/riscv/kernel/signal.c +++ b/arch/riscv/kernel/signal.c @@ -7,6 +7,7 @@ */ #include <linux/compat.h> +#include <linux/cacheflush.h> #include <linux/signal.h> #include <linux/uaccess.h> #include <linux/syscalls.h> @@ -21,7 +22,6 @@ #include <asm/switch_to.h> #include <asm/vector.h> #include <asm/csr.h> -#include <asm/cacheflush.h> #include <asm/usercfi.h> unsigned long signal_minsigstksz __ro_after_init; @@ -453,7 +453,9 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, addr = (unsigned long)&frame->sigreturn_code; /* Make sure the two instructions are pushed to icache. */ - flush_icache_range(addr, addr + sizeof(frame->sigreturn_code)); + err = flush_icache_user_range_checked(addr, addr + sizeof(frame->sigreturn_code)); + if (err) + return err; regs->ra = addr; #endif /* CONFIG_MMU */ diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index b5b5ca1a44f7..890a81d805dc 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -32,6 +32,7 @@ #include <linux/user.h> #include <linux/slab.h> #include <linux/binfmts.h> +#include <linux/cacheflush.h> #include <linux/personality.h> #include <linux/init.h> #include <linux/flat.h> @@ -40,7 +41,6 @@ #include <asm/byteorder.h> #include <linux/unaligned.h> -#include <asm/cacheflush.h> #include <asm/page.h> #include <asm/flat.h> @@ -830,7 +830,9 @@ static int load_flat_file(struct linux_binprm *bprm, #endif /* CONFIG_BINFMT_FLAT_OLD */ } - flush_icache_user_range(start_code, end_code); + ret = flush_icache_user_range_checked(start_code, end_code); + if (ret) + return ret; /* zero the BSS, BRK and stack areas */ if (clear_user((void __user *)(datapos + data_len), bss_len + diff --git a/fs/exec.c b/fs/exec.c index 8d2b14e1d455..9066d2bebd1a 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -23,6 +23,7 @@ * formats. */ +#include <linux/cacheflush.h> #include <linux/kernel_read_file.h> #include <linux/slab.h> #include <linux/file.h> @@ -827,8 +828,13 @@ EXPORT_SYMBOL(open_exec); ssize_t read_code(struct file *file, unsigned long addr, loff_t pos, size_t len) { ssize_t res = vfs_read(file, (void __user *)addr, len, &pos); - if (res > 0) - flush_icache_user_range(addr, addr + len); + + if (res > 0) { + int ret = flush_icache_user_range_checked(addr, addr + len); + + if (ret) + return ret; + } return res; } EXPORT_SYMBOL(read_code); diff --git a/include/linux/cacheflush.h b/include/linux/cacheflush.h index 55f297b2c23f..6a7d6f425737 100644 --- a/include/linux/cacheflush.h +++ b/include/linux/cacheflush.h @@ -26,4 +26,11 @@ static inline void flush_icache_pages(struct vm_area_struct *vma, #define flush_icache_page(vma, page) flush_icache_pages(vma, page, 1) +#ifndef flush_icache_user_range_checked +#define flush_icache_user_range_checked(start, end) ({ \ + flush_icache_user_range((start), (end)); \ + 0; \ +}) +#endif + #endif /* _LINUX_CACHEFLUSH_H */ -- 2.56.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RFC 14/19] riscv: Synchronize instructions written to ESP32-P4 PSRAM 2026-11-25 23:30 ` [PATCH RFC 14/19] riscv: Synchronize instructions written to ESP32-P4 PSRAM Vítor Hugo Silva @ 2026-11-26 23:32 ` sashiko-bot 0 siblings, 0 replies; 3+ messages in thread From: sashiko-bot @ 2026-11-26 23:32 UTC (permalink / raw) To: Vítor Hugo Silva Cc: devicetree, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Alexander Viro, Christian Brauner, Jan Kara, Kees Cook, David Hildenbrand, linux-mm Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] riscv: missing ESP32-P4 icache sync in NOMMU mmap/brk and flush syscall - [Medium] riscv: missing esp32p4_sync_text() in NOMMU __patch_insn_set() - [Medium] riscv: missing NOKPROBE_SYMBOL() on ESP32-P4 text sync helpers -- commit 7842ba5a926e273d15f8232bcb20b17ab7d9d227 Author: Vítor Hugo Silva <vitorhg20080@gmail.com> riscv: Synchronize instructions written to ESP32-P4 PSRAM This commit adds ESP32-P4 PSRAM L1D/L2 writeback and L1I invalidation helpers and wires them into NOMMU kernel instruction patching, executable loading, and signal frame setup. Link: https://docs.espressif.com/projects/esp-idf/en/stable/esp32p4/api-reference/system/mm_sync.html > diff --git a/arch/riscv/include/asm/cacheflush.h b/arch/riscv/include/asm/cacheflush.h > index c2b0a2928f067..a5c20d7d1c9d8 100644 > --- a/arch/riscv/include/asm/cacheflush.h > +++ b/arch/riscv/include/asm/cacheflush.h > @@ -85,6 +85,12 @@ static inline void flush_icache_range(unsigned long start, unsigned long end) > flush_icache_all(); > } > > +#ifdef CONFIG_RISCV_ESP32P4_CLIC > +int esp32p4_sync_user_text(unsigned long start, unsigned long end); > + > +#define flush_icache_user_range_checked esp32p4_sync_user_text > +#endif > + > extern unsigned int riscv_cbom_block_size; > extern unsigned int riscv_cboz_block_size; > extern unsigned int riscv_cbop_block_size; [Severity: Medium] Does leaving flush_icache_user_range() as a plain fence.i miss executable NOMMU mappings created via do_mmap()? In mm/nommu.c, do_mmap_private() populates private mappings in PSRAM with kernel_read() and do_mmap() then flushes them via flush_icache_user_range(): mm/nommu.c:do_mmap() { ... if (vma->vm_flags & VM_EXEC && !region->vm_icache_flushed) { flush_icache_user_range(region->vm_start, region->vm_end); region->vm_icache_flushed = true; } ... } When an ELF FDPIC binary is loaded via elf_fdpic_map_file_by_direct_mmap() or userspace creates a PROT_EXEC mapping, instruction fetch can still observe stale PSRAM instructions because L1D/L2 are not written back and L1_I0 is not invalidated. The NOMMU brk() path in mm/nommu.c and sys_riscv_flush_icache() also still only execute fence.i without synchronizing the ESP32-P4 caches. > diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c > index 2b5adf01c5502..e0687c943358e 100644 > --- a/arch/riscv/kernel/patch.c > +++ b/arch/riscv/kernel/patch.c [ ... ] > @@ -173,9 +180,132 @@ static int __patch_insn_set(void *addr, u8 c, size_t len) > } > NOKPROBE_SYMBOL(__patch_insn_set); > > +#ifdef CONFIG_RISCV_ESP32P4_CLIC [ ... ] > +static int esp32p4_cache_sync(u32 map, u32 start, u32 size, u32 op, > + unsigned int count) > +{ [ ... ] > +} > + > +static int esp32p4_cache_writeback(u32 start, u32 size) > +{ > + int ret; > + > + /* Repeat writeback to avoid losing a sync with conflicting writes. */ > + ret = esp32p4_cache_sync(ESP32P4_CACHE_L1_D, start, size, ESP32P4_CACHE_WRITEBACK, 2); > + if (ret) > + return ret; > + > + return esp32p4_cache_sync(ESP32P4_CACHE_L2, start, size, ESP32P4_CACHE_WRITEBACK, 2); > +} > + > +static int esp32p4_sync_text(void *addr, size_t len, bool fatal) > +{ [ ... ] > +} [Severity: Medium] Should esp32p4_sync_text(), esp32p4_cache_writeback(), and esp32p4_cache_sync() be marked with NOKPROBE_SYMBOL()? __patch_insn_write() is marked NOKPROBE_SYMBOL() and is called when arming or disarming kprobes and preparing single-step slots. If a kprobe is placed on any of these three helpers, patching kernel text for kprobes will recursively trap into the kprobe handler while reprogramming the cache controller. [ ... ] > +int esp32p4_sync_user_text(unsigned long start, unsigned long end) > +{ > + int ret; > + > + if (end > start) { > + ret = esp32p4_sync_text((void *)start, end - start, false); > + if (ret) > + return ret; > + } > + > + flush_icache_range(start, end); > + return 0; > +} > +#endif > + > static int __patch_insn_write(void *addr, const void *insn, size_t len) > { > - return copy_to_kernel_nofault(addr, insn, len); > + int ret = copy_to_kernel_nofault(addr, insn, len); > + > +#ifdef CONFIG_RISCV_ESP32P4_CLIC > + if (!ret) > + esp32p4_sync_text(addr, len, true); > +#endif > + return ret; > } > NOKPROBE_SYMBOL(__patch_insn_write); > #endif /* CONFIG_MMU */ [Severity: Medium] Should the !CONFIG_MMU implementation of __patch_insn_set() also call esp32p4_sync_text(addr, len, true)? __patch_insn_set() modifies kernel text with memset(addr, c, len), and its caller patch_text_set_nosync() only calls flush_icache_range(), which issues fence.i without writing back L1D/L2 or invalidating L1_I0 on ESP32-P4. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261125233020.1380594-1-vitorhg20080@gmail.com?part=14 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-26 23:32 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-25 23:30 [PATCH RFC 00/19] riscv: Add initial support for Espressif ESP32-P4 Vítor Hugo Silva 2026-11-25 23:30 ` [PATCH RFC 14/19] riscv: Synchronize instructions written to ESP32-P4 PSRAM Vítor Hugo Silva 2026-11-26 23:32 ` sashiko-bot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox