Blame SOURCES/kvm-memory-Fix-the-memory-region-type-assignment-order.patch

ae23c9
From c3d30392ea7f29823de3b4514ce3b75d7254ee58 Mon Sep 17 00:00:00 2001
ae23c9
From: Gary R Hook <ghook@redhat.com>
ae23c9
Date: Wed, 10 Apr 2019 00:08:02 +0100
ae23c9
Subject: [PATCH 2/5] memory: Fix the memory region type assignment order
ae23c9
ae23c9
RH-Author: Gary R Hook <ghook@redhat.com>
ae23c9
Message-id: <20190410000803.1744-2-ghook@redhat.com>
ae23c9
Patchwork-id: 85543
ae23c9
O-Subject: [RHEL-8.1 virt 1/2] memory: Fix the memory region type assignment order
ae23c9
Bugzilla: 1667249
ae23c9
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
ae23c9
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
ae23c9
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
ae23c9
ae23c9
BZ: 1667249
ae23c9
Branch: rhel-8.1.0
ae23c9
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1667249
ae23c9
Upstream Status: 4.0.0-rc1
ae23c9
Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=20980582
ae23c9
Conflicts: None
ae23c9
ae23c9
commit 2ddb89b00f947f785c9ca6742f28f954e3b75e62
ae23c9
Author: Singh, Brijesh <brijesh.singh@amd.com>
ae23c9
Date:   Mon Feb 4 22:23:39 2019 +0000
ae23c9
ae23c9
    memory: Fix the memory region type assignment order
ae23c9
ae23c9
    Currently, a callback registered through the RAMBlock notifier
ae23c9
    is not able to get the memory region type (i.e callback is not
ae23c9
    able to use memory_region_is_ram_device function). This is
ae23c9
    because mr->ram assignment happens _after_ the memory is allocated
ae23c9
    whereas the callback is executed during allocation.
ae23c9
ae23c9
    Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1667249
ae23c9
    Suggested-by: Alex Williamson <alex.williamson@redhat.com>
ae23c9
    Cc: Paolo Bonzini <pbonzini@redhat.com>
ae23c9
    Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
ae23c9
    Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
ae23c9
    Message-Id: <20190204222322.26766-2-brijesh.singh@amd.com>
ae23c9
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
ae23c9
ae23c9
Cc: Paolo Bonzini <pbonzini@redhat.com>
ae23c9
Cc: qemu-devel@nongnu.org
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 memory.c | 9 ++++++++-
ae23c9
 1 file changed, 8 insertions(+), 1 deletion(-)
ae23c9
ae23c9
diff --git a/memory.c b/memory.c
ae23c9
index 4974f97..04ff5e9 100644
ae23c9
--- a/memory.c
ae23c9
+++ b/memory.c
ae23c9
@@ -1631,10 +1631,17 @@ void memory_region_init_ram_device_ptr(MemoryRegion *mr,
ae23c9
                                        uint64_t size,
ae23c9
                                        void *ptr)
ae23c9
 {
ae23c9
-    memory_region_init_ram_ptr(mr, owner, name, size, ptr);
ae23c9
+    memory_region_init(mr, owner, name, size);
ae23c9
+    mr->ram = true;
ae23c9
+    mr->terminates = true;
ae23c9
     mr->ram_device = true;
ae23c9
     mr->ops = &ram_device_mem_ops;
ae23c9
     mr->opaque = mr;
ae23c9
+    mr->destructor = memory_region_destructor_ram;
ae23c9
+    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
ae23c9
+    /* qemu_ram_alloc_from_ptr cannot fail with ptr != NULL.  */
ae23c9
+    assert(ptr != NULL);
ae23c9
+    mr->ram_block = qemu_ram_alloc_from_ptr(size, ptr, mr, &error_fatal);
ae23c9
 }
ae23c9
 
ae23c9
 void memory_region_init_alias(MemoryRegion *mr,
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9