All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/vmx: fix vmx_is_singlestep_supported return value
@ 2015-08-24 19:55 Tamas K Lengyel
  2015-08-24 22:55 ` Andrew Cooper
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Tamas K Lengyel @ 2015-08-24 19:55 UTC (permalink / raw)
  To: xen-devel
  Cc: kevin.tian, Tamas K Lengyel, keir, jun.nakajima, andrew.cooper3,
	eddie.dong, jbeulich, Tamas K Lengyel, wei.liu2

The function supposed to return a boolean but instead it returned
the value 0x8000000 which is the Intel internal flag for MTF. This has
caused various checks using this function to falsely report no MTF
capability.

Signed-off-by: Tamas K Lengyel <tlengyel@novetta.com>
---
 xen/arch/x86/hvm/vmx/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 999defe..35bcd79 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -1768,7 +1768,7 @@ static void vmx_enable_msr_exit_interception(struct domain *d)
 
 static bool_t vmx_is_singlestep_supported(void)
 {
-    return cpu_has_monitor_trap_flag;
+    return cpu_has_monitor_trap_flag ? 1 : 0;
 }
 
 static void vmx_vcpu_update_eptp(struct vcpu *v)
-- 
2.1.4

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

* Re: [PATCH] x86/vmx: fix vmx_is_singlestep_supported return value
  2015-08-24 19:55 [PATCH] x86/vmx: fix vmx_is_singlestep_supported return value Tamas K Lengyel
@ 2015-08-24 22:55 ` Andrew Cooper
  2015-08-24 23:51   ` Tamas K Lengyel
  2015-08-25  8:09 ` Wei Liu
  2015-08-28  1:59 ` Tian, Kevin
  2 siblings, 1 reply; 9+ messages in thread
From: Andrew Cooper @ 2015-08-24 22:55 UTC (permalink / raw)
  To: Tamas K Lengyel, xen-devel
  Cc: kevin.tian, keir, jun.nakajima, eddie.dong, jbeulich,
	Tamas K Lengyel, wei.liu2

On 24/08/2015 20:55, Tamas K Lengyel wrote:
> The function supposed to return a boolean but instead it returned
> the value 0x8000000 which is the Intel internal flag for MTF. This has
> caused various checks using this function to falsely report no MTF
> capability.

Ouch.  Given than bool_t is current signed char, that won't be of much use.

>
> Signed-off-by: Tamas K Lengyel <tlengyel@novetta.com>
> ---
>  xen/arch/x86/hvm/vmx/vmx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index 999defe..35bcd79 100644
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -1768,7 +1768,7 @@ static void vmx_enable_msr_exit_interception(struct domain *d)
>  
>  static bool_t vmx_is_singlestep_supported(void)
>  {
> -    return cpu_has_monitor_trap_flag;
> +    return cpu_has_monitor_trap_flag ? 1 : 0;

Prevailing style would tend towards !!cpu_has_monitor_trap_flag

Either way, Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

>  }
>  
>  static void vmx_vcpu_update_eptp(struct vcpu *v)

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

* Re: [PATCH] x86/vmx: fix vmx_is_singlestep_supported return value
  2015-08-24 22:55 ` Andrew Cooper
@ 2015-08-24 23:51   ` Tamas K Lengyel
  2015-08-25  7:58     ` Jan Beulich
  0 siblings, 1 reply; 9+ messages in thread
From: Tamas K Lengyel @ 2015-08-24 23:51 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Tian, Kevin, Tamas K Lengyel, Keir Fraser, Jan Beulich,
	Dong, Eddie, xen-devel@lists.xen.org, Jun Nakajima,
	Tamas K Lengyel, wei.liu2@citrix.com

>> @@ -1768,7 +1768,7 @@ static void vmx_enable_msr_exit_interception(struct domain *d)
>>
>>  static bool_t vmx_is_singlestep_supported(void)
>>  {
>> -    return cpu_has_monitor_trap_flag;
>> +    return cpu_has_monitor_trap_flag ? 1 : 0;
>
> Prevailing style would tend towards !!cpu_has_monitor_trap_flag

Yeap, you are right. If the maintainers prefer I can resend with that style.

>
> Either way, Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Thanks!
Tamas

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

* Re: [PATCH] x86/vmx: fix vmx_is_singlestep_supported return value
  2015-08-24 23:51   ` Tamas K Lengyel
@ 2015-08-25  7:58     ` Jan Beulich
  2015-08-27  7:39       ` Wei Liu
  2015-08-28  2:01       ` Tian, Kevin
  0 siblings, 2 replies; 9+ messages in thread
From: Jan Beulich @ 2015-08-25  7:58 UTC (permalink / raw)
  To: andrew.cooper3, tamas.lengyel
  Cc: kevin.tian, tamas, wei.liu2, xen-devel, jun.nakajima, tlengyel,
	keir

>>> Tamas K Lengyel <tamas.lengyel@zentific.com> 08/25/15 1:51 AM >>>
>>> @@ -1768,7 +1768,7 @@ static void vmx_enable_msr_exit_interception(struct domain *d)
>>>
>>>  static bool_t vmx_is_singlestep_supported(void)
>>>  {
>>> -    return cpu_has_monitor_trap_flag;
>>> +    return cpu_has_monitor_trap_flag ? 1 : 0;
>>
>> Prevailing style would tend towards !!cpu_has_monitor_trap_flag
>
>Yeap, you are right. If the maintainers prefer I can resend with that style.

This could easily be adjusted upon commit. What I'm wondering is whether this
is the right place to fix it: Wouldn't it be better for the cpu_has_* macros
themselves to be adjusted so other (future) users won't fall into the same trap
(vmx_virtual_intr_delivery_enabled() is a good second example bogusly using
int as its return type, and once adjusted to bool_t it would break)?

Jan

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

* Re: [PATCH] x86/vmx: fix vmx_is_singlestep_supported return value
  2015-08-24 19:55 [PATCH] x86/vmx: fix vmx_is_singlestep_supported return value Tamas K Lengyel
  2015-08-24 22:55 ` Andrew Cooper
@ 2015-08-25  8:09 ` Wei Liu
  2015-08-28  1:59 ` Tian, Kevin
  2 siblings, 0 replies; 9+ messages in thread
From: Wei Liu @ 2015-08-25  8:09 UTC (permalink / raw)
  To: Tamas K Lengyel
  Cc: kevin.tian, keir, jun.nakajima, andrew.cooper3, eddie.dong,
	xen-devel, jbeulich, Tamas K Lengyel, wei.liu2

On Mon, Aug 24, 2015 at 03:55:33PM -0400, Tamas K Lengyel wrote:
> The function supposed to return a boolean but instead it returned
> the value 0x8000000 which is the Intel internal flag for MTF. This has
> caused various checks using this function to falsely report no MTF
> capability.
> 
> Signed-off-by: Tamas K Lengyel <tlengyel@novetta.com>

Release-acked-by: Wei Liu <wei.liu2@citrix.com>

> ---
>  xen/arch/x86/hvm/vmx/vmx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index 999defe..35bcd79 100644
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -1768,7 +1768,7 @@ static void vmx_enable_msr_exit_interception(struct domain *d)
>  
>  static bool_t vmx_is_singlestep_supported(void)
>  {
> -    return cpu_has_monitor_trap_flag;
> +    return cpu_has_monitor_trap_flag ? 1 : 0;
>  }
>  
>  static void vmx_vcpu_update_eptp(struct vcpu *v)
> -- 
> 2.1.4

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

* Re: [PATCH] x86/vmx: fix vmx_is_singlestep_supported return value
  2015-08-25  7:58     ` Jan Beulich
@ 2015-08-27  7:39       ` Wei Liu
  2015-08-28  2:01       ` Tian, Kevin
  1 sibling, 0 replies; 9+ messages in thread
From: Wei Liu @ 2015-08-27  7:39 UTC (permalink / raw)
  To: Jan Beulich
  Cc: kevin.tian, tamas, wei.liu2, andrew.cooper3, xen-devel,
	jun.nakajima, tamas.lengyel, tlengyel, keir

On Tue, Aug 25, 2015 at 01:58:42AM -0600, Jan Beulich wrote:
[...]
> (vmx_virtual_intr_delivery_enabled() is a good second example bogusly using
> int as its return type, and once adjusted to bool_t it would break)?
> 

VMX maintainers, I think Jan is waiting for reply from you for that
particular question. We need reply / confirmation from you to get a fix
for this issue.

Wei.

> Jan

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

* Re: [PATCH] x86/vmx: fix vmx_is_singlestep_supported return value
  2015-08-24 19:55 [PATCH] x86/vmx: fix vmx_is_singlestep_supported return value Tamas K Lengyel
  2015-08-24 22:55 ` Andrew Cooper
  2015-08-25  8:09 ` Wei Liu
@ 2015-08-28  1:59 ` Tian, Kevin
  2 siblings, 0 replies; 9+ messages in thread
From: Tian, Kevin @ 2015-08-28  1:59 UTC (permalink / raw)
  To: Tamas K Lengyel, xen-devel@lists.xen.org
  Cc: keir@xen.org, Nakajima, Jun, andrew.cooper3@citrix.com,
	Dong, Eddie, jbeulich@suse.com, Tamas K Lengyel,
	wei.liu2@citrix.com

> From: Tamas K Lengyel [mailto:tamas@tklengyel.com]
> Sent: Tuesday, August 25, 2015 3:56 AM
> 
> The function supposed to return a boolean but instead it returned
> the value 0x8000000 which is the Intel internal flag for MTF. This has
> caused various checks using this function to falsely report no MTF
> capability.
> 
> Signed-off-by: Tamas K Lengyel <tlengyel@novetta.com>

Acked-by: Kevin Tian <kevin.tian@intel.com>

Thanks,
Kevin

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

* Re: [PATCH] x86/vmx: fix vmx_is_singlestep_supported return value
  2015-08-25  7:58     ` Jan Beulich
  2015-08-27  7:39       ` Wei Liu
@ 2015-08-28  2:01       ` Tian, Kevin
  2015-08-28  7:05         ` Jan Beulich
  1 sibling, 1 reply; 9+ messages in thread
From: Tian, Kevin @ 2015-08-28  2:01 UTC (permalink / raw)
  To: Jan Beulich, andrew.cooper3@citrix.com,
	tamas.lengyel@zentific.com
  Cc: tamas@tklengyel.com, keir@xen.org, xen-devel@lists.xen.org,
	Nakajima, Jun, tlengyel@novetta.com, wei.liu2@citrix.com

> From: Jan Beulich [mailto:jbeulich@suse.com]
> Sent: Tuesday, August 25, 2015 3:59 PM
> 
> >>> Tamas K Lengyel <tamas.lengyel@zentific.com> 08/25/15 1:51 AM >>>
> >>> @@ -1768,7 +1768,7 @@ static void vmx_enable_msr_exit_interception(struct
> domain *d)
> >>>
> >>>  static bool_t vmx_is_singlestep_supported(void)
> >>>  {
> >>> -    return cpu_has_monitor_trap_flag;
> >>> +    return cpu_has_monitor_trap_flag ? 1 : 0;
> >>
> >> Prevailing style would tend towards !!cpu_has_monitor_trap_flag
> >
> >Yeap, you are right. If the maintainers prefer I can resend with that style.
> 
> This could easily be adjusted upon commit. What I'm wondering is whether this
> is the right place to fix it: Wouldn't it be better for the cpu_has_* macros
> themselves to be adjusted so other (future) users won't fall into the same trap
> (vmx_virtual_intr_delivery_enabled() is a good second example bogusly using
> int as its return type, and once adjusted to bool_t it would break)?
> 

I'm OK with original patch. Above example can be taken care when changing
return type.

Thanks
Kevin

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

* Re: [PATCH] x86/vmx: fix vmx_is_singlestep_supported return value
  2015-08-28  2:01       ` Tian, Kevin
@ 2015-08-28  7:05         ` Jan Beulich
  0 siblings, 0 replies; 9+ messages in thread
From: Jan Beulich @ 2015-08-28  7:05 UTC (permalink / raw)
  To: Kevin Tian
  Cc: tamas@tklengyel.com, wei.liu2@citrix.com,
	andrew.cooper3@citrix.com, xen-devel@lists.xen.org, Jun Nakajima,
	tamas.lengyel@zentific.com, tlengyel@novetta.com, keir@xen.org

>>> On 28.08.15 at 04:01, <kevin.tian@intel.com> wrote:
>>  From: Jan Beulich [mailto:jbeulich@suse.com]
>> Sent: Tuesday, August 25, 2015 3:59 PM
>> 
>> >>> Tamas K Lengyel <tamas.lengyel@zentific.com> 08/25/15 1:51 AM >>>
>> >>> @@ -1768,7 +1768,7 @@ static void vmx_enable_msr_exit_interception(struct
>> domain *d)
>> >>>
>> >>>  static bool_t vmx_is_singlestep_supported(void)
>> >>>  {
>> >>> -    return cpu_has_monitor_trap_flag;
>> >>> +    return cpu_has_monitor_trap_flag ? 1 : 0;
>> >>
>> >> Prevailing style would tend towards !!cpu_has_monitor_trap_flag
>> >
>> >Yeap, you are right. If the maintainers prefer I can resend with that style.
>> 
>> This could easily be adjusted upon commit. What I'm wondering is whether this
>> is the right place to fix it: Wouldn't it be better for the cpu_has_* macros
>> themselves to be adjusted so other (future) users won't fall into the same trap
>> (vmx_virtual_intr_delivery_enabled() is a good second example bogusly using
>> int as its return type, and once adjusted to bool_t it would break)?
> 
> I'm OK with original patch. Above example can be taken care when changing
> return type.

Okay, I'll commit it the way it is, despite not being convinced of the
approach of waiting for the next one to fall into the same trap.

Jan

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

end of thread, other threads:[~2015-08-28  7:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-24 19:55 [PATCH] x86/vmx: fix vmx_is_singlestep_supported return value Tamas K Lengyel
2015-08-24 22:55 ` Andrew Cooper
2015-08-24 23:51   ` Tamas K Lengyel
2015-08-25  7:58     ` Jan Beulich
2015-08-27  7:39       ` Wei Liu
2015-08-28  2:01       ` Tian, Kevin
2015-08-28  7:05         ` Jan Beulich
2015-08-25  8:09 ` Wei Liu
2015-08-28  1:59 ` Tian, Kevin

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.