Skip to content

Commit b97bd69

Browse files
committed
LoongArch: KVM: Handle the case that EIOINTC's coremap is empty
EIOINTC's coremap in eiointc_update_sw_coremap() can be empty, currently we get a cpuid with -1 in this case, but we actually need 0 because it's similar as the case that cpuid >= 4. This fix an out-of-bounds access to kvm_arch::phyid_map::phys_map[]. Cc: <stable@vger.kernel.org> Fixes: 3956a52 ("LoongArch: KVM: Add EIOINTC read and write functions") Reported-by: Aurelien Jarno <aurel32@debian.org> Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1131431 Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 2db06c1 commit b97bd69

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/loongarch/kvm/intc/eiointc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static inline void eiointc_update_sw_coremap(struct loongarch_eiointc *s,
8383

8484
if (!(s->status & BIT(EIOINTC_ENABLE_CPU_ENCODE))) {
8585
cpuid = ffs(cpuid) - 1;
86-
cpuid = (cpuid >= 4) ? 0 : cpuid;
86+
cpuid = ((cpuid < 0) || (cpuid >= 4)) ? 0 : cpuid;
8787
}
8888

8989
vcpu = kvm_get_vcpu_by_cpuid(s->kvm, cpuid);

0 commit comments

Comments
 (0)