system/memory: Trivial fixes
cover system/memory: Trivial fixes
- Include missing "exec/memory.h"
- Set machine as parent of io/mem regions
Philippe Mathieu-Daudé (3):
cpu-target: Include missing 'exec/memory.h' header monitor/target: Include missing 'exec/memory.h' header system/physmem: Assign global system I/O Memory to machine
cpu-target.c | 1 + monitor/hmp-cmds-target.c | 1 + system/physmem.c | 7 ++++--- 3 files changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/3 cpu-target: Include missing 'exec/memory.h' header
Include "exec/memory.h" in order to avoid:
cpu-target.c:201:50: error: use of undeclared identifier 'TYPE_MEMORY_REGION'
DEFINE_PROP_LINK("memory", CPUState, memory, TYPE_MEMORY_REGION,
^
--- cpu-target.c | 1 + 1 file changed, 1 insertion(+)
cpu-target.c +1 -0
@@ -31,6 +31,7 @@#else #include "hw/core/sysemu-cpu-ops.h" #include "exec/address-spaces.h" +#include "exec/memory.h" #endif #include "sysemu/cpus.h" #include "sysemu/tcg.h"
Signature · 1 line
2.41.0
Re: [PATCH 1/3] cpu-target: Include missing 'exec/memory.h' header
Quoted 6 lines · Philippe Mathieu-Daudé
Include "
exec/memory.h" in order to avoid:cpu-target.c:201:50: error: use of undeclared identifier '
TYPE_MEMORY_REGION'
DEFINE_PROP_LINK("memory", CPUState, memory,TYPE_MEMORY_REGION,
^
Given that we don't actually see this error, presumably we're implicitly dragging it in via some other include? Anyway, better to be explicit than implicit, so
thanks
-- PMM
Re: [PATCH 1/3] cpu-target: Include missing 'exec/memory.h' header
Quoted 10 lines · Peter Maydell
Quoted 6 lines · Philippe Mathieu-Daudé
Include "
exec/memory.h" in order to avoid:cpu-target.c:201:50: error: use of undeclared identifier '
TYPE_MEMORY_REGION'
DEFINE_PROP_LINK("memory", CPUState, memory,TYPE_MEMORY_REGION,
^Given that we don't actually see this error, presumably we're implicitly dragging it in via some other include?
It is pulled in by the exec/cpu-all.h header which I'm trying to sanitize (along with others). I'll add a note about this.
Quoted 3 lines
Anyway, better to be explicit than implicit, so
Reviewed-by Peter Maydell <[email protected]>
Thanks!
PATCH 2/3 monitor/target: Include missing 'exec/memory.h' header
In reply to Philippe Mathieu-DaudéInclude "exec/memory.h" in order to avoid:
monitor/hmp-cmds-target.c:263:10: error: call to undeclared function 'memory_region_is_ram'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
if (!memory_region_is_ram(mrs.mr) && !memory_region_is_romd(mrs.mr)) {
^--- monitor/hmp-cmds-target.c | 1 + 1 file changed, 1 insertion(+)
monitor/hmp-cmds-target.c +1 -0
@@ -25,6 +25,7 @@#include "qemu/osdep.h" #include "disas/disas.h" #include "exec/address-spaces.h" +#include "exec/memory.h" #include "monitor/hmp-target.h" #include "monitor/monitor-internal.h" #include "qapi/error.h"
Signature · 1 line
2.41.0
Re: [PATCH 2/3] monitor/target: Include missing 'exec/memory.h' header
Quoted 26 lines · Philippe Mathieu-Daudé
Include "
exec/memory.h" in order to avoid:
monitor/hmp-cmds-target.c:263:10: error: call to undeclared function 'memory_region_is_ram'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]if (!memory_region_is_ram(mrs.mr) && !memory_region_is_romd(mrs.mr)) { ^Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- monitor/hmp-cmds-target.c | 1 + 1 file changed, 1 insertion(+)monitor/hmp-cmds-target.c +1
-1@@ -25,6 +25,7 @@#include "qemu/osdep.h" #include "disas/disas.h" #include "exec/address-spaces.h" +#include "exec/memory.h" #include "monitor/hmp-target.h" #include "monitor/monitor-internal.h" #include "qapi/error.h" --
Quoted 1 line
2.41.0
thanks
-- PMM
PATCH 3/3 system/physmem: Assign global system I/O Memory to machine
In reply to Philippe Mathieu-DaudéSo far there is only one system I/O and one system memory per machine.
--- system/physmem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
system/physmem.c +4 -3
@@ -2554,12 +2554,13 @@ static void memory_map_init(void) { system_memory =g_malloc (sizeof (*system_memory)); -memory_region_init (system_memory,NULL ,"system" ,UINT64_MAX ); +memory_region_init (system_memory,OBJECT (current_machine), +"system" ,UINT64_MAX );address_space_init (&address_space_memory, system_memory,"memory" ); system_io =g_malloc (sizeof (*system_io)); -memory_region_init_io (system_io,NULL , &unassigned_io_ops,NULL ,"io" , -65536 ); +memory_region_init_io (system_io,OBJECT (current_machine), + &unassigned_io_ops,NULL ,"io" ,65535 );address_space_init (&address_space_io, system_io,"I/O" ); }
Signature · 1 line
2.41.0
Re: [PATCH 3/3] system/physmem: Assign global system I/O Memory to machine
Quoted 19 lines · Philippe Mathieu-Daudé
So far there is only one system I/O and one system memory per machine.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- system/physmem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)system/physmem.c +1
-1@@ -2554,12 +2554,13 @@ static void memory_map_init(void) { system_memory =g_malloc (sizeof (*system_memory)); -memory_region_init (system_memory,NULL ,"system" ,UINT64_MAX ); + memory_region_init(system_memory, OBJECT(current_machine),
system/physmem.c static void memory_map_init(void) · line 2565
Quoted 10 lines
system/physmem.c +3
-2+ "system", UINT64_MAX);address_space_init (&address_space_memory, system_memory,"memory" ); system_io =g_malloc (sizeof (*system_io)); -memory_region_init_io (system_io,NULL , &unassigned_io_ops,NULL ,"io" , -65536 ); +memory_region_init_io (system_io,OBJECT (current_machine), + &unassigned_io_ops,NULL ,"io" ,65535 );address_space_init (&address_space_io, system_io,"I/O" ); }
What's the intention in doing this? What does it change?
It seems to be OK to pass a non-Device owner in for memory_region_init() (whereas it is *not* OK to do that for memory_region_init_ram()), but this seems to be getting a bit tricky.
thanks
-- PMM
Re: [PATCH 3/3] system/physmem: Assign global system I/O Memory to machine
(+Markus I forgot to Cc)
Quoted 23 lines · Peter Maydell
Quoted 22 lines · Philippe Mathieu-Daudé
So far there is only one system I/O and one system memory per machine.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- system/physmem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)system/physmem.c +2
-1@@ -2554,12 +2554,13 @@ static void memory_map_init(void) { system_memory =g_malloc (sizeof (*system_memory)); -memory_region_init (system_memory,NULL ,"system" ,UINT64_MAX ); +memory_region_init (system_memory,OBJECT (current_machine), +"system" ,UINT64_MAX );address_space_init (&address_space_memory, system_memory,"memory" );
Quoted 9 lines
system/physmem.c static void memory_map_init(void) · line 2565
Quoted 7 lines
system/physmem.c +2
-2system_io =g_malloc (sizeof (*system_io)); -memory_region_init_io (system_io,NULL , &unassigned_io_ops,NULL ,"io" , -65536 ); +memory_region_init_io (system_io,OBJECT (current_machine), + &unassigned_io_ops,NULL ,"io" ,65535 );address_space_init (&address_space_io, system_io,"I/O" ); }What's the intention in doing this? What does it change?
We want to remove access to pre-QOM and possibly hotplug QOM paths from external API (CLI & QMP so far).
When the parent object is obvious and missing we simply have to explicit it.
Quoted 4 lines
It seems to be OK to pass a non-Device owner in for
memory_region_init()(whereas it is *not* OK to do that formemory_region_init_ram()), but this seems to be getting a bit tricky.
Yes, memory_region_init_ram() is problematic; I'm hardly trying to ignore it at this point.
09.02.2024 18:00, Philippe Mathieu-Daudé :
Quoted 7 lines
- Include missing "
exec/memory.h"
- Set machine as parent of io/mem regionsPhilippe Mathieu-Daudé (3):
cpu-target: Include missing 'exec/memory.h' header monitor/target: Include missing 'exec/memory.h' header system/physmem: Assign global system I/O Memory to machine
Picked up patches 1 & 2, but not 3 yet.
/mjt
Quoted 5 lines
cpu-target.c | 1 + monitor/hmp-cmds-target.c | 1 + system/physmem.c | 7 ++++--- 3 files changed, 6 insertions(+), 3 deletions(-)