cpu-exec(): also reload CPUClass *cc after longjmp return
PATCH 1/1 cpu-exec(): also reload CPUClass *cc after longjmp return
Local variable CPUClass *cc needs to be reloaded after return from longjmp too. (This fixes the mips-softmmu crash observed on FreeBSD when qemu is built with clang.)
cpu-exec.c +4 -0
@@ -681,6 +681,10 @@ int cpu_exec(CPUArchState *env)* local variables as longjmp is marked 'noreturn'. */ cpu = current_cpu; env = cpu->env_ptr; +#if !(defined(CONFIG_USER_ONLY ) && \ + (defined(TARGET_M68K ) || defined(TARGET_PPC ) || defined(TARGET_S390X ))) + cc =CPU_GET_CLASS (cpu); +#endif } }/* for(;;) */
Quoted 10 lines · Juergen Lock
Local variable CPUClass *cc needs to be reloaded after return from longjmp too. (This fixes the mips-softmmu crash observed on FreeBSD when qemu is built with clang.)
Signed-off-by Juergen Lock <[email protected]>Found-by Dimitry Andric <[email protected]>
cpu-exec.c int cpu_exec(CPUArchState *env) · line 687
Quoted 7 lines
cpu-exec.c +4
-0@@ -681,6 +681,10 @@ int cpu_exec(CPUArchState *env)* local variables as longjmp is marked 'noreturn'. */ cpu = current_cpu; env = cpu->env_ptr; +#if !(defined(CONFIG_USER_ONLY ) && \ + (defined(TARGET_M68K ) || defined(TARGET_PPC ) || defined(TARGET_S390X ))) + cc =CPU_GET_CLASS (cpu); +#endif
This is a c compiler or libc bug -- the C standard says that this local variable should not be trashed by the longjmp. We were actually discussing removing the current workarounds there...
-- PMM
Quoted 8 lines · Peter Maydell
Quoted 7 lines · Juergen Lock
Local variable CPUClass *cc needs to be reloaded after return from longjmp too. (This fixes the mips-softmmu crash observed on FreeBSD when qemu is built with clang.)
Signed-off-by Juergen Lock <[email protected]>Found-by Dimitry Andric <[email protected]>
Quoted 14 lines
cpu-exec.c int cpu_exec(CPUArchState *env) · line 687
Quoted 10 lines
cpu-exec.c +4
-0@@ -681,6 +681,10 @@ int cpu_exec(CPUArchState *env)* local variables as longjmp is marked 'noreturn'. */ cpu = current_cpu; env = cpu->env_ptr; +#if !(defined(CONFIG_USER_ONLY ) && \ + (defined(TARGET_M68K ) || defined(TARGET_PPC ) || defined(TARGET_S390X ))) + cc =CPU_GET_CLASS (cpu); +#endif This is a c compiler or libc bug -- the C standard says that this local variable should not be trashed by the longjmp. We were actually discussing removing the current workarounds there...
But we didn't decide if we should stop supporting the affected compiler versions.
Does this issue also exist with the latest clang version available for your platform?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux
Quoted 24 lines · Jan Kiszka
Quoted 8 lines · Peter Maydell
Quoted 7 lines · Juergen Lock
Local variable CPUClass *cc needs to be reloaded after return from longjmp too. (This fixes the mips-softmmu crash observed on FreeBSD when qemu is built with clang.)
Signed-off-by Juergen Lock <[email protected]>Found-by Dimitry Andric <[email protected]>Quoted 14 lines
cpu-exec.c int cpu_exec(CPUArchState *env) · line 687
Quoted 10 lines
cpu-exec.c +4
-0@@ -681,6 +681,10 @@ int cpu_exec(CPUArchState *env)* local variables as longjmp is marked 'noreturn'. */ cpu = current_cpu; env = cpu->env_ptr; +#if !(defined(CONFIG_USER_ONLY ) && \ + (defined(TARGET_M68K ) || defined(TARGET_PPC ) || defined(TARGET_S390X ))) + cc =CPU_GET_CLASS (cpu); +#endif This is a c compiler or libc bug -- the C standard says that this local variable should not be trashed by the longjmp. We were actually discussing removing the current workarounds there...
Quoted 6 lines
But we didn't decide if we should stop supporting the affected compiler versions.
Does this issue also exist with the latest clang version available for your platform?
It happens with up to date clang as it's in FreeBSD 10.0-current which is due for a release soon. I think the clang folks are looking into this issue but I don't know if a fix will make it into the release... (For now I've added the workaround to the FreeBSD qemu-devel port.)
Thanx,
Juergen
Am 05.10.2013 19:54, schrieb Juergen Lock:
Quoted 29 lines · Jan Kiszka
Quoted 22 lines · Peter Maydell
Quoted 8 lines · Juergen Lock
Quoted 7 lines
Local variable CPUClass *cc needs to be reloaded after return from longjmp too. (This fixes the mips-softmmu crash observed on FreeBSD when qemu is built with clang.)
Signed-off-by Juergen Lock <[email protected]>Found-by Dimitry Andric <[email protected]>Quoted 13 lines
cpu-exec.c int cpu_exec(CPUArchState *env) · line 687
Quoted 10 lines
cpu-exec.c +4
-0@@ -681,6 +681,10 @@ int cpu_exec(CPUArchState *env)* local variables as longjmp is marked 'noreturn'. */ cpu = current_cpu; env = cpu->env_ptr; +#if !(defined(CONFIG_USER_ONLY ) && \ + (defined(TARGET_M68K ) || defined(TARGET_PPC ) || defined(TARGET_S390X ))) + cc =CPU_GET_CLASS (cpu); +#endif This is a c compiler or libc bug -- the C standard says that this local variable should not be trashed by the longjmp. We were actually discussing removing the current workarounds there...
Quoted 6 lines
But we didn't decide if we should stop supporting the affected compiler versions.
Does this issue also exist with the latest clang version available for your platform?
Quoted 8 lines
It happens with up to date clang as it's in FreeBSD 10.0-current which is due for a release soon. I think the clang folks are looking into this issue but I don't know if a fix will make it into the release... (For now I've added the workaround to the FreeBSD qemu-devel port.)
Thanx,
Juergen
Could you try whether QEMU crashes when it was configured with TCG interpreter (--enable-tcg-interpreter)? If it does not crash, it might be that TCG does not save / restore enough registers.
Which register is used for the local variable 'cc'?
Regards,
Stefan
Quoted 36 lines · Stefan Weil
Am 05.10.2013 19:54, schrieb Juergen Lock:
Quoted 35 lines · Jan Kiszka
Quoted 22 lines · Peter Maydell
Quoted 8 lines · Juergen Lock
Quoted 7 lines
Local variable CPUClass *cc needs to be reloaded after return from longjmp too. (This fixes the mips-softmmu crash observed on FreeBSD when qemu is built with clang.)
Signed-off-by Juergen Lock <[email protected]>Found-by Dimitry Andric <[email protected]>Quoted 13 lines
cpu-exec.c int cpu_exec(CPUArchState *env) · line 687
Quoted 10 lines
cpu-exec.c +4
-0@@ -681,6 +681,10 @@ int cpu_exec(CPUArchState *env)* local variables as longjmp is marked 'noreturn'. */ cpu = current_cpu; env = cpu->env_ptr; +#if !(defined(CONFIG_USER_ONLY ) && \ + (defined(TARGET_M68K ) || defined(TARGET_PPC ) || defined(TARGET_S390X ))) + cc =CPU_GET_CLASS (cpu); +#endif This is a c compiler or libc bug -- the C standard says that this local variable should not be trashed by the longjmp. We were actually discussing removing the current workarounds there...
Quoted 6 lines
But we didn't decide if we should stop supporting the affected compiler versions.
Does this issue also exist with the latest clang version available for your platform?
It happens with up to date clang as it's in FreeBSD 10.0-current which is due for a release soon. I think the clang folks are looking into this issue but I don't know if a fix will make it into the release... (For now I've added the workaround to the FreeBSD qemu-devel port.)
Quoted 8 lines
Quoted 2 lines
Thanx,
JuergenCould you try whether QEMU crashes when it was configured with TCG interpreter (--enable-tcg-interpreter)? If it does not crash, it might be that TCG does not save / restore enough registers.
Still crashes the same.
Quoted 2 lines
Which register is used for the local variable 'cc'?
Here is the original debug log with part of the disassembly:
http://people.freebsd.org/~nox/tmp/qemu-1.6.0-mips-softmmu-crash.txt
(I wrote the comment at the top before I knew cc needs to be reloaded...)
So apparently cc gets loaded from the stack before the crash: -0x40(%rbp)
Thanx,
Juergen
Am 05.10.2013 23:45, schrieb Juergen Lock:
Quoted 41 lines · Stefan Weil
Quoted 40 lines
Am 05.10.2013 19:54, schrieb Juergen Lock:
Quoted 37 lines · Jan Kiszka
Quoted 22 lines · Peter Maydell
Quoted 8 lines · Juergen Lock
Quoted 7 lines
Local variable CPUClass *cc needs to be reloaded after return from longjmp too. (This fixes the mips-softmmu crash observed on FreeBSD when qemu is built with clang.)
Signed-off-by Juergen Lock <[email protected]>Found-by Dimitry Andric <[email protected]>Quoted 13 lines
cpu-exec.c int cpu_exec(CPUArchState *env) · line 687
Quoted 10 lines
cpu-exec.c +4
-0@@ -681,6 +681,10 @@ int cpu_exec(CPUArchState *env)* local variables as longjmp is marked 'noreturn'. */ cpu = current_cpu; env = cpu->env_ptr; +#if !(defined(CONFIG_USER_ONLY ) && \ + (defined(TARGET_M68K ) || defined(TARGET_PPC ) || defined(TARGET_S390X ))) + cc =CPU_GET_CLASS (cpu); +#endif This is a c compiler or libc bug -- the C standard says that this local variable should not be trashed by the longjmp. We were actually discussing removing the current workarounds there...
Quoted 6 lines
But we didn't decide if we should stop supporting the affected compiler versions.
Does this issue also exist with the latest clang version available for your platform?
It happens with up to date clang as it's in FreeBSD 10.0-current which is due for a release soon. I think the clang folks are looking into this issue but I don't know if a fix will make it into the release... (For now I've added the workaround to the FreeBSD qemu-devel port.)
Thanx,
Juergen
Quoted 5 lines
Quoted 4 lines
Could you try whether QEMU crashes when it was configured with TCG interpreter (--enable-tcg-interpreter)? If it does not crash, it might be that TCG does not save / restore enough registers.
Still crashes the same.
Practical bugfix beats theoretical optimization, so I'm queuing the patch (w/ message tweaked) until someone comes up with a better one:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu
Thanks,
Andreas
Quoted 14 lines
Quoted 3 lines
Which register is used for the local variable 'cc'?
Here is the original debug log with part of the disassembly:
http://people.freebsd.org/~nox/tmp/qemu-1.6.0-mips-softmmu-crash.txt(I wrote the comment at the top before I knew cc needs to be reloaded...)
So apparently cc gets loaded from the stack before the crash: -0x40(%rbp)
Thanx,
Juergen
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg