[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 21/23] exec/cpu-all: Restrict inclusion of 'exec/user/guest-ba
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v2 21/23] exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h' |
Date: |
Tue, 12 Dec 2023 13:33:57 +0100 |
Declare 'have_guest_base' in "exec/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>
---
include/exec/cpu-all.h | 3 ---
include/exec/cpu_ldst.h | 2 ++
include/exec/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 95af418920..d2ddfae286 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 "exec/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 64e0319996..e039cc7f80 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -69,6 +69,8 @@
#if defined(CONFIG_USER_ONLY)
+#include "exec/user/guest-base.h"
+
#ifndef TARGET_TAGGED_ADDRESSES
static inline abi_ptr cpu_untagged_addr(CPUState *cs, abi_ptr x)
{
diff --git a/include/exec/user/guest-base.h b/include/exec/user/guest-base.h
index afe2ab7fbb..cf40151360 100644
--- a/include/exec/user/guest-base.h
+++ b/include/exec/user/guest-base.h
@@ -7,6 +7,12 @@
#ifndef EXEC_USER_GUEST_BASE_H
#define EXEC_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 e6014f517e..c331d727e1 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 "exec/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 debea5c355..a8c106ec0c 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -7,6 +7,7 @@
#include "qemu.h"
#include "exec/user/tswap-target.h"
+#include "exec/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 0cdaf30d34..84691d707b 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 "exec/user/guest-base.h"
#include "exec/exec-all.h"
#include "exec/gdbstub.h"
#include "gdbstub/user.h"
--
2.41.0
- [PATCH v2 14/23] exec/cpu-all: Remove unused tswapls() definitions, (continued)
- [PATCH v2 14/23] exec/cpu-all: Remove unused tswapls() definitions, Philippe Mathieu-Daudé, 2023/12/12
- [PATCH v2 16/23] exec: Move [b]tswapl() declarations to 'exec/user/tswap-target.h', Philippe Mathieu-Daudé, 2023/12/12
- [PATCH v2 18/23] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h', Philippe Mathieu-Daudé, 2023/12/12
- [PATCH v2 17/23] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation, Philippe Mathieu-Daudé, 2023/12/12
- [PATCH v2 19/23] exec/user: Do not include 'cpu.h' in 'abitypes.h', Philippe Mathieu-Daudé, 2023/12/12
- [PATCH v2 20/23] exec: Declare abi_ptr type in its own 'abi_ptr.h' header, Philippe Mathieu-Daudé, 2023/12/12
- [PATCH v2 21/23] exec/cpu-all: Restrict inclusion of 'exec/user/guest-base.h',
Philippe Mathieu-Daudé <=
- [PATCH v2 23/23] exec/cpu_ldst: Avoid including 'cpu.h', Philippe Mathieu-Daudé, 2023/12/12
- [PATCH v2 22/23] exec/cpu-all: Extract page-protection definitions to page-prot-common.h, Philippe Mathieu-Daudé, 2023/12/12
- Re: [PATCH v2 00/23] exec: Rework of various headers (user focused), Philippe Mathieu-Daudé, 2023/12/12