All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] drivers/hv: correct tsc page sequence invalid value
@ 2015-11-02 11:34 Denis V. Lunev
  2015-11-02 19:42 ` KY Srinivasan
  0 siblings, 1 reply; 5+ messages in thread
From: Denis V. Lunev @ 2015-11-02 11:34 UTC (permalink / raw)
  Cc: rkagan, devel, linux-kernel, Andrey Smetanin, K. Y. Srinivasan,
	Haiyang Zhang, Vitaly Kuznetsov, Denis V. Lunev

From: Andrey Smetanin <asmetanin@virtuozzo.com>

Hypervisor Top Level Functional Specification v3/4 says
that TSC page sequence value = -1(0xFFFFFFFF) is used to
indicate that TSC page no longer reliable source of reference
timer. Unfortunately, we found that Windows Hyper-V guest
side implementation uses sequence value = 0 to indicate
that Tsc page no longer valid. This is clearly visible
inside Windows 2012R2 ntoskrnl.exe HvlGetReferenceTime()
function dissassembly:

HvlGetReferenceTime proc near
                 xchg    ax, ax
loc_1401C3132:
                 mov     rax, cs:HvlpReferenceTscPage
                 mov     r9d, [rax]
                 test    r9d, r9d
                 jz      short loc_1401C3176
                 rdtsc
                 mov     rcx, cs:HvlpReferenceTscPage
                 shl     rdx, 20h
                 or      rdx, rax
                 mov     rax, [rcx+8]
                 mov     rcx, cs:HvlpReferenceTscPage
                 mov     r8, [rcx+10h]
                 mul     rdx
                 mov     rax, cs:HvlpReferenceTscPage
                 add     rdx, r8
                 mov     ecx, [rax]
                 cmp     ecx, r9d
                 jnz     short loc_1401C3132
                 jmp     short loc_1401C3184
loc_1401C3176:
                 mov     ecx, 40000020h
                 rdmsr
                 shl     rdx, 20h
                 or      rdx, rax
loc_1401C3184:
                 mov     rax, rdx
                 retn
HvlGetReferenceTime endp

This patch aligns Tsc page invalid sequence value with
Windows Hyper-V guest implementation which is more
compatible with both Hyper-V hypervisor and KVM hypervisor.

Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
CC: "K. Y. Srinivasan" <kys@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Vitaly Kuznetsov <vkuznets@redhat.com>

TARGET: Microsoft Hyper-V Linux guest drivers
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
 drivers/hv/hv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 6341be8..68d0701 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -139,7 +139,7 @@ static cycle_t read_hv_clock_tsc(struct clocksource *arg)
 	cycle_t current_tick;
 	struct ms_hyperv_tsc_page *tsc_pg = hv_context.tsc_page;
 
-	if (tsc_pg->tsc_sequence != -1) {
+	if (tsc_pg->tsc_sequence != 0) {
 		/*
 		 * Use the tsc page to compute the value.
 		 */
@@ -161,7 +161,7 @@ static cycle_t read_hv_clock_tsc(struct clocksource *arg)
 			if (tsc_pg->tsc_sequence == sequence)
 				return current_tick;
 
-			if (tsc_pg->tsc_sequence != -1)
+			if (tsc_pg->tsc_sequence != 0)
 				continue;
 			/*
 			 * Fallback using MSR method.
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH 1/1] drivers/hv: correct tsc page sequence invalid value
  2015-11-02 11:34 [PATCH 1/1] drivers/hv: correct tsc page sequence invalid value Denis V. Lunev
@ 2015-11-02 19:42 ` KY Srinivasan
  2015-11-12  7:16   ` Denis V. Lunev
  0 siblings, 1 reply; 5+ messages in thread
From: KY Srinivasan @ 2015-11-02 19:42 UTC (permalink / raw)
  To: Denis V. Lunev
  Cc: rkagan, devel, linux-kernel, Andrey Smetanin, Haiyang Zhang,
	Vitaly Kuznetsov



> -----Original Message-----
> From: Denis V. Lunev [mailto:den@openvz.org]
> Sent: Monday, November 2, 2015 3:34 AM
> Cc: rkagan@virtuozzo.com; devel@linuxdriverproject.org; linux-
> kernel@vger.kernel.org; Andrey Smetanin <asmetanin@virtuozzo.com>; KY
> Srinivasan <kys@microsoft.com>; Haiyang Zhang
> <haiyangz@microsoft.com>; Vitaly Kuznetsov <vkuznets@redhat.com>;
> Denis V. Lunev <den@openvz.org>
> Subject: [PATCH 1/1] drivers/hv: correct tsc page sequence invalid value
> 
> From: Andrey Smetanin <asmetanin@virtuozzo.com>
> 
> Hypervisor Top Level Functional Specification v3/4 says
> that TSC page sequence value = -1(0xFFFFFFFF) is used to
> indicate that TSC page no longer reliable source of reference
> timer. Unfortunately, we found that Windows Hyper-V guest
> side implementation uses sequence value = 0 to indicate
> that Tsc page no longer valid. This is clearly visible
> inside Windows 2012R2 ntoskrnl.exe HvlGetReferenceTime()
> function dissassembly:
> 
> HvlGetReferenceTime proc near
>                  xchg    ax, ax
> loc_1401C3132:
>                  mov     rax, cs:HvlpReferenceTscPage
>                  mov     r9d, [rax]
>                  test    r9d, r9d
>                  jz      short loc_1401C3176
>                  rdtsc
>                  mov     rcx, cs:HvlpReferenceTscPage
>                  shl     rdx, 20h
>                  or      rdx, rax
>                  mov     rax, [rcx+8]
>                  mov     rcx, cs:HvlpReferenceTscPage
>                  mov     r8, [rcx+10h]
>                  mul     rdx
>                  mov     rax, cs:HvlpReferenceTscPage
>                  add     rdx, r8
>                  mov     ecx, [rax]
>                  cmp     ecx, r9d
>                  jnz     short loc_1401C3132
>                  jmp     short loc_1401C3184
> loc_1401C3176:
>                  mov     ecx, 40000020h
>                  rdmsr
>                  shl     rdx, 20h
>                  or      rdx, rax
> loc_1401C3184:
>                  mov     rax, rdx
>                  retn
> HvlGetReferenceTime endp
> 
> This patch aligns Tsc page invalid sequence value with
> Windows Hyper-V guest implementation which is more
> compatible with both Hyper-V hypervisor and KVM hypervisor.
> 
> Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
> CC: "K. Y. Srinivasan" <kys@microsoft.com>
Thanks Andrey; the Hyper-V team will be updating the Hyper-V documentation.

Acked-by: K. Y. Srinivasan <kys@microsoft.com>

Regards,

K. Y

> CC: Haiyang Zhang <haiyangz@microsoft.com>
> CC: Vitaly Kuznetsov <vkuznets@redhat.com>
> 
> TARGET: Microsoft Hyper-V Linux guest drivers
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> ---
>  drivers/hv/hv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
> index 6341be8..68d0701 100644
> --- a/drivers/hv/hv.c
> +++ b/drivers/hv/hv.c
> @@ -139,7 +139,7 @@ static cycle_t read_hv_clock_tsc(struct clocksource
> *arg)
>  	cycle_t current_tick;
>  	struct ms_hyperv_tsc_page *tsc_pg = hv_context.tsc_page;
> 
> -	if (tsc_pg->tsc_sequence != -1) {
> +	if (tsc_pg->tsc_sequence != 0) {
>  		/*
>  		 * Use the tsc page to compute the value.
>  		 */
> @@ -161,7 +161,7 @@ static cycle_t read_hv_clock_tsc(struct clocksource
> *arg)
>  			if (tsc_pg->tsc_sequence == sequence)
>  				return current_tick;
> 
> -			if (tsc_pg->tsc_sequence != -1)
> +			if (tsc_pg->tsc_sequence != 0)
>  				continue;
>  			/*
>  			 * Fallback using MSR method.
> --
> 2.1.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] drivers/hv: correct tsc page sequence invalid value
  2015-11-02 19:42 ` KY Srinivasan
@ 2015-11-12  7:16   ` Denis V. Lunev
  2015-11-12 17:35     ` KY Srinivasan
  0 siblings, 1 reply; 5+ messages in thread
From: Denis V. Lunev @ 2015-11-12  7:16 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: rkagan, devel, linux-kernel, Andrey Smetanin, Haiyang Zhang,
	Vitaly Kuznetsov

On 11/02/2015 10:42 PM, KY Srinivasan wrote:
>
>> -----Original Message-----
>> From: Denis V. Lunev [mailto:den@openvz.org]
>> Sent: Monday, November 2, 2015 3:34 AM
>> Cc: rkagan@virtuozzo.com; devel@linuxdriverproject.org; linux-
>> kernel@vger.kernel.org; Andrey Smetanin <asmetanin@virtuozzo.com>; KY
>> Srinivasan <kys@microsoft.com>; Haiyang Zhang
>> <haiyangz@microsoft.com>; Vitaly Kuznetsov <vkuznets@redhat.com>;
>> Denis V. Lunev <den@openvz.org>
>> Subject: [PATCH 1/1] drivers/hv: correct tsc page sequence invalid value
>>
>> From: Andrey Smetanin <asmetanin@virtuozzo.com>
>>
>> Hypervisor Top Level Functional Specification v3/4 says
>> that TSC page sequence value = -1(0xFFFFFFFF) is used to
>> indicate that TSC page no longer reliable source of reference
>> timer. Unfortunately, we found that Windows Hyper-V guest
>> side implementation uses sequence value = 0 to indicate
>> that Tsc page no longer valid. This is clearly visible
>> inside Windows 2012R2 ntoskrnl.exe HvlGetReferenceTime()
>> function dissassembly:
>>
>> HvlGetReferenceTime proc near
>>                   xchg    ax, ax
>> loc_1401C3132:
>>                   mov     rax, cs:HvlpReferenceTscPage
>>                   mov     r9d, [rax]
>>                   test    r9d, r9d
>>                   jz      short loc_1401C3176
>>                   rdtsc
>>                   mov     rcx, cs:HvlpReferenceTscPage
>>                   shl     rdx, 20h
>>                   or      rdx, rax
>>                   mov     rax, [rcx+8]
>>                   mov     rcx, cs:HvlpReferenceTscPage
>>                   mov     r8, [rcx+10h]
>>                   mul     rdx
>>                   mov     rax, cs:HvlpReferenceTscPage
>>                   add     rdx, r8
>>                   mov     ecx, [rax]
>>                   cmp     ecx, r9d
>>                   jnz     short loc_1401C3132
>>                   jmp     short loc_1401C3184
>> loc_1401C3176:
>>                   mov     ecx, 40000020h
>>                   rdmsr
>>                   shl     rdx, 20h
>>                   or      rdx, rax
>> loc_1401C3184:
>>                   mov     rax, rdx
>>                   retn
>> HvlGetReferenceTime endp
>>
>> This patch aligns Tsc page invalid sequence value with
>> Windows Hyper-V guest implementation which is more
>> compatible with both Hyper-V hypervisor and KVM hypervisor.
>>
>> Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
>> CC: "K. Y. Srinivasan" <kys@microsoft.com>
> Thanks Andrey; the Hyper-V team will be updating the Hyper-V documentation.
>
> Acked-by: K. Y. Srinivasan <kys@microsoft.com>
>
> Regards,
>
> K. Y
K.Y.,

can you pls clarify the state of this patch? It is a bit unclear
to me whether it is applied or not.

By the way, I also do not see the following patch
"drivers/hv: cleanup synic msrs if vmbus connect failed"
as applied in the Linux-next. You have promised to resend
it will correct author.

Thank you in advance,
     Den

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 1/1] drivers/hv: correct tsc page sequence invalid value
  2015-11-12  7:16   ` Denis V. Lunev
@ 2015-11-12 17:35     ` KY Srinivasan
  2015-11-12 18:57       ` Denis V. Lunev
  0 siblings, 1 reply; 5+ messages in thread
From: KY Srinivasan @ 2015-11-12 17:35 UTC (permalink / raw)
  To: Denis V. Lunev
  Cc: rkagan, devel, linux-kernel, Andrey Smetanin, Haiyang Zhang,
	Vitaly Kuznetsov



> -----Original Message-----
> From: Denis V. Lunev [mailto:den@openvz.org]
> Sent: Wednesday, November 11, 2015 11:16 PM
> To: KY Srinivasan <kys@microsoft.com>
> Cc: rkagan@virtuozzo.com; devel@linuxdriverproject.org; linux-
> kernel@vger.kernel.org; Andrey Smetanin <asmetanin@virtuozzo.com>;
> Haiyang Zhang <haiyangz@microsoft.com>; Vitaly Kuznetsov
> <vkuznets@redhat.com>
> Subject: Re: [PATCH 1/1] drivers/hv: correct tsc page sequence invalid value
> 
> On 11/02/2015 10:42 PM, KY Srinivasan wrote:
> >
> >> -----Original Message-----
> >> From: Denis V. Lunev [mailto:den@openvz.org]
> >> Sent: Monday, November 2, 2015 3:34 AM
> >> Cc: rkagan@virtuozzo.com; devel@linuxdriverproject.org; linux-
> >> kernel@vger.kernel.org; Andrey Smetanin <asmetanin@virtuozzo.com>;
> KY
> >> Srinivasan <kys@microsoft.com>; Haiyang Zhang
> >> <haiyangz@microsoft.com>; Vitaly Kuznetsov <vkuznets@redhat.com>;
> >> Denis V. Lunev <den@openvz.org>
> >> Subject: [PATCH 1/1] drivers/hv: correct tsc page sequence invalid value
> >>
> >> From: Andrey Smetanin <asmetanin@virtuozzo.com>
> >>
> >> Hypervisor Top Level Functional Specification v3/4 says
> >> that TSC page sequence value = -1(0xFFFFFFFF) is used to
> >> indicate that TSC page no longer reliable source of reference
> >> timer. Unfortunately, we found that Windows Hyper-V guest
> >> side implementation uses sequence value = 0 to indicate
> >> that Tsc page no longer valid. This is clearly visible
> >> inside Windows 2012R2 ntoskrnl.exe HvlGetReferenceTime()
> >> function dissassembly:
> >>
> >> HvlGetReferenceTime proc near
> >>                   xchg    ax, ax
> >> loc_1401C3132:
> >>                   mov     rax, cs:HvlpReferenceTscPage
> >>                   mov     r9d, [rax]
> >>                   test    r9d, r9d
> >>                   jz      short loc_1401C3176
> >>                   rdtsc
> >>                   mov     rcx, cs:HvlpReferenceTscPage
> >>                   shl     rdx, 20h
> >>                   or      rdx, rax
> >>                   mov     rax, [rcx+8]
> >>                   mov     rcx, cs:HvlpReferenceTscPage
> >>                   mov     r8, [rcx+10h]
> >>                   mul     rdx
> >>                   mov     rax, cs:HvlpReferenceTscPage
> >>                   add     rdx, r8
> >>                   mov     ecx, [rax]
> >>                   cmp     ecx, r9d
> >>                   jnz     short loc_1401C3132
> >>                   jmp     short loc_1401C3184
> >> loc_1401C3176:
> >>                   mov     ecx, 40000020h
> >>                   rdmsr
> >>                   shl     rdx, 20h
> >>                   or      rdx, rax
> >> loc_1401C3184:
> >>                   mov     rax, rdx
> >>                   retn
> >> HvlGetReferenceTime endp
> >>
> >> This patch aligns Tsc page invalid sequence value with
> >> Windows Hyper-V guest implementation which is more
> >> compatible with both Hyper-V hypervisor and KVM hypervisor.
> >>
> >> Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
> >> CC: "K. Y. Srinivasan" <kys@microsoft.com>
> > Thanks Andrey; the Hyper-V team will be updating the Hyper-V
> documentation.
> >
> > Acked-by: K. Y. Srinivasan <kys@microsoft.com>
> >
> > Regards,
> >
> > K. Y
> K.Y.,
> 
> can you pls clarify the state of this patch? It is a bit unclear
> to me whether it is applied or not.

I will be submitting this shortly.

> 
> By the way, I also do not see the following patch
> "drivers/hv: cleanup synic msrs if vmbus connect failed"
> as applied in the Linux-next. You have promised to resend
> it will correct author.

It was resent on October 29. It is in Greg's queue.

Regards,

K. Y
> 
> Thank you in advance,
>      Den

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] drivers/hv: correct tsc page sequence invalid value
  2015-11-12 17:35     ` KY Srinivasan
@ 2015-11-12 18:57       ` Denis V. Lunev
  0 siblings, 0 replies; 5+ messages in thread
From: Denis V. Lunev @ 2015-11-12 18:57 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: rkagan, devel, linux-kernel, Andrey Smetanin, Haiyang Zhang,
	Vitaly Kuznetsov

On 11/12/2015 08:35 PM, KY Srinivasan wrote:
>
>> -----Original Message-----
>> From: Denis V. Lunev [mailto:den@openvz.org]
>> Sent: Wednesday, November 11, 2015 11:16 PM
>> To: KY Srinivasan <kys@microsoft.com>
>> Cc: rkagan@virtuozzo.com; devel@linuxdriverproject.org; linux-
>> kernel@vger.kernel.org; Andrey Smetanin <asmetanin@virtuozzo.com>;
>> Haiyang Zhang <haiyangz@microsoft.com>; Vitaly Kuznetsov
>> <vkuznets@redhat.com>
>> Subject: Re: [PATCH 1/1] drivers/hv: correct tsc page sequence invalid value
>>
>> On 11/02/2015 10:42 PM, KY Srinivasan wrote:
>>>> -----Original Message-----
>>>> From: Denis V. Lunev [mailto:den@openvz.org]
>>>> Sent: Monday, November 2, 2015 3:34 AM
>>>> Cc: rkagan@virtuozzo.com; devel@linuxdriverproject.org; linux-
>>>> kernel@vger.kernel.org; Andrey Smetanin <asmetanin@virtuozzo.com>;
>> KY
>>>> Srinivasan <kys@microsoft.com>; Haiyang Zhang
>>>> <haiyangz@microsoft.com>; Vitaly Kuznetsov <vkuznets@redhat.com>;
>>>> Denis V. Lunev <den@openvz.org>
>>>> Subject: [PATCH 1/1] drivers/hv: correct tsc page sequence invalid value
>>>>
>>>> From: Andrey Smetanin <asmetanin@virtuozzo.com>
>>>>
>>>> Hypervisor Top Level Functional Specification v3/4 says
>>>> that TSC page sequence value = -1(0xFFFFFFFF) is used to
>>>> indicate that TSC page no longer reliable source of reference
>>>> timer. Unfortunately, we found that Windows Hyper-V guest
>>>> side implementation uses sequence value = 0 to indicate
>>>> that Tsc page no longer valid. This is clearly visible
>>>> inside Windows 2012R2 ntoskrnl.exe HvlGetReferenceTime()
>>>> function dissassembly:
>>>>
>>>> HvlGetReferenceTime proc near
>>>>                    xchg    ax, ax
>>>> loc_1401C3132:
>>>>                    mov     rax, cs:HvlpReferenceTscPage
>>>>                    mov     r9d, [rax]
>>>>                    test    r9d, r9d
>>>>                    jz      short loc_1401C3176
>>>>                    rdtsc
>>>>                    mov     rcx, cs:HvlpReferenceTscPage
>>>>                    shl     rdx, 20h
>>>>                    or      rdx, rax
>>>>                    mov     rax, [rcx+8]
>>>>                    mov     rcx, cs:HvlpReferenceTscPage
>>>>                    mov     r8, [rcx+10h]
>>>>                    mul     rdx
>>>>                    mov     rax, cs:HvlpReferenceTscPage
>>>>                    add     rdx, r8
>>>>                    mov     ecx, [rax]
>>>>                    cmp     ecx, r9d
>>>>                    jnz     short loc_1401C3132
>>>>                    jmp     short loc_1401C3184
>>>> loc_1401C3176:
>>>>                    mov     ecx, 40000020h
>>>>                    rdmsr
>>>>                    shl     rdx, 20h
>>>>                    or      rdx, rax
>>>> loc_1401C3184:
>>>>                    mov     rax, rdx
>>>>                    retn
>>>> HvlGetReferenceTime endp
>>>>
>>>> This patch aligns Tsc page invalid sequence value with
>>>> Windows Hyper-V guest implementation which is more
>>>> compatible with both Hyper-V hypervisor and KVM hypervisor.
>>>>
>>>> Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
>>>> CC: "K. Y. Srinivasan" <kys@microsoft.com>
>>> Thanks Andrey; the Hyper-V team will be updating the Hyper-V
>> documentation.
>>> Acked-by: K. Y. Srinivasan <kys@microsoft.com>
>>>
>>> Regards,
>>>
>>> K. Y
>> K.Y.,
>>
>> can you pls clarify the state of this patch? It is a bit unclear
>> to me whether it is applied or not.
> I will be submitting this shortly.
>
>> By the way, I also do not see the following patch
>> "drivers/hv: cleanup synic msrs if vmbus connect failed"
>> as applied in the Linux-next. You have promised to resend
>> it will correct author.
> It was resent on October 29. It is in Greg's queue.
>
> Regards,
>
> K. Y
>> Thank you in advance,
>>       Den
thank you very much for this update :)

Den

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-12 18:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-02 11:34 [PATCH 1/1] drivers/hv: correct tsc page sequence invalid value Denis V. Lunev
2015-11-02 19:42 ` KY Srinivasan
2015-11-12  7:16   ` Denis V. Lunev
2015-11-12 17:35     ` KY Srinivasan
2015-11-12 18:57       ` Denis V. Lunev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.