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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 13, 2021 at 03:11:10PM +0800, Huacai Chen wrote:
> 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.

> 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@xxxxxxxxxxx>
> + *         Huacai Chen <chenhuacai@xxxxxxxxxxx>
> + *
> + * Copyright (C) 2020-2021 Loongson Technology Corporation Limited
> + */
> +
> +#undef DEBUG

Please remove this undef DEBUG line.

> +
> +#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.

> +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@xxxxxxxxxx>

  Luis



[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux