From: WANG Xuerui <i.qemu@xen0n.name>
To: Song Gao <gaosong@loongson.cn>, qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, laurent@vivier.eu,
"Xiaojuan Yang" <yangxiaojuan@loongson.cn>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [PATCH v15 4/9] linux-user: Add LoongArch syscall support
Date: Thu, 9 Jun 2022 18:04:27 +0800 [thread overview]
Message-ID: <3b6bb5a5-7da1-00d4-a3ee-8595fe6ea769@xen0n.name> (raw)
In-Reply-To: <20220609024209.2406188-5-gaosong@loongson.cn>
On 2022/6/9 10:42, Song Gao wrote:
> We should disable '__BITS_PER_LONG' at [1] before run gensyscalls.sh
>
> [1] arch/loongarch/include/uapi/asm/bitsperlong.h
I'm not sure why this is necessary, is this for building on 32-bit where
__BITS_PER_LONG are (incorrectly) reflecting the host bitness?
If this is the case, arch/riscv uses the same trick (they are defining
__BITS_PER_LONG as (__SIZEOF_POINTER__ * 8), which is essentially the
same), so they should fail without the hack described here as well. I
don't know if something else could be tweaked to get rid of this hack
(currently unable to investigate deeper for you, taking a break
reviewing this in the middle of my day job).
>
> 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/loongarch64/syscall_nr.h | 312 ++++++++++++++++++++++++
> linux-user/loongarch64/target_syscall.h | 48 ++++
> linux-user/syscall_defs.h | 12 +-
> scripts/gensyscalls.sh | 1 +
> 4 files changed, 368 insertions(+), 5 deletions(-)
> create mode 100644 linux-user/loongarch64/syscall_nr.h
> create mode 100644 linux-user/loongarch64/target_syscall.h
>
> [snip]
>
> diff --git a/linux-user/loongarch64/target_syscall.h b/linux-user/loongarch64/target_syscall.h
> new file mode 100644
> index 0000000000..8b5de52124
> --- /dev/null
> +++ b/linux-user/loongarch64/target_syscall.h
> @@ -0,0 +1,48 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (c) 2021 Loongson Technology Corporation Limited
> + */
> +
> +#ifndef LOONGARCH_TARGET_SYSCALL_H
> +#define LOONGARCH_TARGET_SYSCALL_H
> +
> +#include "qemu/units.h"
> +
> +/*
> + * this struct defines the way the registers are stored on the
> + * stack during a system call.
> + */
> +
> +struct target_pt_regs {
> + /* Saved main processor registers. */
> + target_ulong regs[32];
> +
> + /* Saved special registers. */
> + struct {
> + target_ulong era;
> + target_ulong badv;
> + target_ulong crmd;
> + target_ulong prmd;
> + target_ulong euen;
> + target_ulong ecfg;
> + target_ulong estat;
> + } csr;
> + target_ulong orig_a0;
> + target_ulong __last[0];
> +};
> +
> +#define UNAME_MACHINE "loongarch64"
> +#define UNAME_MINIMUM_RELEASE "5.19.0"
> +
> +#define TARGET_MCL_CURRENT 1
> +#define TARGET_MCL_FUTURE 2
> +#define TARGET_MCL_ONFAULT 4
> +
> +#define TARGET_FORCE_SHMLBA
> +
> +static inline abi_ulong target_shmlba(CPULoongArchState *env)
> +{
> + return 64 * KiB;
> +}
> +
> +#endif
> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
> index 4587b62ac9..b5b9a02816 100644
> --- a/linux-user/syscall_defs.h
> +++ b/linux-user/syscall_defs.h
> @@ -74,7 +74,7 @@
> || defined(TARGET_M68K) || defined(TARGET_CRIS) \
> || defined(TARGET_S390X) || defined(TARGET_OPENRISC) \
> || defined(TARGET_NIOS2) || defined(TARGET_RISCV) \
> - || defined(TARGET_XTENSA)
> + || defined(TARGET_XTENSA) || defined(TARGET_LOONGARCH64)
>
> #define TARGET_IOC_SIZEBITS 14
> #define TARGET_IOC_DIRBITS 2
> @@ -2084,8 +2084,9 @@ struct target_stat64 {
> abi_ulong __unused5;
> };
>
> -#elif defined(TARGET_OPENRISC) || defined(TARGET_NIOS2) \
> - || defined(TARGET_RISCV) || defined(TARGET_HEXAGON)
> +#elif defined(TARGET_OPENRISC) || defined(TARGET_NIOS2) || \
> + defined(TARGET_RISCV) || defined(TARGET_HEXAGON) || \
> + defined(TARGET_LOONGARCH64)
>
> /* These are the asm-generic versions of the stat and stat64 structures */
The finalized LoongArch system call interface doesn't include stat,
fstat or newfstatat. So do we still have to pull in the definitions for
stat structures?
>
> @@ -2113,7 +2114,7 @@ struct target_stat {
> unsigned int __unused5;
> };
>
> -#if !defined(TARGET_RISCV64)
> +#if !defined(TARGET_RISCV64) && !defined(TARGET_LOONGARCH64)
> #define TARGET_HAS_STRUCT_STAT64
> struct target_stat64 {
> uint64_t st_dev;
Similarly here.
> @@ -2258,7 +2259,8 @@ struct target_statfs64 {
> };
> #elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
> defined(TARGET_SPARC64) || defined(TARGET_AARCH64) || \
> - defined(TARGET_RISCV)) && !defined(TARGET_ABI32)
> + defined(TARGET_RISCV) || defined(TARGET_LOONGARCH64)) && \
> + !defined(TARGET_ABI32)
> struct target_statfs {
> abi_long f_type;
> abi_long f_bsize;
> diff --git a/scripts/gensyscalls.sh b/scripts/gensyscalls.sh
> index 8fb450e3c9..b69e1938ab 100755
> --- a/scripts/gensyscalls.sh
> +++ b/scripts/gensyscalls.sh
> @@ -99,4 +99,5 @@ generate_syscall_nr openrisc 32 "$output/linux-user/openrisc/syscall_nr.h"
> generate_syscall_nr riscv 32 "$output/linux-user/riscv/syscall32_nr.h"
> generate_syscall_nr riscv 64 "$output/linux-user/riscv/syscall64_nr.h"
> generate_syscall_nr hexagon 32 "$output/linux-user/hexagon/syscall_nr.h"
> +generate_syscall_nr loongarch 64 "$output/linux-user/loongarch64/syscall_nr.h"
> rm -fr "$TMP"
next prev parent reply other threads:[~2022-06-09 12:22 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 2:42 [PATCH v15 0/9] Add LoongArch linux-user emulation support Song Gao
2022-06-09 2:42 ` [PATCH v15 1/9] linux-user: Add LoongArch generic header files Song Gao
2022-06-09 9:54 ` WANG Xuerui
2022-06-09 2:42 ` [PATCH v15 2/9] linux-user: Add LoongArch signal support Song Gao
2022-06-09 18:00 ` Richard Henderson
2022-06-09 2:42 ` [PATCH v15 3/9] linux-user: Add LoongArch elf support Song Gao
2022-06-09 2:42 ` [PATCH v15 4/9] linux-user: Add LoongArch syscall support Song Gao
2022-06-09 10:04 ` WANG Xuerui [this message]
2022-06-10 1:15 ` gaosong
2022-06-09 2:42 ` [PATCH v15 5/9] linux-user: Add LoongArch cpu_loop support Song Gao
2022-06-09 2:42 ` [PATCH v15 6/9] default-configs: Add loongarch linux-user support Song Gao
2022-06-09 10:11 ` WANG Xuerui
2022-06-09 18:14 ` Richard Henderson
2022-06-09 2:42 ` [PATCH v15 7/9] scripts: add loongarch64 binfmt config Song Gao
2022-06-09 2:42 ` [PATCH v15 8/9] target/loongarch: Adjust functions and structure to support user-mode Song Gao
2022-06-09 10:18 ` WANG Xuerui
2022-06-09 18:42 ` Richard Henderson
2022-06-10 6:53 ` gaosong
2022-06-10 22:45 ` Richard Henderson
2022-06-11 3:10 ` gaosong
2022-06-11 16:06 ` Richard Henderson
2022-06-13 3:50 ` gaosong
2022-06-13 16:05 ` Richard Henderson
2022-06-09 2:42 ` [PATCH v15 9/9] target/loongarch: Update README Song Gao
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=3b6bb5a5-7da1-00d4-a3ee-8595fe6ea769@xen0n.name \
--to=i.qemu@xen0n.name \
--cc=f4bug@amsat.org \
--cc=gaosong@loongson.cn \
--cc=laurent@vivier.eu \
--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).