[FOR,0.12] target-i386: Fix evaluation of DR7 register

Submitted by Jan Kiszka on Dec. 14, 2009, 11:26 a.m.

Details

Message ID 4B2620E3.2050604@siemens.com
State New
Headers show

Commit Message

Jan Kiszka Dec. 14, 2009, 11:26 a.m.
hw_breakpoint_type and hw_breakpoint_len used the wrong index multiplier
to extract type and len.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

 target-i386/cpu.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

TeLeMan Dec. 15, 2009, 2:07 a.m.
raise_exception() in op_helper.c should not be used outside
op_helper.c because of tcg. This patch uses raise_exception2() instead
of raise_exception().
Jan Kiszka Dec. 15, 2009, 11:21 p.m.
TeLeMan wrote:
> raise_exception() in op_helper.c should not be used outside
> op_helper.c because of tcg. This patch uses raise_exception2() instead
> of raise_exception().

Please do not post new patches as reply to others if they are not
directly related. Please do not attach patches and do not use base64
encoding.

Now to the content: env already equals single_cpu_env, so there is no
need in writing it back. That's because break/watchpoints are triggered
synchronously over the context in which they may raise an exception as
result.

Jan
TeLeMan Dec. 16, 2009, 12:28 a.m.
> Now to the content: env already equals single_cpu_env, so there is no
> need in writing it back. That's because break/watchpoints are triggered
> synchronously over the context in which they may raise an exception as
> result.
env in op_help.c is asm(AREG0) not single_cpu_env.
Did you test your codes?
Jan Kiszka Dec. 16, 2009, 12:41 a.m.
TeLeMan wrote:
>> Now to the content: env already equals single_cpu_env, so there is no
>> need in writing it back. That's because break/watchpoints are triggered
>> synchronously over the context in which they may raise an exception as
>> result.
> env in op_help.c is asm(AREG0) not single_cpu_env.

Which makes no difference due to the synchronous characteristics. The
point where env and single_cpu_env diverges while a vcpu is running is
the beginning of a bug.

> Did you test your codes?

I'm using it, including SMP.

There is still a bug, but it's unrelated to the context. It's related to
watchpoints triggering in helper function instead of generated code.
Will fix that later.

Jan

Patch hide | download patch | download mbox

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 9ef1be4..e835f23 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -834,12 +834,12 @@  static inline int hw_breakpoint_enabled(unsigned long dr7, int index)
 
 static inline int hw_breakpoint_type(unsigned long dr7, int index)
 {
-    return (dr7 >> (DR7_TYPE_SHIFT + (index * 2))) & 3;
+    return (dr7 >> (DR7_TYPE_SHIFT + (index * 4))) & 3;
 }
 
 static inline int hw_breakpoint_len(unsigned long dr7, int index)
 {
-    int len = ((dr7 >> (DR7_LEN_SHIFT + (index * 2))) & 3);
+    int len = ((dr7 >> (DR7_LEN_SHIFT + (index * 4))) & 3);
     return (len == 2) ? 8 : len + 1;
 }