From: Zhao Liu <zhao1.liu@intel.com>
To: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Kirill Martynov" <stdcalllevi@yandex-team.ru>,
"Marcelo Tosatti" <mtosatti@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 1/2] i386/cpu: Enable SMM cpu addressspace
Date: Thu, 31 Jul 2025 11:53:54 +0800 [thread overview]
Message-ID: <aIro0jw/CjMssy/v@intel.com> (raw)
In-Reply-To: <e5bde045-01b6-4f81-bc25-fd4312de7fe8@intel.com>
On Thu, Jul 31, 2025 at 12:11:41AM +0800, Xiaoyao Li wrote:
> Date: Thu, 31 Jul 2025 00:11:41 +0800
> From: Xiaoyao Li <xiaoyao.li@intel.com>
> Subject: Re: [PATCH 1/2] i386/cpu: Enable SMM cpu addressspace
>
> 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?
When you're referring cpu->memory, you should aware where's the
difference and why you don't need do the same thing.
This is necessary for a clear commit message, and it also allows more
eyes to check whether it is correct and whether there are any potential
problems. Providing details is always beneficial.
> As you saide,
>
> cpu_address_space_init()
> -> address_space_init()
> -> memory_region_ref()
>
> it already ensures the ref count is increased.
Yes, this is what I mean.
> Why cpu_exec_initfn() increases the refcount of cpu->memory, is
> totally unrelated to cpu_address_space_init().
^^^^^^^^^^^^^^^^^
The validity of cpu->memory must be guaranteed, as this is a prerequisite
for everything else. And isn't it mainly related with the CPU address
space??
It can be said that because the pointer to system_memory needs to be
cached in CPUState, such a ref is useful, thereby ensuring the safety
of the next address space stuff.
next prev parent reply other threads:[~2025-07-31 3:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 5:40 [PATCH 0/2] i386/kvm: Enable SMM addrss space for i386 cpu Xiaoyao Li
2025-07-29 5:40 ` [PATCH 1/2] i386/cpu: Enable SMM cpu addressspace Xiaoyao Li
2025-07-29 7:08 ` Philippe Mathieu-Daudé
2025-07-30 8:11 ` Zhao Liu
2025-07-30 7:55 ` Kirill Martynov
2025-07-30 10:12 ` Xiaoyao Li
2025-07-30 15:20 ` Zhao Liu
2025-07-30 16:11 ` Xiaoyao Li
2025-07-31 3:53 ` Zhao Liu [this message]
2025-08-18 9:37 ` Kirill Martynov
2025-07-29 5:40 ` [PATCH 2/2] target/i386: Define enum X86ASIdx for x86's address spaces Xiaoyao Li
2025-07-29 7:11 ` Philippe Mathieu-Daudé
2025-07-29 12:16 ` Kirill Martynov
2025-07-30 8:23 ` Zhao Liu
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=aIro0jw/CjMssy/v@intel.com \
--to=zhao1.liu@intel.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stdcalllevi@yandex-team.ru \
--cc=xiaoyao.li@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.