[Qemu-devel] [PATCH v1 0/5] Fix misuses of memory_region_allocate_system_memory()

Igor Mammedov posted 5 patches 5 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1555334842-195718-1-git-send-email-imammedo@redhat.com
Test docker-mingw@fedora passed
Test docker-clang@ubuntu passed
Test checkpatch passed
Test asan passed
Maintainers: Halil Pasic <pasic@linux.ibm.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, David Gibson <david@gibson.dropbear.id.au>, Cornelia Huck <cohuck@redhat.com>, Christian Borntraeger <borntraeger@de.ibm.com>, Helge Deller <deller@gmx.de>, Artyom Tarasenko <atar4qemu@gmail.com>, Richard Henderson <rth@twiddle.net>, David Hildenbrand <david@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Hervé Poussineau" <hpoussin@reactos.org>
exec.c                     |  7 ++++---
hw/hppa/machine.c          |  5 ++---
hw/ppc/rs6000_mc.c         | 15 ++++++++++-----
hw/s390x/s390-virtio-ccw.c | 20 +++++++++++++++-----
hw/sparc64/niagara.c       | 25 +++++++++++++------------
memory.c                   |  5 +++++
6 files changed, 49 insertions(+), 28 deletions(-)
[Qemu-devel] [PATCH v1 0/5] Fix misuses of memory_region_allocate_system_memory()
Posted by Igor Mammedov 5 years ago
memory_region_allocate_system_memory() is supposed to be called only once,
but due to lack of the check some boards abused it by  calling it multiple times.
So here goes fixes that replace it with  memory_region_init_ram() in most of
the cases.
However s390 case a bit convolted as we have to keep cross version migration
working and need -mem-path to work there as well. To make it happen I hacked
MemoryRegion aliases to work with migration by allocating 'fake' RAMBlock that
aliases original RAM pointer (asking for comments on approach since I have no
idea how migration works really). It is one way to fix s390 while not abusing
memory_region_allocate_system_memory() and making it work with -mem-path
correctly.
(another a bit more dirty way would be adding machine callback to handle
 -mem-path and overiding it in s390, but migratable aliases approach looks more
cleaner to me API wise and have potential to be reused if we would need to
fix up RAM layout but keep migration stream compatible).

CC: Paolo Bonzini <pbonzini@redhat.com> 
CC: Richard Henderson <rth@twiddle.net> 
CC: Helge Deller <deller@gmx.de> 
CC: "Hervé Poussineau" <hpoussin@reactos.org> 
CC: David Gibson <david@gibson.dropbear.id.au> 
CC: Cornelia Huck <cohuck@redhat.com> 
CC: Halil Pasic <pasic@linux.ibm.com> 
CC: Christian Borntraeger <borntraeger@de.ibm.com> 
CC: David Hildenbrand <david@redhat.com> 
CC: Artyom Tarasenko <atar4qemu@gmail.com> 
CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> 
CC: qemu-ppc@nongnu.org
CC: qemu-s390x@nongnu.org

Igor Mammedov (5):
  sparc64: use memory_region_allocate_system_memory() only for '-m'
    specified RAM
  ppc: rs6000_mc: drop usage of memory_region_allocate_system_memory()
  hppa: drop usage of memory_region_allocate_system_memory() for ROM
  memory: make MemoryRegion alias migratable
  s390: do not call memory_region_allocate_system_memory() multiple
    times

 exec.c                     |  7 ++++---
 hw/hppa/machine.c          |  5 ++---
 hw/ppc/rs6000_mc.c         | 15 ++++++++++-----
 hw/s390x/s390-virtio-ccw.c | 20 +++++++++++++++-----
 hw/sparc64/niagara.c       | 25 +++++++++++++------------
 memory.c                   |  5 +++++
 6 files changed, 49 insertions(+), 28 deletions(-)

-- 
2.7.4