Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753333AbbGNROd (ORCPT ); Tue, 14 Jul 2015 13:14:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59520 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753271AbbGNRO1 (ORCPT ); Tue, 14 Jul 2015 13:14:27 -0400 From: Josh Poimboeuf To: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" Cc: Michal Marek , Peter Zijlstra , Andy Lutomirski , Borislav Petkov , Linus Torvalds , Andi Kleen , Pedro Alves , x86@kernel.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 4/4] x86/stackvalidate: Add ignore macros Date: Tue, 14 Jul 2015 12:14:10 -0500 Message-Id: <48aedf5bfc18c757c1c5150a81d8eb450bf36f78.1436893563.git.jpoimboe@redhat.com> In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2977 Lines: 98 Add new stackvalidate ignore macros: STACKVALIDATE_IGNORE_INSN and STACKVALIDATE_IGNORE_FUNC. These can be used to tell stackvalidate to skip validation of an instruction or a function, respectively. Signed-off-by: Josh Poimboeuf --- arch/x86/include/asm/stackvalidate.h | 28 ++++++++++++++++++++++++++++ arch/x86/kernel/vmlinux.lds.S | 5 ++++- include/linux/stackvalidate.h | 21 +++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 arch/x86/include/asm/stackvalidate.h create mode 100644 include/linux/stackvalidate.h diff --git a/arch/x86/include/asm/stackvalidate.h b/arch/x86/include/asm/stackvalidate.h new file mode 100644 index 0000000..2d23c23 --- /dev/null +++ b/arch/x86/include/asm/stackvalidate.h @@ -0,0 +1,28 @@ +#ifndef _ASM_X86_STACKVALIDATE_H +#define _ASM_X86_STACKVALIDATE_H + +#include + +#ifdef __ASSEMBLY__ + +/* + * This asm macro tells the stack validation script to ignore the instruction + * immediately after the macro. It should only be used in special cases where + * you're 100% sure it won't affect the reliability of frame pointers and + * kernel stack traces. + * + * For more information, see Documentation/stack-validation.txt. + */ +.macro STACKVALIDATE_IGNORE_INSN + .if CONFIG_STACK_VALIDATION + .Ltemp_\@: + .pushsection __stackvalidate_ignore_insn, "a" + _ASM_ALIGN + .long .Ltemp_\@ - . + .popsection + .endif +.endm + +#endif /* __ASSEMBLY__ */ + +#endif /* _ASM_X86_STACKVALIDATE_H */ diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 00bf300..f2f8d7a 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -332,7 +332,10 @@ SECTIONS /* Sections to be discarded */ DISCARDS - /DISCARD/ : { *(.eh_frame) } + /DISCARD/ : { + *(.eh_frame) + *(__stackvalidate_ignore_*) + } } diff --git a/include/linux/stackvalidate.h b/include/linux/stackvalidate.h new file mode 100644 index 0000000..5cc5c97 --- /dev/null +++ b/include/linux/stackvalidate.h @@ -0,0 +1,21 @@ +#ifndef _LINUX_STACKVALIDATE_H +#define _LINUX_STACKVALIDATE_H + +#include + +#ifndef __ASSEMBLY__ + +/* + * This C macro tells the stack validation script to ignore the function. It + * should only be used in special cases where you're 100% sure it won't affect + * the reliability of frame pointers and kernel stack traces. + * + * For more information, see Documentation/stack-validation.txt. + */ +#define STACKVALIDATE_IGNORE_FUNC(_func) \ + static void __used __section(__stackvalidate_ignore_func) \ + *__stackvalidate_ignore_func_##_func = _func + +#endif /* !__ASSEMBLY__ */ + +#endif /* _LINUX_STACKVALIDATE_H */ -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/