On 7/30/2025 11:20 PM, Zhao Liu wrote:
+        cpu_address_space_init(cpu, 1, "cpu-smm", &smram_as_root);

It is worth mentioning in the commit message that directly sharing
MemoryRegion in CPUAddressSpace is safe.

It's unnecessary to me. It's common that different Address space share the
same (root) memory region. e.g., for address space 0 for the cpu, though
what passed in is cpu->memory, they all point to system_memory.

For cpu->memory, there's the "object_ref(OBJECT(cpu->memory))" in
cpu_exec_initfn().

But this case doesn't need to increase ref count like cpu->memory, since
memory_region_ref() provides protection and it's enough.

This is the difference.

So it sounds like now it's more necessary to clarify this, no?


clarify why smram_as_root doesn't need to be object_ref()'ed explicitly like what cpu_exec_initfn() does for cpu->memory?

As you saide,

cpu_address_space_init()
  -> address_space_init()
     -> memory_region_ref()

it already ensures the ref count is increased.

Why cpu_exec_initfn() increases the refcount of cpu->memory, is totally unrelated to cpu_address_space_init().

Reply via email to