[PATCH 2/2] x86/alternatives: adjust alternative_vcall0()

Jan Beulich posted 2 patches 4 years, 2 months ago
[PATCH 2/2] x86/alternatives: adjust alternative_vcall0()
Posted by Jan Beulich 4 years, 2 months ago
I'm puzzled about two inconsistencies with other alternative_vcall<N>()
here: There's a check missing that the supplied function pointer is
actually pointing to a function taking no args. And there's a pointless
pair of parentheses. Correct both.

Fixes: 67d01cdb5518 ("x86: infrastructure to allow converting certain indirect calls to direct ones")
Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/include/asm-x86/alternative.h
+++ b/xen/include/asm-x86/alternative.h
@@ -218,7 +218,8 @@ extern void alternative_branches(void);
 
 #define alternative_vcall0(func) ({             \
     ALT_CALL_NO_ARG1;                           \
-    ((void)alternative_callN(0, int, func));    \
+    (void)sizeof(func());                       \
+    (void)alternative_callN(0, int, func);      \
 })
 
 #define alternative_call0(func) ({              \


Re: [PATCH 2/2] x86/alternatives: adjust alternative_vcall0()
Posted by Wei Chen 4 years, 2 months ago

On 2021/11/17 16:00, Jan Beulich wrote:
> I'm puzzled about two inconsistencies with other alternative_vcall<N>()
> here: There's a check missing that the supplied function pointer is
> actually pointing to a function taking no args. And there's a pointless
> pair of parentheses. Correct both.
> 
> Fixes: 67d01cdb5518 ("x86: infrastructure to allow converting certain indirect calls to direct ones")
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> --- a/xen/include/asm-x86/alternative.h
> +++ b/xen/include/asm-x86/alternative.h
> @@ -218,7 +218,8 @@ extern void alternative_branches(void);
>   
>   #define alternative_vcall0(func) ({             \
>       ALT_CALL_NO_ARG1;                           \
> -    ((void)alternative_callN(0, int, func));    \
> +    (void)sizeof(func());                       \
> +    (void)alternative_callN(0, int, func);      \
>   })
>   
>   #define alternative_call0(func) ({              \
> 
> 

Reviewed-by: Wei Chen <Wei.Chen@arm.com>