From: "Jan Beulich" <JBeulich@novell.com>
To: "Andreas Kleen" <ak@suse.de>
Cc: <linux-kernel@vger.kernel.org>, <discuss@x86-64.org>
Subject: [PATCH] x86-64: adjust ia32entry.S
Date: Wed, 09 Nov 2005 17:10:11 +0100 [thread overview]
Message-ID: <43722D73.76F0.0078.0@novell.com> (raw)
In-Reply-To: 4370C36D.76F0.0078.0@novell.com
[-- Attachment #1: Type: text/plain, Size: 243 bytes --]
IA32 compatibility entry points needlessly played with extended
registers. Additionally, frame unwind information was still incorrect
for ia32_ptregs_common (sorry, my fault).
From: Jan Beulich <jbeulich@novell.com>
(actual patch attached)
[-- Attachment #2: linux-2.6.14-x86_64-ia32entry.patch --]
[-- Type: application/octet-stream, Size: 8388 bytes --]
IA32 compatibility entry points needlessly played with extended
registers. Additionally, frame unwind information was still incorrect
for ia32_ptregs_common (sorry, my fault).
From: Jan Beulich <jbeulich@novell.com>
--- 2.6.14/arch/x86_64/ia32/ia32entry.S 2005-10-28 02:02:08.000000000 +0200
+++ 2.6.14-x86_64-ia32entry/arch/x86_64/ia32/ia32entry.S 2005-11-09 14:02:12.000000000 +0100
@@ -26,13 +26,29 @@
movl %edx,%edx /* zero extension */
.endm
- /* clobbers %eax */
- .macro CLEAR_RREGS
- xorl %eax,%eax
- movq %rax,R11(%rsp)
- movq %rax,R10(%rsp)
- movq %rax,R9(%rsp)
- movq %rax,R8(%rsp)
+ /* clobbers specified register (or %eax) */
+ .macro CLEAR_RREGS r=ax
+ xorl %e\r,%e\r
+ movq %r\r,R15(%rsp)
+ movq %r\r,R14(%rsp)
+ movq %r\r,R13(%rsp)
+ movq %r\r,R12(%rsp)
+ movq %r\r,R11(%rsp)
+ movq %r\r,R10(%rsp)
+ movq %r\r,R9(%rsp)
+ movq %r\r,R8(%rsp)
+ .endm
+
+ .macro CFI_STARTPROC32 simple
+ CFI_STARTPROC \simple
+ CFI_UNDEFINED r8
+ CFI_UNDEFINED r9
+ CFI_UNDEFINED r10
+ CFI_UNDEFINED r11
+ CFI_UNDEFINED r12
+ CFI_UNDEFINED r13
+ CFI_UNDEFINED r14
+ CFI_UNDEFINED r15
.endm
/*
@@ -55,7 +71,7 @@
* with the int 0x80 path.
*/
ENTRY(ia32_sysenter_target)
- CFI_STARTPROC simple
+ CFI_STARTPROC32 simple
CFI_DEF_CFA rsp,0
CFI_REGISTER rsp,rbp
swapgs
@@ -107,7 +123,7 @@ sysenter_do_call:
jnz int_ret_from_sys_call
/* clear IF, that popfq doesn't enable interrupts early */
andl $~0x200,EFLAGS-R11(%rsp)
- RESTORE_ARGS 1,24,1,1,1,1
+ RESTORE_ARGS 1,24,1,1,1
popfq
CFI_ADJUST_CFA_OFFSET -8
/*CFI_RESTORE rflags*/
@@ -123,14 +139,13 @@ sysenter_do_call:
sysenter_tracesys:
CFI_RESTORE_STATE
- SAVE_REST
+ SAVE_REST 1
CLEAR_RREGS
movq $-ENOSYS,RAX(%rsp) /* really needed? */
movq %rsp,%rdi /* &pt_regs -> arg1 */
call syscall_trace_enter
- LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
- RESTORE_REST
- movl %ebp, %ebp
+ LOAD_ARGS ARGOFFSET,0,1 /* reload args from stack in case ptrace changed it */
+ RESTORE_REST 1
/* no need to do an access_ok check here because rbp has been
32bit zero extended */
1: movl (%rbp),%r9d
@@ -161,7 +176,7 @@ sysenter_tracesys:
* with the int 0x80 path.
*/
ENTRY(ia32_cstar_target)
- CFI_STARTPROC simple
+ CFI_STARTPROC32 simple
CFI_DEF_CFA rsp,0
CFI_REGISTER rip,rcx
/*CFI_REGISTER rflags,r11*/
@@ -204,7 +219,7 @@ cstar_do_call:
cli
testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
jnz int_ret_from_sys_call
- RESTORE_ARGS 1,-ARG_SKIP,1,1,1
+ RESTORE_ARGS 1,-ARG_SKIP,1,1
movl RIP-ARGOFFSET(%rsp),%ecx
CFI_REGISTER rip,rcx
movl EFLAGS-ARGOFFSET(%rsp),%r11d
@@ -216,14 +231,14 @@ cstar_do_call:
cstar_tracesys:
CFI_RESTORE_STATE
- SAVE_REST
+ SAVE_REST 1
CLEAR_RREGS
movq $-ENOSYS,RAX(%rsp) /* really needed? */
movq %rsp,%rdi /* &pt_regs -> arg1 */
call syscall_trace_enter
- LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
- RESTORE_REST
- movl RSP-ARGOFFSET(%rsp), %r8d
+ LOAD_ARGS ARGOFFSET,0,1 /* reload args from stack in case ptrace changed it */
+ movl RSP(%rsp), %r8d
+ RESTORE_REST 1
/* no need to do an access_ok check here because r8 has been
32bit zero extended */
1: movl (%r8),%r9d
@@ -259,7 +274,7 @@ ia32_badarg:
*/
ENTRY(ia32_syscall)
- CFI_STARTPROC simple
+ CFI_STARTPROC32 simple
CFI_DEF_CFA rsp,SS+8-RIP
/*CFI_REL_OFFSET ss,SS-RIP*/
CFI_REL_OFFSET rsp,RSP-RIP
@@ -288,12 +303,13 @@ ia32_sysret:
jmp int_ret_from_sys_call
ia32_tracesys:
- SAVE_REST
+ SAVE_REST 1
+ CLEAR_RREGS
movq $-ENOSYS,RAX(%rsp) /* really needed? */
movq %rsp,%rdi /* &pt_regs -> arg1 */
call syscall_trace_enter
- LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
- RESTORE_REST
+ LOAD_ARGS ARGOFFSET,0,1 /* reload args from stack in case ptrace changed it */
+ RESTORE_REST 1
jmp ia32_do_syscall
ia32_badsys:
@@ -318,7 +334,7 @@ quiet_ni_syscall:
jmp ia32_ptregs_common
.endm
- CFI_STARTPROC
+ CFI_STARTPROC32
PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
@@ -333,11 +349,23 @@ quiet_ni_syscall:
ENTRY(ia32_ptregs_common)
popq %r11
- CFI_ADJUST_CFA_OFFSET -8
- CFI_REGISTER rip, r11
- SAVE_REST
+ CFI_ENDPROC
+ CFI_STARTPROC32 simple
+ CFI_DEF_CFA rsp,SS+8-ARGOFFSET
+ CFI_REL_OFFSET rax,RAX-ARGOFFSET
+ CFI_REL_OFFSET rcx,RCX-ARGOFFSET
+ CFI_REL_OFFSET rdx,RDX-ARGOFFSET
+ CFI_REL_OFFSET rsi,RSI-ARGOFFSET
+ CFI_REL_OFFSET rdi,RDI-ARGOFFSET
+ CFI_REL_OFFSET rip,RIP-ARGOFFSET
+/* CFI_REL_OFFSET cs,CS-ARGOFFSET*/
+/* CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
+ CFI_REL_OFFSET rsp,RSP-ARGOFFSET
+/* CFI_REL_OFFSET ss,SS-ARGOFFSET*/
+ SAVE_REST 1
+ CLEAR_RREGS bx
call *%rax
- RESTORE_REST
+ RESTORE_REST 1
jmp ia32_sysret /* misbalances the return cache */
CFI_ENDPROC
--- 2.6.14/include/asm-x86_64/calling.h 2005-10-28 02:02:08.000000000 +0200
+++ 2.6.14-x86_64-ia32entry/include/asm-x86_64/calling.h 2005-11-09 13:33:26.000000000 +0100
@@ -31,7 +31,7 @@
#define ARGOFFSET R11
#define SWFRAME ORIG_RAX
- .macro SAVE_ARGS addskip=0,norcx=0,nor891011=0
+ .macro SAVE_ARGS addskip=0,norcx=0,compat=0
subq $9*8+\addskip,%rsp
CFI_ADJUST_CFA_OFFSET 9*8+\addskip
movq %rdi,8*8(%rsp)
@@ -47,7 +47,7 @@
.endif
movq %rax,4*8(%rsp)
CFI_REL_OFFSET rax,4*8
- .if \nor891011
+ .if \compat
.else
movq %r8,3*8(%rsp)
CFI_REL_OFFSET r8,3*8
@@ -61,14 +61,11 @@
.endm
#define ARG_SKIP 9*8
- .macro RESTORE_ARGS skiprax=0,addskip=0,skiprcx=0,skipr11=0,skipr8910=0,skiprdx=0
- .if \skipr11
+ .macro RESTORE_ARGS skiprax=0,addskip=0,skiprcx=0,compat=0,skiprdx=0
+ .if \compat
.else
movq (%rsp),%r11
CFI_RESTORE r11
- .endif
- .if \skipr8910
- .else
movq 1*8(%rsp),%r10
CFI_RESTORE r10
movq 2*8(%rsp),%r9
@@ -78,22 +75,42 @@
.endif
.if \skiprax
.else
+ .if \compat
+ movl 4*8(%rsp),%eax
+ .else
movq 4*8(%rsp),%rax
+ .endif
CFI_RESTORE rax
.endif
.if \skiprcx
.else
+ .if \compat
+ movl 5*8(%rsp),%ecx
+ .else
movq 5*8(%rsp),%rcx
+ .endif
CFI_RESTORE rcx
.endif
.if \skiprdx
.else
+ .if \compat
+ movl 6*8(%rsp),%edx
+ .else
movq 6*8(%rsp),%rdx
+ .endif
CFI_RESTORE rdx
.endif
+ .if \compat
+ movl 7*8(%rsp),%esi
+ .else
movq 7*8(%rsp),%rsi
+ .endif
CFI_RESTORE rsi
+ .if \compat
+ movl 8*8(%rsp),%edi
+ .else
movq 8*8(%rsp),%rdi
+ .endif
CFI_RESTORE rdi
.if ARG_SKIP+\addskip > 0
addq $ARG_SKIP+\addskip,%rsp
@@ -101,26 +118,42 @@
.endif
.endm
- .macro LOAD_ARGS offset
+ .macro LOAD_ARGS offset,skiprcx=0,compat=0
+ .if \compat
+ .if \skiprcx
+ .else
+ movl \offset+40(%rsp),%ecx
+ .endif
+ movl \offset+48(%rsp),%edx
+ movl \offset+56(%rsp),%esi
+ movl \offset+64(%rsp),%edi
+ movl \offset+72(%rsp),%eax
+ .else
movq \offset(%rsp),%r11
movq \offset+8(%rsp),%r10
movq \offset+16(%rsp),%r9
movq \offset+24(%rsp),%r8
+ .if \skiprcx
+ .else
movq \offset+40(%rsp),%rcx
+ .endif
movq \offset+48(%rsp),%rdx
movq \offset+56(%rsp),%rsi
movq \offset+64(%rsp),%rdi
movq \offset+72(%rsp),%rax
+ .endif
.endm
#define REST_SKIP 6*8
- .macro SAVE_REST
+ .macro SAVE_REST compat=0
subq $REST_SKIP,%rsp
CFI_ADJUST_CFA_OFFSET REST_SKIP
movq %rbx,5*8(%rsp)
CFI_REL_OFFSET rbx,5*8
movq %rbp,4*8(%rsp)
CFI_REL_OFFSET rbp,4*8
+ .if \compat
+ .else
movq %r12,3*8(%rsp)
CFI_REL_OFFSET r12,3*8
movq %r13,2*8(%rsp)
@@ -129,9 +162,16 @@
CFI_REL_OFFSET r14,1*8
movq %r15,(%rsp)
CFI_REL_OFFSET r15,0*8
+ .endif
.endm
- .macro RESTORE_REST
+ .macro RESTORE_REST compat=0
+ .if \compat
+ movl 4*8(%rsp),%ebp
+ CFI_RESTORE rbp
+ movl 5*8(%rsp),%ebx
+ CFI_RESTORE rbx
+ .else
movq (%rsp),%r15
CFI_RESTORE r15
movq 1*8(%rsp),%r14
@@ -144,6 +184,7 @@
CFI_RESTORE rbp
movq 5*8(%rsp),%rbx
CFI_RESTORE rbx
+ .endif
addq $REST_SKIP,%rsp
CFI_ADJUST_CFA_OFFSET -(REST_SKIP)
.endm
--- 2.6.14/include/asm-x86_64/dwarf2.h 2005-10-28 02:02:08.000000000 +0200
+++ 2.6.14-x86_64-ia32entry/include/asm-x86_64/dwarf2.h 2005-11-09 12:49:51.000000000 +0100
@@ -28,6 +28,7 @@
#define CFI_RESTORE .cfi_restore
#define CFI_REMEMBER_STATE .cfi_remember_state
#define CFI_RESTORE_STATE .cfi_restore_state
+#define CFI_UNDEFINED .cfi_undefined
#else
@@ -44,6 +45,7 @@
#define CFI_RESTORE #
#define CFI_REMEMBER_STATE #
#define CFI_RESTORE_STATE #
+#define CFI_UNDEFINED #
#endif
next prev parent reply other threads:[~2005-11-09 16:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-08 13:02 [PATCH] x86-64: separate unwind info generation from CONFIG_DEBUG_INFO Jan Beulich
2005-11-08 14:21 ` [PATCH] x86-64: fix bound check IDT gate Jan Beulich
2005-11-08 14:22 ` [PATCH] x86-64: remove dead die_if_kernel() Jan Beulich
2005-11-08 14:23 ` [PATCH] x86-64: make trap information available to die notification handlers Jan Beulich
2005-11-08 14:23 ` [PATCH] x86-64: adjust double fault handling Jan Beulich
2005-11-08 14:24 ` [PATCH] x86-64: remove unprotected iret Jan Beulich
2005-11-10 3:38 ` [discuss] " Andi Kleen
2005-11-08 14:25 ` [PATCH] x86-64: adjust page fault handling Jan Beulich
2005-11-09 16:10 ` Jan Beulich [this message]
2005-11-11 15:34 ` [PATCH] x86-64: adjust ia32entry.S Andi Kleen
2005-11-11 15:50 ` Jan Beulich
2005-11-11 15:53 ` [discuss] " Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43722D73.76F0.0078.0@novell.com \
--to=jbeulich@novell.com \
--cc=ak@suse.de \
--cc=discuss@x86-64.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox