[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/15] linux-user: Create special-errno.h
From: |
Richard Henderson |
Subject: |
[PULL 09/15] linux-user: Create special-errno.h |
Date: |
Mon, 20 Dec 2021 12:24:54 -0800 |
Pull the two internal errno used by qemu internally into their own
header file. This includes the one define required by safe-syscall.S.
Reviewed-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/cpu_loop-common.h | 1 +
linux-user/generic/target_errno_defs.h | 17 --------------
linux-user/signal-common.h | 2 ++
linux-user/special-errno.h | 32 ++++++++++++++++++++++++++
linux-user/syscall.c | 1 +
linux-user/safe-syscall.S | 2 +-
6 files changed, 37 insertions(+), 18 deletions(-)
create mode 100644 linux-user/special-errno.h
diff --git a/linux-user/cpu_loop-common.h b/linux-user/cpu_loop-common.h
index 8828af28a4..dc0042e4de 100644
--- a/linux-user/cpu_loop-common.h
+++ b/linux-user/cpu_loop-common.h
@@ -21,6 +21,7 @@
#define CPU_LOOP_COMMON_H
#include "exec/log.h"
+#include "special-errno.h"
#define EXCP_DUMP(env, fmt, ...) \
do { \
diff --git a/linux-user/generic/target_errno_defs.h
b/linux-user/generic/target_errno_defs.h
index bb37d88be9..c2f9d403e7 100644
--- a/linux-user/generic/target_errno_defs.h
+++ b/linux-user/generic/target_errno_defs.h
@@ -147,21 +147,4 @@
#define TARGET_ERFKILL 132 /* Operation not possible due to
RF-kill */
#define TARGET_EHWPOISON 133 /* Memory page has hardware error */
-/* QEMU internal, not visible to the guest. This is returned when a
- * system call should be restarted, to tell the main loop that it
- * should wind the guest PC backwards so it will re-execute the syscall
- * after handling any pending signals. They match with the ones the guest
- * kernel uses for the same purpose.
- */
-#define QEMU_ERESTARTSYS 512 /* Restart system call (if SA_RESTART) */
-
-/* QEMU internal, not visible to the guest. This is returned by the
- * do_sigreturn() code after a successful sigreturn syscall, to indicate
- * that it has correctly set the guest registers and so the main loop
- * should not touch them. We use the value the guest would use for
- * ERESTART_NOINTR (which is kernel internal) to guarantee that we won't
- * clash with a valid guest errno now or in the future.
- */
-#define QEMU_ESIGRETURN 513 /* Return from signal */
-
#endif
diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h
index b9f33bb44f..42aa479080 100644
--- a/linux-user/signal-common.h
+++ b/linux-user/signal-common.h
@@ -20,6 +20,8 @@
#ifndef SIGNAL_COMMON_H
#define SIGNAL_COMMON_H
+#include "special-errno.h"
+
/* Fallback addresses into sigtramp page. */
extern abi_ulong default_sigreturn;
extern abi_ulong default_rt_sigreturn;
diff --git a/linux-user/special-errno.h b/linux-user/special-errno.h
new file mode 100644
index 0000000000..4120455baa
--- /dev/null
+++ b/linux-user/special-errno.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * QEMU internal errno values for implementing user-only POSIX.
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2021 Linaro, Ltd.
+ */
+
+#ifndef SPECIAL_ERRNO_H
+#define SPECIAL_ERRNO_H
+
+/*
+ * All of these are QEMU internal, not visible to the guest.
+ * They should be chosen so as to not overlap with any host
+ * or guest errno.
+ */
+
+/*
+ * This is returned when a system call should be restarted, to tell the
+ * main loop that it should wind the guest PC backwards so it will
+ * re-execute the syscall after handling any pending signals.
+ */
+#define QEMU_ERESTARTSYS 512
+
+/*
+ * This is returned after a successful sigreturn syscall, to indicate
+ * that it has correctly set the guest registers and so the main loop
+ * should not touch them.
+ */
+#define QEMU_ESIGRETURN 513
+
+#endif /* SPECIAL_ERRNO_H */
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 2867be4cd3..f5bf6d155c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -136,6 +136,7 @@
#include "qemu/guest-random.h"
#include "qemu/selfmap.h"
#include "user/syscall-trace.h"
+#include "special-errno.h"
#include "qapi/error.h"
#include "fd-trans.h"
#include "tcg/tcg.h"
diff --git a/linux-user/safe-syscall.S b/linux-user/safe-syscall.S
index 7ddc997801..74f7e35694 100644
--- a/linux-user/safe-syscall.S
+++ b/linux-user/safe-syscall.S
@@ -10,7 +10,7 @@
* See the COPYING file in the top-level directory.
*/
-#include "target_errno_defs.h"
+#include "special-errno.h"
/* We have the correct host directory on our include path
* so that this will pull in the right fragment for the architecture.
--
2.25.1
- [PULL 00/15] *-user: simplify safe signal handling, Richard Henderson, 2021/12/20
- [PULL 04/15] linux-user/host/sparc64: Add safe-syscall.inc.S, Richard Henderson, 2021/12/20
- [PULL 02/15] linux-user: Move syscall error detection into safe_syscall_base, Richard Henderson, 2021/12/20
- [PULL 01/15] linux-user: Untabify all safe-syscall.inc.S, Richard Henderson, 2021/12/20
- [PULL 10/15] bsd-user: Create special-errno.h, Richard Henderson, 2021/12/20
- [PULL 14/15] meson: Move linux_user_ss to linux-user/, Richard Henderson, 2021/12/20
- [PULL 07/15] bsd-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS, Richard Henderson, 2021/12/20
- [PULL 03/15] linux-user/host/mips: Add safe-syscall.inc.S, Richard Henderson, 2021/12/20
- [PULL 12/15] common-user: Adjust system call return on FreeBSD, Richard Henderson, 2021/12/20
- [PULL 05/15] linux-user: Remove HAVE_SAFE_SYSCALL and hostdep.h, Richard Henderson, 2021/12/20
- [PULL 09/15] linux-user: Create special-errno.h,
Richard Henderson <=
- [PULL 15/15] meson: Move bsd_user_ss to bsd-user/, Richard Henderson, 2021/12/20
- [PULL 08/15] linux-user: Rename TARGET_QEMU_ESIGRETURN to QEMU_ESIGRETURN, Richard Henderson, 2021/12/20
- [PULL 13/15] linux-user: Move thunk.c from top-level, Richard Henderson, 2021/12/20
- [PULL 11/15] common-user: Move safe-syscall.* from linux-user, Richard Henderson, 2021/12/20
- [PULL 06/15] linux-user: Rename TARGET_ERESTARTSYS to QEMU_ERESTARTSYS, Richard Henderson, 2021/12/20
- Re: [PULL 00/15] *-user: simplify safe signal handling, Richard Henderson, 2021/12/20