[PATCH V3 03/22] LoongArch: Add elf-related definitions

Huacai Chen posted 22 patches 3 years, 9 months ago
There is a newer version of this series
[PATCH V3 03/22] LoongArch: Add elf-related definitions
Posted by Huacai Chen 3 years, 9 months ago
Add elf-related definitions for LoongArch, including: EM_LOONGARCH,
KEXEC_ARCH_LOONGARCH, AUDIT_ARCH_LOONGARCH32, AUDIT_ARCH_LOONGARCH64
and NT_LOONGARCH_*.

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
 include/uapi/linux/audit.h  | 2 ++
 include/uapi/linux/elf-em.h | 1 +
 include/uapi/linux/elf.h    | 5 +++++
 include/uapi/linux/kexec.h  | 1 +
 scripts/sorttable.c         | 5 +++++
 5 files changed, 14 insertions(+)

diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 8eda133ca4c1..7c1dc818b1d5 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -439,6 +439,8 @@ enum {
 #define AUDIT_ARCH_UNICORE	(EM_UNICORE|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_X86_64	(EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_XTENSA	(EM_XTENSA)
+#define AUDIT_ARCH_LOONGARCH32	(EM_LOONGARCH|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_LOONGARCH64	(EM_LOONGARCH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 
 #define AUDIT_PERM_EXEC		1
 #define AUDIT_PERM_WRITE	2
diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index f47e853546fa..ef38c2bc5ab7 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -51,6 +51,7 @@
 #define EM_RISCV	243	/* RISC-V */
 #define EM_BPF		247	/* Linux BPF - in-kernel virtual machine */
 #define EM_CSKY		252	/* C-SKY */
+#define EM_LOONGARCH	258	/* LoongArch */
 #define EM_FRV		0x5441	/* Fujitsu FR-V */
 
 /*
diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
index 7ce993e6786c..1e0ae3f554f6 100644
--- a/include/uapi/linux/elf.h
+++ b/include/uapi/linux/elf.h
@@ -436,6 +436,11 @@ typedef struct elf64_shdr {
 #define NT_MIPS_DSP	0x800		/* MIPS DSP ASE registers */
 #define NT_MIPS_FP_MODE	0x801		/* MIPS floating-point mode */
 #define NT_MIPS_MSA	0x802		/* MIPS SIMD registers */
+#define NT_LOONGARCH_CPUCFG	0xa00	/* LoongArch CPU config registers */
+#define NT_LOONGARCH_CSR	0xa01	/* LoongArch control and status registers */
+#define NT_LOONGARCH_LSX	0xa02	/* LoongArch Loongson SIMD Extension registers */
+#define NT_LOONGARCH_LASX	0xa03	/* LoongArch Loongson Advanced SIMD Extension registers */
+#define NT_LOONGARCH_LBT	0xa04	/* LoongArch Loongson Binary Translation registers */
 
 /* Note types with note name "GNU" */
 #define NT_GNU_PROPERTY_TYPE_0	5
diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h
index fb7e2ef60825..981016e05cfa 100644
--- a/include/uapi/linux/kexec.h
+++ b/include/uapi/linux/kexec.h
@@ -43,6 +43,7 @@
 #define KEXEC_ARCH_MIPS    ( 8 << 16)
 #define KEXEC_ARCH_AARCH64 (183 << 16)
 #define KEXEC_ARCH_RISCV   (243 << 16)
+#define KEXEC_ARCH_LOONGARCH	(258 << 16)
 
 /* The artificial cap on the number of segments passed to kexec_load. */
 #define KEXEC_SEGMENT_MAX 16
diff --git a/scripts/sorttable.c b/scripts/sorttable.c
index d00504c5f530..fba40e99f354 100644
--- a/scripts/sorttable.c
+++ b/scripts/sorttable.c
@@ -60,6 +60,10 @@
 #define EM_RISCV	243
 #endif
 
+#ifndef EM_LOONGARCH
+#define EM_LOONGARCH	258
+#endif
+
 static uint32_t (*r)(const uint32_t *);
 static uint16_t (*r2)(const uint16_t *);
 static uint64_t (*r8)(const uint64_t *);
@@ -313,6 +317,7 @@ static int do_file(char const *const fname, void *addr)
 	case EM_ARCOMPACT:
 	case EM_ARCV2:
 	case EM_ARM:
+	case EM_LOONGARCH:
 	case EM_MICROBLAZE:
 	case EM_MIPS:
 	case EM_XTENSA:
-- 
2.27.0
Re: [PATCH V3 03/22] LoongArch: Add elf-related definitions
Posted by WANG Xuerui 3 years, 9 months ago
Hi,

Why this patch is from V3? I guess it's by mistake so would you re-send 
a proper v10?

On 5/14/22 16:03, Huacai Chen wrote:
> Add elf-related definitions for LoongArch, including: EM_LOONGARCH,
> KEXEC_ARCH_LOONGARCH, AUDIT_ARCH_LOONGARCH32, AUDIT_ARCH_LOONGARCH64
> and NT_LOONGARCH_*.
>
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
>   include/uapi/linux/audit.h  | 2 ++
>   include/uapi/linux/elf-em.h | 1 +
>   include/uapi/linux/elf.h    | 5 +++++
>   include/uapi/linux/kexec.h  | 1 +
>   scripts/sorttable.c         | 5 +++++
>   5 files changed, 14 insertions(+)
>
> diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> index 8eda133ca4c1..7c1dc818b1d5 100644
> --- a/include/uapi/linux/audit.h
> +++ b/include/uapi/linux/audit.h
> @@ -439,6 +439,8 @@ enum {
>   #define AUDIT_ARCH_UNICORE	(EM_UNICORE|__AUDIT_ARCH_LE)
>   #define AUDIT_ARCH_X86_64	(EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
>   #define AUDIT_ARCH_XTENSA	(EM_XTENSA)
> +#define AUDIT_ARCH_LOONGARCH32	(EM_LOONGARCH|__AUDIT_ARCH_LE)
> +#define AUDIT_ARCH_LOONGARCH64	(EM_LOONGARCH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
>   
>   #define AUDIT_PERM_EXEC		1
>   #define AUDIT_PERM_WRITE	2
> diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
> index f47e853546fa..ef38c2bc5ab7 100644
> --- a/include/uapi/linux/elf-em.h
> +++ b/include/uapi/linux/elf-em.h
> @@ -51,6 +51,7 @@
>   #define EM_RISCV	243	/* RISC-V */
>   #define EM_BPF		247	/* Linux BPF - in-kernel virtual machine */
>   #define EM_CSKY		252	/* C-SKY */
> +#define EM_LOONGARCH	258	/* LoongArch */
>   #define EM_FRV		0x5441	/* Fujitsu FR-V */
>   
>   /*
> diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
> index 7ce993e6786c..1e0ae3f554f6 100644
> --- a/include/uapi/linux/elf.h
> +++ b/include/uapi/linux/elf.h
> @@ -436,6 +436,11 @@ typedef struct elf64_shdr {
>   #define NT_MIPS_DSP	0x800		/* MIPS DSP ASE registers */
>   #define NT_MIPS_FP_MODE	0x801		/* MIPS floating-point mode */
>   #define NT_MIPS_MSA	0x802		/* MIPS SIMD registers */
> +#define NT_LOONGARCH_CPUCFG	0xa00	/* LoongArch CPU config registers */
> +#define NT_LOONGARCH_CSR	0xa01	/* LoongArch control and status registers */
> +#define NT_LOONGARCH_LSX	0xa02	/* LoongArch Loongson SIMD Extension registers */
> +#define NT_LOONGARCH_LASX	0xa03	/* LoongArch Loongson Advanced SIMD Extension registers */
> +#define NT_LOONGARCH_LBT	0xa04	/* LoongArch Loongson Binary Translation registers */
>   
>   /* Note types with note name "GNU" */
>   #define NT_GNU_PROPERTY_TYPE_0	5
> diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h
> index fb7e2ef60825..981016e05cfa 100644
> --- a/include/uapi/linux/kexec.h
> +++ b/include/uapi/linux/kexec.h
> @@ -43,6 +43,7 @@
>   #define KEXEC_ARCH_MIPS    ( 8 << 16)
>   #define KEXEC_ARCH_AARCH64 (183 << 16)
>   #define KEXEC_ARCH_RISCV   (243 << 16)
> +#define KEXEC_ARCH_LOONGARCH	(258 << 16)
>   
>   /* The artificial cap on the number of segments passed to kexec_load. */
>   #define KEXEC_SEGMENT_MAX 16
> diff --git a/scripts/sorttable.c b/scripts/sorttable.c
> index d00504c5f530..fba40e99f354 100644
> --- a/scripts/sorttable.c
> +++ b/scripts/sorttable.c
> @@ -60,6 +60,10 @@
>   #define EM_RISCV	243
>   #endif
>   
> +#ifndef EM_LOONGARCH
> +#define EM_LOONGARCH	258
> +#endif
> +
>   static uint32_t (*r)(const uint32_t *);
>   static uint16_t (*r2)(const uint16_t *);
>   static uint64_t (*r8)(const uint64_t *);
> @@ -313,6 +317,7 @@ static int do_file(char const *const fname, void *addr)
>   	case EM_ARCOMPACT:
>   	case EM_ARCV2:
>   	case EM_ARM:
> +	case EM_LOONGARCH:
>   	case EM_MICROBLAZE:
>   	case EM_MIPS:
>   	case EM_XTENSA:
Re: [PATCH V3 03/22] LoongArch: Add elf-related definitions
Posted by Huacai Chen 3 years, 9 months ago
Hi, Xuerui,

On Sat, May 14, 2022 at 9:29 PM WANG Xuerui <kernel@xen0n.name> wrote:
>
> Hi,
>
> Why this patch is from V3? I guess it's by mistake so would you re-send
> a proper v10?
This is just a typo, it is really V10.

Huacai
>
> On 5/14/22 16:03, Huacai Chen wrote:
> > Add elf-related definitions for LoongArch, including: EM_LOONGARCH,
> > KEXEC_ARCH_LOONGARCH, AUDIT_ARCH_LOONGARCH32, AUDIT_ARCH_LOONGARCH64
> > and NT_LOONGARCH_*.
> >
> > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> > ---
> >   include/uapi/linux/audit.h  | 2 ++
> >   include/uapi/linux/elf-em.h | 1 +
> >   include/uapi/linux/elf.h    | 5 +++++
> >   include/uapi/linux/kexec.h  | 1 +
> >   scripts/sorttable.c         | 5 +++++
> >   5 files changed, 14 insertions(+)
> >
> > diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> > index 8eda133ca4c1..7c1dc818b1d5 100644
> > --- a/include/uapi/linux/audit.h
> > +++ b/include/uapi/linux/audit.h
> > @@ -439,6 +439,8 @@ enum {
> >   #define AUDIT_ARCH_UNICORE  (EM_UNICORE|__AUDIT_ARCH_LE)
> >   #define AUDIT_ARCH_X86_64   (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> >   #define AUDIT_ARCH_XTENSA   (EM_XTENSA)
> > +#define AUDIT_ARCH_LOONGARCH32       (EM_LOONGARCH|__AUDIT_ARCH_LE)
> > +#define AUDIT_ARCH_LOONGARCH64       (EM_LOONGARCH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> >
> >   #define AUDIT_PERM_EXEC             1
> >   #define AUDIT_PERM_WRITE    2
> > diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
> > index f47e853546fa..ef38c2bc5ab7 100644
> > --- a/include/uapi/linux/elf-em.h
> > +++ b/include/uapi/linux/elf-em.h
> > @@ -51,6 +51,7 @@
> >   #define EM_RISCV    243     /* RISC-V */
> >   #define EM_BPF              247     /* Linux BPF - in-kernel virtual machine */
> >   #define EM_CSKY             252     /* C-SKY */
> > +#define EM_LOONGARCH 258     /* LoongArch */
> >   #define EM_FRV              0x5441  /* Fujitsu FR-V */
> >
> >   /*
> > diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
> > index 7ce993e6786c..1e0ae3f554f6 100644
> > --- a/include/uapi/linux/elf.h
> > +++ b/include/uapi/linux/elf.h
> > @@ -436,6 +436,11 @@ typedef struct elf64_shdr {
> >   #define NT_MIPS_DSP 0x800           /* MIPS DSP ASE registers */
> >   #define NT_MIPS_FP_MODE     0x801           /* MIPS floating-point mode */
> >   #define NT_MIPS_MSA 0x802           /* MIPS SIMD registers */
> > +#define NT_LOONGARCH_CPUCFG  0xa00   /* LoongArch CPU config registers */
> > +#define NT_LOONGARCH_CSR     0xa01   /* LoongArch control and status registers */
> > +#define NT_LOONGARCH_LSX     0xa02   /* LoongArch Loongson SIMD Extension registers */
> > +#define NT_LOONGARCH_LASX    0xa03   /* LoongArch Loongson Advanced SIMD Extension registers */
> > +#define NT_LOONGARCH_LBT     0xa04   /* LoongArch Loongson Binary Translation registers */
> >
> >   /* Note types with note name "GNU" */
> >   #define NT_GNU_PROPERTY_TYPE_0      5
> > diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h
> > index fb7e2ef60825..981016e05cfa 100644
> > --- a/include/uapi/linux/kexec.h
> > +++ b/include/uapi/linux/kexec.h
> > @@ -43,6 +43,7 @@
> >   #define KEXEC_ARCH_MIPS    ( 8 << 16)
> >   #define KEXEC_ARCH_AARCH64 (183 << 16)
> >   #define KEXEC_ARCH_RISCV   (243 << 16)
> > +#define KEXEC_ARCH_LOONGARCH (258 << 16)
> >
> >   /* The artificial cap on the number of segments passed to kexec_load. */
> >   #define KEXEC_SEGMENT_MAX 16
> > diff --git a/scripts/sorttable.c b/scripts/sorttable.c
> > index d00504c5f530..fba40e99f354 100644
> > --- a/scripts/sorttable.c
> > +++ b/scripts/sorttable.c
> > @@ -60,6 +60,10 @@
> >   #define EM_RISCV    243
> >   #endif
> >
> > +#ifndef EM_LOONGARCH
> > +#define EM_LOONGARCH 258
> > +#endif
> > +
> >   static uint32_t (*r)(const uint32_t *);
> >   static uint16_t (*r2)(const uint16_t *);
> >   static uint64_t (*r8)(const uint64_t *);
> > @@ -313,6 +317,7 @@ static int do_file(char const *const fname, void *addr)
> >       case EM_ARCOMPACT:
> >       case EM_ARCV2:
> >       case EM_ARM:
> > +     case EM_LOONGARCH:
> >       case EM_MICROBLAZE:
> >       case EM_MIPS:
> >       case EM_XTENSA:
Re: [PATCH V3 03/22] LoongArch: Add elf-related definitions
Posted by WANG Xuerui 3 years, 9 months ago
On 5/14/22 22:11, Huacai Chen wrote:

> Hi, Xuerui,
>
> On Sat, May 14, 2022 at 9:29 PM WANG Xuerui <kernel@xen0n.name> wrote:
>> Hi,
>>
>> Why this patch is from V3? I guess it's by mistake so would you re-send
>> a proper v10?
> This is just a typo, it is really V10.
Okay, got it.
>
> Huacai
>> On 5/14/22 16:03, Huacai Chen wrote:
>>> Add elf-related definitions for LoongArch, including: EM_LOONGARCH,
>>> KEXEC_ARCH_LOONGARCH, AUDIT_ARCH_LOONGARCH32, AUDIT_ARCH_LOONGARCH64
>>> and NT_LOONGARCH_*.
>>>
>>> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
>>> ---
>>>    include/uapi/linux/audit.h  | 2 ++
>>>    include/uapi/linux/elf-em.h | 1 +
>>>    include/uapi/linux/elf.h    | 5 +++++
>>>    include/uapi/linux/kexec.h  | 1 +
>>>    scripts/sorttable.c         | 5 +++++
>>>    5 files changed, 14 insertions(+)

The code changes all look good to me, only minor typographic nit: please 
change "elf" to "ELF".

With that:

Reviewed-by: WANG Xuerui <git@xen0n.name>
Re: [PATCH V3 03/22] LoongArch: Add elf-related definitions
Posted by Huacai Chen 3 years, 9 months ago
Hi, Xuerui,

On Sun, May 15, 2022 at 12:13 PM WANG Xuerui <kernel@xen0n.name> wrote:
>
> On 5/14/22 22:11, Huacai Chen wrote:
>
> > Hi, Xuerui,
> >
> > On Sat, May 14, 2022 at 9:29 PM WANG Xuerui <kernel@xen0n.name> wrote:
> >> Hi,
> >>
> >> Why this patch is from V3? I guess it's by mistake so would you re-send
> >> a proper v10?
> > This is just a typo, it is really V10.
> Okay, got it.
> >
> > Huacai
> >> On 5/14/22 16:03, Huacai Chen wrote:
> >>> Add elf-related definitions for LoongArch, including: EM_LOONGARCH,
> >>> KEXEC_ARCH_LOONGARCH, AUDIT_ARCH_LOONGARCH32, AUDIT_ARCH_LOONGARCH64
> >>> and NT_LOONGARCH_*.
> >>>
> >>> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> >>> ---
> >>>    include/uapi/linux/audit.h  | 2 ++
> >>>    include/uapi/linux/elf-em.h | 1 +
> >>>    include/uapi/linux/elf.h    | 5 +++++
> >>>    include/uapi/linux/kexec.h  | 1 +
> >>>    scripts/sorttable.c         | 5 +++++
> >>>    5 files changed, 14 insertions(+)
>
> The code changes all look good to me, only minor typographic nit: please
> change "elf" to "ELF".
OK, thanks,

Huacai
>
> With that:
>
> Reviewed-by: WANG Xuerui <git@xen0n.name>
>