Skip to contentSkip to conversation

x86: Hyper-V: register clocksource only if its advertised

PATCH In review Olaf Hering 5 participants 18 messages Jan 25, 2013 – Jan 29, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Hyper-V: register clocksource only if its advertised

Enable hyperv_clocksource only if its advertised as a feature. XenServer 6 returns the signature which is checked in ms_hyperv_platform(), but it does not offer all features. Currently the clocksource is enabled unconditionally in ms_hyperv_init_platform(), and the result is a hanging guest.

Hyper-V spec Bit 1 indicates the availability of Partition Reference Counter. Register the clocksource only if this bit is set.

The guest in question prints this in dmesg:

 [    0.000000] Hypervisor detected: Microsoft HyperV
 [    0.000000] HyperV: features 0x70, hints 0x0

This bug can be reproduced easily be setting 'viridian=1' in a HVM domU .cfg file. A workaround without this patch is to boot the HVM guest with 'clocksource=jiffies'.

---
 arch/x86/kernel/cpu/mshyperv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/mshyperv.c +2 -1
index 0a630dd..646d192 100644
@@ -68,7 +68,8 @@ static void __init ms_hyperv_init_platform(void)
 	printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
 	       ms_hyperv.features, ms_hyperv.hints);
 
-	clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
+	if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
+		clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
Signature · 1 line
1.8.1.1
#1 lore raw
Quoted 17 lines · Olaf Hering

Enable hyperv_clocksource only if its advertised as a feature. XenServer 6 returns the signature which is checked in ms_hyperv_platform(), but it does not offer all features. Currently the clocksource is enabled unconditionally in ms_hyperv_init_platform(), and the result is a hanging guest.

Hyper-V spec Bit 1 indicates the availability of Partition Reference Counter. Register the clocksource only if this bit is set.

The guest in question prints this in dmesg:

 [    0.000000] Hypervisor detected: Microsoft HyperV
 [    0.000000] HyperV: features 0x70, hints 0x0

This bug can be reproduced easily be setting 'viridian=1' in a HVM domU .cfg file. A workaround without this patch is to boot the HVM guest with 'clocksource=jiffies'.

Quoted 7 lines
---
 arch/x86/kernel/cpu/mshyperv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

This needs to go through the x86 maintainers, not me, sorry.

greg k-h

#2 lore raw
In reply to Olaf Hering
Quoted 18 lines

-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Friday, January 25, 2013 8:37 AM
To: [email protected]
Cc: Olaf Hering; [email protected]; KY Srinivasan; Greg KH
Subject: [PATCH] x86: Hyper-V: register clocksource only if its advertised

Enable hyperv_clocksource only if its advertised as a feature. XenServer 6 returns the signature which is checked in ms_hyperv_platform(), but it does not offer all features. Currently the clocksource is enabled unconditionally in ms_hyperv_init_platform(), and the result is a hanging guest.

Hyper-V spec Bit 1 indicates the availability of Partition Reference Counter. Register the clocksource only if this bit is set.

Quoted 7 lines

The guest in question prints this in dmesg:

 [    0.000000] Hypervisor detected: Microsoft HyperV
 [    0.000000] HyperV: features 0x70, hints 0x0

This bug can be reproduced easily be setting 'viridian=1' in a HVM domU .cfg file. A workaround without this patch is to boot the HVM guest with 'clocksource=jiffies'.

I am curious why you are setting viridian=1 for a Linux HVM guest. Initially when I did the Hyper-V emulation work on Xen, this configuration flag would be set only for Windows guests since the idea was to run the "enlightened" Windows on Xen. While the current Xen emulation code does not emulate "Partition Reference Counter" there is no guarantee that Xen would not do this in the future. Perhaps dealing with this issue by identifying the guest (via the viridian domain or not) may be a safer approach?

Regards,

K. Y

Quoted 27 lines
---
 arch/x86/kernel/cpu/mshyperv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/mshyperv.c +2 -2
index 0a630dd..646d192 100644
@@ -68,7 +68,8 @@ static void __init ms_hyperv_init_platform(void)
 	printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
 	       ms_hyperv.features, ms_hyperv.hints);
 
-	clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
+	if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
+		clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
 }
 
 const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
--

1.8.1.1

#3 lore raw
Quoted 26 lines · KY Srinivasan
Quoted 18 lines

-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Friday, January 25, 2013 8:37 AM
To: [email protected]
Cc: Olaf Hering; [email protected]; KY Srinivasan; Greg KH
Subject: [PATCH] x86: Hyper-V: register clocksource only if its advertised

Enable hyperv_clocksource only if its advertised as a feature. XenServer 6 returns the signature which is checked in ms_hyperv_platform(), but it does not offer all features. Currently the clocksource is enabled unconditionally in ms_hyperv_init_platform(), and the result is a hanging guest.

Hyper-V spec Bit 1 indicates the availability of Partition Reference Counter. Register the clocksource only if this bit is set.

Quoted 7 lines

The guest in question prints this in dmesg:

 [    0.000000] Hypervisor detected: Microsoft HyperV
 [    0.000000] HyperV: features 0x70, hints 0x0

This bug can be reproduced easily be setting 'viridian=1' in a HVM domU .cfg file. A workaround without this patch is to boot the HVM guest with 'clocksource=jiffies'.

Quoted 6 lines

I am curious why you are setting viridian=1 for a Linux HVM guest. Initially when I did the Hyper-V emulation work on Xen, this configuration flag would be set only for Windows guests since the idea was to run the "enlightened" Windows on Xen. While the current Xen emulation code does not emulate "Partition Reference Counter" there is no guarantee that Xen would not do this in the future. Perhaps dealing with this issue by identifying the guest (via the viridian domain or not) may be a safer approach?

I'm not sure if XenServer does that per default, but I used the viridian= flag to reproduce the report.
If Xen starts to emulate the "Partition Reference Counter" it should also advertise this emulation with the feature flag. Are you saying that checking for features is not the right approach?

Olaf

#4 lore raw
Quoted 46 lines

-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Friday, January 25, 2013 11:55 AM
To: KY Srinivasan
Cc: [email protected]; Greg KH
Subject: Re: [PATCH] x86: Hyper-V: register clocksource only if its advertised

Quoted 22 lines · KY Srinivasan
Quoted 22 lines

-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Friday, January 25, 2013 8:37 AM
To: [email protected]
Cc: Olaf Hering; [email protected]; KY Srinivasan; Greg KH
Subject: [PATCH] x86: Hyper-V: register clocksource only if its advertised

Enable hyperv_clocksource only if its advertised as a feature. XenServer 6 returns the signature which is checked in ms_hyperv_platform(), but it does not offer all features. Currently the clocksource is enabled unconditionally in ms_hyperv_init_platform(), and the result is a hanging guest.

Hyper-V spec Bit 1 indicates the availability of Partition Reference Counter. Register the clocksource only if this bit is set.

The guest in question prints this in dmesg:

 [    0.000000] Hypervisor detected: Microsoft HyperV
 [    0.000000] HyperV: features 0x70, hints 0x0
Quoted 6 lines
Quoted 3 lines

This bug can be reproduced easily be setting 'viridian=1' in a HVM domU .cfg file. A workaround without this patch is to boot the HVM guest with 'clocksource=jiffies'.

I am curious why you are setting viridian=1 for a Linux HVM guest. Initially when I did the Hyper-V emulation work on Xen, this configuration flag would be set

only

Quoted 1 line

for Windows guests since the idea was to run the "enlightened" Windows on

Xen.

Quoted 1 line

While the current Xen emulation code does not emulate "Partition Reference

Counter"

Quoted 1 line

there is no guarantee that Xen would not do this in the future. Perhaps dealing

with this issue

Quoted 8 lines
Quoted 1 line

by identifying the guest (via the viridian domain or not) may be a safer

approach?

I'm not sure if XenServer does that per default, but I used the viridian= flag to reproduce the report.
If Xen starts to emulate the "Partition Reference Counter" it should also advertise this emulation with the feature flag. Are you saying that checking for features is not the right approach?

My fear is that there is no guarantee that Xen would not emulate this feature
in the spirit of making Hyper-V emulation "more" complete. Since all this problem is because Xen thinks it is running a viridian domain (when in fact it is running Linux), I felt we should explore why the viridian tag got set for a Linux VM. If we can fix that we would have a solution that does not depend upon assuming that Xen would not emulate a particular Hyper-V feature.

K. Y ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#5 lore raw
Quoted 7 lines · KY Srinivasan

My fear is that there is no guarantee that Xen would not emulate this feature in the spirit of making Hyper-V emulation "more" complete. Since all this problem is because Xen thinks it is running a viridian domain (when in fact it is running Linux), I felt we should explore why the viridian tag got set for a Linux VM. If we can fix that we would have a solution that does not depend upon assuming that Xen would not emulate a particular Hyper-V feature.

In my opinion this logic is backwards. A host provides a set of functionality/features to a given guest, no matter what runs inside the guest. And the guest can query the feature list and configure itself accordingly. In this specific case the guest finds feature A (the cpuid result) and expects that feature B (a clock source) is present as well, even if feature B has its very own availability flag.

Maybe I miss your point.

Olaf

#6 lore raw
Quoted 19 lines

-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Friday, January 25, 2013 12:19 PM
To: KY Srinivasan
Cc: [email protected]; Greg KH; Jan Beulich ([email protected])
Subject: Re: [PATCH] x86: Hyper-V: register clocksource only if its advertised

Quoted 7 lines · KY Srinivasan

My fear is that there is no guarantee that Xen would not emulate this feature in the spirit of making Hyper-V emulation "more" complete. Since all this problem is because Xen thinks it is running a viridian domain (when in fact it is running Linux), I felt we should explore why the viridian tag got set for a Linux VM. If we can fix that we would have a solution that does not depend upon assuming that Xen would not emulate a particular Hyper-V feature.

Quoted 6 lines

In my opinion this logic is backwards. A host provides a set of functionality/features to a given guest, no matter what runs inside the guest. And the guest can query the feature list and configure itself accordingly. In this specific case the guest finds feature A (the cpuid result) and expects that feature B (a clock source) is present as well, even if feature B has its very own availability flag.

I would agree with you in the abstract but not in this specific case. First, the current Hyper-V code in Linux verifies that the underlying hypervisor is Hyper-V and proceeds to setup state that is needed to run Linux on Hyper-V.
If Xen were not emulating Hyper-V, we would not have any issue here. However, Xen does emulate Hyper-V and it is emulating Hyper-V not to run Linux, but to run enlightened Windows (making Windows think it is running on Hyper-V). We have a mechanism in place for controlling this Hyper-V emulation in Xen - the viridian flag. In my view, ensuring that this flag is not set for a non -Windows guest is the only safe approach to dealing with this issue. Your current approach of using the "Partition Reference Counter" feature bit is very fragile. Let us assume that future Windows guests depend on this feature; Xen would certainly emulate this to have a "good" emulation of Hyper-V and we are back to square one.

Regards,

K. Y

Quoted 5 lines

Maybe I miss your point.

Olaf

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#7 lore raw
Quoted 4 lines · KY Srinivasan

Your current approach of using the "Partition Reference Counter" feature bit is very fragile. Let us assume that future Windows guests depend on this feature; Xen would certainly emulate this to have a "good" emulation of Hyper-V and we are back to square one.

If Xen starts to emulate the "Partition Reference Counter" feature, wouldnt it also advertise this feature?

Olaf

#8 lore raw
Quoted 11 lines

-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Friday, January 25, 2013 3:00 PM
To: KY Srinivasan
Cc: [email protected]; Greg KH; Jan Beulich ([email protected])
Subject: Re: [PATCH] x86: Hyper-V: register clocksource only if its advertised

On Fri, Jan 25, KY Srinivasan wrote:

Quoted 7 lines
Quoted 4 lines

Your current approach of using the "Partition Reference Counter" feature bit is very fragile. Let us assume that future Windows guests depend on this feature; Xen would certainly emulate this to have a "good" emulation of Hyper-V and we are back to square one.

If Xen starts to emulate the "Partition Reference Counter" feature, wouldnt it also advertise this feature?

Yes; it has to - if it expects the Windows guests to use it. This would be no different than the other features that Xen emulates and advertises.

K. Y

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#9 lore raw
In reply to Olaf Hering
Quoted 11 lines

-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Friday, January 25, 2013 3:00 PM
To: KY Srinivasan
Cc: [email protected]; Greg KH; Jan Beulich ([email protected])
Subject: Re: [PATCH] x86: Hyper-V: register clocksource only if its advertised

On Fri, Jan 25, KY Srinivasan wrote:

Quoted 7 lines
Quoted 4 lines

Your current approach of using the "Partition Reference Counter" feature bit is very fragile. Let us assume that future Windows guests depend on this feature; Xen would certainly emulate this to have a "good" emulation of Hyper-V and we are back to square one.

If Xen starts to emulate the "Partition Reference Counter" feature, wouldnt it also advertise this feature?

Olaf, did you get a chance to investigate why the viridian bit was set for the Linux HVM domain. I am thinking of re-sending the patch for delivering the Hyper-V vmbus on a separate vector without a run-time check. Let me know.

Regards,

K. Y

Quoted 3 lines

Olaf

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#10 lore raw
Quoted 16 lines · KY Srinivasan
Quoted 16 lines

-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Friday, January 25, 2013 3:00 PM
To: KY Srinivasan
Cc: [email protected]; Greg KH; Jan Beulich ([email protected])
Subject: Re: [PATCH] x86: Hyper-V: register clocksource only if its advertised

Quoted 4 lines · KY Srinivasan

Your current approach of using the "Partition Reference Counter" feature bit is very fragile. Let us assume that future Windows guests depend on this feature; Xen would certainly emulate this to have a "good" emulation of Hyper-V and we are back to square one.

Quoted 5 lines
Quoted 2 lines

If Xen starts to emulate the "Partition Reference Counter" feature, wouldnt it also advertise this feature?

Olaf, did you get a chance to investigate why the viridian bit was set for the Linux HVM domain.

I dont know, most likely XenServer sets this per default?

Quoted 2 lines

I am thinking of re-sending the patch for delivering the Hyper-V vmbus on a separate vector without a run-time check. Let me know.

Are you also acking/nacking this patch?

Olaf

#11 lore raw
In reply to KY Srinivasan
Quoted 24 lines · KY Srinivasan
Quoted 17 lines

-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Friday, January 25, 2013 12:19 PM
To: KY Srinivasan
Cc: [email protected]; Greg KH; Jan Beulich ([email protected])
Subject: Re: [PATCH] x86: Hyper-V: register clocksource only if its advertised

Quoted 7 lines · KY Srinivasan

My fear is that there is no guarantee that Xen would not emulate this feature in the spirit of making Hyper-V emulation "more" complete. Since all this problem is because Xen thinks it is running a viridian domain (when in fact it is running Linux), I felt we should explore why the viridian tag got set for a Linux VM. If we can fix that we would have a solution that does not depend upon assuming that Xen would not emulate a particular Hyper-V feature.

Quoted 6 lines

In my opinion this logic is backwards. A host provides a set of functionality/features to a given guest, no matter what runs inside the guest. And the guest can query the feature list and configure itself accordingly. In this specific case the guest finds feature A (the cpuid result) and expects that feature B (a clock source) is present as well, even if feature B has its very own availability flag.

Quoted 12 lines

I would agree with you in the abstract but not in this specific case. First, the current Hyper-V code in Linux verifies that the underlying hypervisor is Hyper-V and proceeds to setup state that is needed to run Linux on Hyper-V.
If Xen were not emulating Hyper-V, we would not have any issue here. However, Xen does emulate Hyper-V and it is emulating Hyper-V not to run Linux, but to run enlightened Windows (making Windows think it is running on Hyper-V). We have a mechanism in place for controlling this Hyper-V emulation in Xen - the viridian flag. In my view, ensuring that this flag is not set for a non -Windows guest is the only safe approach to dealing with this issue. Your current approach of using the "Partition Reference Counter" feature bit is very fragile. Let us assume that future Windows guests depend on this feature; Xen would certainly emulate this to have a "good" emulation of Hyper-V and we are back to square one.

I think that Olaf made his point very clear: a feature A should only be enabled if the corresponding flag A is set.
In fact it seems to me that this patch is correct on its own merits, regardless of Xen does or does not.

The Xen tools might or might not know whether a guest is going to be Linux, Windows, FreeBSD or whatever else people use nowadays. Setting viridian=1 is the safe choice, given that it shouldn't create any
issues: after all guests are supposed to check for feature flags before using them.

If Xen is going to implement "Partition Reference Counter", it is also going to set the corresponding flag, so the guest OS (Windows, Linux, my pet OS) can check whether the feature is available and decide whether it wants to use it.

#12 lore raw
Quoted 12 lines
Quoted 1 line
Quoted 1 line · Stefano Stabellini

I think that Olaf made his point very clear: a feature A should only be enabled if the corresponding flag A is set.
In fact it seems to me that this patch is correct on its own merits, regardless of Xen does or does not.

The Xen tools might or might not know whether a guest is going to be Linux, Windows, FreeBSD or whatever else people use nowadays. Setting viridian=1 is the safe choice, given that it shouldn't create any
issues: after all guests are supposed to check for feature flags before using them.

Quoted 4 lines

If Xen is going to implement "Partition Reference Counter", it is also going to set the corresponding flag, so the guest OS (Windows, Linux, my pet OS) can check whether the feature is available and decide whether it wants to use it.

While I agree in general, the specific case of the callback vector seems a little more difficult: As KY says, there's no feature flag for this (or perhaps more precisely for it being deliverable across all CPUs), and hence there's both the problem of detection and the problem of disambiguation (as otherwise both the Hyper-V code and the Xen code in Linux could be trying to use the same vector).

Jan

#13 lore raw
Quoted 17 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · Stefano Stabellini

I think that Olaf made his point very clear: a feature A should only be enabled if the corresponding flag A is set.
In fact it seems to me that this patch is correct on its own merits, regardless of Xen does or does not.

The Xen tools might or might not know whether a guest is going to be Linux, Windows, FreeBSD or whatever else people use nowadays. Setting viridian=1 is the safe choice, given that it shouldn't create any
issues: after all guests are supposed to check for feature flags before using them.

Quoted 4 lines

If Xen is going to implement "Partition Reference Counter", it is also going to set the corresponding flag, so the guest OS (Windows, Linux, my pet OS) can check whether the feature is available and decide whether it wants to use it.

Quoted 7 lines

While I agree in general, the specific case of the callback vector seems a little more difficult: As KY says, there's no feature flag for this (or perhaps more precisely for it being deliverable across all CPUs), and hence there's both the problem of detection and the problem of disambiguation (as otherwise both the Hyper-V code and the Xen code in Linux could be trying to use the same vector).

This is true, but belongs to that other thread about the interrupt vector. I agree that the detection in ms_hyperv_platform() should be extended, with a DMI check for example.

The patch which started this thread is still valid because it enables feature B only if the featurebit for B is enabled.

Olaf

#14 lore raw
Quoted 37 lines

-----Original Message-----
From: Olaf Hering [mailto:[email protected]]
Sent: Tuesday, January 29, 2013 4:27 AM
To: Jan Beulich
Cc: Stefano Stabellini; KY Srinivasan; Greg KH; [email protected]
Subject: Re: [PATCH] x86: Hyper-V: register clocksource only if its advertised

Quoted 1 line · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 28.01.13 at 18:44, Stefano Stabellini <[email protected]>

Quoted 16 lines · wrote:
Quoted 11 lines

I think that Olaf made his point very clear: a feature A should only be enabled if the corresponding flag A is set.
In fact it seems to me that this patch is correct on its own merits, regardless of Xen does or does not.

The Xen tools might or might not know whether a guest is going to be Linux, Windows, FreeBSD or whatever else people use nowadays. Setting viridian=1 is the safe choice, given that it shouldn't create any
issues: after all guests are supposed to check for feature flags before using them.

Quoted 4 lines

If Xen is going to implement "Partition Reference Counter", it is also going to set the corresponding flag, so the guest OS (Windows, Linux, my pet OS) can check whether the feature is available and decide whether it wants to use it.

Quoted 7 lines

While I agree in general, the specific case of the callback vector seems a little more difficult: As KY says, there's no feature flag for this (or perhaps more precisely for it being deliverable across all CPUs), and hence there's both the problem of detection and the problem of disambiguation (as otherwise both the Hyper-V code and the Xen code in Linux could be trying to use the same vector).

Quoted 3 lines

This is true, but belongs to that other thread about the interrupt vector. I agree that the detection in ms_hyperv_platform() should be extended, with a DMI check for example.

I want to explore extending ms_hyperv_platform() to detect if Hyper-V is being emulated. Since Hyper-V is never going to emulate Xen, in my view this would be a better option.

Quoted 3 lines

The patch which started this thread is still valid because it enables feature B only if the featurebit for B is enabled.

Why would we need this if we have some other way of detecting that Hyper-V is being emulated. Furthermore, I am not sure I understand the logic here. The fact that the hypervisor supports PARTITION_REFERENCE_COUNTER does not necessarily mean that we should register a clocksource based on that reference counter. It is true that that is the case on Hyper-V today. However, on other hypervisors emulating Hyper-V, other standard clocksources maybe more appropriate.

I agree with you that your patch is valid for making the Hyper-V code more robust but not for dealing with general issue of Xen emulating Hyper-V. I will Ack your patch.

Regards,

K. Y

Quoted 3 lines

Olaf

���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�

#15 lore raw
Quoted 5 lines · KY Srinivasan
Quoted 2 lines

The patch which started this thread is still valid because it enables feature B only if the featurebit for B is enabled.

Why would we need this if we have some other way of detecting that Hyper-V is being emulated.

I don't think that Hyper-V being emulated or not matters here. What matters is whether the feature is available: only if it is then it should be used.

Quoted 5 lines

Furthermore, I am not sure I understand the logic here. The fact that the hypervisor supports PARTITION_REFERENCE_COUNTER does not necessarily mean that we should register a clocksource based on that reference counter. It is true that that is the case on Hyper-V today. However, on other hypervisors emulating Hyper-V, other standard clocksources maybe more appropriate.

The point is that if a feature is NOT supported, then it should NOT be used. Only if it is supported, then Linux might consider using it. And of course can decide not to use it.

Quoted 2 lines

I agree with you that your patch is valid for making the Hyper-V code more robust but not for dealing with general issue of Xen emulating Hyper-V.

What "general issue" would that be?

#16 lore raw
Quoted 38 lines

-----Original Message-----
From: Stefano Stabellini [mailto:[email protected]]
Sent: Tuesday, January 29, 2013 10:31 AM
To: KY Srinivasan
Cc: Olaf Hering; Jan Beulich; Stefano Stabellini; Greg KH; linux- [email protected]
Subject: RE: [PATCH] x86: Hyper-V: register clocksource only if its advertised

Quoted 4 lines · KY Srinivasan
Quoted 2 lines

The patch which started this thread is still valid because it enables feature B only if the featurebit for B is enabled.

Why would we need this if we have some other way of detecting that Hyper-V

is being

Quoted 1 line

emulated.

I don't think that Hyper-V being emulated or not matters here. What matters is whether the feature is available: only if it is then it should be used.

Quoted 1 line

Furthermore, I am not sure I understand the logic here. The fact that the

hypervisor

Quoted 1 line

supports PARTITION_REFERENCE_COUNTER does not necessarily mean that we

should register

Quoted 1 line

a clocksource based on that reference counter. It is true that that is the case on

Hyper-V today.

Quoted 1 line

However, on other hypervisors emulating Hyper-V, other standard

clocksources maybe more

Quoted 1 line

appropriate.

The point is that if a feature is NOT supported, then it should NOT be used. Only if it is supported, then Linux might consider using it. And of course can decide not to use it.

Quoted 5 lines
Quoted 1 line

I agree with you that your patch is valid for making the Hyper-V code more

robust but not for dealing

Quoted 1 line

with general issue of Xen emulating Hyper-V.

What "general issue" would that be?

Not all Hyper-V specific features are advertised via a feature bit. For instance, we need to reserve an IDT entry to have VMBUS interrupts delivered on a per-CPU basis and this reservation is done after confirming that we are running on Hyper-V. With Xen emulating Hyper-V, we have an issue. Since Hyper-V will never emulate Xen, I am going to add a check in the Hyper-V detection code to deal with this issue.

Regards,

K. Y

#17 lore raw
Quoted 11 lines · KY Srinivasan
Quoted 5 lines
Quoted 1 line

I agree with you that your patch is valid for making the Hyper-V code more

robust but not for dealing

Quoted 1 line

with general issue of Xen emulating Hyper-V.

What "general issue" would that be?

Not all Hyper-V specific features are advertised via a feature bit. For instance, we need to reserve an IDT entry to have VMBUS interrupts delivered on a per-CPU basis and this reservation is done after confirming that we are running on Hyper-V. With Xen emulating Hyper-V, we have an issue. Since Hyper-V will never emulate Xen, I am going to add a check in the Hyper-V detection code to deal with this issue.

I personally think that it would be much nicer to have a feature flag somewhere to advertise per-CPU VMBUS interrupts.
However adding a check in the Hyper-V detection code is OK too for me.