Re: [PATCH 3/4] x86: open-code register save/restore in trace_hardirqs thunks

From: Borislav Petkov
Date: Fri Jan 09 2015 - 07:19:57 EST


On Thu, Jan 08, 2015 at 05:25:14PM +0100, Denys Vlasenko wrote:
> This is a preparatory patch for change in "struct pt_regs"
> handling in entry_64.S.
>
> trace_hardirqs thunks were (ab)using a part of pt_regs
> handling code, namely SAVE_ARGS/RESTORE_ARGS macros,
> to save/restore registers across C function calls.
>
> Since SAVE_ARGS is going to be changed, open-code
> register saving/restoring here.
>
> Incidentally, this removes a bit of dead code:
> one SAVE_ARGS was used just to emit a CFI annotation,
> but it also generated unreachable assembly insns.
>
> Signed-off-by: Denys Vlasenko <dvlasenk@xxxxxxxxxx>
> CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> CC: Oleg Nesterov <oleg@xxxxxxxxxx>
> CC: "H. Peter Anvin" <hpa@xxxxxxxxx>
> CC: Andy Lutomirski <luto@xxxxxxxxxxxxxx>
> CC: Frederic Weisbecker <fweisbec@xxxxxxxxx>
> CC: X86 ML <x86@xxxxxxxxxx>
> CC: Alexei Starovoitov <ast@xxxxxxxxxxxx>
> CC: Will Drewry <wad@xxxxxxxxxxxx>
> CC: Kees Cook <keescook@xxxxxxxxxxxx>
> CC: linux-kernel@xxxxxxxxxxxxxxx
> ---
> arch/x86/lib/thunk_64.S | 29 ++++++++++++++++++++++++-----
> 1 file changed, 24 insertions(+), 5 deletions(-)

Hmm, this patch breaks booting my kvm guest: it stops booting at some
point and restarts itself after a couple of seconds.

The monitor says rIP points to ffffffff8167ae30 which is this:

ffffffff8167ae30 <async_page_fault>:
ffffffff8167ae30: ff 15 fa 62 31 00 callq *0x3162fa(%rip) # ffffffff81991130 <pv_irq_ops+0x30>
ffffffff8167ae36: 48 83 ec 78 sub $0x78,%rsp
ffffffff8167ae3a: e8 d1 01 00 00 callq ffffffff8167b010 <error_entry>
ffffffff8167ae3f: 48 89 e7 mov %rsp,%rdi
ffffffff8167ae42: 48 8b 74 24 78 mov 0x78(%rsp),%rsi
ffffffff8167ae47: 48 c7 44 24 78 ff ff movq $0xffffffffffffffff,0x78(%rsp)
ffffffff8167ae4e: ff ff
ffffffff8167ae50: e8 9b 9e 9c ff callq ffffffff81044cf0 <do_async_page_fault>
ffffffff8167ae55: e9 76 02 00 00 jmpq ffffffff8167b0d0 <error_exit>
ffffffff8167ae5a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)

HTH.

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/