From: WANG Xuerui <i.qemu@xen0n.name>
To: Song Gao <gaosong@loongson.cn>, qemu-devel@nongnu.org
Cc: "Xiaojuan Yang" <yangxiaojuan@loongson.cn>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [PATCH v14 20/26] linux-user: Add LoongArch elf support
Date: Sun, 9 Jan 2022 17:25:33 +0800 [thread overview]
Message-ID: <e7e5bbae-d922-bcce-30c5-9fc12d42bbf4@xen0n.name> (raw)
In-Reply-To: <20220106094200.1801206-21-gaosong@loongson.cn>
On 1/6/22 17:41, Song Gao wrote:
> Signed-off-by: Song Gao<gaosong@loongson.cn>
> Signed-off-by: Xiaojuan Yang<yangxiaojuan@loongson.cn>
> Reviewed-by: Richard Henderson<richard.henderson@linaro.org>
> Reviewed-by: Philippe Mathieu-Daudé<f4bug@amsat.org>
> ---
> linux-user/elfload.c | 53 +++++++++++++++++++++++++++++
> linux-user/loongarch64/target_elf.h | 12 +++++++
> 2 files changed, 65 insertions(+)
> create mode 100644 linux-user/loongarch64/target_elf.h
>
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index 767f54c76d..2ee83778f2 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -914,6 +914,59 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUPPCState *en
>
> #endif
>
> +#ifdef TARGET_LOONGARCH64
> +
> +#define ELF_START_MMAP 0x80000000
> +
> +#define ELF_CLASS ELFCLASS64
> +#define ELF_ARCH EM_LOONGARCH
> +
> +#define elf_check_arch(x) ((x) == EM_LOONGARCH)
> +static inline void init_thread(struct target_pt_regs *regs,
> + struct image_info *infop)
> +{
> + regs->csr.crmd = 2 << 3;
This is just "1 << 4" and means to set the CSR.CRMD.PG bit, indicating
that page translation is enabled; it's better to explain this somehow.
(In writing this comment I realized you might be saying "0b10 << 3"
instead, because the only valid combinations for the DA and PG bits are
0b01 and 0b10; so "0b10 << 3" is also okay and maybe clearer.)
> + regs->csr.era = infop->entry;
> + regs->regs[3] = infop->start_stack;
> +}
> +
> +/* See linux kernel: arch/loongarch/include/asm/elf.h. */
> +#define ELF_NREG 45
> +typedef target_elf_greg_t target_elf_gregset_t[ELF_NREG];
> +
> +enum {
> + TARGET_EF_R0 = 0,
> + TARGET_EF_CSR_ERA = TARGET_EF_R0 + 32,
> + TARGET_EF_CSR_BADV = TARGET_EF_R0 + 33,
> +};
> +
> +static void elf_core_copy_regs(target_elf_gregset_t *regs,
> + const CPULoongArchState *env)
> +{
> + int i;
> +
> + (*regs)[TARGET_EF_R0] = 0;
> +
> + for (i = 1; i < ARRAY_SIZE(env->gpr); i++) {
> + (*regs)[TARGET_EF_R0 + i] = tswapreg(env->gpr[i]);
> + }
> +
> + (*regs)[TARGET_EF_CSR_ERA] = tswapreg(env->pc);
> + (*regs)[TARGET_EF_CSR_BADV] = tswapreg(env->badaddr);
> +}
> +
> +#define USE_ELF_CORE_DUMP
> +#define ELF_EXEC_PAGESIZE 4096
> +
> +#define ELF_HWCAP get_elf_hwcap()
> +
> +static uint32_t get_elf_hwcap(void)
> +{
> + return 0;
> +}
> +
> +#endif /* TARGET_LOONGARCH64 */
> +
> #ifdef TARGET_MIPS
>
> #define ELF_START_MMAP 0x80000000
> diff --git a/linux-user/loongarch64/target_elf.h b/linux-user/loongarch64/target_elf.h
> new file mode 100644
> index 0000000000..3c690bbf5b
> --- /dev/null
> +++ b/linux-user/loongarch64/target_elf.h
> @@ -0,0 +1,12 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (c) 2021 Loongson Technology Corporation Limited
> + */
> +
> +#ifndef LOONGARCH_TARGET_ELF_H
> +#define LOONGARCH_TARGET_ELF_H
> +static inline const char *cpu_get_model(uint32_t eflags)
> +{
> + return "Loongson-3A5000";
> +}
> +#endif
next prev parent reply other threads:[~2022-01-09 9:33 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-06 9:41 [PATCH v14 00/26] Add LoongArch linux-user emulation support Song Gao
2022-01-06 9:41 ` [PATCH v14 01/26] target/loongarch: Add README Song Gao
2022-01-09 9:24 ` WANG Xuerui
2022-01-06 9:41 ` [PATCH v14 02/26] target/loongarch: Add core definition Song Gao
2022-01-09 9:25 ` WANG Xuerui
2022-01-09 18:49 ` Richard Henderson
2022-01-10 12:34 ` gaosong
2022-01-10 15:20 ` WANG Xuerui
2022-01-10 13:00 ` gaosong
2022-01-10 15:11 ` WANG Xuerui
2022-01-12 9:28 ` gaosong
2022-01-12 10:17 ` gaosong
2022-01-12 10:26 ` WANG Xuerui
2022-01-06 9:41 ` [PATCH v14 03/26] target/loongarch: Add main translation routines Song Gao
2022-01-09 9:25 ` WANG Xuerui
2022-01-06 9:41 ` [PATCH v14 04/26] target/loongarch: Add fixed point arithmetic instruction translation Song Gao
2022-01-06 9:41 ` [PATCH v14 05/26] target/loongarch: Add fixed point shift " Song Gao
2022-01-06 9:41 ` [PATCH v14 06/26] target/loongarch: Add fixed point bit " Song Gao
2022-01-06 9:41 ` [PATCH v14 07/26] target/loongarch: Add fixed point load/store " Song Gao
2022-01-06 9:41 ` [PATCH v14 08/26] target/loongarch: Add fixed point atomic " Song Gao
2022-01-06 9:41 ` [PATCH v14 09/26] target/loongarch: Add fixed point extra " Song Gao
2022-01-06 9:41 ` [PATCH v14 10/26] target/loongarch: Add floating point arithmetic " Song Gao
2022-01-06 9:41 ` [PATCH v14 11/26] target/loongarch: Add floating point comparison " Song Gao
2022-01-06 9:41 ` [PATCH v14 12/26] target/loongarch: Add floating point conversion " Song Gao
2022-01-06 9:41 ` [PATCH v14 13/26] target/loongarch: Add floating point move " Song Gao
2022-01-06 9:41 ` [PATCH v14 14/26] target/loongarch: Add floating point load/store " Song Gao
2022-01-06 9:41 ` [PATCH v14 15/26] target/loongarch: Add branch " Song Gao
2022-01-06 9:41 ` [PATCH v14 16/26] target/loongarch: Add disassembler Song Gao
2022-01-09 9:25 ` WANG Xuerui
2022-01-09 18:51 ` Richard Henderson
2022-01-06 9:41 ` [PATCH v14 17/26] linux-user: Add LoongArch generic header files Song Gao
2022-01-06 9:41 ` [PATCH v14 18/26] linux-user: Add LoongArch specific structures Song Gao
2022-01-07 4:29 ` Richard Henderson
2022-01-06 9:41 ` [PATCH v14 19/26] linux-user: Add LoongArch signal support Song Gao
2022-01-07 4:58 ` Richard Henderson
2022-01-09 9:25 ` WANG Xuerui
2022-01-06 9:41 ` [PATCH v14 20/26] linux-user: Add LoongArch elf support Song Gao
2022-01-09 9:25 ` WANG Xuerui [this message]
2022-01-06 9:41 ` [PATCH v14 21/26] linux-user: Add LoongArch syscall support Song Gao
2022-01-09 9:25 ` WANG Xuerui
2022-01-06 9:41 ` [PATCH v14 22/26] linux-user: Add LoongArch cpu_loop support Song Gao
2022-01-09 9:25 ` WANG Xuerui
2022-01-06 9:41 ` [PATCH v14 23/26] default-configs: Add loongarch linux-user support Song Gao
2022-01-09 9:25 ` WANG Xuerui
2022-01-06 9:41 ` [PATCH v14 24/26] target/loongarch: Add target build suport Song Gao
2022-01-09 9:25 ` WANG Xuerui
2022-01-06 9:41 ` [PATCH v14 25/26] target/loongarch: 'make check-tcg' support Song Gao
2022-01-09 9:25 ` WANG Xuerui
2022-01-06 9:42 ` [PATCH v14 26/26] scripts: add loongarch64 binfmt config Song Gao
2022-01-09 9:25 ` WANG Xuerui
2022-01-07 5:01 ` [PATCH v14 00/26] Add LoongArch linux-user emulation support Richard Henderson
2022-01-07 7:59 ` gaosong
2022-01-09 5:09 ` WANG Xuerui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e7e5bbae-d922-bcce-30c5-9fc12d42bbf4@xen0n.name \
--to=i.qemu@xen0n.name \
--cc=f4bug@amsat.org \
--cc=gaosong@loongson.cn \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=yangxiaojuan@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).