Skip to content

Commit a0ec2b8

Browse files
author
Marc Zyngier
committed
KVM: arm64: nv: Snapshot S1 ASID tagging information during walk
We currently completely ignore any sort of ASID tagging during a S1 walk, as AT doesn't care about it. However, such information is required if we are going to create anything that looks like a TLB from this walk. Let's capture it both the nG and ASID information while walking the page tables. Reviewed-by: Oliver Upton <oliver.upton@linux.dev> Link: https://lore.kernel.org/r/20250514103501.2225951-5-maz@kernel.org Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 34fa9de commit a0ec2b8

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

arch/arm64/include/asm/kvm_nested.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ struct s1_walk_result {
274274
u64 pa;
275275
s8 level;
276276
u8 APTable;
277+
bool nG;
278+
u16 asid;
277279
bool UXNTable;
278280
bool PXNTable;
279281
bool uwxn;

arch/arm64/kvm/at.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,33 @@ static int walk_s1(struct kvm_vcpu *vcpu, struct s1_walk_info *wi,
414414
wr->pa = desc & GENMASK(47, va_bottom);
415415
wr->pa |= va & GENMASK_ULL(va_bottom - 1, 0);
416416

417+
wr->nG = (wi->regime != TR_EL2) && (desc & PTE_NG);
418+
if (wr->nG) {
419+
u64 asid_ttbr, tcr;
420+
421+
switch (wi->regime) {
422+
case TR_EL10:
423+
tcr = vcpu_read_sys_reg(vcpu, TCR_EL1);
424+
asid_ttbr = ((tcr & TCR_A1) ?
425+
vcpu_read_sys_reg(vcpu, TTBR1_EL1) :
426+
vcpu_read_sys_reg(vcpu, TTBR0_EL1));
427+
break;
428+
case TR_EL20:
429+
tcr = vcpu_read_sys_reg(vcpu, TCR_EL2);
430+
asid_ttbr = ((tcr & TCR_A1) ?
431+
vcpu_read_sys_reg(vcpu, TTBR1_EL2) :
432+
vcpu_read_sys_reg(vcpu, TTBR0_EL2));
433+
break;
434+
default:
435+
BUG();
436+
}
437+
438+
wr->asid = FIELD_GET(TTBR_ASID_MASK, asid_ttbr);
439+
if (!kvm_has_feat_enum(vcpu->kvm, ID_AA64MMFR0_EL1, ASIDBITS, 16) ||
440+
!(tcr & TCR_ASID16))
441+
wr->asid &= GENMASK(7, 0);
442+
}
443+
417444
return 0;
418445

419446
addrsz:

0 commit comments

Comments
 (0)