2013-04-17 09:10:09

by Victor Miasnikov

[permalink] [raw]
Subject: KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ? Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ? Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

Hi!

Short:

>> >> When KVM runs in Hyper-V emulation mode it expects to get Hyper-V hypercalls.
>> >> Mixing KVM hypercalls and Hyper-V requires some tricks. It
VVM>> KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ?
> It's not related.

Are You shue?
Xen-team _think_ too what is not related, but has non-100% _full_ emulation of Hyper-V and, as result, create problems

Question is very simple: Hyper-V users/sysadmins need wait patch a-la this:

==
KVM emulates Hyper-V to host enlightened Windows.

. . .

[ hpa: the problem here is that KVM doesn't emulate Hyper-V well
enough, . . ]

. . .

+ * KVM emulates Hyper-V to support enlightened Windows.
+ * Check to see first if we are on a KVM Hypervisor.
+ if (KVM_cpuid_base())
+ return false;
. . .
==

Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ?



--
Full:

----- Original Message -----
From: "Michael S. Tsirkin"
To: "K. Y. Srinivasan"
Cc:
Sent: Wednesday, April 17, 2013 10:06 AM
Subject: Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V


> On Sun, Feb 03, 2013 at 05:22:38PM -0800, K. Y. Srinivasan wrote:
>> Xen emulates Hyper-V to host enlightened Windows. Looks like this
>> emulation may be turned on by default even for Linux guests. Check and
>> fail Hyper-V detection if we are on Xen.
>>
>> Signed-off-by: K. Y. Srinivasan kys (at) microsoft.com
>
> I'm very curious what's the specific bug that is fixed here?
> I went over the original discussion in
> https://patchwork.kernel.org/patch/2064331/
> and that's still not clear to me. Is there a configuration
> that is broken without this patch but starts working with
> this patch?
>
> It seems that one might want to use hyper-v emulation e.g. to test
> hyper-v code without using windows, so the functionality
> that this patch disables is not completely useless,
> so there should be a good reason for disabling it.
>
> Could you enlighten me please? :)

Short history of question:

{{
==
> > And hypercall has its own set of problems with Windows guests.
> > When KVM runs in Hyper-V emulation mode it expects to get Hyper-V hypercalls.
> > Mixing KVM hypercalls and Hyper-V requires some tricks. It
>
> Can't we simply register a hypercall ID range with Microsoft?
>
> > may also affect WHQLing Windows drivers since driver will talk to HW
> > bypassing Windows interfaces.
>
> Then the WHQL'ed driver doesn't support the PV MMIO hcall?
==

KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ?
}}

{{
>> >> When KVM runs in Hyper-V emulation mode it expects to get Hyper-V hypercalls.
>> >> Mixing KVM hypercalls and Hyper-V requires some tricks. It
>> KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ?
> It's not related.

Are You shue?
Xen-team _think_ too what is not related, but has non-100% _full_ emulation of Hyper-V and, as result, create problems:

==
Xen emulates Hyper-V to host enlightened Windows. Looks like this
emulation may be turned on by default even for Linux guests. Check and
fail Hyper-V detection if we are on Xen.

[ hpa: the problem here is that Xen doesn't emulate Hyper-V well
enough, and if the Xen support isn't compiled in, we end up stubling
over the Hyper-V emulation and try to activate it -- and it fails. ]

. . .

+ /*
+ * Xen emulates Hyper-V to support enlightened Windows.
+ * Check to see first if we are on a Xen Hypervisor.
+ */
+ if (xen_cpuid_base())
+ return false;
+
==
}}


Question is very simple: Hyper-V users/sysadmins need wait patch a-la this:

==
KVM emulates Hyper-V to host enlightened Windows. Looks like this
emulation may be turned on by default even for Linux guests. Check and
fail Hyper-V detection if we are on KVM.

[ hpa: the problem here is that KVM doesn't emulate Hyper-V well
enough, and if the KVM support isn't compiled in, we end up stubling
over the Hyper-V emulation and try to activate it -- and it fails. ]

. . .

+ /*
+ * KVM emulates Hyper-V to support enlightened Windows.
+ * Check to see first if we are on a KVM Hypervisor.
+ */
+ if (KVM_cpuid_base())
+ return false;
+
==


Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ?


Best regards, Victor Miasnikov
Blog: http://vvm.blog.tut.by/

P.S.



----- Original Message -----
From: "Michael S. Tsirkin"
To: "Victor Miasnikov"
Sent: Wednesday, April 17, 2013 10:07 AM

I'm not sure what are we talking about then, but please
use the mailing list appropriate for the subject.


----- Original Message -----
From: "Victor Miasnikov" vvm (a) tut (dot) by
To: "Michael S. Tsirkin"
Cc: "KY Srinivasan"
Sent: Tuesday, April 16, 2013 9:36 AM
Subject: Are You shue what is 100% _full_ emulation of Hyper-V? Re: It's not related Re: KVM "Hyper-V emulation" -- this
can be related "Linux on Hyper-V" ?

Hi!


>> >> When KVM runs in Hyper-V emulation mode it expects to get Hyper-V hypercalls.
>> >> Mixing KVM hypercalls and Hyper-V requires some tricks. It
>> KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ?
> It's not related.

Are You shue?
Xen-team _think_ too what is not related, but has non-100% _full_ emulation of Hyper-V and, as result, create problems:

==
Xen emulates Hyper-V to host enlightened Windows. Looks like this
emulation may be turned on by default even for Linux guests. Check and
fail Hyper-V detection if we are on Xen.

[ hpa: the problem here is that Xen doesn't emulate Hyper-V well
enough, and if the Xen support isn't compiled in, we end up stubling
over the Hyper-V emulation and try to activate it -- and it fails. ]

. . .

+ /*
+ * Xen emulates Hyper-V to support enlightened Windows.
+ * Check to see first if we are on a Xen Hypervisor.
+ */
+ if (xen_cpuid_base())
+ return false;
+
==

( full see ib P.S.)

Best regards, Victor Miasnikov
Blog: http://vvm.blog.tut.by/

P.S.


==
----- Original Message -----
From: "tip-bot for K. Y. Srinivasan"

. . .

Sent: Wednesday, February 13, 2013 3:57 AM
Subject: [tip:x86/hyperv] X86: Add a check to catch Xen emulation of Hyper-V


Commit-ID: db34bbb767bdfa1ebed7214b876fe01c5b7ee457
Gitweb: http://git.kernel.org/tip/db34bbb767bdfa1ebed7214b876fe01c5b7ee457
Author: K. Y. Srinivasan
AuthorDate: Sun, 3 Feb 2013 17:22:38 -0800
Committer: H. Peter Anvin
CommitDate: Tue, 12 Feb 2013 16:27:03 -0800

X86: Add a check to catch Xen emulation of Hyper-V

Xen emulates Hyper-V to host enlightened Windows. Looks like this
emulation may be turned on by default even for Linux guests. Check and
fail Hyper-V detection if we are on Xen.

[ hpa: the problem here is that Xen doesn't emulate Hyper-V well
enough, and if the Xen support isn't compiled in, we end up stubling
over the Hyper-V emulation and try to activate it -- and it fails. ]

Signed-off-by: K. Y. Srinivasan
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: H. Peter Anvin
---
arch/x86/kernel/cpu/mshyperv.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 646d192..4dab317 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -30,6 +30,13 @@ static bool __init ms_hyperv_platform(void)
if (!boot_cpu_has(X86_FEATURE_HYPERVISOR))
return false;

+ /*
+ * Xen emulates Hyper-V to support enlightened Windows.
+ * Check to see first if we are on a Xen Hypervisor.
+ */
+ if (xen_cpuid_base())
+ return false;
+
cpuid(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS,
&eax, &hyp_signature[0], &hyp_signature[1], &hyp_signature[2]);

--
==







----- Original Message -----
From: "Michael S. Tsirkin"
To: "Victor Miasnikov" vvm (a) tut (dot) by
Sent: Tuesday, April 16, 2013 1:11 AM
Subject: Re: KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ? Fw: When KVM runs in Hyper-V emulation
mode it expects to get Hyper-V hypercalls.


> On Mon, Apr 15, 2013 at 04:00:34PM +0300, Victor Miasnikov wrote:
>>
>> ==
>> >> And hypercall has its own set of problems with Windows guests.
>> >> When KVM runs in Hyper-V emulation mode it expects to get Hyper-V hypercalls.
>> >> Mixing KVM hypercalls and Hyper-V requires some tricks. It
>> >
>> >Can't we simply register a hypercall ID range with Microsoft?
>> >
>> >> may also affect WHQLing Windows drivers since driver will talk to HW
>> >> bypassing Windows interfaces.
>> >
>> >Then the WHQL'ed driver doesn't support the PV MMIO hcall?
>> ==
>>
>> KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ?
>>
>>
>
> It's not related.





----- Original Message -----
From: "Victor Miasnikov" vvm (a) tut (dot) by
To: "Michael S. Tsirkin"
Sent: Monday, April 15, 2013 4:00 PM
Subject: KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ? Fw: When KVM runs in Hyper-V emulation mode
it expects to get Hyper-V hypercalls.


Hi!


==
> > And hypercall has its own set of problems with Windows guests.
> > When KVM runs in Hyper-V emulation mode it expects to get Hyper-V hypercalls.
> > Mixing KVM hypercalls and Hyper-V requires some tricks. It
>
> Can't we simply register a hypercall ID range with Microsoft?
>
> > may also affect WHQLing Windows drivers since driver will talk to HW
> > bypassing Windows interfaces.
>
> Then the WHQL'ed driver doesn't support the PV MMIO hcall?
==

KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ?


Best regards, Victor Miasnikov
Blog: http://vvm.blog.tut.by/




2013-04-17 11:15:50

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ? Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ? Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

On Wed, Apr 17, 2013 at 12:10:01PM +0300, Victor Miasnikov wrote:
> Question is very simple: Hyper-V users/sysadmins need wait patch a-la this:
>
> ==
> KVM emulates Hyper-V to host enlightened Windows. Looks like this
> emulation may be turned on by default even for Linux guests. Check and
> fail Hyper-V detection if we are on KVM.

> [ hpa: the problem here is that KVM doesn't emulate Hyper-V well
> enough, and if the KVM support isn't compiled in, we end up stubling
> over the Hyper-V emulation and try to activate it -- and it fails. ]
>
> . . .

What's emulated not well enough?

> + /*
> + * KVM emulates Hyper-V to support enlightened Windows.
> + * Check to see first if we are on a KVM Hypervisor.
> + */

If the hypervisor says it's Hyper-V, that's because it wants
guests to use Hyper-V. I don't see why is guest second-guessing
this a good idea.

> + if (KVM_cpuid_base())
> + return false;
> +
> ==
>
>
> Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ?
>
>
> Best regards, Victor Miasnikov
> Blog: http://vvm.blog.tut.by/
>
> P.S.

No. You are using Hyper-V, not the KVM emulation of it. No patches
dealing with this emulation should have any effect on you.

--
MST

2013-04-17 12:11:54

by Jan Beulich

[permalink] [raw]
Subject: Re: KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ? Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ? Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

>>> On 17.04.13 at 12:16, "Michael S. Tsirkin" <[email protected]> wrote:
> If the hypervisor says it's Hyper-V, that's because it wants
> guests to use Hyper-V. I don't see why is guest second-guessing
> this a good idea.

There are two reasons here: For one, when the hypervisor is not
Hyper-V, but is providing some Hyper-V emulation, that's intended
for Windows guests to use, not e.g. Linux ones, especially when
such guests could use the native hypervisor interface with much
greater benefit.

And second, there reportedly are features of (newer?) Hyper-V
that some emulation may not provide, but that are also not easily
detectable.

Jan

2013-04-17 13:14:28

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: KVM "Hyper-V emulation" -- this can be related "Linux on Hyper-V" ? Or "KVM emulates Hyper-V" as "Hyper-V emulates Hyper-V" ? Re: [PATCH 2/3] X86: Add a check to catch Xen emulation of Hyper-V

On Wed, Apr 17, 2013 at 01:12:37PM +0100, Jan Beulich wrote:
> >>> On 17.04.13 at 12:16, "Michael S. Tsirkin" <[email protected]> wrote:
> > If the hypervisor says it's Hyper-V, that's because it wants
> > guests to use Hyper-V. I don't see why is guest second-guessing
> > this a good idea.
>
> There are two reasons here: For one, when the hypervisor is not
> Hyper-V, but is providing some Hyper-V emulation, that's intended
> for Windows guests to use, not e.g. Linux ones,

Fact is that this patch changed the guest/hypervisor interface which
should not be done lightly. We don't know all uses that Linux is put
to. I gave what seems, to me, like a perfectly valid reason to use
hyper-v emulation with Linux guests, which you snipped out :) Below is
a scanario that will now be broken:
>>>It seems that one might want to use hyper-v emulation e.g. to test
>>>hyper-v code without using windows, so the functionality
>>>that this patch disables is not completely useless,
There could be others.

> such guests could use the native hypervisor interface with much
> greater benefit.

Why not disable the emulation in the hypervisor? What overriding the
hypervisor will lead to, is hypervisors will try harder and mask their
real identity. No one will win in this arms race.

> And second, there reportedly are features of (newer?) Hyper-V
> that some emulation may not provide, but that are also not easily
> detectable.
>
> Jan

Could you be more explicit please? What are these features? How does a
windows guest able to use them if they are both new and not detectable?
Why not just fix the emulation? How will Linux use the new features
when e.g. Xen adds them?

--
MST