[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 15/24] exec: Restrict inclusion of 'user/guest-base.h'
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 15/24] exec: Restrict inclusion of 'user/guest-base.h' |
Date: |
Thu, 18 Apr 2024 21:25:14 +0200 |
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>
---
include/exec/cpu-all.h | 3 ---
include/exec/cpu_ldst.h | 2 ++
include/user/guest-base.h | 6 ++++++
bsd-user/main.c | 1 +
linux-user/elfload.c | 1 +
linux-user/main.c | 1 +
6 files changed, 11 insertions(+), 3 deletions(-)
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 2c5a0a5c81..6d47d3114a 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -73,6 +73,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/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/linux-user/elfload.c b/linux-user/elfload.c
index fc60c01d57..9ed4baa2ac 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"
--
2.41.0
- Re: [PATCH 07/24] exec: Un-inline tlb_vaddr_to_host() and declare it in 'exec/cputlb.h', (continued)
- [PATCH 10/24] exec: Reduce tlb_set_dirty() declaration scope, Philippe Mathieu-Daudé, 2024/04/18
- [PATCH 11/24] exec: Move tlb_reset_dirty*() declarations to 'exec/cputlb.h', Philippe Mathieu-Daudé, 2024/04/18
- [PATCH 12/24] exec: Move CPUTLBEntry helpers to cputlb.c, Philippe Mathieu-Daudé, 2024/04/18
- [PATCH 14/24] exec: Rename 'exec/user/guest-base.h' as 'user/guest-base.h', Philippe Mathieu-Daudé, 2024/04/18
- [PATCH 15/24] exec: Restrict inclusion of 'user/guest-base.h',
Philippe Mathieu-Daudé <=
- [PATCH 19/24] gdbstub: Avoid including 'cpu.h' in 'gdbstub/helpers.h', Philippe Mathieu-Daudé, 2024/04/18
- [PATCH 21/24] plugins: Un-inline qemu_plugin_disable_mem_helpers(), Philippe Mathieu-Daudé, 2024/04/18
- [PATCH 23/24] exec: Remove 'disas/disas.h' from 'exec/log.h', Philippe Mathieu-Daudé, 2024/04/18
- [PATCH 13/24] target/sparc: Replace abi_ulong by uint32_t for TARGET_ABI32, Philippe Mathieu-Daudé, 2024/04/18
- [PATCH 16/24] exec: Move GUEST_ADDR_MAX definition to 'cpu_ldst.h', Philippe Mathieu-Daudé, 2024/04/18