Skip to content

Commit 57ab879

Browse files
matosattibonzini
authored andcommitted
KVM: x86: add start_assignment hook to kvm_x86_ops
Add a start_assignment hook to kvm_x86_ops, which is called when kvm_arch_start_assignment is done. The hook is required to update the wakeup vector of a sleeping vCPU when a device is assigned to the guest. Signed-off-by: Marcelo Tosatti <[email protected]> Message-Id: <[email protected]> Reviewed-by: Peter Xu <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 9805cf0 commit 57ab879

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

arch/x86/include/asm/kvm-x86-ops.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ KVM_X86_OP_NULL(post_block)
9999
KVM_X86_OP_NULL(vcpu_blocking)
100100
KVM_X86_OP_NULL(vcpu_unblocking)
101101
KVM_X86_OP_NULL(update_pi_irte)
102+
KVM_X86_OP_NULL(start_assignment)
102103
KVM_X86_OP_NULL(apicv_post_state_restore)
103104
KVM_X86_OP_NULL(dy_apicv_has_pending_interrupt)
104105
KVM_X86_OP_NULL(set_hv_timer)

arch/x86/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,7 @@ struct kvm_x86_ops {
13521352

13531353
int (*update_pi_irte)(struct kvm *kvm, unsigned int host_irq,
13541354
uint32_t guest_irq, bool set);
1355+
void (*start_assignment)(struct kvm *kvm);
13551356
void (*apicv_post_state_restore)(struct kvm_vcpu *vcpu);
13561357
bool (*dy_apicv_has_pending_interrupt)(struct kvm_vcpu *vcpu);
13571358

arch/x86/kvm/x86.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11504,7 +11504,8 @@ bool kvm_arch_can_dequeue_async_page_present(struct kvm_vcpu *vcpu)
1150411504

1150511505
void kvm_arch_start_assignment(struct kvm *kvm)
1150611506
{
11507-
atomic_inc(&kvm->arch.assigned_device_count);
11507+
if (atomic_inc_return(&kvm->arch.assigned_device_count) == 1)
11508+
static_call_cond(kvm_x86_start_assignment)(kvm);
1150811509
}
1150911510
EXPORT_SYMBOL_GPL(kvm_arch_start_assignment);
1151011511

0 commit comments

Comments
 (0)