[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190506142254.GG2650@hirez.programming.kicks-ass.net>
Date: Mon, 6 May 2019 16:22:54 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Andy Lutomirski <luto@...capital.net>,
Steven Rostedt <rostedt@...dmis.org>,
Linux List Kernel Mailing <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Andy Lutomirski <luto@...nel.org>,
Nicolai Stange <nstange@...e.de>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>,
the arch/x86 maintainers <x86@...nel.org>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Jiri Kosina <jikos@...nel.org>,
Miroslav Benes <mbenes@...e.cz>,
Petr Mladek <pmladek@...e.com>,
Joe Lawrence <joe.lawrence@...hat.com>,
Shuah Khan <shuah@...nel.org>,
Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
Tim Chen <tim.c.chen@...ux.intel.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Mimi Zohar <zohar@...ux.ibm.com>,
Juergen Gross <jgross@...e.com>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Nayna Jain <nayna@...ux.ibm.com>,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
Joerg Roedel <jroedel@...e.de>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@...r.kernel.org>, stable <stable@...r.kernel.org>
Subject: Re: [RFC][PATCH 1/2] x86: Allow breakpoints to emulate call functions
On Mon, May 06, 2019 at 10:19:51AM +0200, Peter Zijlstra wrote:
> +.Lfrom_usermode_no_fixup_\@:
> +.endm
> +
> +.macro IRET_FRAME
> +
> + /* orig_eax is already POP'ed when we're here */
> +
> + testl $CS_FROM_KERNEL, 1*4(%esp)
> + jz .Lfinished_frame_\@
> +
> + pushl %eax
> +
>From there..
> + lea 10*4(%esp), %eax # address of <previous context>
> + cmpl %eax, 4*4(%esp) # if ->sp is unmodified
> + jnz .Lmodified_sp_do_fixup_\@
> +
> + /*
> + * Fast path; regs->sp wasn't modified, reuse the original IRET frame.
> + */
> + pop %eax
> + add $6*4, %esp
> + jmp .Lfinished_frame_\@;
> +
> +.Lmodified_sp_do_fixup_\@:
... until here, needs to go, it is buggy. While a clever idea, it looses
updates to regs->ip and ->flags.
> +
> + /*
> + * Reconstruct the 3 entry IRET frame right after the (modified)
> + * regs->sp without lowering %esp in between, such that an NMI in the
> + * middle doesn't scribble our stack.
> + */
> + pushl %ecx
> + movl 5*4(%esp), %eax # (modified) regs->sp
> +
> + movl 4*4(%esp), %ecx # flags
> + movl %ecx, -4(%eax)
> +
> + movl 3*4(%esp), %ecx # cs
> + andl $0x0000ffff, %ecx
> + movl %ecx, -8(%eax)
> +
> + movl 2*4(%esp), %ecx # ip
> + movl %ecx, -12(%eax)
> +
> + movl 1*4(%esp), %ecx # eax
> + movl %ecx, -16(%eax)
> +
> + popl %ecx
> + lea -16(%eax), %esp
> + popl %eax
> +
> +.Lfinished_frame_\@:
> +.endm
Powered by blists - more mailing lists