qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] Add new utility function memory_region_allocate_aux_memory()
@ 2017-07-04 17:02 Peter Maydell
  2017-07-04 17:02 ` [Qemu-devel] [PATCH 1/3] include/hw/boards.h: Document memory_region_allocate_system_memory() Peter Maydell
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Peter Maydell @ 2017-07-04 17:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches, Paolo Bonzini, Eduardo Habkost, Marcel Apfelbaum

Many board models and several devices need to create auxiliary
regions of RAM (in addition to the main lump of 'system' memory),
to model static RAMs, video memory, ROMs, etc. Currently they do
this with a sequence like:
       memory_region_init_ram(sram, NULL, "sram", 0x10000, &error_fatal);
       vmstate_register_ram_global(sram);

but the need for the second function call is not obvious and if
omitted the bug is subtle (possible migration failure). This series
wraps the two calls up into a single new function
memory_region_allocate_aux_memory(), named to parallel the existing
memory_region_allocate_system_memory().

Patch 1 documents memory_region_allocate_system_memory() which
has a couple of non-obvious wrinkles. Patch 2 implements the new
utility function. Patch 3 changes a lot of callsites to use it
with the aid of the included coccinelle patch. (I think most
of the remaining callsites of vmstate_register_ram_global() are
not changed just because they report the error up to their caller
rather than using error_fatal. I'm not sure what kind of error you
might get back that wasn't "out of memory", which we usually make
fatal anyway, so perhaps we could change those callsites too.)

thanks
-- PMM

Peter Maydell (3):
  include/hw/boards.h: Document memory_region_allocate_system_memory()
  memory.h: Add new utility function memory_region_allocate_aux_memory()
  hw: Use new memory_region_allocate_aux_memory() function

 include/exec/memory.h                     | 23 +++++++++++++++++++++++
 include/hw/boards.h                       | 29 +++++++++++++++++++++++++++++
 hw/arm/exynos4210.c                       | 10 ++++------
 hw/arm/exynos4_boards.c                   | 12 +++++-------
 hw/arm/integratorcp.c                     |  5 ++---
 hw/arm/mainstone.c                        |  5 ++---
 hw/arm/musicpal.c                         |  5 ++---
 hw/arm/omap1.c                            |  5 ++---
 hw/arm/omap2.c                            |  5 ++---
 hw/arm/omap_sx1.c                         | 10 ++++------
 hw/arm/palm.c                             |  4 +---
 hw/arm/pxa2xx.c                           | 20 ++++++++------------
 hw/arm/realview.c                         | 14 +++++---------
 hw/arm/spitz.c                            |  3 +--
 hw/arm/stellaris.c                        |  9 +++------
 hw/arm/stm32f205_soc.c                    | 10 +++-------
 hw/arm/tosa.c                             |  3 +--
 hw/arm/vexpress.c                         | 12 +++---------
 hw/arm/virt.c                             |  3 +--
 hw/arm/xilinx_zynq.c                      |  5 ++---
 hw/arm/xlnx-zynqmp.c                      |  5 ++---
 hw/block/onenand.c                        |  5 ++---
 hw/cris/axis_dev88.c                      |  5 ++---
 hw/display/cg3.c                          |  5 ++---
 hw/display/sm501.c                        |  5 ++---
 hw/display/tc6393xb.c                     |  5 ++---
 hw/display/tcx.c                          |  5 ++---
 hw/display/vmware_vga.c                   |  5 ++---
 hw/i386/pc.c                              |  5 ++---
 hw/i386/pc_sysfw.c                        |  8 +++-----
 hw/i386/xen/xen-hvm.c                     |  4 +---
 hw/input/milkymist-softusb.c              | 10 ++++------
 hw/m68k/an5206.c                          |  3 +--
 hw/m68k/mcf5208.c                         |  3 +--
 hw/microblaze/petalogix_ml605_mmu.c       | 11 +++++------
 hw/microblaze/petalogix_s3adsp1800_mmu.c  | 12 +++++-------
 hw/mips/mips_fulong2e.c                   |  4 +---
 hw/mips/mips_jazz.c                       | 10 ++++------
 hw/mips/mips_mipssim.c                    |  5 ++---
 hw/mips/mips_r4k.c                        |  5 ++---
 hw/moxie/moxiesim.c                       |  6 ++----
 hw/net/milkymist-minimac2.c               |  6 +++---
 hw/openrisc/openrisc_sim.c                |  3 +--
 hw/pci-host/prep.c                        |  5 +----
 hw/ppc/mac_newworld.c                     |  5 ++---
 hw/ppc/mac_oldworld.c                     |  5 ++---
 hw/ppc/ppc405_boards.c                    | 14 +++++---------
 hw/ppc/ppc405_uc.c                        |  5 ++---
 hw/s390x/sclp.c                           |  5 ++---
 hw/sh4/r2d.c                              |  3 +--
 hw/sh4/shix.c                             | 13 +++++--------
 hw/sparc/leon3.c                          |  3 +--
 hw/sparc/sun4m.c                          | 13 +++++--------
 hw/sparc64/sun4u.c                        | 10 ++++------
 hw/tricore/tricore_testboard.c            | 30 ++++++++++++------------------
 hw/unicore32/puv3.c                       |  4 +---
 hw/xtensa/sim.c                           |  6 ++----
 hw/xtensa/xtfpga.c                        | 14 +++++---------
 memory.c                                  |  8 ++++++++
 scripts/coccinelle/allocate_aux_mem.cocci | 14 ++++++++++++++
 60 files changed, 228 insertions(+), 256 deletions(-)
 create mode 100644 scripts/coccinelle/allocate_aux_mem.cocci

-- 
2.7.4

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2017-07-17 16:28 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-04 17:02 [Qemu-devel] [PATCH 0/3] Add new utility function memory_region_allocate_aux_memory() Peter Maydell
2017-07-04 17:02 ` [Qemu-devel] [PATCH 1/3] include/hw/boards.h: Document memory_region_allocate_system_memory() Peter Maydell
2017-07-06  3:18   ` Philippe Mathieu-Daudé
2017-07-06  8:46     ` Paolo Bonzini
2017-07-04 17:02 ` [Qemu-devel] [PATCH 2/3] memory.h: Add new utility function memory_region_allocate_aux_memory() Peter Maydell
2017-07-04 17:02 ` [Qemu-devel] [PATCH 3/3] hw: Use new memory_region_allocate_aux_memory() function Peter Maydell
2017-07-05 12:21 ` [Qemu-devel] [PATCH 0/3] Add new utility function memory_region_allocate_aux_memory() Paolo Bonzini
2017-07-06 14:52   ` Peter Maydell
2017-07-06 14:56     ` Paolo Bonzini
2017-07-06 16:26       ` Peter Maydell
2017-07-06 16:49         ` Paolo Bonzini
2017-07-07 13:18         ` Igor Mammedov
2017-07-07 13:49           ` Peter Maydell
2017-07-17 16:28       ` Peter Maydell
2017-07-07 13:06     ` Igor Mammedov
2017-07-06 17:13   ` Peter Maydell
2017-07-06 17:26     ` Paolo Bonzini
2017-07-06 17:47       ` Peter Maydell
2017-07-07 10:43         ` Peter Maydell
2017-07-07 10:55           ` Paolo Bonzini
2017-07-07 11:58       ` Peter Maydell
2017-07-07 12:03         ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).