Skip to content

Commit d4feec4

Browse files
paulusmackgregkh
authored andcommitted
KVM: PPC: Book3S HV: Don't lose pending doorbell request on migration on P9
commit ff42df49e75f053a8a6b4c2533100cdcc23afe69 upstream. On POWER9, when userspace reads the value of the DPDES register on a vCPU, it is possible for 0 to be returned although there is a doorbell interrupt pending for the vCPU. This can lead to a doorbell interrupt being lost across migration. If the guest kernel uses doorbell interrupts for IPIs, then it could malfunction because of the lost interrupt. This happens because a newly-generated doorbell interrupt is signalled by setting vcpu->arch.doorbell_request to 1; the DPDES value in vcpu->arch.vcore->dpdes is not updated, because it can only be updated when holding the vcpu mutex, in order to avoid races. To fix this, we OR in vcpu->arch.doorbell_request when reading the DPDES value. Cc: stable@vger.kernel.org # v4.13+ Fixes: 5790069 ("KVM: PPC: Book3S HV: Virtualize doorbell facility on POWER9") Signed-off-by: Paul Mackerras <paulus@ozlabs.org> Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1ea91b6 commit d4feec4

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

arch/powerpc/kvm/book3s_hv.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,14 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
13561356
*val = get_reg_val(id, vcpu->arch.pspb);
13571357
break;
13581358
case KVM_REG_PPC_DPDES:
1359-
*val = get_reg_val(id, vcpu->arch.vcore->dpdes);
1359+
/*
1360+
* On POWER9, where we are emulating msgsndp etc.,
1361+
* we return 1 bit for each vcpu, which can come from
1362+
* either vcore->dpdes or doorbell_request.
1363+
* On POWER8, doorbell_request is 0.
1364+
*/
1365+
*val = get_reg_val(id, vcpu->arch.vcore->dpdes |
1366+
vcpu->arch.doorbell_request);
13601367
break;
13611368
case KVM_REG_PPC_VTB:
13621369
*val = get_reg_val(id, vcpu->arch.vcore->vtb);

0 commit comments

Comments
 (0)