From: Tim <mdspan.github@gmail.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, richard.henderson@linaro.org,
zhao1.liu@intel.com, Tim <mdspan.github@gmail.com>
Subject: [PATCH v2 2/5] accel/tcg: compare large pages under the flush mask
Date: Fri, 20 Nov 2026 10:44:28 +0000 [thread overview]
Message-ID: <20261120104431.733136-3-mdspan.github@gmail.com> (raw)
In-Reply-To: <20261120104431.733136-1-mdspan.github@gmail.com>
tlb_flush_range_locked() flushes entries whose address matches the
range under @mask, the low @bits of the address. Its large page
check, however, compares the range end with the recorded large page
in all bits. If the large page was entered under an address that
differs from the flushed range above @bits, the check fails, and the
large page is not flushed.
Compare under @mask as well. This matters for the x86 LAM emulation
in a later patch, which installs TLB entries under tagged addresses
and flushes every tagged alias on INVLPG of the untagged address with
tlb_flush_page_bits_by_mmuidx().
Signed-off-by: Tim <mdspan.github@gmail.com>
---
accel/tcg/cputlb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index dc83f3ba..ad2a5aa1 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -691,8 +691,10 @@ static void tlb_flush_range_locked(CPUState *cpu, int midx,
* Check if we need to flush due to large pages.
* Because large_page_mask contains all 1's from the msb,
* we only need to test the end of the range.
+ * Compare under @mask, ignoring bits above @bits.
*/
- if (((addr + len - 1) & d->large_page_mask) == d->large_page_addr) {
+ if (((addr + len - 1) & d->large_page_mask & mask) ==
+ (d->large_page_addr & mask)) {
tlb_debug("forcing full flush midx %d ("
"%016" VADDR_PRIx "/%016" VADDR_PRIx ")\n",
midx, d->large_page_addr, d->large_page_mask);
--
2.47.3
next prev parent reply other threads:[~2026-11-20 10:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 10:44 [PATCH v2 0/5] target/i386: emulate LAM in TCG Tim
2026-11-20 10:44 ` [PATCH v2 1/5] target/i386: mask the PML5 table address taken from CR3 Tim
2026-11-20 10:44 ` Tim [this message]
2026-11-20 10:44 ` [PATCH v2 3/5] target/i386: use separate MMU indexes for instruction fetch Tim
2026-11-20 18:31 ` Richard Henderson
2026-11-20 10:44 ` [PATCH v2 4/5] target/i386: emulate LAM in TCG Tim
2026-11-20 10:44 ` [PATCH v2 5/5] tests/tcg/x86_64: add a LAM system test Tim
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=20261120104431.733136-3-mdspan.github@gmail.com \
--to=mdspan.github@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=zhao1.liu@intel.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.