[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ba2fdf7e25f3476ca4a48b48065614f0@AcuMS.aculab.com>
Date: Fri, 16 Oct 2020 08:47:33 +0000
From: David Laight <David.Laight@...LAB.COM>
To: "'hpa@...or.com'" <hpa@...or.com>, Ian Rogers <irogers@...gle.com>,
"Thomas Gleixner" <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"Borislav Petkov" <bp@...en8.de>,
"x86@...nel.org" <x86@...nel.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
"Josh Poimboeuf" <jpoimboe@...hat.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>
CC: Numfor Mbiziwo-Tiapo <nums@...gle.com>
Subject: RE: [PATCH v2] x86/insn, tools/x86: Fix some potential undefined
behavior.
From: hpa@...or.com
> Sent: 15 October 2020 22:35
> >Don't perform unaligned loads in __get_next and __peek_nbyte_next as
> >these are forms of undefined behavior.
...
> > #define __get_next(t, insn) \
> >- ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; })
> >+ ({ t r; memcpy(&r, insn->next_byte, sizeof(t)); insn->next_byte += sizeof(t); r; })
Interesting other idea.
Can you add an 'aligned(1)' into the '*(t *)' cast?
I think '*(t aligned(1) *)' is the right cast.
(gcc seems to accept it either size of the type.)
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists