2019-09-13 19:58:24

by Suthikulpanit, Suravee

[permalink] [raw]
Subject: [PATCH v3 09/16] kvm: x86: hyperv: Use APICv deactivate request interface

Since disabling APICv has to be done for all vcpus on AMD-based system,
adopt the newly introduced kvm_make_apicv_deactivate_request() interface.

Signed-off-by: Suravee Suthikulpanit <[email protected]>
---
arch/x86/kvm/hyperv.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index c10a8b1..1d011b4 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -772,9 +772,17 @@ int kvm_hv_activate_synic(struct kvm_vcpu *vcpu, bool dont_zero_synic_pages)

/*
* Hyper-V SynIC auto EOI SINT's are
- * not compatible with APICV, so deactivate APICV
+ * not compatible with APICV, so request
+ * to deactivate APICV permanently.
+ *
+ * Since this requires updating
+ * APIC_ACCESS_PAGE_PRIVATE_MEMSLOT,
+ * also take srcu lock.
*/
- kvm_vcpu_deactivate_apicv(vcpu);
+ vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
+ kvm_make_apicv_deactivate_request(vcpu, true);
+ srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
+
synic->active = true;
synic->dont_zero_synic_pages = dont_zero_synic_pages;
return 0;
--
1.8.3.1


2019-10-09 09:22:54

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH v3 09/16] kvm: x86: hyperv: Use APICv deactivate request interface

On 13/09/19 21:01, Suthikulpanit, Suravee wrote:
> + *
> + * Since this requires updating
> + * APIC_ACCESS_PAGE_PRIVATE_MEMSLOT,
> + * also take srcu lock.

This comment is incorrect, it says you are entering a read-side critical
section to update the data structure. It's only needed because
kvm_make_apicv_deactivate_request expects that it needs to unlock and
relock kvm->srcu.

Paolo

> */
> - kvm_vcpu_deactivate_apicv(vcpu);
> + vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
> + kvm_make_apicv_deactivate_request(vcpu, true);
> + srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
> +