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 v3 0/5] target/i386: emulate LAM in TCG
Date: Tue, 24 Nov 2026 10:16:49 +0000 [thread overview]
Message-ID: <20261124101655.2269531-1-mdspan.github@gmail.com> (raw)
This series emulates LAM in TCG for x86_64 system mode and reports it
in "-cpu max". linux-user support will follow in a separate series.
Patch 1 keeps the CR3 LAM bits out of the PML5 table address. Patch 2
makes the large-page check in tlb_flush_range_locked() compare under
the flush mask, as agreed in [2]. Patch 3 adds MMU indexes for
LAM-masked data accesses. Patch 4 is the LAM emulation, and patch 5
adds a system-mode test.
The design follows the RFC thread [1]:
- On a TLB miss, get_physical_address() masks the address and runs
the canonical check and the page walk on the result. The entry is
installed under the tagged address, so each tag of a page has its
own entry. INVLPG and INVLPGA flush every tagged alias with
tlb_flush_page_bits_by_mmuidx(), and a change of CR4.LAM_SUP
flushes the TLB.
- Patch 3 adds LAM forms of the three 64-bit data MMU indexes and an
hflags bit, HF_LAM, that is set while LAM is enabled. With HF_LAM
set, data accesses use the LAM indexes, and only those are masked.
Instruction fetches always use the normal indexes, so fetch and
data entries for a tagged address are in separate TLBs. Without
LAM, only the normal indexes are used.
- Exceptions do not report the tagged address, which answers
Richard's question [3]. On #PF, CR2 receives the masked address
(SDM Vol. 3A, section 4.4.3), and #GP reports no address.
- gdbstub, monitor, and qemu_plugin_translate_vaddr() translate a
tagged address as a data access does.
Known gaps:
- Data breakpoints on an untagged address do not fire for accesses
through a tagged alias.
- With LAM_U48 and 5-level paging, gdbstub, monitor, and
qemu_plugin_translate_vaddr() translate an instruction address at
or above 2^47 as a data address, not as a fetch does.
v3:
- Patch 3: LAM forms of the 64-bit data MMU indexes, selected by the
new HF_LAM bit, in place of the fetch MMU indexes, as Richard
suggested [5] and agreed [6].
- Patch 4: mask only for the LAM MMU indexes.
- Patch 5: test exception delivery with a tagged IDTR base, which
covers the LAM indexes from x86_mmu_index_kernel_pl().
v2:
- New patch 3: separate MMU indexes for instruction fetch, as
Richard suggested [4].
- Patch 4: mask only for non-fetch MMU indexes.
- Patch 5: set exe_name only where it differs from the default, for
the check added in commit 1138de1d.
v2: https://lore.kernel.org/qemu-devel/20261120104431.733136-1-mdspan.github@gmail.com/
v1: https://lore.kernel.org/qemu-devel/20261110130108.706228-1-mdspan.github@gmail.com/
[1] https://lists.nongnu.org/archive/html/qemu-devel/2026-10/msg01840.html
[2] https://lists.nongnu.org/archive/html/qemu-devel/2026-11/msg01599.html
[3] https://lists.nongnu.org/archive/html/qemu-devel/2026-10/msg05620.html
[4] https://lore.kernel.org/qemu-devel/4a2dd42c-fe8e-46ad-a74c-bae94d088be8@linaro.org/
[5] https://lists.nongnu.org/archive/html/qemu-devel/2026-11/msg04655.html
[6] https://lists.nongnu.org/archive/html/qemu-devel/2026-11/msg04942.html
Tim (5):
target/i386: mask the PML5 table address taken from CR3
accel/tcg: compare large pages under the flush mask
target/i386: add MMU indexes for LAM-masked data accesses
target/i386: emulate LAM in TCG
tests/tcg/x86_64: add a LAM system test
accel/tcg/cputlb.c | 4 +-
target/i386/cpu.c | 2 +-
target/i386/cpu.h | 89 ++-
target/i386/helper.c | 21 +-
target/i386/tcg/seg_helper.c | 2 +-
target/i386/tcg/system/excp_helper.c | 15 +-
target/i386/tcg/system/misc_helper.c | 24 +-
target/i386/tcg/system/svm_helper.c | 3 +-
target/i386/tcg/tcg-cpu.c | 12 +-
tests/tcg/x86_64/system/boot.S | 14 +
tests/tcg/x86_64/system/lam.c | 835 +++++++++++++++++++++++++++
tests/tcg/x86_64/system/meson.build | 16 +
12 files changed, 1018 insertions(+), 19 deletions(-)
create mode 100644 tests/tcg/x86_64/system/lam.c
base-commit: 45b7c3e45e2b778e560a0734daa6aa0059bc0edc
--
2.47.3
next reply other threads:[~2026-11-24 10:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 10:16 Tim [this message]
2026-11-24 10:16 ` [PATCH v3 1/5] target/i386: mask the PML5 table address taken from CR3 Tim
2026-11-24 10:16 ` [PATCH v3 2/5] accel/tcg: compare large pages under the flush mask Tim
2026-11-24 10:16 ` [PATCH v3 3/5] target/i386: add MMU indexes for LAM-masked data accesses Tim
2026-11-24 10:16 ` [PATCH v3 4/5] target/i386: emulate LAM in TCG Tim
2026-11-24 10:16 ` [PATCH v3 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=20261124101655.2269531-1-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.