Skip to contentSkip to conversation

x86/vmx: fix vmx_is_singlestep_supported return value

PATCH In review Tamas K Lengyel 6 participants 9 messages Aug 24, 2015 – Aug 28, 2015

lore
Share & tools
lore
#0 lore raw

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
index 999defe..35bcd79 100644
@@ -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
#1 lore raw
Quoted 4 lines · Tamas K Lengyel

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.

Quoted 11 lines
---
 xen/arch/x86/hvm/vmx/vmx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/vmx/vmx.c +0 -0
index 999defe..35bcd79 100644

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)
#2 lore raw
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

#3 lore raw
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

#4 lore raw

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 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.

Quoted 1 line

Jan

#5 lore raw
In reply to Jan Beulich
Quoted 14 lines

From: Jan Beulich [mailto:[email protected]]
Sent: Tuesday, August 25, 2015 3:59 PM

Quoted 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(struct

domain *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 -1
 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

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 to bool_t it would break)?

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

Thanks
Kevin

#6 lore raw
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 PM

Quoted 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(struct

domain *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 -1
 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 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 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

#7 lore raw
In reply to Tamas K Lengyel
Quoted 6 lines · Tamas K Lengyel

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.

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
index 999defe..35bcd79 100644
@@ -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
Acked-by on v1 1/1
#8 lore raw
In reply to Tamas K Lengyel
Quoted 9 lines

From: Tamas K Lengyel [mailto:[email protected]]
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.

Thanks,
Kevin