From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Jon Doron <arilou@gmail.com>
Cc: kvm@vger.kernel.org, linux-hyperv@vger.kernel.org
Subject: Re: [PATCH v1 2/3] x86/kvm/hyper-v: enable hypercalls regardless of hypercall page
Date: Wed, 04 Mar 2020 14:58:18 +0100 [thread overview]
Message-ID: <87pndsdxxh.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <20200303130356.50405-3-arilou@gmail.com>
Jon Doron <arilou@gmail.com> writes:
> Microsoft's kdvm.dll dbgtransport module does not respect the hypercall
> page and simply identifies the CPU being used (AMD/Intel) and according
> to it simply makes hypercalls with the relevant instruction
> (vmmcall/vmcall respectively).
>
> The relevant function in kdvm is KdHvConnectHypervisor which first checks
> if the hypercall page has been enabled via HV_X64_MSR_HYPERCALL_ENABLE,
> and in case it was not it simply sets the HV_X64_MSR_GUEST_OS_ID to
> 0x1000101010001 which means:
> build_number = 0x0001
> service_version = 0x01
> minor_version = 0x01
> major_version = 0x01
> os_id = 0x00 (Undefined)
> vendor_id = 1 (Microsoft)
> os_type = 0 (A value of 0 indicates a proprietary, closed source OS)
>
> and starts issuing the hypercall without setting the hypercall page.
>
> To resolve this issue simply enable hypercalls if the guest_os_id is
> not 0.
>
> Signed-off-by: Jon Doron <arilou@gmail.com>
> ---
> arch/x86/kvm/hyperv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
> index 13176ec23496..7ec962d433af 100644
> --- a/arch/x86/kvm/hyperv.c
> +++ b/arch/x86/kvm/hyperv.c
> @@ -1615,7 +1615,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vcpu *current_vcpu, u64 ingpa, u64 outgpa,
>
> bool kvm_hv_hypercall_enabled(struct kvm *kvm)
> {
> - return READ_ONCE(kvm->arch.hyperv.hv_hypercall) & HV_X64_MSR_HYPERCALL_ENABLE;
> + return READ_ONCE(kvm->arch.hyperv.hv_guest_os_id) != 0;
> }
>
> static void kvm_hv_hypercall_set_result(struct kvm_vcpu *vcpu, u64 result)
I would've enabled it in both cases,
return (READ_ONCE(kvm->arch.hyperv.hv_hypercall) &
HV_X64_MSR_HYPERCALL_ENABLE) || (READ_ONCE(kvm->arch.hyperv.hv_guest_os_id) != 0);
to be safe. We can also check what genuine Hyper-V does but I bet it has
hypercalls always enabled. Also, the function can be made inline,
there's a single caller.
--
Vitaly
next prev parent reply other threads:[~2020-03-04 13:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200303130356.50405-1-arilou@gmail.com>
[not found] ` <20200303130356.50405-2-arilou@gmail.com>
2020-03-04 13:51 ` [PATCH v1 1/3] x86/kvm/hyper-v: Add support for synthetic debugger capability Vitaly Kuznetsov
2020-03-05 13:56 ` Jon Doron
[not found] ` <20200303130356.50405-3-arilou@gmail.com>
2020-03-04 13:58 ` Vitaly Kuznetsov [this message]
2020-03-05 13:57 ` [PATCH v1 2/3] x86/kvm/hyper-v: enable hypercalls regardless of hypercall page Jon Doron
[not found] ` <20200303130356.50405-4-arilou@gmail.com>
[not found] ` <87mu8wdxtt.fsf@vitty.brq.redhat.com>
2020-03-05 13:58 ` [PATCH v1 3/3] x86/kvm/hyper-v: Add support for synthetic debugger via hypercalls Jon Doron
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=87pndsdxxh.fsf@vitty.brq.redhat.com \
--to=vkuznets@redhat.com \
--cc=arilou@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
/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).