[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 3/5] x86/hvm: Adjust hvmemul_rep_stos() to compile with -Wvla



> -----Original Message-----
> From: Andrew Cooper [mailto:andrew.cooper3@xxxxxxxxxx]
> Sent: 24 September 2018 14:00
> To: Xen-devel <xen-devel@xxxxxxxxxxxxx>
> Cc: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>; Jan Beulich
> <JBeulich@xxxxxxxx>; Wei Liu <wei.liu2@xxxxxxxxxx>; Paul Durrant
> <Paul.Durrant@xxxxxxxxxx>
> Subject: [PATCH 3/5] x86/hvm: Adjust hvmemul_rep_stos() to compile with -
> Wvla
> 
> For at least "gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609", the
> typecast of buf triggers a Variable Length Array warning.
> 
> Alter the asm expression to avoid the typecast, which necessitates the
> introduction of a memory clobber as the compiler can no longer identify
> the total quantity of written memory.
> 
> Despite the memory clobber, there is no change to the generated.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Reviewed-by: Paul Durrant <paul.durrant@xxxxxxxxxx>

> ---
> CC: Jan Beulich <JBeulich@xxxxxxxx>
> CC: Wei Liu <wei.liu2@xxxxxxxxxx>
> CC: Paul Durrant <paul.durrant@xxxxxxxxxx>
> ---
>  xen/arch/x86/hvm/emulate.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
> index a577685..eab66ea 100644
> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c
> @@ -1859,7 +1859,7 @@ static int hvmemul_rep_stos(
>      switch ( p2mt )
>      {
>          unsigned long bytes;
> -        void *buf;
> +        char *buf;
> 
>      default:
>          /* Allocate temporary buffer. */
> @@ -1882,10 +1882,10 @@ static int hvmemul_rep_stos(
>  #define CASE(bits, suffix)                                     \
>              case (bits) / 8:                                   \
>                  asm ( "rep stos" #suffix                       \
> -                      : "=m" (*(char (*)[bytes])buf),          \
> +                      : "=m" (*buf),                           \
>                          "=D" (dummy), "=c" (dummy)             \
>                        : "a" (*(const uint##bits##_t *)p_data), \
> -                         "1" (buf), "2" (*reps) );             \
> +                        "1" (buf), "2" (*reps) : "memory" );   \
>                  break
>              CASE(8, b);
>              CASE(16, w);
> --
> 2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.