KVM: arm64: nested: Fix VA sign extension in VNCR/TLBI paths
Subsystems (4)
PATCH 1/1 KVM: arm64: nested: Fix VA sign extension in VNCR/TLBI paths
From: gyutrange <[email protected]>
VNCR/TLBI VA reconstruction currently uses bit 48 as the sign bit, but for 48-bit virtual addresses the correct sign bit is bit 47. Using 48 can mis-canonicalize addresses in the negative half and may cause missed invalidations.
Although VNCR_EL2 encodes other architectural fields (RESS, BADDR; see Arm ARM D24.2.206), sign_extend64() interprets its second argument as the index of the sign bit. Passing 48 prevents propagation of the canonical sign bit for 48-bit VAs.
Impact:
- Incorrect canonicalization of VAs with bit47=1
- Potential stale VNCR pseudo-TLB entries after TLBI or MMU notifier
- Possible incorrect translation/permissions or DoS when combined with other issues
--- arch/arm64/kvm/nested.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/nested.c +1 -1
@@ -1169,7 +1169,7 @@ int kvm_vcpu_allocate_vncr_tlb(struct kvm_vcpu *vcpu)static u64 read_vncr_el2 (struct kvm_vcpu *vcpu) { -return (u64 )sign_extend64 (__vcpu_sys_reg (vcpu,VNCR_EL2 ),48 ); +return (u64 )sign_extend64 (__vcpu_sys_reg (vcpu,VNCR_EL2 ),47 ); }static int kvm_translate_vncr (struct kvm_vcpu *vcpu)
Signature · 1 line
2.43.0
Marc Zyngier
maintainerQuoted 5 lines · Gyujeong Jin
From: gyutrange <[email protected]>
VNCR/TLBI VA reconstruction currently uses bit 48 as the sign bit, but for 48-bit virtual addresses the correct sign bit is bit 47.
No, that's not the case. Bit 55 is used at all times to determine which half of the address space a VA gets resolved from.
Quoted 10 lines
Using 48 can mis-canonicalize addresses in the negative half and may cause missed invalidations.
Although
VNCR_EL2encodes other architectural fields (RESS, BADDR; see Arm ARM D24.2.206),sign_extend64()interprets its second argument as the index of the sign bit. Passing 48 prevents propagation of the canonical sign bit for 48-bit VAs.Impact:
- Incorrect canonicalization of VAs with bit47=1
No. We are not trying to make the VA canonical.
Quoted 1 line
- Potential stale VNCR pseudo-TLB entries after TLBI or MMU notifier
No. The pseudo TLB is never created the first place.
Quoted 2 lines
- Possible incorrect translation/permissions or DoS when combined with other issues
Please explain, as "other issues" is not a valid argument.
Thanks,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Greg KH
maintainerQuoted 1 line · Gyujeong Jin
From: gyutrange <[email protected]>
Does not match your signed-off-by line :(
Greg KH
maintainerQuoted 18 lines · Gyujeong Jin
From: gyutrange <[email protected]>
VNCR/TLBI VA reconstruction currently uses bit 48 as the sign bit, but for 48-bit virtual addresses the correct sign bit is bit 47. Using 48 can mis-canonicalize addresses in the negative half and may cause missed invalidations.
Although
VNCR_EL2encodes other architectural fields (RESS, BADDR; see Arm ARM D24.2.206),sign_extend64()interprets its second argument as the index of the sign bit. Passing 48 prevents propagation of the canonical sign bit for 48-bit VAs.Impact:
- Incorrect canonicalization of VAs with bit47=1
- Potential stale VNCR pseudo-TLB entries after TLBI or MMU notifier
- Possible incorrect translation/permissions or DoS when combined with other issues
Quoted 8 lines
Fixes 667304740537 ("KVM: arm64: Mask out non-VA bits from TLBI VA* on VNCR invalidation")Reported-by DongHa Lee <[email protected]>Reported-by Gyujeong Jin <[email protected]>Reported-by Daehyeon Ko <[email protected]>Reported-by Geonha Lee <[email protected]>Reported-by Hyungyu Oh <[email protected]>Reported-by Jaewon Yang <[email protected]>
Please do not use fake email addresses.