Re: [PATCH V5 15/22] LoongArch: Add elf and module support

From
Luis Chamberlain <mcgrof@kernel.org>
Date
2021-10-13 12:56:30
Also in
linux-arch, lkml
Reply to
Huacai Chen, 2021-10-13
On Wed, Oct 13, 2021 at 03:11:10PM +0800, Huacai Chen wrote:
quoted hunk ↗ jump to hunk
diff --git a/arch/loongarch/include/asm/vermagic.h b/arch/loongarch/include/asm/vermagic.h
new file mode 100644
index 000000000000..9882dfd4702a
--- /dev/null
+++ b/arch/loongarch/include/asm/vermagic.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020-2021 Loongson Technology Corporation Limited
+ */
+#ifndef _ASM_VERMAGIC_H
+#define _ASM_VERMAGIC_H
+
+#define MODULE_PROC_FAMILY "LOONGARCH "
I take it this not a mips arch? There are other longarchs under
arch/mips/include/asm/vermagic.h which is why I ask.
quoted hunk ↗ jump to hunk
diff --git a/arch/loongarch/kernel/module.c b/arch/loongarch/kernel/module.c
new file mode 100644
index 000000000000..af7c403b032b
--- /dev/null
+++ b/arch/loongarch/kernel/module.c
@@ -0,0 +1,652 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Author: Hanlu Li <lihanlu@loongson.cn>
+ *         Huacai Chen <chenhuacai@loongson.cn>
+ *
+ * Copyright (C) 2020-2021 Loongson Technology Corporation Limited
+ */
+
+#undef DEBUG
Please remove this undef DEBUG line.
quoted hunk ↗ jump to hunk
+
+#include <linux/moduleloader.h>
+#include <linux/elf.h>
+#include <linux/mm.h>
+#include <linux/vmalloc.h>
+#include <linux/slab.h>
+#include <linux/fs.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+
+static int rela_stack_push(s64 stack_value, s64 *rela_stack, size_t *rela_stack_top)
+{
+	if (*rela_stack_top >= RELA_STACK_DEPTH)
+		return -ENOEXEC;
+
+	rela_stack[(*rela_stack_top)++] = stack_value;
+	pr_debug("%s stack_value = 0x%llx\n", __func__, stack_value);
If you are going to use pr_debug() so much you may want to add
a define for #define pr_fmt(fmt) at the very top.
quoted hunk ↗ jump to hunk
+int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
+		       unsigned int symindex, unsigned int relsec,
+		       struct module *me)
+{
Nit: Please use struct module *mod, it is much more common in other places.

Other than that, this looks fine to me.

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>

  Luis
Thread (25 messages) 25 messages, 3 authors, last reply 2021-10-14
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