Re: [RFC PATCH v6 03/12] livepatch: Add klp-convert tool

From
Joe Lawrence <joe.lawrence@redhat.com>
Date
2022-02-16 16:56:21
Also in
linux-kbuild, lkml
Reply to
Joe Lawrence, 2022-02-16
On Wed, Feb 16, 2022 at 11:39:31AM -0500, Joe Lawrence wrote:
quoted hunk ↗ jump to hunk
diff --git a/include/uapi/linux/livepatch.h b/include/uapi/linux/livepatch.h
index e19430918a07..2ee98e985c2a 100644
--- a/include/uapi/linux/livepatch.h
+++ b/include/uapi/linux/livepatch.h
@@ -9,7 +9,17 @@
 #ifndef _UAPI_LIVEPATCH_H
 #define _UAPI_LIVEPATCH_H
 
+#include <linux/types.h>
+
 #define KLP_RELA_PREFIX		".klp.rela."
 #define KLP_SYM_PREFIX		".klp.sym."
 
+struct klp_module_reloc {
+	union {
+		void *sym;
+		__u64 sym64;	/* Force 64-bit width */
+	};
+	__u32 sympos;
+} __packed;
+
[ ... snip ... ]
diff --git a/scripts/livepatch/klp-convert.h b/scripts/livepatch/klp-convert.h
new file mode 100644
index 000000000000..35b9dc4e32c4
--- /dev/null
+++ b/scripts/livepatch/klp-convert.h
[ ... snip ... ]

+struct klp_module_reloc {
+	union {
+		void *sym;
+		uint64_t sym64;	/* Force 64-bit width */
+	};
+	uint32_t sympos;
+} __packed;
This was a hack I added to force a consistent width for the symbol
pointer in case the user was building for 32-bit.  The actual void
*sym64 value itself is not so interesting as it's only needed for the
compiler to create a relocation (later resolved by klp-convert).  That
said, sympos is used by klp-convert, and I bet it's not endian-safe
here.

Better suggestions welcome :)

-- Joe
Thread (28 messages) 28 messages, 4 authors, last reply 2023-02-07
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help