All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vítor Hugo Silva" <vitorhg20080@gmail.com>
Cc: linux-mm@kvack.org, pjw@kernel.org, palmer@dabbelt.com,
	aou@eecs.berkeley.edu, alex@ghiti.fr, viro@zeniv.linux.org.uk,
	brauner@kernel.org, jack@suse.cz, kees@kernel.org,
	david@kernel.org
Subject: Re: [PATCH RFC v3] riscv: Synchronize instructions written to ESP32-P4 PSRAM
Date: Tue, 01 Dec 2026 12:24:07 +0000	[thread overview]
Message-ID: <sashiko-outbox-243254@kernel.org> (raw)
In-Reply-To: <20261130122328.280061-1-vitorhg20080@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] riscv: undefined CONFIG_RISCV_ESP32P4_CLIC leaves ESP32-P4
  cache sync dead code
- [Medium] riscv: missing ESP32-P4 PSRAM cache sync in
  flush_icache_user_page()
--

commit a93787bea05c89af4cecca5e149bea63b6550ca3
Author: Vítor Hugo Silva <vitorhg20080@gmail.com>

riscv: Synchronize instructions written to ESP32-P4 PSRAM

This commit adds ESP32-P4 L1D/L2 writeback and L1I invalidation routines
for PSRAM instruction ranges, hooking them into kernel text patching,
executable loading, NOMMU mmap/brk, signal trampolines, and
riscv_flush_icache().

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..b87b06292606d 100644
> --- a/arch/riscv/include/asm/cacheflush.h
> +++ b/arch/riscv/include/asm/cacheflush.h
> @@ -75,15 +75,26 @@ void flush_icache_mm(struct mm_struct *mm, bool local);
>  
>  #endif /* CONFIG_SMP */
>  
> +#define flush_icache_range flush_icache_range
> +#ifdef CONFIG_RISCV_ESP32P4_CLIC
> +extern bool riscv_esp32p4_cache_enabled;
> +
> +void flush_icache_range(unsigned long start, unsigned long end);
> +int esp32p4_sync_user_text(unsigned long start, unsigned long end);
> +
> +#define flush_icache_user_range_checked esp32p4_sync_user_text
> +#else
> +#define riscv_esp32p4_cache_enabled false

[Severity: High]
Is a Kconfig definition for RISCV_ESP32P4_CLIC missing from this patch
(or a prerequisite series)?

RISCV_ESP32P4_CLIC is not defined in any Kconfig file in the tree, so the
#ifdef CONFIG_RISCV_ESP32P4_CLIC guards here and in setup.c, sys_riscv.c,
and arch/riscv/mm/cacheflush.c always evaluate to false, compiling out
all of the ESP32-P4 cache synchronization code.

[ ... ]

> diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c
> index f8ead7cb7c7d6..b8cebf1882105 100644
> --- a/arch/riscv/mm/cacheflush.c
> +++ b/arch/riscv/mm/cacheflush.c
> @@ -4,10 +4,147 @@

[ ... ]

> +void flush_icache_range(unsigned long start, unsigned long end)
> +{
> +	esp32p4_sync_text(start, end, true);
> +	flush_icache_all();
> +}
> +EXPORT_SYMBOL(flush_icache_range);
> +NOKPROBE_SYMBOL(flush_icache_range);
> +
> +int esp32p4_sync_user_text(unsigned long start, unsigned long end)
> +{
> +	int ret = esp32p4_sync_text(start, end, false);
> +
> +	if (!ret)
> +		flush_icache_all();
> +
> +	return ret;
> +}
> +NOKPROBE_SYMBOL(esp32p4_sync_user_text);
> +#endif

[Severity: Medium]
Should flush_icache_user_page() in arch/riscv/include/asm/cacheflush.h
also synchronize the PSRAM range on ESP32-P4?

arch/riscv/include/asm/cacheflush.h:
#define flush_icache_user_page(vma, pg, addr, len)	\
do {							\
	if (vma->vm_flags & VM_EXEC)			\
		flush_icache_mm(vma->vm_mm, 0);		\
} while (0)

When __access_remote_vm() in mm/nommu.c writes to an executable user VMA
(for example via PTRACE_POKETEXT or /proc/pid/mem), copy_to_user_page()
calls flush_icache_user_page(vma, page, vaddr, len).  Because
flush_icache_user_page() only calls flush_icache_mm(), L1D/L2 writeback
and L1I invalidation are skipped and instruction fetch can still observe
stale bytes from PSRAM.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130122328.280061-1-vitorhg20080@gmail.com?part=1


  reply	other threads:[~2026-12-01 12:24 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-25 23:30 ` [PATCH RFC 01/19] riscv: Prepare ESP32-P4 early CLIC trap vectors Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 02/19] riscv: Handle ESP32-P4 CLIC trap context Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 03/19] dt-bindings: interrupt-controller: Add Espressif ESP32-P4 CLIC Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 04/19] irqchip: Add Espressif ESP32-P4 CLIC support Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 05/19] dt-bindings: interrupt-controller: Add Espressif ESP32-P4 interrupt matrix Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 06/19] irqchip: Add Espressif ESP32-P4 interrupt matrix support Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 07/19] dt-bindings: timer: Add Espressif ESP32-P4 CLINT Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 08/19] clocksource/drivers/timer-clint: Add Espressif ESP32-P4 support Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-26 23:32   ` sashiko-bot
2026-11-27 16:18   ` [PATCH RFC v2] " Vítor Hugo Silva
2026-11-27 16:18     ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 09/19] dt-bindings: serial: Add Espressif ESP32-P4 UART Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 10/19] serial: esp32: Restore the ESP32 UART driver Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-26 23:32   ` sashiko-bot
2026-11-27 16:55   ` [PATCH RFC 1/4] serial: esp32: Validate the baud rate before programming the UART Vítor Hugo Silva
2026-11-27 16:55     ` Vítor Hugo Silva
2026-11-27 16:55     ` [PATCH RFC 2/4] serial: esp32: Fix ESP32-S3 baud rate prescaler calculation Vítor Hugo Silva
2026-11-27 16:55       ` Vítor Hugo Silva
2026-11-27 16:55     ` [PATCH RFC 3/4] serial: esp32: Deliver and mask receive break interrupts Vítor Hugo Silva
2026-11-27 16:55       ` Vítor Hugo Silva
2026-11-27 16:55     ` [PATCH RFC 4/4] serial: esp32: Enable the UART clock during port registration Vítor Hugo Silva
2026-11-27 16:55       ` Vítor Hugo Silva
2026-11-27 19:25   ` [PATCH RFC 1/2] serial: esp32: Enable hardware RTS/CTS flow control Vítor Hugo Silva
2026-11-27 19:25     ` Vítor Hugo Silva
2026-11-27 19:25     ` [PATCH RFC 2/2] serial: esp32: Report active-low CTS correctly on ESP32-S3 and ESP32-P4 Vítor Hugo Silva
2026-11-27 19:25       ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 11/19] serial: esp32: Add support for the ESP32-P4 UART Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-26 23:32   ` sashiko-bot
2026-11-27 19:39   ` [PATCH RFC v2] " Vítor Hugo Silva
2026-11-27 19:39     ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 12/19] serial: esp32: Rearm TX interrupts when the FIFO is full Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-26 23:32   ` sashiko-bot
2026-11-27 15:40     ` Vítor Hugo Silva
2026-11-27 15:56   ` [PATCH RFC v2] " Vítor Hugo Silva
2026-11-27 15:56     ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 13/19] serial: esp32: Add early console support for ESP32-P4 Vítor Hugo Silva
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
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-26 23:32   ` sashiko-bot
2026-11-27 22:13   ` [PATCH RFC v2] " Vítor Hugo Silva
2026-11-27 22:13     ` Vítor Hugo Silva
2026-11-28 22:16     ` sashiko-bot
2026-11-30 10:31       ` Vítor Hugo Silva
2026-11-30 12:23     ` [PATCH RFC v3] " Vítor Hugo Silva
2026-11-30 12:23       ` Vítor Hugo Silva
2026-12-01 12:24       ` sashiko-bot [this message]
2026-11-25 23:30 ` [PATCH RFC 15/19] riscv: Align init data to the ESP32-P4 PMP granularity Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 16/19] dt-bindings: riscv: Add Waveshare ESP32-P4-Module-DEV-KIT Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 17/19] dt-bindings: riscv: cpus: Document Espressif ESP32-P4 HP harts Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 18/19] riscv: dts: Add Waveshare ESP32-P4-Module-DEV-KIT Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-25 23:30 ` [PATCH RFC 19/19] MAINTAINERS: Add the Espressif ESP32-P4 platform Vítor Hugo Silva
2026-11-25 23:30   ` Vítor Hugo Silva
2026-11-26 23:32 ` [PATCH RFC 00/19] riscv: Add initial support for Espressif ESP32-P4 sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-243254@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=brauner@kernel.org \
    --cc=david@kernel.org \
    --cc=jack@suse.cz \
    --cc=kees@kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=viro@zeniv.linux.org.uk \
    --cc=vitorhg20080@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.