|
Message-ID: <20170208094313.GI6536@twins.programming.kicks-ass.net> Date: Wed, 8 Feb 2017 10:43:13 +0100 From: Peter Zijlstra <peterz@...radead.org> To: Mark Rutland <mark.rutland@....com> Cc: Kees Cook <keescook@...omium.org>, "Reshetova, Elena" <elena.reshetova@...el.com>, Greg KH <gregkh@...uxfoundation.org>, Arnd Bergmann <arnd@...db.de>, Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...nel.org>, "H. Peter Anvin" <h.peter.anvin@...el.com>, Will Deacon <will.deacon@....com>, David Windsor <dwindsor@...il.com>, Hans Liljestrand <ishkamiel@...il.com>, David Howells <dhowells@...hat.com>, LKML <linux-kernel@...r.kernel.org>, "kernel-hardening@...ts.openwall.com" <kernel-hardening@...ts.openwall.com> Subject: Re: Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION On Wed, Feb 08, 2017 at 10:12:50AM +0100, Peter Zijlstra wrote: > Something like: > > #define EX_REG_HANDLER(_reg) \ > bool ex_handler_value_##_reg(const struct exception_table_entry *fixup, \ > struct pt_regs *regs, int trapnr) \ > { \ > void (*handler)(unsigned long) = \ > (void *)((unsigned long)&fixup->to + fixup->to); \ > \ > if (trapnr != X86_TRAP_UD) \ > return false; \ > \ > regs->ip += 2; /* size of UD2 instruction */ \ > handler(regs->_reg); \ > return true; \ > } > > EX_REG_HANDLER(bx); > EX_REG_HANDLER(cx); > ... > EX_REG_HANDLER(ss); > > > asm ( > " .macro reg_to_handler r\n" > " .irp rs,bx,cx,...,ss\n" > " .ifc \\r, %\\rs\n" > " ex_handler_value_\\rs\n" > " .endif\n" " .ifc \\r, %e\\rs\n" " ex_handler_value_\\rs\n" " .endif\n" " .ifc \\r, %r\\rs\n" " ex_handler_value_\\rs\n" " .endif\n" > " .endr\n" > " .endm\n" > ); to match the 16, 32 and 64 bit names of the same registers. The byte registers will need additional magic :/ > #define EXCEPTION_VALUE(val, handler) \ > asm volatile ("1: ud2" \ > _ASM_EXTABLE_HANDLE(1b, handler, \ > reg_to_handler %0) \ > : : "r" (val)) > > > Where the generic version can simply be: > > #define EXCEPTION_VALUE(val, handler) handler((unsigned long)val) > > > Makes sense?
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.