[RFC PATCH v8 13/14] mm: Assert CoCo shared allocations may sleep

From: Aneesh Kumar K.V (Arm)

Date: Thu Sep 24 2026 - 06:14:19 EST


On platforms with memory encryption, alloc_cc_shared_pages_node()
transitions the allocated memory to the shared state.
set_memory_decrypted() may sleep, so the transition must run from a
sleepable context.

Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@xxxxxxxxxx>
---
mm/cc_shared.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/mm/cc_shared.c b/mm/cc_shared.c
index 9eb79832a702..6f68a3f44ef8 100644
--- a/mm/cc_shared.c
+++ b/mm/cc_shared.c
@@ -8,6 +8,7 @@
#include <linux/errno.h>
#include <linux/export.h>
#include <linux/gfp.h>
+#include <linux/kernel.h>
#include <linux/log2.h>
#include <linux/mm.h>
#include <linux/mem_encrypt.h>
@@ -106,6 +107,8 @@ static int __alloc_cc_shared_pages_node(int nid, gfp_t gfp,
unsigned int order;
int ret;

+ might_sleep();
+
ret = cc_shared_calc_layout(requested, &layout);
if (ret)
return ret;
--
2.43.0