[PATCH 17/40] nitro_enclaves: Add the slot pool donation commands
From: Alexander Graf
Date: Wed Nov 11 2026 - 18:17:42 EST
Nitro Sandboxes introduce the concept of memory donations. In order to
launch more sandboxes, the parent instance needs to donate some of its
memory. A device that supports Nitro Sandboxes keeps its slot pool in
that memory: the descriptors of its slots and the memory the slots run
on. In preparation to donate that memory, add the commands that donate
memory for the slot descriptors and the registers that say how much of
it the device wants.
Signed-off-by: Alexander Graf <graf@xxxxxxxxxx>
---
drivers/virt/nitro_enclaves/ne_pci_dev.h | 60 ++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/drivers/virt/nitro_enclaves/ne_pci_dev.h b/drivers/virt/nitro_enclaves/ne_pci_dev.h
index 835413fca8040..e651e74ab656e 100644
--- a/drivers/virt/nitro_enclaves/ne_pci_dev.h
+++ b/drivers/virt/nitro_enclaves/ne_pci_dev.h
@@ -95,6 +95,42 @@
*/
#define NE_RECV_DATA_SIZE (240)
+/**
+ * DOC: Slot pool registers in the NE PCI device MMIO BAR
+ */
+
+/**
+ * NE_SLOT_POOL_MAX - (2 bytes) Register reporting the highest number of
+ * slots the device lets the pool grow to, or zero on a
+ * device that needs no donation (Read-Only).
+ */
+#define NE_SLOT_POOL_MAX (0x01f2)
+
+/**
+ * NE_SLOT_POOL_LIMIT - (2 bytes) Register reporting how many slots the
+ * pool has room for with the pages donated so far
+ * (Read-Only).
+ */
+#define NE_SLOT_POOL_LIMIT (0x01f6)
+
+/**
+ * NE_SLOT_POOL_GRAN_SIZE - (4 bytes) Register reporting the size, in bytes,
+ * of one donation to the pool (Read-Only).
+ */
+#define NE_SLOT_POOL_GRAN_SIZE (0x0200)
+
+/**
+ * NE_SLOT_POOL_GRAN_ALIGN - (4 bytes) Register reporting the alignment a
+ * donation to the pool has to meet (Read-Only).
+ */
+#define NE_SLOT_POOL_GRAN_ALIGN (0x0204)
+
+/**
+ * NE_SLOT_POOL_BASE_SIZE - (4 bytes) Register reporting the size, in bytes,
+ * of the base donation (Read-Only).
+ */
+#define NE_SLOT_POOL_BASE_SIZE (0x0208)
+
/**
* DOC: MSI-X interrupt vectors
*/
@@ -125,6 +161,10 @@
* @SLOT_ADD_BULK_VCPUS: Add a number of vCPUs, not providing CPU ids.
* @SLOT_ADD_INFO_PAGE: Give a slot the info page, a memory region the
* device writes.
+ * @SLOT_POOL_DONATE: Donate one page of parent memory to the slot
+ * pool.
+ * @SLOT_POOL_SHUTDOWN: Give the whole slot pool back.
+ * @SLOT_POOL_BASE_DONATE: Donate the base run of the slot pool.
* @MAX_CMD: A gatekeeper for max possible command type.
*/
enum ne_pci_dev_cmd_type {
@@ -142,6 +182,9 @@ enum ne_pci_dev_cmd_type {
SLOT_ADD_BULK_VCPUS = 11,
/* 12 is a command this driver does not implement. */
SLOT_ADD_INFO_PAGE = 13,
+ SLOT_POOL_DONATE = 16,
+ SLOT_POOL_SHUTDOWN = 17,
+ SLOT_POOL_BASE_DONATE = 25,
MAX_CMD,
};
@@ -284,6 +327,23 @@ struct slot_add_info_page_req {
u64 info_size;
};
+/**
+ * struct slot_pool_donate_req - SLOT_POOL_DONATE and SLOT_POOL_BASE_DONATE
+ * request.
+ * @paddr: Physical address of the donated run of pages.
+ */
+struct slot_pool_donate_req {
+ u64 paddr;
+};
+
+/**
+ * struct slot_pool_shutdown_req - SLOT_POOL_SHUTDOWN request.
+ * @unused: In order to avoid weird sizeof edge cases.
+ */
+struct slot_pool_shutdown_req {
+ u8 unused;
+};
+
/**
* struct ne_pci_dev_cmd_reply - NE PCI device command reply.
*
--
2.47.1