summaryrefslogtreecommitdiff
path: root/arch/arm64
diff options
context:
space:
mode:
authorOliver Upton <oliver.upton@linux.dev>2023-06-22 19:09:22 +0300
committerOliver Upton <oliver.upton@linux.dev>2023-06-22 20:17:14 +0300
commit192df2aa0113ddddee2a93e453ff46610807b425 (patch)
tree31fba9a3378b132bbb5ba28908e933fc8ffd85e1 /arch/arm64
parent92d05e2492f1400029e84b5a72e15811ef787ee9 (diff)
downloadlinux-192df2aa0113ddddee2a93e453ff46610807b425.tar.xz
KVM: arm64: Fix misuse of KVM_ARM_VCPU_POWER_OFF bit index
KVM_ARM_VCPU_POWER_OFF is as bit index, _not_ a literal bitmask. Nonetheless, commit e3c1c0cae31e ("KVM: arm64: Relax invariance of KVM_ARM_VCPU_POWER_OFF") started using it that way, meaning that powering off a vCPU with the KVM_ARM_VCPU_INIT ioctl is completely broken. Fix it by using a shifted bit for the bitwise operations instead. Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Fixes: e3c1c0cae31e ("KVM: arm64: Relax invariance of KVM_ARM_VCPU_POWER_OFF") Acked-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230622160922.1925530-1-oliver.upton@linux.dev Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Diffstat (limited to 'arch/arm64')
-rw-r--r--arch/arm64/kvm/arm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 2e1f5561141c..c2c14059f6a8 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -1280,8 +1280,8 @@ static int kvm_arch_vcpu_ioctl_vcpu_init(struct kvm_vcpu *vcpu,
* reflecting it in the finalized feature set, thus limiting its scope
* to a single KVM_ARM_VCPU_INIT call.
*/
- if (init->features[0] & KVM_ARM_VCPU_POWER_OFF) {
- init->features[0] &= ~KVM_ARM_VCPU_POWER_OFF;
+ if (init->features[0] & BIT(KVM_ARM_VCPU_POWER_OFF)) {
+ init->features[0] &= ~BIT(KVM_ARM_VCPU_POWER_OFF);
power_off = true;
}