From patchwork Sat Jan 28 18:13:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 138402 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E93941007D2 for ; Sun, 29 Jan 2012 05:14:16 +1100 (EST) Received: from localhost ([::1]:48624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrCmz-0001ty-SA for incoming@patchwork.ozlabs.org; Sat, 28 Jan 2012 13:14:13 -0500 Received: from eggs.gnu.org ([140.186.70.92]:51108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrCmt-0001tt-OJ for qemu-devel@nongnu.org; Sat, 28 Jan 2012 13:14:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RrCms-0006DE-A2 for qemu-devel@nongnu.org; Sat, 28 Jan 2012 13:14:07 -0500 Received: from mail-iy0-f173.google.com ([209.85.210.173]:44439) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrCmr-0006Bv-Uh for qemu-devel@nongnu.org; Sat, 28 Jan 2012 13:14:06 -0500 Received: by iahk25 with SMTP id k25so4376356iah.4 for ; Sat, 28 Jan 2012 10:14:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=XO9dZrEts4yYtAZXSbkNs6A/88RoXYKqBfGucgmL8VQ=; b=l3TTEg94eAUrQPzmmKeQU0YHFdQkcscEsWLF+kki0HAn9SoIkvw3XLHTBYU4mxq+F0 C2NeYdY+je44xRIKnrDgLHlkarGINCkeAr5FSZdsC/kR0LkqlC9VGMFBsTBf80XnOSsd bwCXPabdZ5Ir3jwnVDQWWaN55VwgWcAr2HPbQ= Received: by 10.50.77.234 with SMTP id v10mr11753368igw.29.1327774445283; Sat, 28 Jan 2012 10:14:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.15.167 with HTTP; Sat, 28 Jan 2012 10:13:45 -0800 (PST) From: Blue Swirl Date: Sat, 28 Jan 2012 18:13:45 +0000 Message-ID: To: Avi Kivity , Stefan Berger , qemu-devel X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.173 Subject: [Qemu-devel] [PATCH] exec-obsolete: fix length handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Fix suspend/resume broken by off-by-one error in 59abb06198ee9471e29c970f294eae80c0b39be1. Adjust the loop so that it handles correctly the case start = (ram_addr_t)-TARGET_PAGE_SIZE, length = TARGET_PAGE_SIZE. Reported-by: Stefan Berger Signed-off-by: Blue Swirl --- exec-obsolete.h | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) } @@ -96,12 +95,11 @@ static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start, { int mask; uint8_t *p; - ram_addr_t addr, end; + ram_addr_t cur; - end = start + length; mask = ~dirty_flags; p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS); - for (addr = start; addr <= end; addr += TARGET_PAGE_SIZE) { + for (cur = 0; cur < length; cur += TARGET_PAGE_SIZE) { *p++ &= mask; } } From fb378616b9aeab9032fa3c2341724529002fcea9 Mon Sep 17 00:00:00 2001 Message-Id: From: Blue Swirl Date: Sat, 28 Jan 2012 18:02:08 +0000 Subject: [PATCH] exec-obsolete: fix length handling Fix suspend/resume broken by off-by-one error in 59abb06198ee9471e29c970f294eae80c0b39be1. Adjust the loop so that it handles correctly the case start = (ram_addr_t)-TARGET_PAGE_SIZE, length = TARGET_PAGE_SIZE. Reported-by: Stefan Berger Signed-off-by: Blue Swirl --- exec-obsolete.h | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) diff --git a/exec-obsolete.h b/exec-obsolete.h index 03cf35e..1bba970 100644 --- a/exec-obsolete.h +++ b/exec-obsolete.h @@ -81,11 +81,10 @@ static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start, int dirty_flags) { uint8_t *p; - ram_addr_t addr, end; + ram_addr_t cur; - end = start + length; p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS); - for (addr = start; addr <= end; addr += TARGET_PAGE_SIZE) { + for (cur = 0; cur < length; cur += TARGET_PAGE_SIZE) { *p++ |= dirty_flags; } } @@ -96,12 +95,11 @@ static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start, { int mask; uint8_t *p; - ram_addr_t addr, end; + ram_addr_t cur; - end = start + length; mask = ~dirty_flags; p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS); - for (addr = start; addr <= end; addr += TARGET_PAGE_SIZE) { + for (cur = 0; cur < length; cur += TARGET_PAGE_SIZE) { *p++ &= mask; } } -- 1.7.2.5