xref: /openbmc/qemu/include/exec/ramblock.h (revision 4b870dc4)
141aa4e9fSJuan Quintela /*
241aa4e9fSJuan Quintela  * Declarations for cpu physical memory functions
341aa4e9fSJuan Quintela  *
441aa4e9fSJuan Quintela  * Copyright 2011 Red Hat, Inc. and/or its affiliates
541aa4e9fSJuan Quintela  *
641aa4e9fSJuan Quintela  * Authors:
741aa4e9fSJuan Quintela  *  Avi Kivity <avi@redhat.com>
841aa4e9fSJuan Quintela  *
941aa4e9fSJuan Quintela  * This work is licensed under the terms of the GNU GPL, version 2 or
1041aa4e9fSJuan Quintela  * later.  See the COPYING file in the top-level directory.
1141aa4e9fSJuan Quintela  *
1241aa4e9fSJuan Quintela  */
1341aa4e9fSJuan Quintela 
1441aa4e9fSJuan Quintela /*
1541aa4e9fSJuan Quintela  * This header is for use by exec.c and memory.c ONLY.  Do not include it.
1641aa4e9fSJuan Quintela  * The functions declared here will be removed soon.
1741aa4e9fSJuan Quintela  */
1841aa4e9fSJuan Quintela 
1941aa4e9fSJuan Quintela #ifndef QEMU_EXEC_RAMBLOCK_H
2041aa4e9fSJuan Quintela #define QEMU_EXEC_RAMBLOCK_H
2141aa4e9fSJuan Quintela 
2241aa4e9fSJuan Quintela #ifndef CONFIG_USER_ONLY
2341aa4e9fSJuan Quintela #include "cpu-common.h"
2440d7ca33SPhilippe Mathieu-Daudé #include "qemu/rcu.h"
2540d7ca33SPhilippe Mathieu-Daudé #include "exec/ramlist.h"
2641aa4e9fSJuan Quintela 
2741aa4e9fSJuan Quintela struct RAMBlock {
2841aa4e9fSJuan Quintela     struct rcu_head rcu;
2941aa4e9fSJuan Quintela     struct MemoryRegion *mr;
3041aa4e9fSJuan Quintela     uint8_t *host;
3141aa4e9fSJuan Quintela     uint8_t *colo_cache; /* For colo, VM's ram cache */
3241aa4e9fSJuan Quintela     ram_addr_t offset;
3341aa4e9fSJuan Quintela     ram_addr_t used_length;
3441aa4e9fSJuan Quintela     ram_addr_t max_length;
3541aa4e9fSJuan Quintela     void (*resized)(const char*, uint64_t length, void *host);
3641aa4e9fSJuan Quintela     uint32_t flags;
3741aa4e9fSJuan Quintela     /* Protected by iothread lock.  */
3841aa4e9fSJuan Quintela     char idstr[256];
3941aa4e9fSJuan Quintela     /* RCU-enabled, writes protected by the ramlist lock */
4041aa4e9fSJuan Quintela     QLIST_ENTRY(RAMBlock) next;
4141aa4e9fSJuan Quintela     QLIST_HEAD(, RAMBlockNotifier) ramblock_notifiers;
4241aa4e9fSJuan Quintela     int fd;
43*4b870dc4SAlexander Graf     uint64_t fd_offset;
4441aa4e9fSJuan Quintela     size_t page_size;
4541aa4e9fSJuan Quintela     /* dirty bitmap used during migration */
4641aa4e9fSJuan Quintela     unsigned long *bmap;
4741aa4e9fSJuan Quintela     /* bitmap of already received pages in postcopy */
4841aa4e9fSJuan Quintela     unsigned long *receivedmap;
4941aa4e9fSJuan Quintela 
5041aa4e9fSJuan Quintela     /*
5141aa4e9fSJuan Quintela      * bitmap to track already cleared dirty bitmap.  When the bit is
5241aa4e9fSJuan Quintela      * set, it means the corresponding memory chunk needs a log-clear.
5341aa4e9fSJuan Quintela      * Set this up to non-NULL to enable the capability to postpone
5441aa4e9fSJuan Quintela      * and split clearing of dirty bitmap on the remote node (e.g.,
5541aa4e9fSJuan Quintela      * KVM).  The bitmap will be set only when doing global sync.
5641aa4e9fSJuan Quintela      *
57cedb70eaSPeter Xu      * It is only used during src side of ram migration, and it is
58cedb70eaSPeter Xu      * protected by the global ram_state.bitmap_mutex.
59cedb70eaSPeter Xu      *
6041aa4e9fSJuan Quintela      * NOTE: this bitmap is different comparing to the other bitmaps
6141aa4e9fSJuan Quintela      * in that one bit can represent multiple guest pages (which is
6241aa4e9fSJuan Quintela      * decided by the `clear_bmap_shift' variable below).  On
6341aa4e9fSJuan Quintela      * destination side, this should always be NULL, and the variable
6441aa4e9fSJuan Quintela      * `clear_bmap_shift' is meaningless.
6541aa4e9fSJuan Quintela      */
6641aa4e9fSJuan Quintela     unsigned long *clear_bmap;
6741aa4e9fSJuan Quintela     uint8_t clear_bmap_shift;
68898ba906SDavid Hildenbrand 
69898ba906SDavid Hildenbrand     /*
70898ba906SDavid Hildenbrand      * RAM block length that corresponds to the used_length on the migration
71898ba906SDavid Hildenbrand      * source (after RAM block sizes were synchronized). Especially, after
72898ba906SDavid Hildenbrand      * starting to run the guest, used_length and postcopy_length can differ.
73898ba906SDavid Hildenbrand      * Used to register/unregister uffd handlers and as the size of the received
74898ba906SDavid Hildenbrand      * bitmap. Receiving any page beyond this length will bail out, as it
75898ba906SDavid Hildenbrand      * could not have been valid on the source.
76898ba906SDavid Hildenbrand      */
77898ba906SDavid Hildenbrand     ram_addr_t postcopy_length;
7841aa4e9fSJuan Quintela };
7941aa4e9fSJuan Quintela #endif
8041aa4e9fSJuan Quintela #endif
81