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

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