[PATCH v6 2/3] kho: add KHOSER_COPY_PTR to allow phys copy of serialized ptr

Tarun Sahu <[email protected]>
Newsgroups org.infradead.lists.kexec,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <[email protected]>
Adding KHOSER_COPY_PTR to copy one serializeable pointer to
another. It basically allows copy of phys val of the
serializeable pointer.

It ignores the typecheck if any of the argument is of void *

Signed-off-by: Tarun Sahu <[email protected]>
Reviewed-by: Pratyush Yadav (Google) <[email protected]>
Reviewed-by: Pasha Tatashin <[email protected]>
---
 include/linux/kho/abi/kexec_handover.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/kho/abi/kexec_handover.h b/include/linux/kho/abi/kexec_handover.h
index 5e2eb8519bda..a5a518e881fd 100644
--- a/include/linux/kho/abi/kexec_handover.h
+++ b/include/linux/kho/abi/kexec_handover.h
@@ -139,6 +139,17 @@
 		(typeof((s).ptr))((s).phys ? phys_to_virt((s).phys) : NULL); \
 	})
 
+#define KHOSER_COPY_PTR(dest, src)							  \
+	({										  \
+		static_assert(								  \
+			__builtin_types_compatible_p(typeof(dest.ptr), typeof(src.ptr)) ||\
+			__builtin_types_compatible_p(typeof(dest.ptr), void *) ||	  \
+			__builtin_types_compatible_p(typeof(src.ptr), void *),		  \
+			"pointer type mismatch in KHOSER_COPY_PTR"			  \
+		);									  \
+		(dest).phys = (src).phys;						  \
+	})
+
 /*
  * This header is embedded at the beginning of each `kho_vmalloc_chunk`
  * and contains a pointer to the next chunk in the linked list,
-- 
2.55.0.rc0.799.gd6f94ed593-goog
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.