Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-12 Thread Josh Poimboeuf
On Fri, Jun 12, 2015 at 05:00:50PM +0100, Pedro Alves wrote: > On 06/12/2015 03:10 PM, Josh Poimboeuf wrote: > > That said, the kernel has much more custom features than other projects. > > There are some sneaky macros, like _ASM_EXTABLE and ALTERNATIVE, which > > hide code in various sections. Un

Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-12 Thread Pedro Alves
On 06/12/2015 03:10 PM, Josh Poimboeuf wrote: > On Fri, Jun 12, 2015 at 12:18:16PM +0100, Pedro Alves wrote: >> On 06/11/2015 03:10 PM, Josh Poimboeuf wrote: >> >>> C would definitely make more sense when analyzing object code. In fact, >>> asmvalidate is written in C. But then I guess we'd have

Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-12 Thread Josh Poimboeuf
On Fri, Jun 12, 2015 at 12:18:16PM +0100, Pedro Alves wrote: > On 06/11/2015 03:10 PM, Josh Poimboeuf wrote: > > > C would definitely make more sense when analyzing object code. In fact, > > asmvalidate is written in C. But then I guess we'd have to re-implement > > the .cfi stuff and populate t

Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-12 Thread Pedro Alves
On 06/11/2015 03:10 PM, Josh Poimboeuf wrote: > C would definitely make more sense when analyzing object code. In fact, > asmvalidate is written in C. But then I guess we'd have to re-implement > the .cfi stuff and populate the DWARF sections manually instead of > letting the assembler do it. W

Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-11 Thread Josh Poimboeuf
On Thu, Jun 11, 2015 at 08:10:50AM +0200, Ingo Molnar wrote: > * Josh Poimboeuf wrote: > > > I imagine that an automatic CFI annotation adder would walk through > > > functions > > > one instruction at a time and keep track of the frame state. If so, then > > > it > > > could verify that commo

Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-11 Thread Josh Poimboeuf
On Thu, Jun 11, 2015 at 08:08:07AM +0200, Ingo Molnar wrote: > > * Josh Poimboeuf wrote: > > > I should also mention that my proposed ia32_ptregs_common patch, which > > duplicated the needed code, was more optimized for performance than code > > size. > > > > But if you're more worried about

Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-10 Thread Ingo Molnar
* Josh Poimboeuf wrote: > > I imagine that an automatic CFI annotation adder would walk through > > functions > > one instruction at a time and keep track of the frame state. If so, then it > > could verify that common jump targets had identical state and continue > > walking > > through th

Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-10 Thread Ingo Molnar
* Josh Poimboeuf wrote: > I should also mention that my proposed ia32_ptregs_common patch, which > duplicated the needed code, was more optimized for performance than code size. > > But if you're more worried about code size, we could turn ia32_ptregs_common > into a proper callable function,

Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-10 Thread Josh Poimboeuf
On Wed, Jun 10, 2015 at 01:58:45PM -0500, Josh Poimboeuf wrote: > On Wed, Jun 10, 2015 at 11:15:19AM -0700, Andy Lutomirski wrote: > > On Wed, Jun 10, 2015 at 10:53 AM, Josh Poimboeuf > > wrote: > > > On Wed, Jun 10, 2015 at 10:21:36AM -0700, Andy Lutomirski wrote: > > >> GCC can generate those,

Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-10 Thread Josh Poimboeuf
On Wed, Jun 10, 2015 at 11:15:19AM -0700, Andy Lutomirski wrote: > On Wed, Jun 10, 2015 at 10:53 AM, Josh Poimboeuf wrote: > > On Wed, Jun 10, 2015 at 10:21:36AM -0700, Andy Lutomirski wrote: > >> On Jun 10, 2015 5:07 AM, "Josh Poimboeuf" wrote: > >> > 2. Each callable function must never leave i

Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-10 Thread Vojtech Pavlik
On Wed, Jun 10, 2015 at 10:21:36AM -0700, Andy Lutomirski wrote: > On Jun 10, 2015 5:07 AM, "Josh Poimboeuf" wrote: > > > > Add a new CONFIG_ASM_VALIDATION option which adds an asmvalidate host > > tool which runs on every compiled .S file. Its goal is to enforce sane > > rules on all asm code, s

Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-10 Thread Andy Lutomirski
On Wed, Jun 10, 2015 at 11:16 AM, Vojtech Pavlik wrote: > On Wed, Jun 10, 2015 at 10:21:36AM -0700, Andy Lutomirski wrote: >> On Jun 10, 2015 5:07 AM, "Josh Poimboeuf" wrote: >> > >> > Add a new CONFIG_ASM_VALIDATION option which adds an asmvalidate host >> > tool which runs on every compiled .S

Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-10 Thread Andy Lutomirski
On Wed, Jun 10, 2015 at 10:53 AM, Josh Poimboeuf wrote: > On Wed, Jun 10, 2015 at 10:21:36AM -0700, Andy Lutomirski wrote: >> On Jun 10, 2015 5:07 AM, "Josh Poimboeuf" wrote: >> > >> > Add a new CONFIG_ASM_VALIDATION option which adds an asmvalidate host >> > tool which runs on every compiled .S

Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-10 Thread Josh Poimboeuf
On Wed, Jun 10, 2015 at 10:21:36AM -0700, Andy Lutomirski wrote: > On Jun 10, 2015 5:07 AM, "Josh Poimboeuf" wrote: > > > > Add a new CONFIG_ASM_VALIDATION option which adds an asmvalidate host > > tool which runs on every compiled .S file. Its goal is to enforce sane > > rules on all asm code, s

Re: [PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-10 Thread Andy Lutomirski
On Jun 10, 2015 5:07 AM, "Josh Poimboeuf" wrote: > > Add a new CONFIG_ASM_VALIDATION option which adds an asmvalidate host > tool which runs on every compiled .S file. Its goal is to enforce sane > rules on all asm code, so that stack debug metadata (frame/back chain > pointers and/or DWARF CFI m

[PATCH v5 02/10] x86: Compile-time asm code validation

2015-06-10 Thread Josh Poimboeuf
Add a new CONFIG_ASM_VALIDATION option which adds an asmvalidate host tool which runs on every compiled .S file. Its goal is to enforce sane rules on all asm code, so that stack debug metadata (frame/back chain pointers and/or DWARF CFI metadata) can be made reliable. It enforces the following ru