From: Roman Kagan <rkagan@virtuozzo.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: <linux-kernel@vger.kernel.org>, <kvm@vger.kernel.org>,
Andrey Smetanin <asmetanin@virtuozzo.com>
Subject: Re: [PATCH] KVM: Hyper-V: do not do hypercall userspace exits if SynIC is disabled
Date: Tue, 29 Mar 2016 13:48:04 +0300 [thread overview]
Message-ID: <20160329104803.GA15614@rkaganb.sw.ru> (raw)
In-Reply-To: <1459244096-7213-1-git-send-email-pbonzini@redhat.com>
On Tue, Mar 29, 2016 at 11:34:56AM +0200, Paolo Bonzini wrote:
> If SynIC is disabled, there is nothing that userspace can do to
> handle these exits; on the other hand, userspace probably will
> not know about KVM_EXIT_HYPERV_HCALL and complain about it or
> even exit. Just prevent anything bad from happening by handling
> the hypercall in KVM and returning an "invalid hypercall" code.
I wonder if this has been encountered in real life or just found by code
inspection?
> Fixes: 83326e43f27e9a8a501427a0060f8af519a39bb2
> Cc: Andrey Smetanin <asmetanin@virtuozzo.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> arch/x86/kvm/hyperv.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
> index b960d9ea171f..9e2becd20a59 100644
> --- a/arch/x86/kvm/hyperv.c
> +++ b/arch/x86/kvm/hyperv.c
> @@ -1237,14 +1237,17 @@ int kvm_hv_hypercall(struct kvm_vcpu *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 =
> + if (vcpu_to_synic(vcpu)->active) {
> + 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;
> + return 0;
> + }
> + /* fall through */
I'd rather put it the other way around, with explicit error path and a
comment:
/* don't bother userspace if it has no way to handle it */
if (!vcpu_to_synic(vcpu)->active) {
res = HV_STATUS_INVALID_HYPERCALL_CODE;
break;
}
but that's just nitpicking, so
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
[ Andrey has left the company so I'm not sure he even receives the
messages sent to this address ]
Thanks,
Roman.
next prev parent reply other threads:[~2016-03-29 12:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-29 9:34 Paolo Bonzini
2016-03-29 10:48 ` Roman Kagan [this message]
2016-03-29 10:50 ` Paolo Bonzini
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=20160329104803.GA15614@rkaganb.sw.ru \
--to=rkagan@virtuozzo.com \
--cc=asmetanin@virtuozzo.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@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
all inboxes | Powered by JetHome®