Confidential computing guests require memory to be accepted before use.
The unaccepted memory bitmap maintained by firmware does not track
hotplugged memory ranges.
Call arch_accept_memory() during the hot-add path to explicitly validate
and transition the newly added memory to a private state, making it
usable by the guest.
Signed-off-by: Pratik R. Sampat <prsampat@amd.com>
---
mm/memory_hotplug.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index a63ec679d861..8cfbf0541430 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -38,6 +38,7 @@
#include <linux/node.h>
#include <asm/tlbflush.h>
+#include <asm/unaccepted_memory.h>
#include "internal.h"
#include "shuffle.h"
@@ -1567,6 +1568,9 @@ int add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags)
if (!strcmp(res->name, "System RAM"))
firmware_map_add_hotplug(start, start + size, "System RAM");
+ if (IS_ENABLED(CONFIG_UNACCEPTED_MEMORY))
+ arch_accept_memory(start, start + size);
+
/* device_online() will take the lock when calling online_pages() */
mem_hotplug_done();
--
2.52.0
On 1/12/26 21:22, Pratik R. Sampat wrote: > Confidential computing guests require memory to be accepted before use. > The unaccepted memory bitmap maintained by firmware does not track > hotplugged memory ranges. > > Call arch_accept_memory() during the hot-add path to explicitly validate > and transition the newly added memory to a private state, making it > usable by the guest. > > Signed-off-by: Pratik R. Sampat <prsampat@amd.com> > --- > mm/memory_hotplug.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index a63ec679d861..8cfbf0541430 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -38,6 +38,7 @@ > #include <linux/node.h> > > #include <asm/tlbflush.h> > +#include <asm/unaccepted_memory.h> > > #include "internal.h" > #include "shuffle.h" > @@ -1567,6 +1568,9 @@ int add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) > if (!strcmp(res->name, "System RAM")) > firmware_map_add_hotplug(start, start + size, "System RAM"); > > + if (IS_ENABLED(CONFIG_UNACCEPTED_MEMORY)) > + arch_accept_memory(start, start + size); > + > /* device_online() will take the lock when calling online_pages() */ > mem_hotplug_done(); > As discussed, for things like virtio-mem or the HV-balloon this might be the wrong thing to do, but I don't expect these mechanisms to be used in CoCo environments just yet (and doing so would require enabling work for them). So I'm fine with this for now. -- Cheers David
On 1/14/26 4:30 AM, David Hildenbrand (Red Hat) wrote: > On 1/12/26 21:22, Pratik R. Sampat wrote: >> Confidential computing guests require memory to be accepted before use. >> The unaccepted memory bitmap maintained by firmware does not track >> hotplugged memory ranges. >> >> Call arch_accept_memory() during the hot-add path to explicitly validate >> and transition the newly added memory to a private state, making it >> usable by the guest. >> >> Signed-off-by: Pratik R. Sampat <prsampat@amd.com> >> --- >> mm/memory_hotplug.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c >> index a63ec679d861..8cfbf0541430 100644 >> --- a/mm/memory_hotplug.c >> +++ b/mm/memory_hotplug.c >> @@ -38,6 +38,7 @@ >> #include <linux/node.h> >> #include <asm/tlbflush.h> >> +#include <asm/unaccepted_memory.h> >> #include "internal.h" >> #include "shuffle.h" >> @@ -1567,6 +1568,9 @@ int add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) >> if (!strcmp(res->name, "System RAM")) >> firmware_map_add_hotplug(start, start + size, "System RAM"); >> + if (IS_ENABLED(CONFIG_UNACCEPTED_MEMORY)) >> + arch_accept_memory(start, start + size); >> + >> /* device_online() will take the lock when calling online_pages() */ >> mem_hotplug_done(); >> > > As discussed, for things like virtio-mem or the HV-balloon this might be the wrong thing to do, but I don't expect these mechanisms to be used in CoCo environments just yet (and doing so would require enabling work for them). > Ack. > So I'm fine with this for now. > Thanks!
Hi Pratik,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on tip/x86/core linus/master v6.19-rc5 next-20260109]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Pratik-R-Sampat/mm-memory_hotplug-Add-support-to-accept-memory-during-hot-add/20260113-042631
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20260112202300.43546-2-prsampat%40amd.com
patch subject: [PATCH v2 1/2] mm/memory_hotplug: Add support to accept memory during hot-add
config: s390-defconfig (https://download.01.org/0day-ci/archive/20260113/202601131632.NrQzg2Wm-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9b8addffa70cee5b2acc5454712d9cf78ce45710)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260113/202601131632.NrQzg2Wm-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601131632.NrQzg2Wm-lkp@intel.com/
All errors (new ones prefixed by >>):
>> mm/memory_hotplug.c:41:10: fatal error: 'asm/unaccepted_memory.h' file not found
41 | #include <asm/unaccepted_memory.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
vim +41 mm/memory_hotplug.c
39
40 #include <asm/tlbflush.h>
> 41 #include <asm/unaccepted_memory.h>
42
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Pratik,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on tip/x86/core linus/master v6.19-rc5 next-20260109]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Pratik-R-Sampat/mm-memory_hotplug-Add-support-to-accept-memory-during-hot-add/20260113-042631
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20260112202300.43546-2-prsampat%40amd.com
patch subject: [PATCH v2 1/2] mm/memory_hotplug: Add support to accept memory during hot-add
config: s390-randconfig-001-20260113 (https://download.01.org/0day-ci/archive/20260113/202601131156.Kfi0QLIm-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260113/202601131156.Kfi0QLIm-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601131156.Kfi0QLIm-lkp@intel.com/
All errors (new ones prefixed by >>):
>> mm/memory_hotplug.c:41:10: fatal error: asm/unaccepted_memory.h: No such file or directory
#include <asm/unaccepted_memory.h>
^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
vim +41 mm/memory_hotplug.c
39
40 #include <asm/tlbflush.h>
> 41 #include <asm/unaccepted_memory.h>
42
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On Mon, 12 Jan 2026 14:22:59 -0600 "Pratik R. Sampat" <prsampat@amd.com> wrote: > Confidential computing guests require memory to be accepted before use. > The unaccepted memory bitmap maintained by firmware does not track > hotplugged memory ranges. > > Call arch_accept_memory() during the hot-add path to explicitly validate > and transition the newly added memory to a private state, making it > usable by the guest. > > Signed-off-by: Pratik R. Sampat <prsampat@amd.com> > --- > mm/memory_hotplug.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index a63ec679d861..8cfbf0541430 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -38,6 +38,7 @@ > #include <linux/node.h> > > #include <asm/tlbflush.h> > +#include <asm/unaccepted_memory.h> This only exists for x86! Otherwise, the mm/ changes are minimal so I volunteer this patchset for the x86 tree ;)
On 1/12/26 3:04 PM, Andrew Morton wrote: > On Mon, 12 Jan 2026 14:22:59 -0600 "Pratik R. Sampat" <prsampat@amd.com> wrote: > >> Confidential computing guests require memory to be accepted before use. >> The unaccepted memory bitmap maintained by firmware does not track >> hotplugged memory ranges. >> >> Call arch_accept_memory() during the hot-add path to explicitly validate >> and transition the newly added memory to a private state, making it >> usable by the guest. >> >> Signed-off-by: Pratik R. Sampat <prsampat@amd.com> >> --- >> mm/memory_hotplug.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c >> index a63ec679d861..8cfbf0541430 100644 >> --- a/mm/memory_hotplug.c >> +++ b/mm/memory_hotplug.c >> @@ -38,6 +38,7 @@ >> #include <linux/node.h> >> >> #include <asm/tlbflush.h> >> +#include <asm/unaccepted_memory.h> > > This only exists for x86! Ah, I missed that entirely. Thanks for catching that. Probably not the best option to have a generic unaccepted_memory.h as well. Maybe, I should have arch_[un]accept_memory() definitions within mm.h wrapped within CONFIG_UNACCEPTED_MEMORY instead so that its cleaner. > > Otherwise, the mm/ changes are minimal so I volunteer this patchset > for the x86 tree ;) Ack! --Pratik
On Mon, 12 Jan 2026 16:23:37 -0600 "Pratik R. Sampat" <prsampat@amd.com> wrote:
>
>
> On 1/12/26 3:04 PM, Andrew Morton wrote:
> > On Mon, 12 Jan 2026 14:22:59 -0600 "Pratik R. Sampat" <prsampat@amd.com> wrote:
> >
> >> Confidential computing guests require memory to be accepted before use.
> >> The unaccepted memory bitmap maintained by firmware does not track
> >> hotplugged memory ranges.
> >>
> >> Call arch_accept_memory() during the hot-add path to explicitly validate
> >> and transition the newly added memory to a private state, making it
> >> usable by the guest.
> >>
> >> Signed-off-by: Pratik R. Sampat <prsampat@amd.com>
> >> ---
> >> mm/memory_hotplug.c | 4 ++++
> >> 1 file changed, 4 insertions(+)
> >>
> >> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> >> index a63ec679d861..8cfbf0541430 100644
> >> --- a/mm/memory_hotplug.c
> >> +++ b/mm/memory_hotplug.c
> >> @@ -38,6 +38,7 @@
> >> #include <linux/node.h>
> >>
> >> #include <asm/tlbflush.h>
> >> +#include <asm/unaccepted_memory.h>
> >
> > This only exists for x86!
>
> Ah, I missed that entirely. Thanks for catching that.
>
> Probably not the best option to have a generic unaccepted_memory.h as well.
> Maybe, I should have arch_[un]accept_memory() definitions within mm.h wrapped
> within CONFIG_UNACCEPTED_MEMORY instead so that its cleaner.
Something like that.
The idiomatic Linus way is to use
#ifndef arch_accept_memory
#define arch_accept_memory ...
#endif
Lots of prior art here:
grep -r include/linux "ifndef arch_"
Oh, arch_get_idle_state_flags() got it all wrong.
#ifdef CONFIG_ACPI_PROCESSOR_IDLE
#ifndef arch_get_idle_state_flags
static inline unsigned int arch_get_idle_state_flags(u32 arch_flags)
{
return 0;
}
#endif
#endif /* CONFIG_ACPI_PROCESSOR_IDLE */
- shouldn't have needed "ifdef CONFIG_ACPI_PROCESSOR_IDLE"
- should have appended
#define arch_get_idle_state_flags arch_get_idle_state_flags
in case cpp hit the same lines a second time.
On 1/12/26 4:43 PM, Andrew Morton wrote:
> On Mon, 12 Jan 2026 16:23:37 -0600 "Pratik R. Sampat" <prsampat@amd.com> wrote:
>
>>
>>
>> On 1/12/26 3:04 PM, Andrew Morton wrote:
>>> On Mon, 12 Jan 2026 14:22:59 -0600 "Pratik R. Sampat" <prsampat@amd.com> wrote:
>>>
>>>> Confidential computing guests require memory to be accepted before use.
>>>> The unaccepted memory bitmap maintained by firmware does not track
>>>> hotplugged memory ranges.
>>>>
>>>> Call arch_accept_memory() during the hot-add path to explicitly validate
>>>> and transition the newly added memory to a private state, making it
>>>> usable by the guest.
>>>>
>>>> Signed-off-by: Pratik R. Sampat <prsampat@amd.com>
>>>> ---
>>>> mm/memory_hotplug.c | 4 ++++
>>>> 1 file changed, 4 insertions(+)
>>>>
>>>> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
>>>> index a63ec679d861..8cfbf0541430 100644
>>>> --- a/mm/memory_hotplug.c
>>>> +++ b/mm/memory_hotplug.c
>>>> @@ -38,6 +38,7 @@
>>>> #include <linux/node.h>
>>>>
>>>> #include <asm/tlbflush.h>
>>>> +#include <asm/unaccepted_memory.h>
>>>
>>> This only exists for x86!
>>
>> Ah, I missed that entirely. Thanks for catching that.
>>
>> Probably not the best option to have a generic unaccepted_memory.h as well.
>> Maybe, I should have arch_[un]accept_memory() definitions within mm.h wrapped
>> within CONFIG_UNACCEPTED_MEMORY instead so that its cleaner.
>
> Something like that.
>
> The idiomatic Linus way is to use
>
> #ifndef arch_accept_memory
> #define arch_accept_memory ...
> #endif
>
> Lots of prior art here:
>
> grep -r include/linux "ifndef arch_"
>
>
> Oh, arch_get_idle_state_flags() got it all wrong.
>
> #ifdef CONFIG_ACPI_PROCESSOR_IDLE
> #ifndef arch_get_idle_state_flags
> static inline unsigned int arch_get_idle_state_flags(u32 arch_flags)
> {
> return 0;
> }
> #endif
> #endif /* CONFIG_ACPI_PROCESSOR_IDLE */
>
> - shouldn't have needed "ifdef CONFIG_ACPI_PROCESSOR_IDLE"
>
> - should have appended
>
> #define arch_get_idle_state_flags arch_get_idle_state_flags
>
> in case cpp hit the same lines a second time.
>
Got it. Thanks for clearing that up. I'll make sure to do it this way
in the next iteration.
--Pratik
© 2016 - 2026 Red Hat, Inc.