]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: arm64: Fix hypercall bitmap writeback when vcpus have already run
authorMarc Zyngier <maz@kernel.org>
Mon, 16 May 2022 16:32:54 +0000 (17:32 +0100)
committerMarc Zyngier <maz@kernel.org>
Mon, 16 May 2022 16:40:48 +0000 (17:40 +0100)
We generally want to disallow hypercall bitmaps being changed
once vcpus have already run. But we must allow the write if
the written value is unchanged so that userspace can rewrite
the register file on reboot, for example.

Without this, a QEMU-based VM will fail to reboot correctly.

The original code was correct, and it is me that introduced
the regression.

Fixes: 26dc25ee5635 ("KVM: arm64: Setup a framework for hypercall bitmap firmware registers")
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/hypercalls.c

index ccbd3cefb91a1109b9f47fe59bfe754506ee3718..c9f401fa01a93c00ac20a3f6d9e2146a5592a12a 100644 (file)
@@ -379,7 +379,8 @@ static int kvm_arm_set_fw_reg_bmap(struct kvm_vcpu *vcpu, u64 reg_id, u64 val)
 
        mutex_lock(&kvm->lock);
 
-       if (test_bit(KVM_ARCH_FLAG_HAS_RAN_ONCE, &kvm->arch.flags)) {
+       if (test_bit(KVM_ARCH_FLAG_HAS_RAN_ONCE, &kvm->arch.flags) &&
+           val != *fw_reg_bmap) {
                ret = -EBUSY;
                goto out;
        }