diff mbox

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

Message ID 1411016616-29879-1-git-send-email-jcmvbkbc@gmail.com
State New
Headers show

Commit Message

Max Filippov Sept. 18, 2014, 5:03 a.m. UTC
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.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Peter Maydell Sept. 18, 2014, 6:33 p.m. UTC | #1
On 17 September 2014 22:03, Max Filippov <jcmvbkbc@gmail.com> wrote:
> 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.
>
> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
> ---
>  exec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/exec.c b/exec.c
> index 2b24651..759055d 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -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;

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

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

thanks
-- PMM
Peter Maydell Sept. 19, 2014, 5:24 p.m. UTC | #2
On 18 September 2014 11:33, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 17 September 2014 22:03, Max Filippov <jcmvbkbc@gmail.com> wrote:
>> 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.
>>
>> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
>> ---
>>  exec.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/exec.c b/exec.c
>> index 2b24651..759055d 100644
>> --- a/exec.c
>> +++ b/exec.c
>> @@ -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;
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> and sorry for the breakage; I'll apply this to master in a bit.

Applied to master; thanks.

-- PMM
diff mbox

Patch

diff --git a/exec.c b/exec.c
index 2b24651..759055d 100644
--- a/exec.c
+++ b/exec.c
@@ -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;