x86/vmx: fix vmx_is_singlestep_supported return value
PATCH 1/1 x86/vmx: fix vmx_is_singlestep_supported return value
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.
--- xen/arch/x86/hvm/vmx/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/vmx/vmx.c +1 -1
@@ -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)
Signature · 1 line
2.1.4
Quoted 4 lines · Tamas K Lengyel
The function supposed to return a boolean but instead it returned the value
0x8000000which 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.
Quoted 11 lines
Signed-off-by Tamas K Lengyel <[email protected]>--- xen/arch/x86/hvm/vmx/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/x86/hvm/vmx/vmx.c +0
-0
xen/arch/x86/hvm/vmx/vmx.c static void vmx_enable_msr_exit_interception(struct domain *d) · line 1771
Quoted 5 lines
xen/arch/x86/hvm/vmx/vmx.c +1
-1@@ -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 <[email protected]>
Quoted 3 lines
xen/arch/x86/hvm/vmx/vmx.c +0
-0}static void vmx_vcpu_update_eptp (struct vcpu *v)
Quoted 8 lines
xen/arch/x86/hvm/vmx/vmx.c static void vmx_enable_msr_exit_interception(struct domain *d) · line 1771
Quoted 6 lines
xen/arch/x86/hvm/vmx/vmx.c +1
-1@@ -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.
Quoted 2 lines
Either way, Reviewed-by: Andrew Cooper <[email protected]>
Thanks!
Tamas
Quoted 11 lines
Quoted 9 lines
xen/arch/x86/hvm/vmx/vmx.c static void vmx_enable_msr_exit_interception(struct domain *d) · line 1771
Quoted 7 lines
Tamas K Lengyel <[email protected]> 08/25/15 1:51 AM >>>
xen/arch/x86/hvm/vmx/vmx.c +1
-1@@ -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
On Tue, Aug 25, 2015 at 01:58:42AM -0600, Jan Beulich wrote:
[...]
Quoted 3 lines
(
vmx_virtual_intr_delivery_enabled()is a good second example bogusly using int as its return type, and once adjusted tobool_tit 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.
Quoted 1 line
Jan
Quoted 14 lines
From: Jan Beulich [mailto:[email protected]]
Sent: Tuesday, August 25, 2015 3:59 PMQuoted 2 lines
Quoted 2 lines
Review static void vmx_enable_msr_exit_interception(struct
Quoted 2 lines
Tamas K Lengyel <[email protected]> 08/25/15 1:51 AM >>>
(quoted diff) +0
-0@@ -1768,7 +1768,7 @@ static void vmx_enable_msr_exit_interception(structdomain *d)
Quoted 8 lines
Quoted 7 lines
xen/arch/x86/hvm/vmx/vmx.c static void vmx_enable_msr_exit_interception(struct domain *d) · line 1771
Quoted 5 lines
xen/arch/x86/hvm/vmx/vmx.c +1
-1static 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
Quoted 8 lines
Quoted 1 line
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 tobool_tit would break)?
I'm OK with original patch. Above example can be taken care when changing return type.
Thanks
Kevin
Quoted 17 lines
Quoted 17 lines
Quoted 1 line · On 28.08.15 at 04:01, <[email protected]> wrote:
From: Jan Beulich [mailto:[email protected]]
Sent: Tuesday, August 25, 2015 3:59 PMQuoted 2 lines
Quoted 2 lines
Review static void vmx_enable_msr_exit_interception(struct
Quoted 2 lines
Tamas K Lengyel <[email protected]> 08/25/15 1:51 AM >>>
(quoted diff) +0
-0@@ -1768,7 +1768,7 @@ static void vmx_enable_msr_exit_interception(structdomain *d)
Quoted 9 lines
Quoted 7 lines
xen/arch/x86/hvm/vmx/vmx.c static void vmx_enable_msr_exit_interception(struct domain *d) · line 1771
Quoted 5 lines
xen/arch/x86/hvm/vmx/vmx.c +1
-1static 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.
Quoted 8 lines
Quoted 5 lines
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 tobool_tit 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
Quoted 6 lines · Tamas K Lengyel
The function supposed to return a boolean but instead it returned the value
0x8000000which 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 <[email protected]>
Quoted 19 lines
--- xen/arch/x86/hvm/vmx/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/x86/hvm/vmx/vmx.c +1
-1@@ -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)Signature · 1 line
2.1.4
Quoted 9 lines
From: Tamas K Lengyel [mailto:[email protected]]
Sent: Tuesday, August 25, 2015 3:56 AMThe function supposed to return a boolean but instead it returned the value
0x8000000which 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 <[email protected]>
Thanks,
Kevin