Skip to content

Commit 192df2a

Browse files
committed
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 e3c1c0c ("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: e3c1c0c ("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>
1 parent 92d05e2 commit 192df2a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

arch/arm64/kvm/arm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,8 +1280,8 @@ static int kvm_arch_vcpu_ioctl_vcpu_init(struct kvm_vcpu *vcpu,
12801280
* reflecting it in the finalized feature set, thus limiting its scope
12811281
* to a single KVM_ARM_VCPU_INIT call.
12821282
*/
1283-
if (init->features[0] & KVM_ARM_VCPU_POWER_OFF) {
1284-
init->features[0] &= ~KVM_ARM_VCPU_POWER_OFF;
1283+
if (init->features[0] & BIT(KVM_ARM_VCPU_POWER_OFF)) {
1284+
init->features[0] &= ~BIT(KVM_ARM_VCPU_POWER_OFF);
12851285
power_off = true;
12861286
}
12871287

0 commit comments

Comments
 (0)