public inbox for opensbi@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] lib: sbi: Flush cache entries after writing PMP CSRs
@ 2026-02-26 12:34 cp0613
  2026-02-26 12:34 ` [PATCH v2 1/2] lib: sbi: Introduce sbi_hart_pmp_fence_vma cp0613
  2026-02-26 12:34 ` [PATCH v2 2/2] lib: sbi: Flush cache entries after writing PMP CSRs cp0613
  0 siblings, 2 replies; 5+ messages in thread
From: cp0613 @ 2026-02-26 12:34 UTC (permalink / raw)
  To: opensbi; +Cc: anup, samuel.holland, guoren, Chen Pei

From: Chen Pei <cp0613@linux.alibaba.com>

As the privileged specification states, after writing to the PMP CSRs,
a SFENCE.VMA or HFENCE.GVMA instruction should be executed with rs1=x0
and rs2=x0 to flush all address translation cache entries.

The original implementation does not cover all possible cases. For
example, the unconfigure and map_range/unmap_range functions of
sbi_hart_protection calls pmp_set but does not execute the SFENCE.VMA
instruction. This patch covers these cases, ensuring that dbtr, sse, and
other modules can safely update pmpcfg.

Considering the performance issues caused by flush all address translation
cache entries, sbi_hart_pmp_fence_vma is introduced to flush only the
entries corresponding to a given address and size.

Changes in v2:
 - Introduce sbi_hart_pmp_fence_vma
 - Use sbi_hart_pmp_fence_vma when calling map_range/unmap_range in
   sbi_hart_protection to avoid performance issues caused by using
   sbi_hart_pmp_fence_all.

Chen Pei (2):
  lib: sbi: Introduce sbi_hart_pmp_fence_vma
  lib: sbi: Flush cache entries after writing PMP CSRs

 include/sbi/sbi_hart_pmp.h       |  3 ++-
 lib/sbi/sbi_hart_pmp.c           | 41 ++++++++++++++++++++++++++++----
 platform/generic/eswin/eic770x.c |  2 +-
 3 files changed, 40 insertions(+), 6 deletions(-)

-- 
2.50.1


-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-02-28  5:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-26 12:34 [PATCH v2 0/2] lib: sbi: Flush cache entries after writing PMP CSRs cp0613
2026-02-26 12:34 ` [PATCH v2 1/2] lib: sbi: Introduce sbi_hart_pmp_fence_vma cp0613
2026-02-26 12:34 ` [PATCH v2 2/2] lib: sbi: Flush cache entries after writing PMP CSRs cp0613
2026-02-27  1:19   ` Guo Ren
2026-02-27  1:21   ` Guo Ren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox