qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 02/22] acpi-build: remove dependency from ram_addr.h
Date: Sat, 28 Mar 2015 19:58:56 +0100	[thread overview]
Message-ID: <20150328195825-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1427391520-29497-3-git-send-email-pbonzini@redhat.com>

On Thu, Mar 26, 2015 at 06:38:20PM +0100, Paolo Bonzini wrote:
> ram_addr_t is an internal interface, everyone should go through
> MemoryRegion.  Clean it up by making rom_add_blob return a
> MemoryRegion* and using the new qemu_ram_resize infrastructure.
> 
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  hw/core/loader.c     |  8 ++++----
>  hw/i386/acpi-build.c | 36 ++++++++++++++++++------------------
>  include/hw/loader.h  |  8 +++++---
>  3 files changed, 27 insertions(+), 25 deletions(-)
> 
> diff --git a/hw/core/loader.c b/hw/core/loader.c
> index d4c441f..7ee675c 100644
> --- a/hw/core/loader.c
> +++ b/hw/core/loader.c
> @@ -835,12 +835,12 @@ err:
>      return -1;
>  }
>  
> -ram_addr_t rom_add_blob(const char *name, const void *blob, size_t len,
> +MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len,
>                     size_t max_len, hwaddr addr, const char *fw_file_name,
>                     FWCfgReadCallback fw_callback, void *callback_opaque)
>  {
>      Rom *rom;
> -    ram_addr_t ret = RAM_ADDR_MAX;
> +    MemoryRegion *mr = NULL;
>  
>      rom           = g_malloc0(sizeof(*rom));
>      rom->name     = g_strdup(name);
> @@ -858,7 +858,7 @@ ram_addr_t rom_add_blob(const char *name, const void *blob, size_t len,
>  
>          if (rom_file_has_mr) {
>              data = rom_set_mr(rom, OBJECT(fw_cfg), devpath);
> -            ret = memory_region_get_ram_addr(rom->mr);
> +            mr = rom->mr;
>          } else {
>              data = rom->data;
>          }
> @@ -867,7 +867,7 @@ ram_addr_t rom_add_blob(const char *name, const void *blob, size_t len,
>                                   fw_callback, callback_opaque,
>                                   data, rom->datasize);
>      }
> -    return ret;
> +    return mr;
>  }
>  
>  /* This function is specific for elf program because we don't need to allocate
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index d0a5c85..ec4d1e8 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -58,7 +58,6 @@
>  
>  #include "qapi/qmp/qint.h"
>  #include "qom/qom-qobject.h"
> -#include "exec/ram_addr.h"
>  
>  /* These are used to size the ACPI tables for -M pc-i440fx-1.7 and
>   * -M pc-i440fx-2.0.  Even if the actual amount of AML generated grows
> @@ -1323,13 +1322,13 @@ static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre)
>  typedef
>  struct AcpiBuildState {
>      /* Copy of table in RAM (for patching). */
> -    ram_addr_t table_ram;
> +    MemoryRegion *table_mr;
>      /* Is table patched? */
>      uint8_t patched;
>      PcGuestInfo *guest_info;
>      void *rsdp;
> -    ram_addr_t rsdp_ram;
> -    ram_addr_t linker_ram;
> +    MemoryRegion *rsdp_mr;
> +    MemoryRegion *linker_mr;
>  } AcpiBuildState;
>  
>  static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
> @@ -1513,15 +1512,15 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
>      g_array_free(table_offsets, true);
>  }
>  
> -static void acpi_ram_update(ram_addr_t ram, GArray *data)
> +static void acpi_ram_update(MemoryRegion *mr, GArray *data)
>  {
>      uint32_t size = acpi_data_len(data);
>  
>      /* Make sure RAM size is correct - in case it got changed e.g. by migration */
> -    qemu_ram_resize(ram, size, &error_abort);
> +    memory_region_ram_resize(mr, size, &error_abort);
>  
> -    memcpy(qemu_get_ram_ptr(ram), data->data, size);
> -    cpu_physical_memory_set_dirty_range_nocode(ram, size);
> +    memcpy(memory_region_get_ram_ptr(mr), data->data, size);
> +    memory_region_set_dirty(mr, 0, size);
>  }
>  
>  static void acpi_build_update(void *build_opaque, uint32_t offset)
> @@ -1539,15 +1538,15 @@ static void acpi_build_update(void *build_opaque, uint32_t offset)
>  
>      acpi_build(build_state->guest_info, &tables);
>  
> -    acpi_ram_update(build_state->table_ram, tables.table_data);
> +    acpi_ram_update(build_state->table_mr, tables.table_data);
>  
>      if (build_state->rsdp) {
>          memcpy(build_state->rsdp, tables.rsdp->data, acpi_data_len(tables.rsdp));
>      } else {
> -        acpi_ram_update(build_state->rsdp_ram, tables.rsdp);
> +        acpi_ram_update(build_state->rsdp_mr, tables.rsdp);
>      }
>  
> -    acpi_ram_update(build_state->linker_ram, tables.linker);
> +    acpi_ram_update(build_state->linker_mr, tables.linker);
>      acpi_build_tables_cleanup(&tables, true);
>  }
>  
> @@ -1557,8 +1556,9 @@ static void acpi_build_reset(void *build_opaque)
>      build_state->patched = 0;
>  }
>  
> -static ram_addr_t acpi_add_rom_blob(AcpiBuildState *build_state, GArray *blob,
> -                               const char *name, uint64_t max_size)
> +static MemoryRegion *acpi_add_rom_blob(AcpiBuildState *build_state,
> +                                       GArray *blob, const char *name,
> +                                       uint64_t max_size)
>  {
>      return rom_add_blob(name, blob->data, acpi_data_len(blob), max_size, -1,
>                          name, acpi_build_update, build_state);
> @@ -1604,12 +1604,12 @@ void acpi_setup(PcGuestInfo *guest_info)
>      acpi_build(build_state->guest_info, &tables);
>  
>      /* Now expose it all to Guest */
> -    build_state->table_ram = acpi_add_rom_blob(build_state, tables.table_data,
> +    build_state->table_mr = acpi_add_rom_blob(build_state, tables.table_data,
>                                                 ACPI_BUILD_TABLE_FILE,
>                                                 ACPI_BUILD_TABLE_MAX_SIZE);
> -    assert(build_state->table_ram != RAM_ADDR_MAX);
> +    assert(build_state->table_mr != NULL);
>  
> -    build_state->linker_ram =
> +    build_state->linker_mr =
>          acpi_add_rom_blob(build_state, tables.linker, "etc/table-loader", 0);
>  
>      fw_cfg_add_file(guest_info->fw_cfg, ACPI_BUILD_TPMLOG_FILE,
> @@ -1627,10 +1627,10 @@ void acpi_setup(PcGuestInfo *guest_info)
>          fw_cfg_add_file_callback(guest_info->fw_cfg, ACPI_BUILD_RSDP_FILE,
>                                   acpi_build_update, build_state,
>                                   build_state->rsdp, rsdp_size);
> -        build_state->rsdp_ram = (ram_addr_t)-1;
> +        build_state->rsdp_mr = NULL;
>      } else {
>          build_state->rsdp = NULL;
> -        build_state->rsdp_ram = acpi_add_rom_blob(build_state, tables.rsdp,
> +        build_state->rsdp_mr = acpi_add_rom_blob(build_state, tables.rsdp,
>                                                    ACPI_BUILD_RSDP_FILE, 0);
>      }
>  
> diff --git a/include/hw/loader.h b/include/hw/loader.h
> index 4f0681b..485ff8f 100644
> --- a/include/hw/loader.h
> +++ b/include/hw/loader.h
> @@ -68,9 +68,11 @@ extern bool rom_file_has_mr;
>  int rom_add_file(const char *file, const char *fw_dir,
>                   hwaddr addr, int32_t bootindex,
>                   bool option_rom);
> -ram_addr_t rom_add_blob(const char *name, const void *blob, size_t len,
> -                   size_t max_len, hwaddr addr, const char *fw_file_name,
> -                   FWCfgReadCallback fw_callback, void *callback_opaque);
> +MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len,
> +                           size_t max_len, hwaddr addr,
> +                           const char *fw_file_name,
> +                           FWCfgReadCallback fw_callback,
> +                           void *callback_opaque);
>  int rom_add_elf_program(const char *name, void *data, size_t datasize,
>                          size_t romsize, hwaddr addr);
>  int rom_load_all(void);
> -- 
> 2.3.3
> 

  reply	other threads:[~2015-03-28 18:59 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-26 17:38 [Qemu-devel] [PATCH 00/22] Dirty bitmap atomic access and optimizations Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 01/22] memory: add memory_region_ram_resize Paolo Bonzini
2015-03-28 18:58   ` Michael S. Tsirkin
2015-03-29  7:30     ` Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 02/22] acpi-build: remove dependency from ram_addr.h Paolo Bonzini
2015-03-28 18:58   ` Michael S. Tsirkin [this message]
2015-03-26 17:38 ` [Qemu-devel] [PATCH 03/22] memory: the only dirty memory flag for users is DIRTY_MEMORY_VGA Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 04/22] display: enable DIRTY_MEMORY_VGA tracking explicitly Paolo Bonzini
2015-04-20 13:11   ` Stefan Hajnoczi
2015-04-20 13:54     ` Paolo Bonzini
2015-04-22  9:12       ` Stefan Hajnoczi
2015-03-26 17:38 ` [Qemu-devel] [PATCH 05/22] memory: return bitmap from memory_region_is_logging Paolo Bonzini
2015-03-27  5:44   ` Fam Zheng
2015-03-27  6:01     ` Paolo Bonzini
2015-03-28 18:54   ` Michael S. Tsirkin
2015-03-29  7:33     ` Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 06/22] framebuffer: check memory_region_is_logging Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 07/22] ui/console: " Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 08/22] memory: track DIRTY_MEMORY_CODE in mr->dirty_log_mask Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 09/22] memory: return DIRTY_MEMORY_MIGRATION from memory_region_is_logging Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 10/22] ram_addr: tweaks to xen_modified_memory Paolo Bonzini
2015-03-28 19:04   ` Stefano Stabellini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 11/22] exec: simplify notdirty_mem_write Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 12/22] exec: use memory_region_is_logging to optimize dirty tracking Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 13/22] exec: pass client mask to cpu_physical_memory_set_dirty_range Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 14/22] exec: only check relevant bitmaps for cleanliness Paolo Bonzini
2015-03-27  6:10   ` Fam Zheng
2015-03-27  9:19     ` Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 15/22] memory: do not touch code dirty bitmap unless TCG is enabled Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 16/22] bitmap: add atomic set functions Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 17/22] bitmap: add atomic test and clear Paolo Bonzini
2015-03-27  6:37   ` Fam Zheng
2015-03-27  9:21     ` Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 18/22] memory: use atomic ops for setting dirty memory bits Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 19/22] migration: move dirty bitmap sync to ram_addr.h Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 20/22] memory: replace cpu_physical_memory_reset_dirty() with test-and-clear Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 21/22] memory: make cpu_physical_memory_sync_dirty_bitmap() fully atomic Paolo Bonzini
2015-03-26 17:38 ` [Qemu-devel] [PATCH 22/22] migration: run bitmap sync outside iothread lock Paolo Bonzini
2015-04-20 13:23 ` [Qemu-devel] [PATCH 00/22] Dirty bitmap atomic access and optimizations Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150328195825-mutt-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).