From patchwork Mon Apr 19 09:43:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshiaki Tamura X-Patchwork-Id: 50437 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C0370B7CF8 for ; Mon, 19 Apr 2010 20:18:09 +1000 (EST) Received: from localhost ([127.0.0.1]:38024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O3nwg-0005iT-Tc for incoming@patchwork.ozlabs.org; Mon, 19 Apr 2010 06:11:14 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O3nau-0006zn-6Z for qemu-devel@nongnu.org; Mon, 19 Apr 2010 05:48:44 -0400 Received: from [140.186.70.92] (port=52019 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O3naj-0006uM-Qs for qemu-devel@nongnu.org; Mon, 19 Apr 2010 05:48:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O3nah-0007uW-5b for qemu-devel@nongnu.org; Mon, 19 Apr 2010 05:48:33 -0400 Received: from sh.osrg.net ([192.16.179.4]:33417) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O3nag-0007t0-MB for qemu-devel@nongnu.org; Mon, 19 Apr 2010 05:48:31 -0400 Received: from fs.osrg.net (postfix@fs.osrg.net [10.0.0.12]) by sh.osrg.net (8.14.3/8.14.3/OSRG-NET) with ESMTP id o3J9mKtX008804; Mon, 19 Apr 2010 18:48:21 +0900 Received: from localhost (hype-wd0.osrg.net [10.72.1.16]) by fs.osrg.net (Postfix) with ESMTP id 44A373E02EE; Mon, 19 Apr 2010 18:48:20 +0900 (JST) From: Yoshiaki Tamura To: qemu-devel@nongnu.org Date: Mon, 19 Apr 2010 18:43:13 +0900 Message-Id: <1271670198-12793-2-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> X-Mailer: git-send-email 1.7.0.31.g1df487 In-Reply-To: <1271670198-12793-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> References: <1271670198-12793-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> X-Dispatcher: imput version 20070423(IM149) Lines: 65 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (sh.osrg.net [192.16.179.4]); Mon, 19 Apr 2010 18:48:22 +0900 (JST) X-Virus-Scanned: clamav-milter 0.95.3 at sh X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: aliguori@us.ibm.com, ohmura.kei@lab.ntt.co.jp, mtosatti@redhat.com, Yoshiaki Tamura , avi@redhat.com Subject: [Qemu-devel] [PATCH v3 1/6] Modify DIRTY_FLAG value and DIRTY_IDX introduce to use as indexes of bit-based phys_ram_dirty. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org It uses ffs() to convert DIRTY_FLAG to DIRTY_IDX. Signed-off-by: Yoshiaki Tamura --- cpu-all.h | 30 ++++++++++++++++++++++++++---- 1 files changed, 26 insertions(+), 4 deletions(-) diff --git a/cpu-all.h b/cpu-all.h index f8bfa66..8c2d678 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -37,6 +37,9 @@ #include "softfloat.h" +/* to use ffs in flag_to_idx() */ +#include + #if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) #define BSWAP_NEEDED #endif @@ -853,7 +856,6 @@ target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr); /* memory API */ extern int phys_ram_fd; -extern uint8_t *phys_ram_dirty; extern ram_addr_t ram_size; extern ram_addr_t last_ram_offset; @@ -878,9 +880,29 @@ extern int mem_prealloc; /* Set if TLB entry is an IO callback. */ #define TLB_MMIO (1 << 5) -#define VGA_DIRTY_FLAG 0x01 -#define CODE_DIRTY_FLAG 0x02 -#define MIGRATION_DIRTY_FLAG 0x08 +/* Use DIRTY_IDX as indexes of bit-based phys_ram_dirty. */ +#define MASTER_DIRTY_IDX 0 +#define VGA_DIRTY_IDX 1 +#define CODE_DIRTY_IDX 2 +#define MIGRATION_DIRTY_IDX 3 +#define NUM_DIRTY_IDX 4 + +#define MASTER_DIRTY_FLAG (1 << MASTER_DIRTY_IDX) +#define VGA_DIRTY_FLAG (1 << VGA_DIRTY_IDX) +#define CODE_DIRTY_FLAG (1 << CODE_DIRTY_IDX) +#define MIGRATION_DIRTY_FLAG (1 << MIGRATION_DIRTY_IDX) + +extern unsigned long *phys_ram_dirty[NUM_DIRTY_IDX]; + +static inline int flag_to_idx(int flag) +{ + return ffs(flag) - 1; +} + +static inline int idx_to_flag(int idx) +{ + return 1 << idx; +} /* read dirty bit (return 0 or 1) */ static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)