From: Dan Carpenter <dan@pereq.eu>
To: Marc Zyngier <maz@kernel.org>
Cc: "Oliver Upton" <oupton@kernel.org>,
"Fuad Tabba" <fuad.tabba@linux.dev>,
"Joey Gouly" <joey.gouly@arm.com>,
"Steffen Eiden" <seiden@linux.ibm.com>,
"Suzuki K Poulose" <suzuki.poulose@arm.com>,
"Zenghui Yu" <yuzenghui@huawei.com>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Will Deacon" <will@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Jintack Lim" <jintack.lim@linaro.org>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
"Karthik Bhargavan" <karthik@pereq.eu>,
"Clément Blaudeau" <clement@cryspen.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v2 2/4] KVM: arm64: Trap TCR2_EL1 writes when S1PIE or S1POE is hidden
Date: Fri, 20 Nov 2026 08:33:00 +0300 [thread overview]
Message-ID: <av_bjCyoM93HColG@stanley.mountain> (raw)
In-Reply-To: <86wlq8zssf.wl-maz@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 2003 bytes --]
On Thu, Nov 19, 2026 at 04:32:00PM +0000, Marc Zyngier wrote:
> On Thu, 19 Nov 2026 13:25:35 +0000,
> Dan Carpenter <dan@pereq.eu> wrote:
> >
> > A VMM can offer FEAT_TCR2 to a guest but hide FEAT_S1PIE or FEAT_S1POE,
> > for example this is done to keep the VM migratable. KVM then stops
> > loading the PIR_EL1, PIRE0_EL1 and POR_EL1 registers for that guest. But
> > the guest's writes to the TCR2_EL1 register don't trap, and the CPU still
> > acts on its PIE, POE and E0POE bits.
> >
> > If a guest turned these features on, it would run with the permission
> > settings another VM left on the CPU. Technically this is a kind of
> > information leak and a guest could figure out another guests permission
> > setting based on which accesses fault.
> >
> > For these VMs, set the TCR_EL1 bit in HFGWTR_EL2 so that writes to
> > TCR_EL1 and TCR2_EL1 trap, and clear the hidden bits in a new
> > access_tcr2_el1() handler.
> >
> > Fixes: 58627b722ee2 ("KVM: arm64: Make PIR{,E0}_EL1 UNDEF if S1PIE is not advertised to the guest")
> > Fixes: b86c9bea6349 ("KVM: arm64: Save/restore POE registers")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Dan Carpenter <dan@pereq.eu>
> > ---
> > v2: This is a new patch
> >
> > This is only a partial fix, I will update nested virtualization in the
> > next patch and the !vcpu_has_nv(vcpu) condition in __compute_hfgwtr() will
> > go away.
>
> No, I really don't want to go down that road.
>
Yeah. Thanks, Marc.
I'm still a KVM newbie. I'm embarrassed I sent that in retrospect. I
had Claude create a checklist based on analysing your review comments so
I can hopefully get ahead of it a bit. Attached for your amusement.
Apparently 10% of the time your review is "Why?"
Also Claude says that it could have found the Sashiko bugs by reviewing
patches to see if any different bugs get exposed by making a fix. We
shall see.
Btw, I'm still hoping to get you that selftest but I need to send a few
more fixes first.
regards,
dan carpenter
[-- Attachment #2: marc-review-checklist.md --]
[-- Type: text/markdown, Size: 5346 bytes --]
# Predicting Marc Zyngier's review comments (KVM/arm64)
From 1000 of Marc's review emails (`~/progs/kernel/tmp/maz_reviews/sample/`), read in four parts, plus his
replies to our own patches in November 2026. The counts are emails per 1000 (rough). The checklist is the
part to use; the rest explains it.
## Pre-send checklist
**Rationale and correctness**
- [ ] The commit message says *why*, with the concrete sequence of events that goes wrong. "Why?" / "What
is the rationale?" is his most common question (~100).
- [ ] The behaviour matches the ARM ARM (or the GIC/PSCI spec), using its terms: UNDEF, RES0, CONSTRAINED
UNPREDICTABLE. Cite the section if it isn't obvious. Not "what QEMU does" or "what x86 does" (~95).
- [ ] The root cause is fixed rather than papered over. A WARN stays until the bug behind it is fixed.
**Cost**
- [ ] Nothing new runs on every entry or exit, and nothing new traps, unless it has to. Prefer
vcpu_load()/vcpu_put() or a static key. Don't make VMs without the feature pay for it. Under nested
virtualization, ID-register reads and EL2 accesses trap, so count them. Any performance claim needs
numbers from an exit-heavy workload such as hackbench (~55).
*Ours:* trapping TCR_EL1 to fix TCR2 got "an absolute performance sink"; the `loaded` checks in
kvm_inject_nested() got "fast-path bloating".
**Minimal fixes**
- [ ] The smallest backportable change: no rework, no churn (renames, reordering, moving files,
guard() conversions), no speculative fields or hooks, no Kconfig options ("battery included") (~40).
- [ ] Fixes: points at the real culprit, and only at something actually broken. Cc: stable only if the
backport is worth having (~30).
**Reuse**
- [ ] Use the existing infrastructure instead of a parallel mechanism: generated sysreg definitions,
config.c feature maps, FGT/FGU, the trap tables, sanitised registers, vcpu requests, existing helpers.
No magic numbers or duplicate definitions; use BIT()/GENMASK()/FIELD_PREP() (~55).
**Nested virtualization**
- [ ] Nested virtualization is VHE-only, and nVHE is effectively dead for new features. Don't add code for
combinations that can't exist.
- [ ] A new trap register comes with everything it traps: encoding_to_cgt[]/encoding_to_fgt[] entries, FGU,
RES0/RES1 in kvm_init_nv_sysregs(), and VNCR where it applies. No half-done features.
- [ ] Keep nested-only hacks local, so that someone who doesn't think about nested virtualization can't undo
them by accident.
**Userspace ABI**
- [ ] Assume any VMM, in any order, and saving or restoring at any time; not only QEMU. No KVM-internal state
in the UAPI, and no new capabilities for KVM's own problems. Tracepoints and stats are ABI. Choose the
errno with care. Ask whether a WARN can be triggered from userspace: it panics under pKVM (~65).
**Locking**
- [ ] For each lock, READ_ONCE() or preempt_disable(), know what it protects against, and what stops the vcpu
running or the value changing "behind your back" (~45).
**Code style** (~70, mostly "nit:")
- [ ] Clear names (not "Java-esque"); one helper per job, written once, no single-caller one-liners; no
unneeded inline/__always_inline; no macro abuse.
- [ ] Comments only where the reason isn't obvious; no stale, wrong or obvious ones.
- [ ] Don't break lines just for 80 columns; he ignores checkpatch line length.
**Commit message**
- [ ] Short and technical: not a cover letter, not a recap of earlier versions, not marketing, no "No
functional change intended" restating what was said. It matches the code. The subject says what the
patch really does, with the right prefix ("KVM: arm64:", "KVM: arm64: nv:") (~40).
**Series and process**
- [ ] One logical change per patch, bisectable, documentation and UAPI in their own patches, the feature
enabled last, each hunk in the patch that uses it (~45).
- [ ] A cover letter; a "Changes since vN" log for each version; Cc the maintainers and earlier reviewers;
based on kvmarm/next or -rc1..-rc3, and only fixes after about -rc6; tested, and say how (QEMU as well
as kvmtool, 64K pages, lockdep, a selftest for anything with a reproducer) (~60).
- [ ] When he replies with a diff ("completely untested", "How about this instead?"), take it. If he writes a
comment, paste it in verbatim.
## What makes him blunt
Ignored review comments, missing changelogs, maintainers left off Cc, untested code ("I stopped reading
here"), churn, hand-waving about performance without numbers, "go read the x86 patch", and wrong bot
findings. He does credit correct bot findings ("Sashiko has spotted an interesting corner case") and
accepted a patch with "Assisted-by: Claude" without comment: what matters is whether the content is right.
## Our own patches, November 2026
| Patch | His comment | Checklist item |
|---|---|---|
| NULL deref v1, `loaded` checks | fast-path bloat; load the vcpu in the ioctl instead | Cost, minimal fixes |
| AT TCR2 v1 | asked for a comment explaining why it works; gave one | Paste his comment verbatim |
| TCR2 trap patches | trapping TCR_EL1 is a performance sink; load 0s instead | Cost |
| mmio_needed (Sashiko) | "multiple ways to commit" the exception state | Root cause, reuse |
next prev parent reply other threads:[~2026-11-20 5:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 13:25 [PATCH v2 0/4] KVM: arm64: nv: Fix AT emulation for nested virtualization Dan Carpenter
2026-11-19 13:25 ` [PATCH v2 1/4] KVM: arm64: nv: Fix AT emulation for TCR2_EL1 Dan Carpenter
2026-11-19 13:25 ` [PATCH v2 2/4] KVM: arm64: Trap TCR2_EL1 writes when S1PIE or S1POE is hidden Dan Carpenter
2026-11-19 16:32 ` Marc Zyngier
2026-11-20 5:33 ` Dan Carpenter [this message]
2026-11-19 13:25 ` [PATCH v2 3/4] KVM: arm64: nv: Clear hidden TCR2 bits for nested guests Dan Carpenter
2026-11-19 13:25 ` [PATCH v2 4/4] KVM: arm64: nv: Update the shadow MMU's VMID for AT emulation Dan Carpenter
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=av_bjCyoM93HColG@stanley.mountain \
--to=dan@pereq.eu \
--cc=catalin.marinas@arm.com \
--cc=clement@cryspen.com \
--cc=fuad.tabba@linux.dev \
--cc=jintack.lim@linaro.org \
--cc=joey.gouly@arm.com \
--cc=karthik@pereq.eu \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=seiden@linux.ibm.com \
--cc=stable@vger.kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.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