[PATCH 19/40] nitro_enclaves: Add the slot pool growth commands
From: Alexander Graf
Date: Wed Nov 11 2026 - 18:07:27 EST
In preparation to grow the slot pool at runtime, add
SLOT_POOL_MEM_DONATE and SLOT_POOL_GET_LIMITS.
The slot pool has two halves: the slot descriptors, which
SLOT_POOL_DONATE grows, and the memory the device runs slots out of,
which SLOT_POOL_MEM_DONATE grows. Its reply names the part of the
offered run that the device took. A slot needs room in both halves.
SLOT_POOL_GET_LIMITS reports both counts, along with how many slots one
memory donation adds, so that the parent knows which half to grow next.
Both replies get an arm of the reply union.
Signed-off-by: Alexander Graf <graf@xxxxxxxxxx>
---
drivers/virt/nitro_enclaves/ne_pci_dev.h | 50 ++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/drivers/virt/nitro_enclaves/ne_pci_dev.h b/drivers/virt/nitro_enclaves/ne_pci_dev.h
index 4e991c4b0e70f..3718f893e4f65 100644
--- a/drivers/virt/nitro_enclaves/ne_pci_dev.h
+++ b/drivers/virt/nitro_enclaves/ne_pci_dev.h
@@ -164,6 +164,10 @@
* @SLOT_POOL_DONATE: Donate one page of parent memory to the slot
* pool.
* @SLOT_POOL_SHUTDOWN: Give the whole slot pool back.
+ * @SLOT_POOL_MEM_DONATE: Donate a run of parent memory to the memory the
+ * device runs a slot out of.
+ * @SLOT_POOL_GET_LIMITS: Report how many slots each half of the pool has
+ * room for.
* @SLOT_POOL_BASE_DONATE: Donate the base run of the slot pool.
* @MAX_CMD: A gatekeeper for max possible command type.
*/
@@ -185,6 +189,8 @@ enum ne_pci_dev_cmd_type {
SLOT_POOL_DONATE = 16,
SLOT_POOL_SHUTDOWN = 17,
SLOT_POOL_BASE_DONATE = 25,
+ SLOT_POOL_MEM_DONATE = 26,
+ SLOT_POOL_GET_LIMITS = 27,
MAX_CMD,
};
@@ -344,6 +350,16 @@ struct slot_pool_shutdown_req {
u8 unused;
};
+/**
+ * struct slot_pool_mem_donate_req - SLOT_POOL_MEM_DONATE request.
+ * @paddr: Physical address of the donated run of memory.
+ * @size: Size, in bytes, of the donated run.
+ */
+struct slot_pool_mem_donate_req {
+ u64 paddr;
+ u64 size;
+};
+
/**
* struct ne_pci_dev_cmd_reply - NE PCI device command reply.
*
@@ -377,6 +393,21 @@ struct slot_pool_shutdown_req {
* @info.state: SLOT_INFO. Slot state.
* @info.padding1: SLOT_INFO. Padding for the overall data
* structure.
+ * @mem_donate: Fields SLOT_POOL_MEM_DONATE fills.
+ * @mem_donate.consumed_paddr: SLOT_POOL_MEM_DONATE. Physical address of the
+ * run the device took out of the donation.
+ * @mem_donate.consumed_size: SLOT_POOL_MEM_DONATE. Size, in bytes, of the
+ * run the device took, zero where it took none.
+ * @limits: Fields SLOT_POOL_GET_LIMITS fills.
+ * @limits.meta_limit: SLOT_POOL_GET_LIMITS. Slots the descriptors
+ * donated so far have room for.
+ * @limits.mem_limit: SLOT_POOL_GET_LIMITS. Slots the memory donated
+ * so far has room to run.
+ * @limits.slots_per_donation: SLOT_POOL_GET_LIMITS. Slots one donation of
+ * memory adds to the memory the device runs a
+ * slot out of.
+ * @limits.reserved14: SLOT_POOL_GET_LIMITS. Bytes the device writes as
+ * zero.
*/
struct ne_pci_dev_cmd_reply {
s32 rc;
@@ -402,6 +433,16 @@ struct ne_pci_dev_cmd_reply {
u16 state;
u8 padding1[6];
} info;
+ struct {
+ u64 consumed_paddr;
+ u64 consumed_size;
+ } mem_donate;
+ struct {
+ u16 meta_limit;
+ u16 mem_limit;
+ u16 slots_per_donation;
+ u16 reserved14;
+ } limits;
};
};
@@ -417,6 +458,15 @@ static_assert(offsetof(struct ne_pci_dev_cmd_reply, info.mem_size) == 40);
static_assert(offsetof(struct ne_pci_dev_cmd_reply, info.nr_vcpus) == 48);
static_assert(offsetof(struct ne_pci_dev_cmd_reply, info.flags) == 56);
static_assert(offsetof(struct ne_pci_dev_cmd_reply, info.state) == 64);
+static_assert(offsetof(struct ne_pci_dev_cmd_reply,
+ mem_donate.consumed_paddr) == 8);
+static_assert(offsetof(struct ne_pci_dev_cmd_reply,
+ mem_donate.consumed_size) == 16);
+static_assert(offsetof(struct ne_pci_dev_cmd_reply, limits.meta_limit) == 8);
+static_assert(offsetof(struct ne_pci_dev_cmd_reply, limits.mem_limit) == 10);
+static_assert(offsetof(struct ne_pci_dev_cmd_reply,
+ limits.slots_per_donation) == 12);
+static_assert(offsetof(struct ne_pci_dev_cmd_reply, limits.reserved14) == 14);
/**
* struct ne_pci_dev - Nitro Enclaves (NE) PCI device.
--
2.47.1