[RFC PATCH 16/18] arm64: add kernel modules text and rodata replication support

From: Nikita Panov

Date: Thu Aug 27 2026 - 12:25:34 EST


Acked-by: Artem Kuzin <artem.kuzin@xxxxxxxxxx>
Acked-by: Alexander Grubnikov <alexander.grubnikov@xxxxxxxxxx>
Acked-by: Ilya Hanov <ilya.hanov@xxxxxxxxxxxxxxxxxxx>
Acked-by: Denis Darvish <darvish.denis@xxxxxxxxxx>
Signed-off-by: Nikita Panov <panov.nikita@xxxxxxxxxx>
---
arch/arm64/kernel/module.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c
index 24adb581af0e..61f605f74d86 100644
--- a/arch/arm64/kernel/module.c
+++ b/arch/arm64/kernel/module.c
@@ -18,6 +18,7 @@
#include <linux/moduleloader.h>
#include <linux/random.h>
#include <linux/scs.h>
+#include <linux/vmalloc.h>

#include <asm/alternative.h>
#include <asm/insn.h>
@@ -25,6 +26,16 @@
#include <asm/sections.h>
#include <asm/text-patching.h>

+#ifdef CONFIG_KERNEL_REPLICATION
+void module_replicate(void *ptr)
+{
+ gfp_t gfp_mask = GFP_KERNEL;
+
+ __vmalloc_node_replicate_range(ptr, gfp_mask,
+ PAGE_KERNEL, 0);
+}
+#endif /*CONFIG_KERNEL_REPLICATION*/
+
enum aarch64_reloc_op {
RELOC_OP_NONE,
RELOC_OP_ABS,
--
2.34.1