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

Re: [Xen-devel] [PATCH] compat: Allow CHECK_FIELD_COMMON_ macro deal with fields that are handles



>>> On 11.01.14 at 00:20, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx> wrote:
> CHECK_FIELD_COMMON_ and CHECK_FIELD_COMMON macros verify whether the field in
> 64- and 32-bit versions of a structure is at the same offset by comparing
> address of the field in both structures.
> 
> However, if the field itself is a handle, it is either
> 
> typedef struct {
>     <type> *p;
> } __guest_handle_<type>
> 
> or
> 
> typedef struct {
>     compat_ptr_t c;
>     <type> *_[0] __attribute__((__packed__));
> } __compat_handle_<type>
> 
> and compiler will warn that we are trying to compare addresses of different
> structures.
> 
> By casting the addresses to (void *) we will avoid this warning.

Which means you didn't understand the purpose: If a structure
contains a handle, it shouldn't be subject to checking at all, but
would need translation instead.

Jan

> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
> ---
>  xen/include/xen/compat.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/include/xen/compat.h b/xen/include/xen/compat.h
> index ca60699..6de2d14 100644
> --- a/xen/include/xen/compat.h
> +++ b/xen/include/xen/compat.h
> @@ -158,14 +158,14 @@ static inline int name(xen_ ## t ## _t *x, compat_ ## t 
> ## _t *c) \
>  { \
>      BUILD_BUG_ON(offsetof(xen_ ## t ## _t, f) != \
>                   offsetof(compat_ ## t ## _t, f)); \
> -    return &x->f == &c->f; \
> +    return (void *)&x->f == (void *)&c->f; \
>  }
>  #define CHECK_FIELD_COMMON_(k, name, n, f) \
>  static inline int name(k xen_ ## n *x, k compat_ ## n *c) \
>  { \
>      BUILD_BUG_ON(offsetof(k xen_ ## n, f) != \
>                   offsetof(k compat_ ## n, f)); \
> -    return &x->f == &c->f; \
> +    return (void *)&x->f == (void *)&c->f; \
>  }
>  
>  #define CHECK_FIELD(t, f) \
> -- 
> 1.8.1.4
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxx 
> http://lists.xen.org/xen-devel 




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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