public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug regression/40132] New: failure to assign asm constraints properly
@ 2009-05-13 16:52 rostedt at goodmis dot org
2009-05-13 17:17 ` [Bug regression/40132] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: rostedt at goodmis dot org @ 2009-05-13 16:52 UTC (permalink / raw)
To: gcc-bugs
# gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.4.0/configure --prefix=/usr/local/dist
--program-prefix=dist- --without-doc --enable-bootstrap
Thread model: posix
gcc version 4.4.0 (GCC)
I just compiled to gcc 4.4.0 (replacing my 4.2.2 version) and found that the
function_graph tracer in linux broke. Investigating it further, I found that
gcc did not properly assign the constraints used in arch/x86/kernel/ftrace.c
(Linux 2.6.30-rc5).
Maybe the constraints are not assigned properly, but it worked in all my
previous versions of gcc, and I do not see anything wrong with it.
Here's the code (prepare_ftrace_return):
unsigned long return_hooker = (unsigned long)
&return_to_handler;
[...]
/*
* Protect against fault, even if it shouldn't
* happen. This tool is too much intrusive to
* ignore such a protection.
*/
asm volatile(
"1: " _ASM_MOV " (%[parent]), %[old]\n"
"2: " _ASM_MOV " %[return_hooker], (%[parent])\n"
" movl $0, %[faulted]\n"
"3:\n"
".section .fixup, \"ax\"\n"
"4: movl $1, %[faulted]\n"
" jmp 3b\n"
".previous\n"
_ASM_EXTABLE(1b, 4b)
_ASM_EXTABLE(2b, 4b)
: [old] "=r" (old), [faulted] "=r" (faulted)
: [parent] "r" (parent), [return_hooker] "r" (return_hooker)
: "memory"
);
Here's what gcc 4.2.2 does (working):
ffffffff80228893: 48 c7 c0 3d be 20 80 mov $0xffffffff8020be3d,%rax
ffffffff8022889a: 4c 8b 27 mov (%rdi),%r12
ffffffff8022889d: 48 89 07 mov %rax,(%rdi)
ffffffff802288a0: b8 00 00 00 00 mov $0x0,%eax
ffffffff802288a5: 85 c0 test %eax,%eax
The return_hooker is put into %rax, old is %r12 and all is fine.
But gcc 4.4.0 decided to use %r12 for both the return_hooker and old!
ffffffff80229503: 49 c7 c4 7d bf 20 80 mov $0xffffffff8020bf7d,%r12
ffffffff8022950a: 4c 8b 27 mov (%rdi),%r12
ffffffff8022950d: 4c 89 27 mov %r12,(%rdi)
ffffffff80229510: b8 00 00 00 00 mov $0x0,%eax
ffffffff80229515: 85 c0 test %eax,%eax
Thus overwriting the return_hooker variable before it is used as an input!
Is there something wrong with the constraints, or is this indeed a bug in GCC?
--
Summary: failure to assign asm constraints properly
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: regression
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rostedt at goodmis dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40132
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug regression/40132] failure to assign asm constraints properly
2009-05-13 16:52 [Bug regression/40132] New: failure to assign asm constraints properly rostedt at goodmis dot org
@ 2009-05-13 17:17 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-05-13 17:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2009-05-13 17:17 -------
What GCC is doing is correct according to the source you gave it. The source
needs to be modified to mark old as being an early clobber.
Like:
asm volatile(
"1: " _ASM_MOV " (%[parent]), %[old]\n"
"2: " _ASM_MOV " %[return_hooker], (%[parent])\n"
" movl $0, %[faulted]\n"
"3:\n"
".section .fixup, \"ax\"\n"
"4: movl $1, %[faulted]\n"
" jmp 3b\n"
".previous\n"
_ASM_EXTABLE(1b, 4b)
_ASM_EXTABLE(2b, 4b)
: [old] "=&r" (old), [faulted] "=r" (faulted)
: [parent] "r" (parent), [return_hooker] "r" (return_hooker)
: "memory"
);
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|critical |normal
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40132
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-13 17:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-13 16:52 [Bug regression/40132] New: failure to assign asm constraints properly rostedt at goodmis dot org
2009-05-13 17:17 ` [Bug regression/40132] " pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).