SEV-SNP Unaccepted Memory Hotplug
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest2 patches 12 repliesIn review
- v32 patches 9 repliesSuperseded
- v22 patches 12 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 RFC | 4 patches | 35 replies | Superseded |
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | mm/memory_hotplug: Add support to accept memory during hot-adddrivers/ include/ mm/ | +54 | 12 replies | |
| 2/2 | x86/sev: Add support to unaccept memory after hot-removearch/ arch/ arch/ +3 more | +95 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.
Cover letter [PATCH v4 0/2] SEV-SNP Unaccepted Memory Hotplug
Guest memory hot-plug/remove via the QEMU monitor is used by virtual machines to dynamically scale the memory capacity of a system with virtually zero downtime to the guest. For confidential VMs, memory has to be first accepted before it can be used. Add support to accept memory that has been hot-added and revert back it's state for hypervisors to be able to use the pages during hot-remove.
Usage (for SNP guests)
----------------------
Step1: Spawn a QEMU SNP guest with the additional parameter of slots and maximum possible memory, along with the initial memory as below:
"-m X,slots=Y,maxmem=Z".
Step2: Once the guest is booted, launch the qemu monitor and hotplug the memory as follows:
(qemu) object_add memory-backend-memfd,id=mem1,size=1G (qemu) device_add pc-dimm,id=dimm1,memdev=mem1
Memory is accepted up-front when added to the guest.
If using auto-onlining by either:
a) echo online > /sys/devices/system/memory/auto_online_blocks, OR
b) enable CONFIG_MHP_DEFAULT_ONLINE_TYPE_* while compiling kernel
Memory should show up automatically.
Otherwise, memory can also be onlined by echoing 1 to the newly added blocks in: /sys/devices/system/memory/memoryXX/online
Step3: memory can be hot-removed via the qemu monitor using:
(qemu) device_remove dimm1
(qemu) object_remove mem1
Tip: Enable the kvm_convert_memory event in QEMU to observe memory conversions between private and shared during hotplug/remove.
The series is based on
git.kernel.org/pub/scm/virt/kvm/kvm.git next
Comments and feedback appreciated!
Changelog Patch v3..v4:
-----------------------
https://lore.kernel.org/all/[email protected]/
1. Unconditionally accept all hotplug pages and set bitmap for the ones that are in the bit range (Kiryl)
2. Fix implementation similarly for unacceptance and merge unaccept_memory() implementation within unaccept_hotplug_memory()
3. Use max()/min() when clamping memory ranges to operate in the bitmap (Andrew)
4. Fall through arch_unaccept_memory() for TDX platforms (Kiryl). However, retain the panic() similar to arch_accept_memory() since it is a can't-happen scenario for other archs.
Changelog Patch v2..v3:
-----------------------
https://lore.kernel.org/all/[email protected]/
1. Account for cold-plugged memory at boot and introduce proper handling of the unaccepted bitmap during both hotplug and remove. (Kiryl)
2. #include<asm/unaccepted_memory.h> within memory_hotplug caused build failures on non-x86 archs (Andrew). Instead of introducing #if-deffery to have arch agnostic fall throughs, create hotplug specific helper functions since we now also need to take care of managing the bitmaps due to 1. as well.
Changelog RFC..Patch v2:
------------------------
https://lore.kernel.org/all/[email protected]/
Based on feedback from the RFC, reworked the series to accept memory upfront on hotplug. This is done for two reasons:
1. Avoids modifying the unaccepted bitmap. Extending the bitmap would require either:
* Dynamically allocating the bitmap, which would need changes to EFI struct definitions, or
* Pre-allocating a larger bitmap to accommodate hotpluggable memory. This poses challenges since e820 is parsed before SRAT, which contains the actual memory ranges information.
2. There are currently no known use-cases that would benefit from lazy acceptance of hotplugged ranges which warrants this additional complexity.
Pratik R. Sampat (2):
mm/memory_hotplug: Add support to accept memory during hot-add x86/sev: Add support to unaccept memory after hot-remove
arch/x86/coco/sev/core.c | 13 +++ arch/x86/include/asm/sev.h | 2 + arch/x86/include/asm/unaccepted_memory.h | 15 ++++ drivers/firmware/efi/unaccepted_memory.c | 106 +++++++++++++++++++++++ include/linux/mm.h | 9 ++ mm/memory_hotplug.c | 4 + 6 files changed, 149 insertions(+)
Signature · 1 line
2.52.0