From: cp0613@linux.alibaba.com
To: samuel.holland@sifive.com
Cc: anup@brainfault.org, opensbi@lists.infradead.org
Subject: Re: [PATCH] lib: sbi: Flush cache entries after writing PMP CSRs
Date: Fri, 7 Nov 2025 15:50:38 +0800 [thread overview]
Message-ID: <20251107075038.1836-1-cp0613@linux.alibaba.com> (raw)
In-Reply-To: <560e84db-664b-4cc5-9eb3-e526e94139ad@sifive.com>
On 2025-10-30 10:36 AM, Samuel Holland wrote:
> > If hardware is filling TLB entries for M-mode then it must tag these TLB
> > entries with privilege level so that they don't match for S-mode otherwise
> > a simple M-mode to S-mode switch at boot-time will allow bootloaders
> > to access M-mode memory with M-mode permissions.
> Yes, agreed, the TLB entries must be tagged with the privilege mode, but that's
> not the problem here. The problem has nothing at all to do with privilege mode
> transitions, and nothing to do with executing code in S-mode, either. The bug
> can be observed purely within the scope of the function calling
> sbi_hart_map_saddr().
> sbi_hart_map_saddr() rewrites a PMP range to allow M-mode access to some address
> range that it previously did not have permission to access. The problem is that
> this PMP change may not be observed until software executes a sfence.vma
> covering at least this address range. So without this patch, it is
> architecturally valid to receive an access fault when M-mode attempts to access
> this address range (i.e. on the very next line of code after calling
> sbi_hart_map_saddr()).
Hi Samuel,
Thank you so much for participating in the discussion.
You pointed out the key points, this is indeed a case.
Thanks,
Pei
> > Regards,
> > Samuel
> >>> Further, flushing TLB entries in sbi_hart_map/unmap_saddr() also
> >>> slows-down many SBI calls which use shared memory.
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
prev parent reply other threads:[~2025-11-07 7:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 9:54 [PATCH] lib: sbi: Flush cache entries after writing PMP CSRs cp0613
2025-10-20 4:36 ` Anup Patel
2025-10-29 22:32 ` Samuel Holland
2025-10-30 5:50 ` Anup Patel
2025-10-30 10:36 ` Samuel Holland
2025-10-31 3:49 ` Anup Patel
2025-11-07 8:13 ` cp0613
2025-11-07 7:50 ` cp0613 [this message]
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=20251107075038.1836-1-cp0613@linux.alibaba.com \
--to=cp0613@linux.alibaba.com \
--cc=anup@brainfault.org \
--cc=opensbi@lists.infradead.org \
--cc=samuel.holland@sifive.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox