linux/arch/loongarch/kvm
WANG Xuerui 179af5751a LoongArch: KVM: Fix input validation of _kvm_get_cpucfg() & kvm_check_cpucfg()
The range check for the CPUCFG ID is wrong (should have been a ||
instead of &&) and useless in effect, so fix the obvious mistake.

Furthermore, the juggling of the temp return value is unnecessary,
because it is semantically equivalent and more readable to just
return at every switch case's end. This is done too to avoid potential
bugs in the future related to the unwanted complexity.

Also, the return value of _kvm_get_cpucfg is meant to be checked, but
this was not done, so bad CPUCFG IDs wrongly fall back to the default
case and 0 is incorrectly returned; check the return value to fix the
UAPI behavior.

While at it, also remove the redundant range check in kvm_check_cpucfg,
because out-of-range CPUCFG IDs are already rejected by the -EINVAL
as returned by _kvm_get_cpucfg().

Fixes: db1ecca22e ("LoongArch: KVM: Add LSX (128bit SIMD) support")
Fixes: 118e10cd89 ("LoongArch: KVM: Add LASX (256bit SIMD) support")
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
2024-02-23 14:36:31 +08:00
..
exit.c LoongArch: KVM: Add LASX (256bit SIMD) support 2023-12-19 10:48:28 +08:00
interrupt.c LoongArch: KVM: Implement vcpu interrupt operations 2023-10-02 10:01:28 +08:00
Kconfig KVM: introduce CONFIG_KVM_COMMON 2024-01-08 08:09:38 -05:00
main.c LoongArch: KVM: Allow to access HW timer CSR registers always 2023-12-19 10:48:27 +08:00
Makefile LoongArch: KVM: Enable kvm config and add the makefile 2023-10-02 10:01:29 +08:00
mmu.c LoongArch: KVM: Fix build due to API changes 2024-01-26 16:22:07 +08:00
switch.S LoongArch: KVM: Add LASX (256bit SIMD) support 2023-12-19 10:48:28 +08:00
timer.c LoongArch: KVM: Fix timer emulation with oneshot mode 2023-12-19 10:48:28 +08:00
tlb.c LoongArch: KVM: Implement virtual machine tlb operations 2023-10-02 10:01:28 +08:00
trace.h LoongArch: KVM: Add LASX (256bit SIMD) support 2023-12-19 10:48:28 +08:00
vcpu.c LoongArch: KVM: Fix input validation of _kvm_get_cpucfg() & kvm_check_cpucfg() 2024-02-23 14:36:31 +08:00
vm.c LoongArch: KVM: Implement VM related functions 2023-10-02 10:01:27 +08:00