Skip to contentSkip to conversation

exec.c: fix setting 1-byte-long watchpoints

PATCH Applied Max Filippov 2 participants 3 messages Sep 18, 2014 – Sep 19, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exec.c: fix setting 1-byte-long watchpoints

With commit 05068c0dfb5b 'exec.c: Relax restrictions on watchpoint length and alignment' it's no longer possible to set 1-byte-long watchpoint because of incorrect address range check.
Fix that by changing condition that checks for address wraparound.

---
 exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
exec.c +1 -1
index 2b24651..759055d 100644
@@ -595,7 +595,7 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
     CPUWatchpoint *wp;
 
     /* forbid ranges which are empty or run off the end of the address space */
-    if (len == 0 || (addr + len - 1) <= addr) {
+    if (len == 0 || (addr + len - 1) < addr) {
         error_report("tried to set invalid watchpoint at %"
                      VADDR_PRIx ", len=%" VADDR_PRIu, addr, len);
         return -EINVAL;
Signature · 1 line
1.8.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Max Filippov

With commit 05068c0dfb5b 'exec.c: Relax restrictions on watchpoint length and alignment' it's no longer possible to set 1-byte-long watchpoint because of incorrect address range check.
Fix that by changing condition that checks for address wraparound.

---
 exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
exec.c +0 -0
index 2b24651..759055d 100644

exec.c int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, · line 601

Quoted 8 lines
exec.c +1 -1
@@ -595,7 +595,7 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
     CPUWatchpoint *wp;
 
     /* forbid ranges which are empty or run off the end of the address space */
-    if (len == 0 || (addr + len - 1) <= addr) {
+    if (len == 0 || (addr + len - 1) < addr) {
         error_report("tried to set invalid watchpoint at %"
                      VADDR_PRIx ", len=%" VADDR_PRIu, addr, len);
         return -EINVAL;

and sorry for the breakage; I'll apply this to master in a bit.

thanks
-- PMM

#2 lore raw
Quoted 27 lines · Peter Maydell
Quoted 15 lines · Max Filippov

With commit 05068c0dfb5b 'exec.c: Relax restrictions on watchpoint length and alignment' it's no longer possible to set 1-byte-long watchpoint because of incorrect address range check.
Fix that by changing condition that checks for address wraparound.

---
 exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
exec.c +0 -0
index 2b24651..759055d 100644

exec.c int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, · line 601

Quoted 8 lines
exec.c +1 -1
@@ -595,7 +595,7 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
     CPUWatchpoint *wp;
 
     /* forbid ranges which are empty or run off the end of the address space */
-    if (len == 0 || (addr + len - 1) <= addr) {
+    if (len == 0 || (addr + len - 1) < addr) {
         error_report("tried to set invalid watchpoint at %"
                      VADDR_PRIx ", len=%" VADDR_PRIu, addr, len);
         return -EINVAL;
Quoted 1 line

and sorry for the breakage; I'll apply this to master in a bit.

Applied to master; thanks.

-- PMM