[Devel] [PATCH RHEL7 COMMIT] ms/kvm/x86: Pass return code of kvm_emulate_hypercall

Konstantin Khorenko khorenko at virtuozzo.com
Sat Feb 20 08:11:49 PST 2016


The commit is pushed to "branch-rh7-3.10.0-327.4.5.vz7.11.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.4.5.vz7.11.5
------>
commit 12007497013e7a6bff36a88459d0a1c15ffc11c4
Author: Andrey Smetanin <asmetanin at virtuozzo.com>
Date:   Sat Feb 20 20:11:49 2016 +0400

    ms/kvm/x86: Pass return code of kvm_emulate_hypercall
    
    Series description:
    
    KVM: Hyper-V VMBus hypercalls
    
    The patch implements userspace exit 'KVM_EXIT_HYPERV'
    for Hyper-V VMBus hypercalls(postmsg, signalevent)
    to handle these hypercalls by QEMU.
    
    Changes v3:
    * use vcpu->arch.complete_userspace_io to setup hypercall
    result
    * rebase for 'next-20160211'
    
    Changes v2:
    * use KVM_EXIT_HYPERV for hypercalls
    
    https://jira.sw.ru/browse/PSBM-44419
    
    Andrey Smetanin (5):
    ms/kvm/x86: Rename Hyper-V long spin wait hypercall
    ms/drivers/hv: Move VMBus hypercall codes into Hyper-V UAPI header
    ms/kvm/x86: Pass return code of kvm_emulate_hypercall
    ms/kvm/x86: Reject Hyper-V hypercall continuation
    ms/kvm/x86: Hyper-V VMBus hypercall userspace exit
    
    Reviewed-by: Roman Kagan <rkagan at virtuozzo.com>
    ===============================================
    This patch description:
    
    Pass the return code from kvm_emulate_hypercall on to the caller,
    in order to allow it to indicate to the userspace that
    the hypercall has to be handled there.
    
    Also adjust all the existing code paths to return 1 to make sure the
    hypercall isn't passed to the userspace without setting kvm_run
    appropriately.
    
    Signed-off-by: Andrey Smetanin <asmetanin at virtuozzo.com>
    
    Reviewed-by: Roman Kagan <rkagan at virtuozzo.com>
    CC: Gleb Natapov <gleb at kernel.org>
    CC: Paolo Bonzini <pbonzini at redhat.com>
    CC: Joerg Roedel <joro at 8bytes.org>
    CC: "K. Y. Srinivasan" <kys at microsoft.com>
    CC: Haiyang Zhang <haiyangz at microsoft.com>
    CC: Roman Kagan <rkagan at virtuozzo.com>
    CC: Denis V. Lunev <den at openvz.org>
    CC: qemu-devel at nongnu.org
    Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
    (cherry picked from commit 0d9c055eaaf41bebb0e6b095fff447523121fad3)
---
 arch/x86/kvm/hyperv.c | 2 +-
 arch/x86/kvm/svm.c    | 3 +--
 arch/x86/kvm/vmx.c    | 3 +--
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 04fb760..9d60d33 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -1077,7 +1077,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	 */
 	if (kvm_x86_ops->get_cpl(vcpu) != 0 || !is_protmode(vcpu)) {
 		kvm_queue_exception(vcpu, UD_VECTOR);
-		return 0;
+		return 1;
 	}
 
 	kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index f8bde17..12850b2 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1942,8 +1942,7 @@ static int vmmcall_interception(struct vcpu_svm *svm)
 {
 	svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
 	skip_emulated_instruction(&svm->vcpu);
-	kvm_emulate_hypercall(&svm->vcpu);
-	return 1;
+	return kvm_emulate_hypercall(&svm->vcpu);
 }
 
 static unsigned long nested_svm_get_tdp_cr3(struct kvm_vcpu *vcpu)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 4474efc..06ae2d3 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5300,8 +5300,7 @@ static int handle_halt(struct kvm_vcpu *vcpu)
 static int handle_vmcall(struct kvm_vcpu *vcpu)
 {
 	skip_emulated_instruction(vcpu);
-	kvm_emulate_hypercall(vcpu);
-	return 1;
+	return kvm_emulate_hypercall(vcpu);
 }
 
 static int handle_invd(struct kvm_vcpu *vcpu)


More information about the Devel mailing list