From: Igor Mammedov <imammedo@redhat.com>
To: fanhuang <FangSheng.Huang@amd.com>
Cc: <qemu-devel@nongnu.org>, <david@kernel.org>, <mst@redhat.com>,
<gourry@gourry.net>, <philmd@mailo.com>, <peterx@redhat.com>,
<Zhigang.Luo@amd.com>, <Lianjie.Shi@amd.com>
Subject: Re: [PATCH v13 04/10] hw/i386: hook sp-mem into the pc machine plug path
Date: Mon, 22 Jun 2026 14:44:04 +0200 [thread overview]
Message-ID: <20260622144404.1a2e7c04@imammedo> (raw)
In-Reply-To: <20260619111136.3481329-5-FangSheng.Huang@amd.com>
On Fri, 19 Jun 2026 19:11:30 +0800
fanhuang <FangSheng.Huang@amd.com> wrote:
> Add the pc machine hookup for TYPE_SP_MEM so each sp-mem instance is
> placed by the memory-device framework and reported to the guest as
> E820_SOFT_RESERVED.
>
> Signed-off-by: FangSheng Huang <FangSheng.Huang@amd.com>
> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> ---
> hw/i386/e820_memory_layout.h | 11 ++++++-----
> hw/i386/pc.c | 36 ++++++++++++++++++++++++++++++++++++
> hw/i386/Kconfig | 2 ++
> 3 files changed, 44 insertions(+), 5 deletions(-)
>
> diff --git a/hw/i386/e820_memory_layout.h b/hw/i386/e820_memory_layout.h
> index b50acfa201..6ef169db9c 100644
> --- a/hw/i386/e820_memory_layout.h
> +++ b/hw/i386/e820_memory_layout.h
> @@ -10,11 +10,12 @@
> #define HW_I386_E820_MEMORY_LAYOUT_H
>
> /* e820 types */
> -#define E820_RAM 1
> -#define E820_RESERVED 2
> -#define E820_ACPI 3
> -#define E820_NVS 4
> -#define E820_UNUSABLE 5
> +#define E820_RAM 1
> +#define E820_RESERVED 2
> +#define E820_ACPI 3
> +#define E820_NVS 4
> +#define E820_UNUSABLE 5
> +#define E820_SOFT_RESERVED 0xefffffff
>
> struct e820_entry {
> uint64_t address;
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 73a625327c..782122f7be 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -63,6 +63,7 @@
> #include "hw/i386/kvm/xen_gnttab.h"
> #include "hw/i386/kvm/xen_xenstore.h"
> #include "hw/mem/memory-device.h"
> +#include "hw/mem/sp-mem.h"
> #include "e820_memory_layout.h"
> #include "trace.h"
> #include "sev.h"
> @@ -1285,11 +1286,43 @@ static void pc_hv_balloon_plug(HotplugHandler *hotplug_dev,
> memory_device_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev));
> }
>
> +static void pc_sp_mem_pre_plug(HotplugHandler *hotplug_dev,
> + DeviceState *dev, Error **errp)
> +{
> + MachineState *ms = MACHINE(hotplug_dev);
> + SpMemDevice *spm = SP_MEM(dev);
> +
> + if (ms->numa_state && spm->node >= ms->numa_state->num_nodes) {
> + error_setg(errp,
> + "'node' property value %" PRIu32
> + " exceeds the number of NUMA nodes (%d)",
> + spm->node, ms->numa_state->num_nodes);
> + return;
> + }
> + memory_device_pre_plug(MEMORY_DEVICE(dev), ms, errp);
> +}
> +
> +static void pc_sp_mem_plug(HotplugHandler *hotplug_dev,
> + DeviceState *dev, Error **errp)
^^^ fix indent
> +{
> + SpMemDevice *spm = SP_MEM(dev);
> + MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(MEMORY_DEVICE(dev));
> + uint64_t addr, size;
> +
> + memory_device_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev));
> +
> + addr = mdc->get_addr(MEMORY_DEVICE(dev));
> + size = memory_region_size(host_memory_backend_get_memory(spm->hostmem));
> + e820_add_entry(addr, size, E820_SOFT_RESERVED);
> +}
> +
> static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
> DeviceState *dev, Error **errp)
> {
> if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> pc_memory_pre_plug(hotplug_dev, dev, errp);
> + } else if (object_dynamic_cast(OBJECT(dev), TYPE_SP_MEM)) {
> + pc_sp_mem_pre_plug(hotplug_dev, dev, errp);
> } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
> x86_cpu_pre_plug(hotplug_dev, dev, errp);
> } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) {
> @@ -1326,6 +1359,8 @@ static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev,
> {
> if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> pc_memory_plug(hotplug_dev, dev, errp);
> + } else if (object_dynamic_cast(OBJECT(dev), TYPE_SP_MEM)) {
> + pc_sp_mem_plug(hotplug_dev, dev, errp);
> } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
> x86_cpu_plug(hotplug_dev, dev, errp);
> } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) {
> @@ -1370,6 +1405,7 @@ static HotplugHandler *pc_get_hotplug_handler(MachineState *machine,
> DeviceState *dev)
> {
> if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) ||
> + object_dynamic_cast(OBJECT(dev), TYPE_SP_MEM) ||
> object_dynamic_cast(OBJECT(dev), TYPE_CPU) ||
> object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI) ||
> object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI) ||
> diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
> index 12473acaa7..e27d8816e5 100644
> --- a/hw/i386/Kconfig
> +++ b/hw/i386/Kconfig
> @@ -84,6 +84,7 @@ config I440FX
> select PCI_I440FX
> select PIIX
> select DIMM
> + select SP_MEM
> select SMBIOS
> select SMBIOS_LEGACY
> select FW_CFG_DMA
> @@ -113,6 +114,7 @@ config Q35
> select LPC_ICH9
> select AHCI_ICH9
> select DIMM
> + select SP_MEM
> select SMBIOS
> select FW_CFG_DMA
>
next prev parent reply other threads:[~2026-06-22 12:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-19 11:11 [PATCH v13 00/10] hw/mem: add sp-mem device for Specific Purpose Memory fanhuang
2026-06-19 11:11 ` [PATCH v13 01/10] " fanhuang
2026-06-22 12:49 ` Igor Mammedov
2026-06-19 11:11 ` [PATCH v13 02/10] qapi, hmp: introspection for the sp-mem device fanhuang
2026-06-22 12:52 ` Igor Mammedov
2026-06-22 12:55 ` Daniel P. Berrangé
2026-06-22 13:07 ` Igor Mammedov
2026-06-22 13:22 ` Daniel P. Berrangé
2026-06-19 11:11 ` [PATCH v13 03/10] i386/acpi-build: partition device_memory SRAT umbrella for sp-mem fanhuang
2026-06-19 11:11 ` [PATCH v13 04/10] hw/i386: hook sp-mem into the pc machine plug path fanhuang
2026-06-22 12:44 ` Igor Mammedov [this message]
2026-06-19 11:11 ` [PATCH v13 05/10] MAINTAINERS: cover sp-mem under Memory devices, add R: tag fanhuang
2026-06-19 11:11 ` [PATCH v13 06/10] tests/acpi: add empty expected blobs for sp-mem SRAT test fanhuang
2026-06-22 12:53 ` Igor Mammedov
2026-06-19 11:11 ` [PATCH v13 07/10] tests/acpi: add bios-tables-test case for sp-mem fanhuang
2026-06-22 13:00 ` Igor Mammedov
2026-06-19 11:11 ` [PATCH v13 08/10] tests/acpi: generate expected blobs for sp-mem SRAT test fanhuang
2026-06-22 13:09 ` Igor Mammedov
2026-06-19 11:11 ` [PATCH v13 09/10] tests/qtest: add e820 fw_cfg test fanhuang
2026-06-22 14:09 ` Igor Mammedov
2026-06-19 11:11 ` [PATCH v13 10/10] tests/qtest: cover sp-mem SOFT_RESERVED e820 entry fanhuang
2026-06-22 14:09 ` Igor Mammedov
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=20260622144404.1a2e7c04@imammedo \
--to=imammedo@redhat.com \
--cc=FangSheng.Huang@amd.com \
--cc=Lianjie.Shi@amd.com \
--cc=Zhigang.Luo@amd.com \
--cc=david@kernel.org \
--cc=gourry@gourry.net \
--cc=mst@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@mailo.com \
--cc=qemu-devel@nongnu.org \
/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.