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 c0dfc19458734dc142aaa70b8f88916b19b6f97b
Author: Andrey Smetanin <asmeta...@virtuozzo.com>
Date:   Sat Feb 20 20:11:48 2016 +0400

    ms/kvm/x86: Hyper-V VMBus hypercall userspace exit
    
    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 <rka...@virtuozzo.com>
    ===============================================
    This patch description:
    
    The patch implements KVM_EXIT_HYPERV userspace exit
    functionality for Hyper-V VMBus hypercalls:
    HV_X64_HCALL_POST_MESSAGE, HV_X64_HCALL_SIGNAL_EVENT.
    
    Changes v3:
    * use vcpu->arch.complete_userspace_io to setup hypercall
    result
    
    Changes v2:
    * use KVM_EXIT_HYPERV for hypercalls
    
    Signed-off-by: Andrey Smetanin <asmeta...@virtuozzo.com>
    
    Reviewed-by: Roman Kagan <rka...@virtuozzo.com>
    CC: Gleb Natapov <g...@kernel.org>
    CC: Paolo Bonzini <pbonz...@redhat.com>
    CC: Joerg Roedel <j...@8bytes.org>
    CC: "K. Y. Srinivasan" <k...@microsoft.com>
    CC: Haiyang Zhang <haiya...@microsoft.com>
    CC: Roman Kagan <rka...@virtuozzo.com>
    CC: Denis V. Lunev <d...@openvz.org>
    CC: qemu-de...@nongnu.org
    Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
    (cherry picked from commit 83326e43f27e9a8a501427a0060f8af519a39bb2)
---
 Documentation/virtual/kvm/api.txt |  6 ++++++
 arch/x86/kvm/hyperv.c             | 39 ++++++++++++++++++++++++++++++++-------
 include/uapi/linux/kvm.h          |  6 ++++++
 3 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/Documentation/virtual/kvm/api.txt 
b/Documentation/virtual/kvm/api.txt
index bccc810..34c9991 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -2891,6 +2891,7 @@ specific flags for the system-level event.
 
                struct kvm_hyperv_exit {
 #define KVM_EXIT_HYPERV_SYNIC          1
+#define KVM_EXIT_HYPERV_HCALL          2
                        __u32 type;
                        union {
                                struct {
@@ -2899,6 +2900,11 @@ specific flags for the system-level event.
                                        __u64 evt_page;
                                        __u64 msg_page;
                                } synic;
+                               struct {
+                                       __u64 input;
+                                       __u64 result;
+                                       __u64 params[2];
+                               } hcall;
                        } u;
                };
                /* KVM_EXIT_HYPERV */
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 44a5e98..04fb760 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -1043,6 +1043,27 @@ bool kvm_hv_hypercall_enabled(struct kvm *kvm)
        return kvm->arch.hyperv.hv_hypercall & HV_X64_MSR_HYPERCALL_ENABLE;
 }
 
+static void kvm_hv_hypercall_set_result(struct kvm_vcpu *vcpu, u64 result)
+{
+       bool longmode;
+
+       longmode = is_64_bit_mode(vcpu);
+       if (longmode)
+               kvm_register_write(vcpu, VCPU_REGS_RAX, result);
+       else {
+               kvm_register_write(vcpu, VCPU_REGS_RDX, result >> 32);
+               kvm_register_write(vcpu, VCPU_REGS_RAX, result & 0xffffffff);
+       }
+}
+
+static int kvm_hv_hypercall_complete_userspace(struct kvm_vcpu *vcpu)
+{
+       struct kvm_run *run = vcpu->run;
+
+       kvm_hv_hypercall_set_result(vcpu, run->hyperv.u.hcall.result);
+       return 1;
+}
+
 int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 {
        u64 param, ingpa, outgpa, ret;
@@ -1095,6 +1116,16 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
        case HVCALL_NOTIFY_LONG_SPIN_WAIT:
                kvm_vcpu_on_spin(vcpu);
                break;
+       case HVCALL_POST_MESSAGE:
+       case HVCALL_SIGNAL_EVENT:
+               vcpu->run->exit_reason = KVM_EXIT_HYPERV;
+               vcpu->run->hyperv.type = KVM_EXIT_HYPERV_HCALL;
+               vcpu->run->hyperv.u.hcall.input = param;
+               vcpu->run->hyperv.u.hcall.params[0] = ingpa;
+               vcpu->run->hyperv.u.hcall.params[1] = outgpa;
+               vcpu->arch.complete_userspace_io =
+                               kvm_hv_hypercall_complete_userspace;
+               return 0;
        default:
                res = HV_STATUS_INVALID_HYPERCALL_CODE;
                break;
@@ -1102,12 +1133,6 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 
 set_result:
        ret = res | (((u64)rep_done & 0xfff) << 32);
-       if (longmode) {
-               kvm_register_write(vcpu, VCPU_REGS_RAX, ret);
-       } else {
-               kvm_register_write(vcpu, VCPU_REGS_RDX, ret >> 32);
-               kvm_register_write(vcpu, VCPU_REGS_RAX, ret & 0xffffffff);
-       }
-
+       kvm_hv_hypercall_set_result(vcpu, ret);
        return 1;
 }
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index 158391b..e8ea8a0 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -149,6 +149,7 @@ struct kvm_pit_config {
 
 struct kvm_hyperv_exit {
 #define KVM_EXIT_HYPERV_SYNIC          1
+#define KVM_EXIT_HYPERV_HCALL          2
        __u32 type;
        union {
                struct {
@@ -157,6 +158,11 @@ struct kvm_hyperv_exit {
                        __u64 evt_page;
                        __u64 msg_page;
                } synic;
+               struct {
+                       __u64 input;
+                       __u64 result;
+                       __u64 params[2];
+               } hcall;
        } u;
 };
 
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to