mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
KVM: arm64: Sign-extend VA for range-based TLBI invalidation
When the decode_range_tlbi() helper was moved to be used for S1 TLBIs,
the required sign extension was omitted. Add it.
As a result, special care must be taken to not overflow PA bits when
this is used for S2 invalidation.
Fixes: 85bba00425 ("KVM: arm64: nv: Move TLBI range decoding to a helper")
Reported-by: sashiko-bot@kernel.org
Link: https://lore.kernel.org/r/20260801130337.EB2BA1F00AC4@smtp.kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260806091026.620700-7-maz@kernel.org
Signed-off-by: Oliver Upton <oupton@kernel.org>
This commit is contained in:
parent
38640bc32b
commit
2393470085
|
|
@ -291,6 +291,13 @@ static inline u64 decode_range_tlbi(u64 val, u64 *range, u16 *asid)
|
|||
|
||||
base = (val & GENMASK(36, 0)) << shift;
|
||||
|
||||
/*
|
||||
* We only deal with at most 48bit VA/IPA, so 48 is where we
|
||||
* sign-extend from. Should we support FEAT_L{VP}A* at some point,
|
||||
* this will need to be revisited.
|
||||
*/
|
||||
base = (u64)sign_extend64(base, 48);
|
||||
|
||||
if (asid)
|
||||
*asid = FIELD_GET(TLBIR_ASID_MASK, val);
|
||||
|
||||
|
|
|
|||
|
|
@ -4057,6 +4057,7 @@ static bool handle_ripas2e1is(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
|
|||
u32 sys_encoding = sys_insn(p->Op0, p->Op1, p->CRn, p->CRm, p->Op2);
|
||||
u64 vttbr = vcpu_read_sys_reg(vcpu, VTTBR_EL2);
|
||||
u64 base, range;
|
||||
int pa_bits;
|
||||
|
||||
if (!kvm_supported_tlbi_ipas2_op(vcpu, sys_encoding))
|
||||
return undef_access(vcpu, p, r);
|
||||
|
|
@ -4068,6 +4069,16 @@ static bool handle_ripas2e1is(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
|
|||
*/
|
||||
base = decode_range_tlbi(p->regval, &range, NULL);
|
||||
|
||||
/*
|
||||
* Ignore TLBIs that start out of PA_bits range, and cap the
|
||||
* invalidation to the [base:bit(PA_bits)] interval.
|
||||
*/
|
||||
pa_bits = kvm_get_pa_bits(vcpu->kvm);
|
||||
if (fls64(base) > pa_bits)
|
||||
return true;
|
||||
|
||||
range = min(range, BIT_ULL(pa_bits) - base);
|
||||
|
||||
kvm_s2_mmu_iterate_by_vmid(vcpu->kvm, get_vmid(vttbr),
|
||||
&(union tlbi_info) {
|
||||
.range = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user