From: Warner Losh <imp@bsdimp.com>
To: qemu-devel@nongnu.org
Cc: Kyle Evans <kevans@freebsd.org>,
qemu-arm@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
Warner Losh <imp@bsdimp.com>, Stacey Son <sson@FreeBSD.org>,
Ajeet Singh <itachis@FreeBSD.org>,
Richard Henderson <richard.henderson@linaro.org>
Subject: [PULL 08/15] bsd-user:Add AArch64 improvements and signal handling functions
Date: Wed, 24 Jul 2024 16:04:41 -0600 [thread overview]
Message-ID: <20240724220449.10398-9-imp@bsdimp.com> (raw)
In-Reply-To: <20240724220449.10398-1-imp@bsdimp.com>
From: Stacey Son <sson@FreeBSD.org>
Added get_ucontext_sigreturn function to check processor state ensuring current execution mode is EL0 and no flags
indicating interrupts or exceptions are set.
Updated AArch64 code to use CF directly without reading/writing the entire processor state, improving efficiency.
Changed FP data structures to use Int128 instead of __uint128_t, leveraging QEMU's generic mechanism for referencing this type.
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Ajeet Singh <itachis@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20240707191128.10509-9-itachis@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/aarch64/signal.c | 20 +++++++++++++++++++-
bsd-user/aarch64/target_arch_cpu.h | 7 ++-----
bsd-user/aarch64/target_arch_reg.h | 2 +-
bsd-user/aarch64/target_arch_signal.h | 2 +-
bsd-user/qemu.h | 3 +++
5 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/bsd-user/aarch64/signal.c b/bsd-user/aarch64/signal.c
index 13faac8ce60..6bc73a798f3 100644
--- a/bsd-user/aarch64/signal.c
+++ b/bsd-user/aarch64/signal.c
@@ -21,7 +21,7 @@
#include "qemu.h"
/*
- * Compare to sendsig() in sys/arm64/arm64/machdep.c
+ * Compare to sendsig() in sys/arm64/arm64/exec_machdep.c
* Assumes that target stack frame memory is locked.
*/
abi_long set_sigtramp_args(CPUARMState *regs, int sig,
@@ -117,3 +117,21 @@ abi_long set_mcontext(CPUARMState *regs, target_mcontext_t *mcp, int srflag)
return err;
}
+
+/* Compare to sys_sigreturn() in arm64/arm64/machdep.c */
+abi_long get_ucontext_sigreturn(CPUARMState *regs, abi_ulong target_sf,
+ abi_ulong *target_uc)
+{
+ uint32_t pstate = pstate_read(regs);
+
+ *target_uc = 0;
+
+ if ((pstate & PSTATE_M) != PSTATE_MODE_EL0t ||
+ (pstate & (PSTATE_F | PSTATE_I | PSTATE_A | PSTATE_D)) != 0) {
+ return -TARGET_EINVAL;
+ }
+
+ *target_uc = target_sf;
+
+ return 0;
+}
diff --git a/bsd-user/aarch64/target_arch_cpu.h b/bsd-user/aarch64/target_arch_cpu.h
index 5c150bb7e9c..b288e0d069b 100644
--- a/bsd-user/aarch64/target_arch_cpu.h
+++ b/bsd-user/aarch64/target_arch_cpu.h
@@ -48,7 +48,6 @@ static inline void target_cpu_loop(CPUARMState *env)
CPUState *cs = env_cpu(env);
int trapnr, ec, fsc, si_code, si_signo;
uint64_t code, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8;
- uint32_t pstate;
abi_long ret;
for (;;) {
@@ -88,18 +87,16 @@ static inline void target_cpu_loop(CPUARMState *env)
* The carry bit is cleared for no error; set for error.
* See arm64/arm64/vm_machdep.c cpu_set_syscall_retval()
*/
- pstate = pstate_read(env);
if (ret >= 0) {
- pstate &= ~PSTATE_C;
+ env->CF = 0;
env->xregs[0] = ret;
} else if (ret == -TARGET_ERESTART) {
env->pc -= 4;
break;
} else if (ret != -TARGET_EJUSTRETURN) {
- pstate |= PSTATE_C;
+ env->CF = 1;
env->xregs[0] = -ret;
}
- pstate_write(env, pstate);
break;
case EXCP_INTERRUPT:
diff --git a/bsd-user/aarch64/target_arch_reg.h b/bsd-user/aarch64/target_arch_reg.h
index 5c7154f0c18..b53302e7f7a 100644
--- a/bsd-user/aarch64/target_arch_reg.h
+++ b/bsd-user/aarch64/target_arch_reg.h
@@ -31,7 +31,7 @@ typedef struct target_reg {
} target_reg_t;
typedef struct target_fpreg {
- __uint128_t fp_q[32];
+ Int128 fp_q[32];
uint32_t fp_sr;
uint32_t fp_cr;
} target_fpreg_t;
diff --git a/bsd-user/aarch64/target_arch_signal.h b/bsd-user/aarch64/target_arch_signal.h
index df171733166..bff752a67ab 100644
--- a/bsd-user/aarch64/target_arch_signal.h
+++ b/bsd-user/aarch64/target_arch_signal.h
@@ -49,7 +49,7 @@ struct target_gpregs {
};
struct target_fpregs {
- __uint128_t fp_q[32];
+ Int128 fp_q[32];
uint32_t fp_sr;
uint32_t fp_cr;
uint32_t fp_flags;
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 9d2fc7148eb..3736c417860 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -17,6 +17,9 @@
#ifndef QEMU_H
#define QEMU_H
+#include <sys/param.h>
+
+#include "qemu/int128.h"
#include "cpu.h"
#include "qemu/units.h"
#include "exec/cpu_ldst.h"
--
2.45.1
next prev parent reply other threads:[~2024-07-24 22:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-24 22:04 [PULL 00/15] Bsd user for 9.1 patches Warner Losh
2024-07-24 22:04 ` [PULL 01/15] bsd-user:Add CPU initialization and management functions Warner Losh
2024-07-24 22:04 ` [PULL 02/15] bsd-user:Add AArch64 register handling and related functions Warner Losh
2024-07-24 22:04 ` [PULL 03/15] bsd-user:Add ARM AArch64 support and capabilities Warner Losh
2024-07-24 22:04 ` [PULL 04/15] bsd-user:Add ARM AArch64 signal handling support Warner Losh
2024-07-24 22:04 ` [PULL 05/15] bsd-user:Add get_mcontext function for ARM AArch64 Warner Losh
2024-07-24 22:04 ` [PULL 06/15] bsd-user:Add setup_sigframe_arch " Warner Losh
2024-07-24 22:04 ` [PULL 07/15] bsd-user:Add set_mcontext " Warner Losh
2024-07-24 22:04 ` Warner Losh [this message]
2024-07-24 22:04 ` [PULL 09/15] bsd-user: Simplify the implementation of execve Warner Losh
2024-07-24 22:04 ` [PULL 10/15] bsd-user: Hard wire aarch64 to be 4k pages only Warner Losh
2024-07-24 22:04 ` [PULL 11/15] bsd-user: Sync fork_start/fork_end with linux-user Warner Losh
2024-07-24 22:04 ` [PULL 12/15] bsd-user: Define TARGET_SIGSTACK_ALIGN and use it to round stack Warner Losh
2024-07-24 22:04 ` [PULL 13/15] bsd-user: Make compile for non-linux user-mode stuff Warner Losh
2024-07-24 22:04 ` [PULL 14/15] bsd-user: Add aarch64 build to tree Warner Losh
2024-07-24 22:04 ` [PULL 15/15] bsd-user: Add target.h for aarch64 Warner Losh
2024-07-25 0:07 ` [PULL 00/15] Bsd user for 9.1 patches Richard Henderson
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=20240724220449.10398-9-imp@bsdimp.com \
--to=imp@bsdimp.com \
--cc=itachis@FreeBSD.org \
--cc=kevans@freebsd.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sson@FreeBSD.org \
/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).