From: Vipin Sharma <vipinsh@google.com>
To: seanjc@google.com, pbonzini@redhat.com, vkuznets@redhat.com,
dmatlack@google.com
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Vipin Sharma <vipinsh@google.com>
Subject: [Patch v4 08/13] KVM: x86: hyper-v: Use common code for hypercall userspace exit
Date: Mon, 12 Dec 2022 10:37:15 -0800 [thread overview]
Message-ID: <20221212183720.4062037-9-vipinsh@google.com> (raw)
In-Reply-To: <20221212183720.4062037-1-vipinsh@google.com>
Remove duplicate code to exit to userspace for hyper-v hypercalls and
use a common place to exit.
No functional change intended.
Signed-off-by: Vipin Sharma <vipinsh@google.com>
Suggested-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
arch/x86/kvm/hyperv.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 283b6d179dbe..2eb68533d188 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -2521,14 +2521,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
ret = HV_STATUS_INVALID_HYPERCALL_INPUT;
break;
}
- vcpu->run->exit_reason = KVM_EXIT_HYPERV;
- vcpu->run->hyperv.type = KVM_EXIT_HYPERV_HCALL;
- vcpu->run->hyperv.u.hcall.input = hc.param;
- vcpu->run->hyperv.u.hcall.params[0] = hc.ingpa;
- vcpu->run->hyperv.u.hcall.params[1] = hc.outgpa;
- vcpu->arch.complete_userspace_io =
- kvm_hv_hypercall_complete_userspace;
- return 0;
+ goto hypercall_userspace_exit;
case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST:
if (unlikely(hc.var_cnt)) {
ret = HV_STATUS_INVALID_HYPERCALL_INPUT;
@@ -2587,14 +2580,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
ret = HV_STATUS_OPERATION_DENIED;
break;
}
- vcpu->run->exit_reason = KVM_EXIT_HYPERV;
- vcpu->run->hyperv.type = KVM_EXIT_HYPERV_HCALL;
- vcpu->run->hyperv.u.hcall.input = hc.param;
- vcpu->run->hyperv.u.hcall.params[0] = hc.ingpa;
- vcpu->run->hyperv.u.hcall.params[1] = hc.outgpa;
- vcpu->arch.complete_userspace_io =
- kvm_hv_hypercall_complete_userspace;
- return 0;
+ goto hypercall_userspace_exit;
}
default:
ret = HV_STATUS_INVALID_HYPERCALL_CODE;
@@ -2603,6 +2589,15 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
hypercall_complete:
return kvm_hv_hypercall_complete(vcpu, ret);
+
+hypercall_userspace_exit:
+ vcpu->run->exit_reason = KVM_EXIT_HYPERV;
+ vcpu->run->hyperv.type = KVM_EXIT_HYPERV_HCALL;
+ vcpu->run->hyperv.u.hcall.input = hc.param;
+ vcpu->run->hyperv.u.hcall.params[0] = hc.ingpa;
+ vcpu->run->hyperv.u.hcall.params[1] = hc.outgpa;
+ vcpu->arch.complete_userspace_io = kvm_hv_hypercall_complete_userspace;
+ return 0;
}
void kvm_hv_init_vm(struct kvm *kvm)
--
2.39.0.rc1.256.g54fd8350bd-goog
next prev parent reply other threads:[~2022-12-12 18:38 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-12 18:37 [Patch v4 00/13] Add Hyper-v extended hypercall support in KVM Vipin Sharma
2022-12-12 18:37 ` [Patch v4 01/13] x86/hyperv: Add HV_EXPOSE_INVARIANT_TSC define Vipin Sharma
2022-12-12 18:37 ` [Patch v4 02/13] KVM: x86: Add a KVM-only leaf for CPUID_8000_0007_EDX Vipin Sharma
2022-12-27 20:20 ` Aaron Lewis
2022-12-12 18:37 ` [Patch v4 03/13] KVM: x86: Hyper-V invariant TSC control Vipin Sharma
2022-12-12 18:37 ` [Patch v4 04/13] KVM: selftests: Rename 'msr->available' to 'msr->fault_exepected' in hyperv_features test Vipin Sharma
2022-12-12 18:37 ` [Patch v4 05/13] KVM: selftests: Convert hyperv_features test to using KVM_X86_CPU_FEATURE() Vipin Sharma
2022-12-12 18:37 ` [Patch v4 06/13] KVM: selftests: Test that values written to Hyper-V MSRs are preserved Vipin Sharma
2022-12-12 18:37 ` [Patch v4 07/13] KVM: selftests: Test Hyper-V invariant TSC control Vipin Sharma
2022-12-12 18:37 ` Vipin Sharma [this message]
2022-12-12 18:37 ` [Patch v4 09/13] KVM: x86: hyper-v: Add extended hypercall support in Hyper-v Vipin Sharma
2022-12-12 18:37 ` [Patch v4 10/13] KVM: selftests: Test Hyper-V extended hypercall enablement Vipin Sharma
2022-12-12 18:37 ` [Patch v4 11/13] KVM: selftests: Replace hardcoded Linux OS id with HYPERV_LINUX_OS_ID Vipin Sharma
2022-12-12 18:37 ` [Patch v4 12/13] KVM: selftests: Make vCPU exit reason test assertion common Vipin Sharma
2023-02-01 23:24 ` Sean Christopherson
2023-02-02 18:31 ` Vipin Sharma
2023-02-02 18:51 ` Sean Christopherson
2023-02-02 18:59 ` Vipin Sharma
2023-02-03 22:08 ` Vipin Sharma
2023-02-03 22:57 ` Sean Christopherson
2022-12-12 18:37 ` [Patch v4 13/13] KVM: selftests: Test Hyper-V extended hypercall exit to userspace Vipin Sharma
2023-01-04 0:33 ` [Patch v4 00/13] Add Hyper-v extended hypercall support in KVM Vipin Sharma
2023-02-01 22:39 ` (subset) " Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221212183720.4062037-9-vipinsh@google.com \
--to=vipinsh@google.com \
--cc=dmatlack@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).