diff mbox series

[RFC,10/13] softmmu/physmem: Add private memory address space

Message ID 20211111141352.26311-11-chao.p.peng@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series KVM: mm: fd-based approach for supporting KVM guest private memory | expand

Commit Message

Chao Peng Nov. 11, 2021, 2:13 p.m. UTC
Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
---
 include/exec/address-spaces.h |  2 ++
 softmmu/physmem.c             | 13 +++++++++++++
 2 files changed, 15 insertions(+)

Comments

Philippe Mathieu-Daudé Jan. 18, 2022, 9:41 a.m. UTC | #1
Hi,

On 11/11/21 15:13, Chao Peng wrote:
> Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
> ---
>  include/exec/address-spaces.h |  2 ++
>  softmmu/physmem.c             | 13 +++++++++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/include/exec/address-spaces.h b/include/exec/address-spaces.h
> index db8bfa9a92..b3f45001c0 100644
> --- a/include/exec/address-spaces.h
> +++ b/include/exec/address-spaces.h
> @@ -27,6 +27,7 @@
>   * until a proper bus interface is available.
>   */
>  MemoryRegion *get_system_memory(void);
> +MemoryRegion *get_system_private_memory(void);
>  
>  /* Get the root I/O port region.  This interface should only be used
>   * temporarily until a proper bus interface is available.
> @@ -34,6 +35,7 @@ MemoryRegion *get_system_memory(void);
>  MemoryRegion *get_system_io(void);
>  
>  extern AddressSpace address_space_memory;
> +extern AddressSpace address_space_private_memory;
>  extern AddressSpace address_space_io;
>  
>  #endif
> diff --git a/softmmu/physmem.c b/softmmu/physmem.c
> index f4d6eeaa17..a2d339fd88 100644
> --- a/softmmu/physmem.c
> +++ b/softmmu/physmem.c
> @@ -85,10 +85,13 @@
>  RAMList ram_list = { .blocks = QLIST_HEAD_INITIALIZER(ram_list.blocks) };
>  
>  static MemoryRegion *system_memory;
> +static MemoryRegion *system_private_memory;
>  static MemoryRegion *system_io;
>  
>  AddressSpace address_space_io;
>  AddressSpace address_space_memory;
> +AddressSpace address_space_private_memory;
> +
>  
>  static MemoryRegion io_mem_unassigned;
>  
> @@ -2669,6 +2672,11 @@ static void memory_map_init(void)
>      memory_region_init(system_memory, NULL, "system", UINT64_MAX);
>      address_space_init(&address_space_memory, system_memory, "memory");
>  
> +    system_private_memory = g_malloc(sizeof(*system_private_memory));
> +
> +    memory_region_init(system_private_memory, NULL, "system-private", UINT64_MAX);
> +    address_space_init(&address_space_private_memory, system_private_memory, "private-memory");

Since the description is quite scarce, I don't understand why we need to
add this KVM specific "system-private" MR/AS to all machines on all
architectures.

>      system_io = g_malloc(sizeof(*system_io));
>      memory_region_init_io(system_io, NULL, &unassigned_io_ops, NULL, "io",
>                            65536);

(We already want to get ride of the "io" MR/AS which is specific to
x86 or machines).

> @@ -2680,6 +2688,11 @@ MemoryRegion *get_system_memory(void)
>      return system_memory;
>  }
>  
> +MemoryRegion *get_system_private_memory(void)
> +{
> +    return system_private_memory;
> +}
> +
>  MemoryRegion *get_system_io(void)
>  {
>      return system_io;
diff mbox series

Patch

diff --git a/include/exec/address-spaces.h b/include/exec/address-spaces.h
index db8bfa9a92..b3f45001c0 100644
--- a/include/exec/address-spaces.h
+++ b/include/exec/address-spaces.h
@@ -27,6 +27,7 @@ 
  * until a proper bus interface is available.
  */
 MemoryRegion *get_system_memory(void);
+MemoryRegion *get_system_private_memory(void);
 
 /* Get the root I/O port region.  This interface should only be used
  * temporarily until a proper bus interface is available.
@@ -34,6 +35,7 @@  MemoryRegion *get_system_memory(void);
 MemoryRegion *get_system_io(void);
 
 extern AddressSpace address_space_memory;
+extern AddressSpace address_space_private_memory;
 extern AddressSpace address_space_io;
 
 #endif
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index f4d6eeaa17..a2d339fd88 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -85,10 +85,13 @@ 
 RAMList ram_list = { .blocks = QLIST_HEAD_INITIALIZER(ram_list.blocks) };
 
 static MemoryRegion *system_memory;
+static MemoryRegion *system_private_memory;
 static MemoryRegion *system_io;
 
 AddressSpace address_space_io;
 AddressSpace address_space_memory;
+AddressSpace address_space_private_memory;
+
 
 static MemoryRegion io_mem_unassigned;
 
@@ -2669,6 +2672,11 @@  static void memory_map_init(void)
     memory_region_init(system_memory, NULL, "system", UINT64_MAX);
     address_space_init(&address_space_memory, system_memory, "memory");
 
+    system_private_memory = g_malloc(sizeof(*system_private_memory));
+
+    memory_region_init(system_private_memory, NULL, "system-private", UINT64_MAX);
+    address_space_init(&address_space_private_memory, system_private_memory, "private-memory");
+
     system_io = g_malloc(sizeof(*system_io));
     memory_region_init_io(system_io, NULL, &unassigned_io_ops, NULL, "io",
                           65536);
@@ -2680,6 +2688,11 @@  MemoryRegion *get_system_memory(void)
     return system_memory;
 }
 
+MemoryRegion *get_system_private_memory(void)
+{
+    return system_private_memory;
+}
+
 MemoryRegion *get_system_io(void)
 {
     return system_io;