[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQJQydX9OU_rem+BObR0eWc-jrrwirUYVKH9rnN=Z8LG6A@mail.gmail.com>
Date: Mon, 24 Nov 2014 10:02:52 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: David Howells <dhowells@...hat.com>
Cc: Christian Borntraeger <borntraeger@...ibm.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
linux-arch@...r.kernel.org, linux-mips@...ux-mips.org,
linux-x86_64@...r.kernel.org, linux-s390@...r.kernel.org,
Paolo Bonzini <pbonzini@...hat.com>,
paulmck@...ux.vnet.ibm.com, Ingo Molnar <mingo@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will.deacon@....com>
Subject: Re: [PATCH/RFC 7/7] kernel: Force ACCESS_ONCE to work only on scalar types
On Mon, Nov 24, 2014 at 5:30 AM, David Howells <dhowells@...hat.com> wrote:
> Christian Borntraeger <borntraeger@...ibm.com> wrote:
>
>> +#define get_scalar_volatile_pointer(x) ({ \
>> + typeof(x) *__p = &(x); \
>> + volatile typeof(x) *__vp = __p; \
>> + (void)(long)*__p; __vp; })
>> +#define ACCESS_ONCE(x) (*get_scalar_volatile_pointer(x))
If the goal is to catch non-scalar users, the following is shorter:
#define ACCESS_ONCE(x) (((typeof(x))0) + *(volatile typeof(x) *)&(x))
it will block union and struct accesses.
If you want to allow union and disallow struct, then replace + with ,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists