From patchwork Fri Jun 4 21:45:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cam Macdonell X-Patchwork-Id: 104343 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o54Lk9HW012849 for ; Fri, 4 Jun 2010 21:46:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754320Ab0FDVqF (ORCPT ); Fri, 4 Jun 2010 17:46:05 -0400 Received: from fleet.cs.ualberta.ca ([129.128.22.22]:52446 "EHLO fleet.cs.ualberta.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752129Ab0FDVqB (ORCPT ); Fri, 4 Jun 2010 17:46:01 -0400 Received: from localhost.localdomain (st-brides.cs.ualberta.ca [129.128.23.21]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-auth.cs.ualberta.ca (Postfix) with ESMTP id 62A7728040; Fri, 4 Jun 2010 15:46:00 -0600 (MDT) From: Cam Macdonell To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Cam Macdonell Subject: [PATCH v6 3/6] Change phys_ram_dirty to phys_ram_status Date: Fri, 4 Jun 2010 15:45:39 -0600 Message-Id: <1275687942-12312-4-git-send-email-cam@cs.ualberta.ca> X-Mailer: git-send-email 1.6.3.2.198.g6096d In-Reply-To: <1275687942-12312-3-git-send-email-cam@cs.ualberta.ca> References: <1275687942-12312-1-git-send-email-cam@cs.ualberta.ca> <1275687942-12312-2-git-send-email-cam@cs.ualberta.ca> <1275687942-12312-3-git-send-email-cam@cs.ualberta.ca> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 04 Jun 2010 21:46:10 +0000 (UTC) diff --git a/cpu-all.h b/cpu-all.h index 47a5722..9080cc7 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -858,7 +858,7 @@ 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 uint8_t *phys_ram_flags; extern ram_addr_t ram_size; extern ram_addr_t last_ram_offset; @@ -887,32 +887,34 @@ extern int mem_prealloc; #define CODE_DIRTY_FLAG 0x02 #define MIGRATION_DIRTY_FLAG 0x08 +#define DIRTY_ALL_FLAG (VGA_DIRTY_FLAG | CODE_DIRTY_FLAG | MIGRATION_DIRTY_FLAG) + /* read dirty bit (return 0 or 1) */ static inline int cpu_physical_memory_is_dirty(ram_addr_t addr) { - return phys_ram_dirty[addr >> TARGET_PAGE_BITS] == 0xff; + return phys_ram_flags[addr >> TARGET_PAGE_BITS] == DIRTY_ALL_FLAG; } static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr) { - return phys_ram_dirty[addr >> TARGET_PAGE_BITS]; + return phys_ram_flags[addr >> TARGET_PAGE_BITS]; } static inline int cpu_physical_memory_get_dirty(ram_addr_t addr, int dirty_flags) { - return phys_ram_dirty[addr >> TARGET_PAGE_BITS] & dirty_flags; + return phys_ram_flags[addr >> TARGET_PAGE_BITS] & dirty_flags; } static inline void cpu_physical_memory_set_dirty(ram_addr_t addr) { - phys_ram_dirty[addr >> TARGET_PAGE_BITS] = 0xff; + phys_ram_flags[addr >> TARGET_PAGE_BITS] = DIRTY_ALL_FLAG; } static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr, int dirty_flags) { - return phys_ram_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags; + return phys_ram_flags[addr >> TARGET_PAGE_BITS] |= dirty_flags; } static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start, @@ -924,7 +926,7 @@ static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start, len = length >> TARGET_PAGE_BITS; mask = ~dirty_flags; - p = phys_ram_dirty + (start >> TARGET_PAGE_BITS); + p = phys_ram_flags + (start >> TARGET_PAGE_BITS); for (i = 0; i < len; i++) { p[i] &= mask; } diff --git a/exec.c b/exec.c index 7b0e1c5..39c18a7 100644 --- a/exec.c +++ b/exec.c @@ -116,7 +116,7 @@ uint8_t *code_gen_ptr; #if !defined(CONFIG_USER_ONLY) int phys_ram_fd; -uint8_t *phys_ram_dirty; +uint8_t *phys_ram_flags; static int in_migration; typedef struct RAMBlock { @@ -2801,10 +2801,10 @@ ram_addr_t qemu_ram_map(ram_addr_t size, void *host) new_block->next = ram_blocks; ram_blocks = new_block; - phys_ram_dirty = qemu_realloc(phys_ram_dirty, + phys_ram_flags = qemu_realloc(phys_ram_flags, (last_ram_offset + size) >> TARGET_PAGE_BITS); - memset(phys_ram_dirty + (last_ram_offset >> TARGET_PAGE_BITS), - 0xff, size >> TARGET_PAGE_BITS); + memset(phys_ram_flags + (last_ram_offset >> TARGET_PAGE_BITS), + DIRTY_ALL_FLAG, size >> TARGET_PAGE_BITS); last_ram_offset += size; @@ -2853,10 +2853,10 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size) new_block->next = ram_blocks; ram_blocks = new_block; - phys_ram_dirty = qemu_realloc(phys_ram_dirty, + phys_ram_flags = qemu_realloc(phys_ram_flags, (last_ram_offset + size) >> TARGET_PAGE_BITS); - memset(phys_ram_dirty + (last_ram_offset >> TARGET_PAGE_BITS), - 0xff, size >> TARGET_PAGE_BITS); + memset(phys_ram_flags + (last_ram_offset >> TARGET_PAGE_BITS), + DIRTY_ALL_FLAG, size >> TARGET_PAGE_BITS); last_ram_offset += size; @@ -3024,11 +3024,11 @@ static void notdirty_mem_writeb(void *opaque, target_phys_addr_t ram_addr, #endif } stb_p(qemu_get_ram_ptr(ram_addr), val); - dirty_flags |= (0xff & ~CODE_DIRTY_FLAG); + dirty_flags |= (DIRTY_ALL_FLAG & ~CODE_DIRTY_FLAG); cpu_physical_memory_set_dirty_flags(ram_addr, dirty_flags); /* we remove the notdirty callback only if the code has been flushed */ - if (dirty_flags == 0xff) + if (dirty_flags == DIRTY_ALL_FLAG) tlb_set_dirty(cpu_single_env, cpu_single_env->mem_io_vaddr); } @@ -3044,11 +3044,11 @@ static void notdirty_mem_writew(void *opaque, target_phys_addr_t ram_addr, #endif } stw_p(qemu_get_ram_ptr(ram_addr), val); - dirty_flags |= (0xff & ~CODE_DIRTY_FLAG); + dirty_flags |= (DIRTY_ALL_FLAG & ~CODE_DIRTY_FLAG); cpu_physical_memory_set_dirty_flags(ram_addr, dirty_flags); /* we remove the notdirty callback only if the code has been flushed */ - if (dirty_flags == 0xff) + if (dirty_flags == DIRTY_ALL_FLAG) tlb_set_dirty(cpu_single_env, cpu_single_env->mem_io_vaddr); } @@ -3064,11 +3064,11 @@ static void notdirty_mem_writel(void *opaque, target_phys_addr_t ram_addr, #endif } stl_p(qemu_get_ram_ptr(ram_addr), val); - dirty_flags |= (0xff & ~CODE_DIRTY_FLAG); + dirty_flags |= (DIRTY_ALL_FLAG & ~CODE_DIRTY_FLAG); cpu_physical_memory_set_dirty_flags(ram_addr, dirty_flags); /* we remove the notdirty callback only if the code has been flushed */ - if (dirty_flags == 0xff) + if (dirty_flags == DIRTY_ALL_FLAG) tlb_set_dirty(cpu_single_env, cpu_single_env->mem_io_vaddr); } @@ -3485,7 +3485,7 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, tb_invalidate_phys_page_range(addr1, addr1 + l, 0); /* set dirty bit */ cpu_physical_memory_set_dirty_flags( - addr1, (0xff & ~CODE_DIRTY_FLAG)); + addr1, (DIRTY_ALL_FLAG & ~CODE_DIRTY_FLAG)); } /* qemu doesn't execute guest code directly, but kvm does therefore flush instruction caches */ @@ -3699,7 +3699,7 @@ void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len, tb_invalidate_phys_page_range(addr1, addr1 + l, 0); /* set dirty bit */ cpu_physical_memory_set_dirty_flags( - addr1, (0xff & ~CODE_DIRTY_FLAG)); + addr1, (DIRTY_ALL_FLAG & ~CODE_DIRTY_FLAG)); } addr1 += l; access_len -= l; @@ -3860,7 +3860,7 @@ void stl_phys_notdirty(target_phys_addr_t addr, uint32_t val) tb_invalidate_phys_page_range(addr1, addr1 + 4, 0); /* set dirty bit */ cpu_physical_memory_set_dirty_flags( - addr1, (0xff & ~CODE_DIRTY_FLAG)); + addr1, (DIRTY_ALL_FLAG & ~CODE_DIRTY_FLAG)); } } } @@ -3929,7 +3929,7 @@ void stl_phys(target_phys_addr_t addr, uint32_t val) tb_invalidate_phys_page_range(addr1, addr1 + 4, 0); /* set dirty bit */ cpu_physical_memory_set_dirty_flags(addr1, - (0xff & ~CODE_DIRTY_FLAG)); + (DIRTY_ALL_FLAG & ~CODE_DIRTY_FLAG)); } } } @@ -3972,7 +3972,7 @@ void stw_phys(target_phys_addr_t addr, uint32_t val) tb_invalidate_phys_page_range(addr1, addr1 + 2, 0); /* set dirty bit */ cpu_physical_memory_set_dirty_flags(addr1, - (0xff & ~CODE_DIRTY_FLAG)); + (DIRTY_ALL_FLAG & ~CODE_DIRTY_FLAG)); } } }