lkml.org 
[lkml]   [2019]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 05/10] efi/libstub: distinguish between native/mixed not 32/64 bit
On Sat, 14 Dec 2019 at 20:49, Arvind Sankar <nivedita@alum.mit.edu> wrote:
>
> On Sat, Dec 14, 2019 at 02:46:27PM -0500, Arvind Sankar wrote:
> > On Sat, Dec 14, 2019 at 06:57:30PM +0100, Ard Biesheuvel wrote:
> > > +
> > > +#define efi_table_attr(table, attr, instance) ({ \
> > > + __typeof__(((table##_t *)0)->attr) __ret; \
> > > + if (efi_is_native()) { \
> > > + __ret = ((table##_t *)instance)->attr; \
> > > + } else { \
> > > + __typeof__(((table##_32_t *)0)->attr) at; \
> > > + at = (((table##_32_t *)(unsigned long)instance)->attr); \
> > > + __ret = (__typeof__(__ret))(unsigned long)at; \
> > > + } \
> > > + __ret; \
> > > +})
> >
> > The casting of `at' is appropriate if the attr is a pointer type which
> > needs to be zero-extended to 64-bit, but for other fields it is
> > unnecessary at best and possibly dangerous. There are probably no
> > instances currently where it is called for a non-pointer field, but is
> > it possible to detect if the type is pointer and avoid the cast if not?
>
> To clarify, I mean the casting via `unsigned long' -- casting to type of
> __ret should be ok. We could also use uintptr_t for cleanliness when the
> cast is required?

Could you give an example of how it could break?

\
 
 \ /
  Last update: 2019-12-14 20:54    [W:0.066 / U:0.772 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site