Skip to contentSkip to conversation

Add qemu_ram_remap

PATCH In review Huang Ying 1 participant 1 message Feb 9, 2011 KVM

lore
Share & tools
lore

Huang Ying

author
#0 lore raw

PATCH 1/2 Add qemu_ram_remap

qemu_ram_remap() unmaps the specified RAM pages, then re-maps these pages again. This is used by KVM HWPoison support to clear HWPoisoned page tables across guest rebooting, so that a new page may be allocated later to recover the memory error.

---
 cpu-all.h    |    4 +++
 cpu-common.h |    1 
 exec.c       |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 65 insertions(+), 1 deletion(-)
cpu-all.h +4 -0
@@ -863,10 +863,14 @@ target_phys_addr_t cpu_get_phys_page_deb
 extern int phys_ram_fd;
 extern ram_addr_t ram_size;
 
+/* RAM is pre-allocated and passed into qemu_ram_alloc_from_ptr */
+#define RAM_PREALLOC_MASK	(1 << 0)
+
 typedef struct RAMBlock {
     uint8_t *host;
     ram_addr_t offset;
     ram_addr_t length;
+    uint32_t flags;
     char idstr[256];
     QLIST_ENTRY(RAMBlock) next;
 #if defined(__linux__) && !defined(TARGET_S390X)
exec.c +60 -1

79 lines not on this page · raw message

cpu-common.h +1 -0
@@ -50,6 +50,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(Devic
                         ram_addr_t size, void *host);
 ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size);
 void qemu_ram_free(ram_addr_t addr);
+void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
 /* This should only be used for ram local to a device.  */
 void *qemu_get_ram_ptr(ram_addr_t addr);
 /* Same but slower, to use for migration, where the order of