Re: [PATCH v2] x86/insn, tools/x86: Fix some potential undefined behavior.

2020-10-16 Thread Peter Zijlstra
On Thu, Oct 15, 2020 at 02:34:57PM -0700, h...@zytor.com wrote: > Wait, what? > > You are taking about x86-specific code, and on x86 unaligned memory > accesses are supported, well-defined, and ubiquitous. Objtool uses this x86 instruction decoder, people are cross-buildling objtool to

RE: [PATCH v2] x86/insn, tools/x86: Fix some potential undefined behavior.

2020-10-16 Thread David Laight
From: h...@zytor.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;

RE: [PATCH v2] x86/insn, tools/x86: Fix some potential undefined behavior.

2020-10-16 Thread David Laight
From: Ian Rogers > Sent: 15 October 2020 22:47 ... > The decoder is a shared code and using unaligned macros makes life > hard for the other users of the code. Memcpy is the "standard" > workaround for this kind of undefined behavior. >

Re: [PATCH v2] x86/insn, tools/x86: Fix some potential undefined behavior.

2020-10-15 Thread Masami Hiramatsu
On Thu, 15 Oct 2020 09:12:16 -0700 Ian Rogers wrote: > From: Numfor Mbiziwo-Tiapo > > Don't perform unaligned loads in __get_next and __peek_nbyte_next as > these are forms of undefined behavior. > > These problems were identified using the undefined behavior sanitizer > (ubsan) with the

Re: [PATCH v2] x86/insn, tools/x86: Fix some potential undefined behavior.

2020-10-15 Thread Ian Rogers
On Thu, Oct 15, 2020 at 2:35 PM wrote: > > On October 15, 2020 9:12:16 AM PDT, Ian Rogers wrote: > >From: Numfor Mbiziwo-Tiapo > > > >Don't perform unaligned loads in __get_next and __peek_nbyte_next as > >these are forms of undefined behavior. > > > >These problems were identified using the

Re: [PATCH v2] x86/insn, tools/x86: Fix some potential undefined behavior.

2020-10-15 Thread hpa
On October 15, 2020 9:12:16 AM PDT, Ian Rogers wrote: >From: Numfor Mbiziwo-Tiapo > >Don't perform unaligned loads in __get_next and __peek_nbyte_next as >these are forms of undefined behavior. > >These problems were identified using the undefined behavior sanitizer >(ubsan) with the tools

[PATCH v2] x86/insn, tools/x86: Fix some potential undefined behavior.

2020-10-15 Thread Ian Rogers
From: Numfor Mbiziwo-Tiapo Don't perform unaligned loads in __get_next and __peek_nbyte_next as these are forms of undefined behavior. These problems were identified using the undefined behavior sanitizer (ubsan) with the tools version of the code and perf test. Part of this patch was