Re: [PATCH v5 03/22] cc_platform: Add new attribute to prevent ACPI memory hotplug

From: Kai Huang
Date: Wed Jun 29 2022 - 05:13:32 EST


On Wed, 2022-06-29 at 10:48 +0200, Igor Mammedov wrote:
> > Hi Rafael,  Igor,
> >
> > On my test machine, the acpi_memory_device_add() is not called for system
> > memory.  It probably because my machine doesn't have memory device in ACPI.
> >
> > I don't know whether we can have any memory device in ACPI if such memory is
> > present during boot?  Any comments here?
>
> I don't see anything in ACPI spec that forbids memory device being present at
> boot.
> Such memory may also be present in E820, but in QEMU is not done as linux used
> to
> online all E820 memory as normal which breaks hotplug. And I don't know if it
> still true.
>
> Also NVDIMMs also use memory device, so they may be affected by this patch as
> well.

AFAICT NVDIMM uses different device ID so won't be impacted. But right there's
no specification around "whether firmware will create ACPI memory device for
boot-time present memory", so I guess we need to treat it is possible. So I
agree having the check at the beginning of acpi_memory_device_add() looks
incorrect.

Also as Christoph commented I'll give up introducing new CC attribute.

>
> >
> > And CC_ATTR_ACPI_MEMORY_HOTPLUG_DISABLED is only true on TDX bare-metal
> > system,
> > but cannot be true in Qemu guest.  But yes if this flag ever becomes true in
>
> that's temporary, once TDX support lands in KVM/QEMU, this patch will silently
> break usecase.

I don't think so. KVM/Qemu won't expose TDX to guest, so this code won't be
true in guest.

--
Thanks,
-Kai