2015-04-07 16:43:24

by Denys Vlasenko

[permalink] [raw]
Subject: [PATCH] x86/asm/entry/64: Add forgotten CFI annotation

Signed-off-by: Denys Vlasenko <[email protected]>
CC: Linus Torvalds <[email protected]>
CC: Steven Rostedt <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: Borislav Petkov <[email protected]>
CC: "H. Peter Anvin" <[email protected]>
CC: Andy Lutomirski <[email protected]>
CC: Oleg Nesterov <[email protected]>
CC: Frederic Weisbecker <[email protected]>
CC: Alexei Starovoitov <[email protected]>
CC: Will Drewry <[email protected]>
CC: Kees Cook <[email protected]>
CC: [email protected]
CC: [email protected]
---
arch/x86/kernel/entry_64.S | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 65485b3..15261ba 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -429,6 +429,7 @@ return_from_execve:
1:
/* must use IRET code path (pt_regs->cs may have changed) */
addq $8, %rsp
+ CFI_ADJUST_CFA_OFFSET -8
ZERO_EXTRA_REGS
movq %rax,RAX(%rsp)
jmp int_ret_from_sys_call
--
1.8.1.4


2015-04-08 07:18:32

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH] x86/asm/entry/64: Add forgotten CFI annotation


* Denys Vlasenko <[email protected]> wrote:

> Signed-off-by: Denys Vlasenko <[email protected]>
> CC: Linus Torvalds <[email protected]>
> CC: Steven Rostedt <[email protected]>
> CC: Ingo Molnar <[email protected]>
> CC: Borislav Petkov <[email protected]>
> CC: "H. Peter Anvin" <[email protected]>
> CC: Andy Lutomirski <[email protected]>
> CC: Oleg Nesterov <[email protected]>
> CC: Frederic Weisbecker <[email protected]>
> CC: Alexei Starovoitov <[email protected]>
> CC: Will Drewry <[email protected]>
> CC: Kees Cook <[email protected]>
> CC: [email protected]
> CC: [email protected]
> ---
> arch/x86/kernel/entry_64.S | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
> index 65485b3..15261ba 100644
> --- a/arch/x86/kernel/entry_64.S
> +++ b/arch/x86/kernel/entry_64.S
> @@ -429,6 +429,7 @@ return_from_execve:
> 1:
> /* must use IRET code path (pt_regs->cs may have changed) */
> addq $8, %rsp
> + CFI_ADJUST_CFA_OFFSET -8
> ZERO_EXTRA_REGS
> movq %rax,RAX(%rsp)
> jmp int_ret_from_sys_call

So given that this is a pretty common pattern:

triton:~/tip> git grep -A 1 'addq.*%rsp' arch/x86/kernel/entry_64.S
arch/x86/kernel/entry_64.S: addq $8, %rsp
arch/x86/kernel/entry_64.S- CFI_ADJUST_CFA_OFFSET -8
--
arch/x86/kernel/entry_64.S: addq $8, %rsp
arch/x86/kernel/entry_64.S- DEFAULT_FRAME 0
--
arch/x86/kernel/entry_64.S: addq $8, %rsp
arch/x86/kernel/entry_64.S- DEFAULT_FRAME 0
--
arch/x86/kernel/entry_64.S: addq $-0x80,(%rsp) /* Adjust vector to [-256,-1] range */
arch/x86/kernel/entry_64.S- interrupt do_IRQ
--
arch/x86/kernel/entry_64.S: addq $0x30,%rsp
arch/x86/kernel/entry_64.S- CFI_ADJUST_CFA_OFFSET -0x30
--
arch/x86/kernel/entry_64.S: addq $0x30,%rsp
arch/x86/kernel/entry_64.S- CFI_ADJUST_CFA_OFFSET -0x30
--
arch/x86/kernel/entry_64.S: addq $(6*8), %rsp
arch/x86/kernel/entry_64.S- CFI_ADJUST_CFA_OFFSET -6*8
--
arch/x86/kernel/entry_64.S: addq $(10*8), %rsp
arch/x86/kernel/entry_64.S- CFI_ADJUST_CFA_OFFSET -10*8


it might make sense to introduce addq_cfi, to further hide the dwarf
uglies?

btw., doesn't:

arch/x86/kernel/entry_64.S: addq $-0x80,(%rsp) /* Adjust vector to [-256,-1] range */

before the do_IRQ() call need a CFI adjustment as well?

Thanks,

Ingo

Subject: [tip:x86/asm] x86/asm/entry/64: Add forgotten CFI annotation

Commit-ID: 8b3607b5b8c591d8bf045911cb7c90ecaa6e7b73
Gitweb: http://git.kernel.org/tip/8b3607b5b8c591d8bf045911cb7c90ecaa6e7b73
Author: Denys Vlasenko <[email protected]>
AuthorDate: Tue, 7 Apr 2015 18:42:47 +0200
Committer: Ingo Molnar <[email protected]>
CommitDate: Wed, 8 Apr 2015 09:18:36 +0200

x86/asm/entry/64: Add forgotten CFI annotation

Signed-off-by: Denys Vlasenko <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Will Drewry <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/kernel/entry_64.S | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 4ca03c5..3197f41 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -506,6 +506,7 @@ return_from_execve:
1:
/* must use IRET code path (pt_regs->cs may have changed) */
addq $8, %rsp
+ CFI_ADJUST_CFA_OFFSET -8
ZERO_EXTRA_REGS
movq %rax,RAX(%rsp)
jmp int_ret_from_sys_call