1 /* 2 * Declarations for cpu physical memory functions 3 * 4 * Copyright 2011 Red Hat, Inc. and/or its affiliates 5 * 6 * Authors: 7 * Avi Kivity <avi@redhat.com> 8 * 9 * This work is licensed under the terms of the GNU GPL, version 2 or 10 * later. See the COPYING file in the top-level directory. 11 * 12 */ 13 14 /* 15 * This header is for use by exec.c and memory.c ONLY. Do not include it. 16 * The functions declared here will be removed soon. 17 */ 18 19 #ifndef QEMU_EXEC_RAMBLOCK_H 20 #define QEMU_EXEC_RAMBLOCK_H 21 22 #ifndef CONFIG_USER_ONLY 23 #include "cpu-common.h" 24 25 struct RAMBlock { 26 struct rcu_head rcu; 27 struct MemoryRegion *mr; 28 uint8_t *host; 29 uint8_t *colo_cache; /* For colo, VM's ram cache */ 30 ram_addr_t offset; 31 ram_addr_t used_length; 32 ram_addr_t max_length; 33 void (*resized)(const char*, uint64_t length, void *host); 34 uint32_t flags; 35 /* Protected by iothread lock. */ 36 char idstr[256]; 37 /* RCU-enabled, writes protected by the ramlist lock */ 38 QLIST_ENTRY(RAMBlock) next; 39 QLIST_HEAD(, RAMBlockNotifier) ramblock_notifiers; 40 int fd; 41 size_t page_size; 42 /* dirty bitmap used during migration */ 43 unsigned long *bmap; 44 /* bitmap of already received pages in postcopy */ 45 unsigned long *receivedmap; 46 47 /* 48 * bitmap to track already cleared dirty bitmap. When the bit is 49 * set, it means the corresponding memory chunk needs a log-clear. 50 * Set this up to non-NULL to enable the capability to postpone 51 * and split clearing of dirty bitmap on the remote node (e.g., 52 * KVM). The bitmap will be set only when doing global sync. 53 * 54 * NOTE: this bitmap is different comparing to the other bitmaps 55 * in that one bit can represent multiple guest pages (which is 56 * decided by the `clear_bmap_shift' variable below). On 57 * destination side, this should always be NULL, and the variable 58 * `clear_bmap_shift' is meaningless. 59 */ 60 unsigned long *clear_bmap; 61 uint8_t clear_bmap_shift; 62 63 /* 64 * RAM block length that corresponds to the used_length on the migration 65 * source (after RAM block sizes were synchronized). Especially, after 66 * starting to run the guest, used_length and postcopy_length can differ. 67 * Used to register/unregister uffd handlers and as the size of the received 68 * bitmap. Receiving any page beyond this length will bail out, as it 69 * could not have been valid on the source. 70 */ 71 ram_addr_t postcopy_length; 72 }; 73 #endif 74 #endif 75