All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rishab Pradeep <rishab@rispop.dev>
To: qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, richard.henderson@linaro.org,
	pbonzini@redhat.com, palmer@dabbelt.com,
	alistair.francis@wdc.com, liwei1518@gmail.com,
	daniel.barboza@oss.qualcomm.com, zhiwei_liu@linux.alibaba.com,
	chao.liu@processmission.com, tarun.patanjali@utexas.edu,
	christopher.elwood2024@gmail.com,
	Rishab Pradeep <rishab@rispop.dev>
Subject: [RFC PATCH 1/2] accel/tcg: Add probe_access_perm()
Date: Tue, 24 Nov 2026 01:18:35 -0600	[thread overview]
Message-ID: <20261124071836.208740-2-rishab@rispop.dev> (raw)
In-Reply-To: <20261124071836.208740-1-rishab@rispop.dev>

Add a permission-only variant of probe_access() for callers that need
a faulting translation check without the side effects of an access.
The first user is the RISC-V Zicfiss AMO check in the next patch.

After a successful lookup it does not process watchpoints, mark clean
RAM dirty, or request the plugin slow path.  It also does not assert
that (addr, size) stays within one page: a caller probing the first
page of a page-crossing access should pass the full size, so that
target hooks (e.g. RISC-V PMP) see the same range as the real access,
and then probe the second page itself.

Side effects of the target's tlb_fill hook still apply, for example a
page walk updating guest PTE A/D bits.

Co-developed-by: Tarun Patanjali <tarun.patanjali@utexas.edu>
Signed-off-by: Tarun Patanjali <tarun.patanjali@utexas.edu>
Co-developed-by: Chris Elwood <christopher.elwood2024@gmail.com>
Signed-off-by: Chris Elwood <christopher.elwood2024@gmail.com>
Signed-off-by: Rishab Pradeep <rishab@rispop.dev>
---
 accel/tcg/cputlb.c        | 11 +++++++++++
 include/accel/tcg/probe.h | 20 ++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index d79eae58df..6144a4efb0 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1435,6 +1435,17 @@ int probe_access_flags(CPUArchState *env, vaddr addr, int size,
     return flags;
 }
 
+void probe_access_perm(CPUArchState *env, vaddr addr, int fault_size,
+                       MMUAccessType access_type, int mmu_idx,
+                       uintptr_t retaddr)
+{
+    CPUTLBEntryFull *full;
+    void *host;
+
+    probe_access_internal(env_cpu(env), addr, fault_size, access_type,
+                          mmu_idx, false, &host, &full, retaddr, false);
+}
+
 void *probe_access(CPUArchState *env, vaddr addr, int size,
                    MMUAccessType access_type, int mmu_idx, uintptr_t retaddr)
 {
diff --git a/include/accel/tcg/probe.h b/include/accel/tcg/probe.h
index 0b788901ba..4233aa9489 100644
--- a/include/accel/tcg/probe.h
+++ b/include/accel/tcg/probe.h
@@ -71,6 +71,26 @@ int probe_access_flags(CPUArchState *env, vaddr addr, int size,
 
 #ifndef CONFIG_USER_ONLY
 
+/**
+ * probe_access_perm:
+ * @env: CPUArchState
+ * @addr: guest virtual address to look up
+ * @fault_size: size passed to the target's tlb_fill (not asserted to
+ *              stay within one page; the caller splits page crossings)
+ * @access_type: read, write or execute permission
+ * @mmu_idx: MMU index to use for lookup
+ * @retaddr: return address for unwinding
+ *
+ * Permission-only lookup.  Raise an exception if the page does not
+ * satisfy @access_type.  Unlike probe_access, after a successful lookup
+ * do not process watchpoints or mark clean RAM dirty, and do not request
+ * plugin slow-path.  Side effects of the target's tlb_fill hook still
+ * apply, for example a page walk updating guest PTE A/D bits.
+ */
+void probe_access_perm(CPUArchState *env, vaddr addr, int fault_size,
+                       MMUAccessType access_type, int mmu_idx,
+                       uintptr_t retaddr);
+
 /**
  * probe_access_full:
  * Like probe_access_flags, except also return into @pfull.
-- 
2.56.0



  reply	other threads:[~2026-11-24  7:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  7:18 [RFC PATCH 0/2] target/riscv: Check store permission before split AMOs with Zicfiss Rishab Pradeep
2026-11-24  7:18 ` Rishab Pradeep [this message]
2026-11-24  7:18 ` [RFC PATCH 2/2] " Rishab Pradeep

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=20261124071836.208740-2-rishab@rispop.dev \
    --to=rishab@rispop.dev \
    --cc=alistair.francis@wdc.com \
    --cc=chao.liu@processmission.com \
    --cc=christopher.elwood2024@gmail.com \
    --cc=daniel.barboza@oss.qualcomm.com \
    --cc=liwei1518@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=tarun.patanjali@utexas.edu \
    --cc=zhiwei_liu@linux.alibaba.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.