v1 2026-10-29

CoCo 客户机内存气球支持 · v1

为CoCo客户机启用virtio-balloon报告与动态调整,解决SWIOTLB和内存unaccept问题。

原始补丁链接

子 Patch(13)

1/13
virtio_ring: support per-virtqueue DMA mapping ops
为 virtqueue 增加可覆盖的 map_ops,vring_map_one_sg()/unmap/error/sync 改走 vq->map_ops;间接描述符表仍用设备级 DMA 路径映射,供宿主 VMM 访问。
2/13
virtio_balloon: add reporting_vq DMA map ops
CC guest 上报空闲页时 DMA 层会拒绝未加密或 swiotlb scatterlist;宿主只读描述符中的 GPA/长度,故在 CC_ATTR_GUEST_MEM_ENCRYPT 下给 reporting_vq 挂 map_ops 直接转 GPA,不 bounce/解密。
3/13
x86/coco/sev: add snp_unaccept_memory()
新增 snp_unaccept_memory() 并接入 arch_unaccept_memory();动态撤回内存时以 PVALIDATE validate=false 撤销 RMP 校验,2MB PMD 失败回退 4KB,并触发 GHCB Page State Change 让宿主私有转共享。
4/13
x86/coco/sev: fix zeropad #VC on unaccepted memory
SEV-SNP 下已接受 4K 页紧邻未接受 2M 块时,load_unaligned_zeropad() 越界会触发 #VC 0x404/0x400;在 vc_raw_handle_exception() 对内核态 EX_TYPE_ZEROPAD 先 fixup_exception(),再走原 exitcode 处理。
5/13
efi/libstub: start unaccepted bitmap at address 0
When EFI_UNACCEPTED_MEMORY is present in the EFI memory map or the platform supports dynamic memory unacceptance (such as AMD SEV-SNP), start the EFI unaccepted memory bitmap at physical address 0 (ph
6/13
efi/unaccepted: add mark_memory_unaccepted()
Introduce mark_memory_unaccepted() to mark a physical memory range as unaccepted in the EFI unaccepted memory bitmap. Use unaccepted_memory_order() to query the page order matching the EFI unaccepted
7/13
mm/page_alloc: allow lower-order unaccepted_pages
Currently, zone->unaccepted_pages assumes all unaccepted blocks are MAX_PAGE_ORDER. However, dynamic memory unacceptance operates at unaccepted_memory_order() granularity (typically 2 MiB / PMD_ORDER
8/13
mm/page_alloc: route unaccepted isolated pages
When free page reporting unaccepts isolated pages on confidential computing guests, __putback_isolated_page() must not return those unaccepted pages directly to zone->free_area; doing so would violate
9/13
mm/page_reporting: account for unaccepted memory
When lazy unaccepted memory is active, pages on zone->unaccepted_pages are counted in NR_FREE_PAGES (MIGRATE_MOVABLE) as well as NR_UNACCEPTED. Without accounting for NR_UNACCEPTED in free page report
10/13
virtio_balloon: add higher-order page inflation
In confidential computing guests requiring page state transitions, unaccepted memory tracking operates at the EFI unaccepted memory unit granularity (typically 2MB / order 9 on x86). Inflating the bal
11/13
virtio_balloon: unaccept free reporting ranges
In confidential computing guests with dynamic unaccepted memory transitions, configure the free page reporting order to unaccepted_memory_order(). Invoke mark_memory_unaccepted() on each scatterlist r
12/13
virtio_balloon: unaccept inflated balloon pages
When pages are allocated for balloon inflation in confidential computing guests requiring page state transitions, mark the allocated pages as unaccepted via mark_memory_unaccepted() before notifying t
13/13
virtio_balloon: enforce ACCESS_PLATFORM in CoCo
In confidential computing environments (CC_ATTR_GUEST_MEM_ENCRYPT), virtio devices require VIRTIO_F_ACCESS_PLATFORM to negotiate restricted memory access and DMA bounce buffering for virtqueue rings a