diff mbox series

[v2,01/32] memory: Correctly return alias region type

Message ID 20200224204828.23167-2-philmd@redhat.com
State New
Headers show
Series hw: Sanitize various MemoryRegion uses | expand

Commit Message

Philippe Mathieu-Daudé Feb. 24, 2020, 8:47 p.m. UTC
Since memory region aliases are neither rom nor ram, they are
described as i/o, which is often incorrect. Return instead the
type of the original region we are aliasing.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
Cc: qemu-trivial@nongnu.org

 memory.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Alistair Francis Feb. 24, 2020, 9:14 p.m. UTC | #1
On Mon, Feb 24, 2020 at 12:49 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> Since memory region aliases are neither rom nor ram, they are
> described as i/o, which is often incorrect. Return instead the
> type of the original region we are aliasing.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
> Cc: qemu-trivial@nongnu.org
>
>  memory.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/memory.c b/memory.c
> index aeaa8dcc9e..ce1179874e 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -2818,6 +2818,9 @@ void address_space_destroy(AddressSpace *as)
>
>  static const char *memory_region_type(MemoryRegion *mr)
>  {
> +    if (mr->alias) {
> +        return memory_region_type(mr->alias);
> +    }
>      if (memory_region_is_ram_device(mr)) {
>          return "ramd";
>      } else if (memory_region_is_romd(mr)) {
> --
> 2.21.1
>
>
diff mbox series

Patch

diff --git a/memory.c b/memory.c
index aeaa8dcc9e..ce1179874e 100644
--- a/memory.c
+++ b/memory.c
@@ -2818,6 +2818,9 @@  void address_space_destroy(AddressSpace *as)
 
 static const char *memory_region_type(MemoryRegion *mr)
 {
+    if (mr->alias) {
+        return memory_region_type(mr->alias);
+    }
     if (memory_region_is_ram_device(mr)) {
         return "ramd";
     } else if (memory_region_is_romd(mr)) {