aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2023-12-11 21:51:26 +0100
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2024-04-26 17:03:05 +0200
commit16aa8eaaace3f8eb2d14521705fdccab518388a3 (patch)
treeb208ad5804bffbe1acadb0673edada801a23c506
parentd3cbde7402fa44b1be898df0e13257e6fc399974 (diff)
downloadqemu-16aa8eaaace3f8eb2d14521705fdccab518388a3.tar.xz
exec: Restrict inclusion of 'user/guest-base.h'
Declare 'have_guest_base' in "user/guest-base.h". Very few files require this header, so explicitly include it there instead of "exec/cpu-all.h" which is used in many source files. Assert this user-specific header is only included from user emulation. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20231211212003.21686-23-philmd@linaro.org> Reviewed-by: Anton Johansson <anjo@rev.ng>
-rw-r--r--bsd-user/main.c1
-rw-r--r--include/exec/cpu-all.h3
-rw-r--r--include/exec/cpu_ldst.h2
-rw-r--r--include/user/guest-base.h6
-rw-r--r--linux-user/elfload.c1
-rw-r--r--linux-user/main.c1
6 files changed, 11 insertions, 3 deletions
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 01b313756e..29a629d877 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -36,6 +36,7 @@
#include "qemu/help_option.h"
#include "qemu/module.h"
#include "exec/exec-all.h"
+#include "user/guest-base.h"
#include "tcg/startup.h"
#include "qemu/timer.h"
#include "qemu/envlist.h"
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 027f19e052..e75ec13cd0 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -65,9 +65,6 @@
#if defined(CONFIG_USER_ONLY)
#include "exec/user/abitypes.h"
-#include "user/guest-base.h"
-
-extern bool have_guest_base;
/*
* If non-zero, the guest virtual address space is a contiguous subset
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index f3c2a3ca74..7d0a0412ad 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -74,6 +74,8 @@
#if defined(CONFIG_USER_ONLY)
+#include "user/guest-base.h"
+
#ifndef TARGET_TAGGED_ADDRESSES
static inline abi_ptr cpu_untagged_addr(CPUState *cs, abi_ptr x)
{
diff --git a/include/user/guest-base.h b/include/user/guest-base.h
index 1e42bca5db..055c1d14fe 100644
--- a/include/user/guest-base.h
+++ b/include/user/guest-base.h
@@ -7,6 +7,12 @@
#ifndef USER_GUEST_BASE_H
#define USER_GUEST_BASE_H
+#ifndef CONFIG_USER_ONLY
+#error Cannot include this header from system emulation
+#endif
+
extern uintptr_t guest_base;
+extern bool have_guest_base;
+
#endif
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 207455c1ba..f9461d2844 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -8,6 +8,7 @@
#include "qemu.h"
#include "user/tswap-target.h"
+#include "user/guest-base.h"
#include "user-internals.h"
#include "signal-common.h"
#include "loader.h"
diff --git a/linux-user/main.c b/linux-user/main.c
index 149e35432e..94e4c47f05 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -38,6 +38,7 @@
#include "qemu/help_option.h"
#include "qemu/module.h"
#include "qemu/plugin.h"
+#include "user/guest-base.h"
#include "exec/exec-all.h"
#include "exec/gdbstub.h"
#include "gdbstub/user.h"