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.

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

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.

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. Was

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 the

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 to

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. Unless

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

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

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

2015-06-11 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

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

2015-06-11 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

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 jpoim...@redhat.com 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

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 jpoim...@redhat.com 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

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

2015-06-11 Thread Ingo Molnar
* Josh Poimboeuf jpoim...@redhat.com 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

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

2015-06-11 Thread Ingo Molnar
* Josh Poimboeuf jpoim...@redhat.com 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

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

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,

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,

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

[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

[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

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 jpoim...@redhat.com wrote: On Wed, Jun 10, 2015 at 10:21:36AM -0700, Andy Lutomirski wrote: On Jun 10, 2015 5:07 AM, Josh Poimboeuf jpoim...@redhat.com wrote: 2. Each callable

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 vojt...@suse.com wrote: On Wed, Jun 10, 2015 at 10:21:36AM -0700, Andy Lutomirski wrote: On Jun 10, 2015 5:07 AM, Josh Poimboeuf jpoim...@redhat.com wrote: Add a new CONFIG_ASM_VALIDATION option which adds an asmvalidate host tool which runs

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 jpoim...@redhat.com 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

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 jpoim...@redhat.com 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

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 jpoim...@redhat.com wrote: On Wed, Jun 10, 2015 at 10:21:36AM -0700, Andy Lutomirski wrote: On Jun 10, 2015 5:07 AM, Josh Poimboeuf jpoim...@redhat.com wrote: Add a new CONFIG_ASM_VALIDATION option which adds an asmvalidate host tool which

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 jpoim...@redhat.com 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

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 jpoim...@redhat.com wrote: On Wed, Jun 10, 2015 at 10:21:36AM -0700, Andy Lutomirski wrote: GCC can generate