From patchwork Wed Oct 9 11:28:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 281855 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 441022C00A3 for ; Wed, 9 Oct 2013 23:04:02 +1100 (EST) Received: from localhost ([::1]:41282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTs2E-0004TY-Mm for incoming@patchwork.ozlabs.org; Wed, 09 Oct 2013 07:34:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTrx9-0005AF-BF for qemu-devel@nongnu.org; Wed, 09 Oct 2013 07:29:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTrx3-0001EJ-DT for qemu-devel@nongnu.org; Wed, 09 Oct 2013 07:29:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTrx3-0001EE-5g for qemu-devel@nongnu.org; Wed, 09 Oct 2013 07:29:13 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r99BTBR3007108 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 9 Oct 2013 07:29:11 -0400 Received: from trasno.mitica (ovpn-113-116.phx2.redhat.com [10.3.113.116]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r99BSoPb015327; Wed, 9 Oct 2013 07:29:10 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 9 Oct 2013 13:28:37 +0200 Message-Id: <1381318130-10620-16-git-send-email-quintela@redhat.com> In-Reply-To: <1381318130-10620-1-git-send-email-quintela@redhat.com> References: <1381318130-10620-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: chegu_vinod@hp.com Subject: [Qemu-devel] [PATCH 15/28] memory: make sure that client is always inside range 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 Signed-off-by: Juan Quintela --- include/exec/memory-internal.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h index 3947caa..e08ac42 100644 --- a/include/exec/memory-internal.h +++ b/include/exec/memory-internal.h @@ -43,6 +43,7 @@ void qemu_ram_free_from_ptr(ram_addr_t addr); static inline bool cpu_physical_memory_get_dirty_flag(ram_addr_t addr, unsigned client) { + assert(client < DIRTY_MEMORY_NUM); return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] & (1 << client); } @@ -73,6 +74,7 @@ static inline int cpu_physical_memory_get_dirty(ram_addr_t start, static inline void cpu_physical_memory_set_dirty_flag(ram_addr_t addr, unsigned client) { + assert(client < DIRTY_MEMORY_NUM); ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= (1 << client); } @@ -88,6 +90,8 @@ static inline int cpu_physical_memory_clear_dirty_flag(ram_addr_t addr, { int mask = ~(1 << client); + assert(client < DIRTY_MEMORY_NUM); + return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] &= mask; }