From: Tangnianyao <tangnianyao@huawei.com>
To: Mark Rutland <mark.rutland@arm.com>
Cc: Marc Zyngier <maz@kernel.org>,
Wei-Lin Chang <weilin.chang@arm.com>, <oupton@kernel.org>,
<joey.gouly@arm.com>, <seiden@linux.ibm.com>,
<suzuki.poulose@arm.com>, <yuzenghui@huawei.com>,
<catalin.marinas@arm.com>, <will@kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <kvmarm@lists.linux.dev>,
<linux-kernel@vger.kernel.org>,
"guoyang (C)" <guoyang2@huawei.com>,
"huanglingyan (A)" <huanglingyan2@huawei.com>,
"Wangzhou (B)" <wangzhou1@hisilicon.com>
Subject: Re: Question about the "TLBs and I-cache are private to each vCPU" guarantee with VTTBR_EL2.CnP
Date: Tue, 7 Jul 2026 10:41:35 +0800 [thread overview]
Message-ID: <7d97b19a-ef56-dea1-cd99-056e0e34a7fa@huawei.com> (raw)
In-Reply-To: <akvKvePWiu4pB47Q@J2N7QTR9R3.cambridge.arm.com>
On 7/6/2026 23:33, Mark Rutland wrote:
> On Mon, Jul 06, 2026 at 10:15:04PM +0800, Tangnianyao wrote:
>> Two SMT threads(PE0,PE1) on the same physical core share TLB.
> Critially those are *NOT* allowed to share entries allocated with
> CnP==0, and are only allowed to share entries where CnP was enabled at
> stage 1 (and stage 2 if applicable).
>
> Please see the ARM ARM:
>
> https://developer.arm.com/documentation/ddi0487/mc/
>
> Specifically, section D8.12.3.4 "Common not private translations":
>
> https://developer.arm.com/documentation/ddi0487/mc/-Part-D-The-AArch64-System-Level-Architecture/-Chapter-D8-The-AArch64-Virtual-Memory-System-Architecture/-D8-16-Translation-Lookaside-Buffers/-D8-16-3-Use-of-ASIDs-and-VMIDs-to-reduce-TLB-maintenance-requirements
>
>> VM0 has 2 vcpus, vcpu0 and vcpu1 that share all architectural context
>> except the address translation context.
>>
>> Vcpu0 may observe TLB entries that are supposed to be private to vcpu1
>> in the following case:
>>
>> PE0(core0,smt0) PE1(core0,smt1)
>> vcpu0 load
>> vcpu0 va->pa0
>> vcpu0 put
>> vcpu1 load
>> vcpu1 flush local tlb
>> vcpu1 modify desc to va->pa1
>> vcpu0 load
>> vcpu0 hit *va->pa1*
> How is CnP managed in this example?
>
> If *either* of the vCPUs don't set TTBRn_EL1.CnP, that is not permitted
> to happen.
>
> If *both* of the vCPUs set TTBRn_EL1.CnP, then surely that is
> indistinguishable from physical CPUs:
>
> PE0(core0,smt0) PE1(core0,smt1)
> cpu0 va->pa0
> cpu1 flush local tlb
> cpu1 modify desc to va->pa1
> cpu0 hit *va->pa1*
>
> Mark.
>
> .
>
Thanks for the clarification.
Stage-1 CnP determines whether Stage-1 translation entries may be shared
across vCPUs, and the hardware is responsible for enforcing the
architectural semantics.
Given that, why does KVM still need to guarantee that TLBs are private to
each vCPU?
Assuming VTTBR_EL2.CnP == 1:
If TTBRx_EL1.CnP == 1, the guest is responsible for ensuring that the
translations referenced by TTBRx_EL1 are shareable, as required by the
architecture.
If TTBRx_EL1.CnP == 0, the hardware must ensure that Stage-1 translations
are not shared, again according to the architectural definition.
The reason I'm asking is the potential performance impact. In a scenario
where multiple vCPUs of the same VM are scheduled onto a single PE, this
TLB flush may prevent a vCPU from reusing its previously populated
translation entries, potentially increasing TLB misses.
Thanks,
Nianyao Tang
next prev parent reply other threads:[~2026-07-07 2:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-04 7:45 Question about the "TLBs and I-cache are private to each vCPU" guarantee with VTTBR_EL2.CnP Tangnianyao
2026-07-05 17:28 ` Wei-Lin Chang
2026-07-06 3:30 ` Tangnianyao
2026-07-06 7:25 ` Marc Zyngier
2026-07-06 8:25 ` Tangnianyao
2026-07-06 8:44 ` Marc Zyngier
2026-07-06 14:15 ` Tangnianyao
2026-07-06 15:18 ` Will Deacon
2026-07-06 15:33 ` Mark Rutland
2026-07-07 2:41 ` Tangnianyao [this message]
2026-07-07 6:36 ` Oliver Upton
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=7d97b19a-ef56-dea1-cd99-056e0e34a7fa@huawei.com \
--to=tangnianyao@huawei.com \
--cc=catalin.marinas@arm.com \
--cc=guoyang2@huawei.com \
--cc=huanglingyan2@huawei.com \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=seiden@linux.ibm.com \
--cc=suzuki.poulose@arm.com \
--cc=wangzhou1@hisilicon.com \
--cc=weilin.chang@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