aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2024-04-26 15:28:13 -0700
committerRichard Henderson <richard.henderson@linaro.org>2024-04-26 15:28:13 -0700
commitfd87be1dada5672f877e03c2ca8504458292c479 (patch)
tree0d16a4a1b07aa48ad251a83c37b5baf902da70a9 /include
parent77bcaf5f222fb19667738dc2ca7dec6172d69db7 (diff)
parent671558d290ffb93752d3245e7c5604b04b6dcdf2 (diff)
downloadqemu-fd87be1dada5672f877e03c2ca8504458292c479.zip
qemu-fd87be1dada5672f877e03c2ca8504458292c479.tar.gz
qemu-fd87be1dada5672f877e03c2ca8504458292c479.tar.bz2
Merge tag 'accel-20240426' of https://github.com/philmd/qemu into staging
Accelerators patches A lot of trivial cleanups and simplifications (moving methods around, adding/removing #include statements). Most notable changes: - Rename NEED_CPU_H -> COMPILING_PER_TARGET - Rename few template headers using the '.h.inc' suffix - Extract some definitions / declarations into their own header: - accel/tcg/user-retaddr.h (helper_retaddr) - include/exec/abi_ptr.h (abi_ptr) - include/exec/breakpoint.h (CPUBreakpoint, CPUWatchpoint) - include/exec/mmu-access-type.h (MMUAccessType) - include/user/tswap-target.h (tswapl, bswaptls) # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmYsAuEACgkQ4+MsLN6t # wN78Rg//V9UoE0U9Lh6Sd2WpcSAYP9D1CBa+iGXhrmel0utER1sQLu022nvcLdHc # XtCgtX3H0yECF8dPX02rVp8IbSlOv3c8N/a6BxD79cRGqgXBYR/dEUqfXqeLJn3l # a58YU3i7sLNQ0l7VnwTiBnI0lw170/xJl2B2mcR1SvWuH3dr5vTeIXNureu36ORo # rc0oqWHbw1Pyyn8ADE2kPyFCOiwPwvcOvAk8dXGfib+mNCwNVV+ZUtAPi711VD8d # 9VW2gu2sXwnWdpROrSugSw+aPVF4UjltL9qJEl5bxoqWFmlET1Zn2NpKvsocUXmh # CMQQS2Tr4LpaaVQJGxx0yUe0B65X5+gCkIhsMOubED7GRyTCjrkOPm6exz3ge6WV # YmIboggFAk3OjAzLs7yZVkWsTK1Y3+3eX0u7AWPUsUu7rCT/Toc6QxDS7eT2hJfq # UDXI355PGbImgiArQa+OsT7v1Le4/iQa+TfN4fdUDpxEdfaxhnijWh+E91CEp+w/ # Mq7db9Z1aMnhFKIKdkPYyfwB74yXQrmYchJ0QojZjbzqNGwkt9VeC7O9RcYjEaHM # hMIexwccxexqGH22wn8vPd6ZVKtiLaG4AXO0v6Dn2YJ7/zb/ntcI6lRZqdBAHKNK # MzkjTRRRR0wAfu8Lk8CaNNEqUP4Po43fbYymo6AZhIR8NqfApL0= # =ifBx # -----END PGP SIGNATURE----- # gpg: Signature made Fri 26 Apr 2024 12:39:13 PM PDT # gpg: using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE # gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [full] * tag 'accel-20240426' of https://github.com/philmd/qemu: (38 commits) plugins: Include missing 'qemu/bitmap.h' header hw/core: Avoid including the full 'hw/core/cpu.h' in 'tcg-cpu-ops.h' exec: Move CPUTLBEntry helpers to cputlb.c exec: Restrict inclusion of 'user/guest-base.h' exec: Rename 'exec/user/guest-base.h' as 'user/guest-base.h' exec: Restrict 'cpu_ldst.h' to TCG accelerator exec: Restrict TCG specific declarations of 'cputlb.h' exec: Declare CPUBreakpoint/CPUWatchpoint type in 'breakpoint.h' header exec: Declare MMUAccessType type in 'mmu-access-type.h' header exec: Declare abi_ptr type in its own 'abi_ptr.h' header exec/user: Do not include 'cpu.h' in 'abitypes.h' exec: Move [b]tswapl() declarations to 'exec/user/tswap-target.h' exec: Declare target_words_bigendian() in 'exec/tswap.h' exec/cpu-all: Remove unused tswapls() definitions exec/cpu-all: Remove unused 'qemu/thread.h' header exec/cpu-all: Reduce 'qemu/rcu.h' header inclusion accel/hvf: Use accel-specific per-vcpu @dirty field accel/nvmm: Use accel-specific per-vcpu @dirty field accel/whpx: Use accel-specific per-vcpu @dirty field accel/tcg: Rename helper-head.h -> helper-head.h.inc ... Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'include')
-rw-r--r--include/exec/abi_ptr.h33
-rw-r--r--include/exec/breakpoint.h30
-rw-r--r--include/exec/cpu-all.h16
-rw-r--r--include/exec/cpu-defs.h2
-rw-r--r--include/exec/cpu_ldst.h105
-rw-r--r--include/exec/cputlb.h5
-rw-r--r--include/exec/exec-all.h3
-rw-r--r--include/exec/helper-gen.h.inc2
-rw-r--r--include/exec/helper-head.h.inc (renamed from include/exec/helper-head.h)4
-rw-r--r--include/exec/helper-info.c.inc2
-rw-r--r--include/exec/helper-proto.h.inc2
-rw-r--r--include/exec/memop.h4
-rw-r--r--include/exec/memory.h4
-rw-r--r--include/exec/mmu-access-type.h18
-rw-r--r--include/exec/ram_addr.h1
-rw-r--r--include/exec/translator.h5
-rw-r--r--include/exec/tswap.h16
-rw-r--r--include/exec/user/abitypes.h8
-rw-r--r--include/exec/user/guest-base.h12
-rw-r--r--include/gdbstub/helpers.h12
-rw-r--r--include/hw/core/cpu.h42
-rw-r--r--include/hw/core/tcg-cpu-ops.h6
-rw-r--r--include/qemu/osdep.h2
-rw-r--r--include/qemu/plugin.h1
-rw-r--r--include/semihosting/uaccess.h4
-rw-r--r--include/sysemu/hvf.h8
-rw-r--r--include/sysemu/hvf_int.h1
-rw-r--r--include/sysemu/kvm.h6
-rw-r--r--include/sysemu/nvmm.h4
-rw-r--r--include/sysemu/whpx.h4
-rw-r--r--include/sysemu/xen.h4
-rw-r--r--include/user/guest-base.h18
-rw-r--r--include/user/tswap-target.h22
33 files changed, 210 insertions, 196 deletions
diff --git a/include/exec/abi_ptr.h b/include/exec/abi_ptr.h
new file mode 100644
index 0000000..2aedcce
--- /dev/null
+++ b/include/exec/abi_ptr.h
@@ -0,0 +1,33 @@
+/*
+ * QEMU abi_ptr type definitions
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+#ifndef EXEC_ABI_PTR_H
+#define EXEC_ABI_PTR_H
+
+#include "cpu-param.h"
+
+#if defined(CONFIG_USER_ONLY)
+/*
+ * sparc32plus has 64bit long but 32bit space address
+ * this can make bad result with g2h() and h2g()
+ */
+#if TARGET_VIRT_ADDR_SPACE_BITS <= 32
+typedef uint32_t abi_ptr;
+#define TARGET_ABI_FMT_ptr "%x"
+#else
+typedef uint64_t abi_ptr;
+#define TARGET_ABI_FMT_ptr "%"PRIx64
+#endif
+
+#else /* !CONFIG_USER_ONLY */
+
+#include "exec/target_long.h"
+
+typedef target_ulong abi_ptr;
+#define TARGET_ABI_FMT_ptr TARGET_FMT_lx
+
+#endif /* !CONFIG_USER_ONLY */
+
+#endif
diff --git a/include/exec/breakpoint.h b/include/exec/breakpoint.h
new file mode 100644
index 0000000..95f0482
--- /dev/null
+++ b/include/exec/breakpoint.h
@@ -0,0 +1,30 @@
+/*
+ * QEMU breakpoint & watchpoint definitions
+ *
+ * Copyright (c) 2012 SUSE LINUX Products GmbH
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef EXEC_BREAKPOINT_H
+#define EXEC_BREAKPOINT_H
+
+#include "qemu/queue.h"
+#include "exec/vaddr.h"
+#include "exec/memattrs.h"
+
+typedef struct CPUBreakpoint {
+ vaddr pc;
+ int flags; /* BP_* */
+ QTAILQ_ENTRY(CPUBreakpoint) entry;
+} CPUBreakpoint;
+
+typedef struct CPUWatchpoint {
+ vaddr vaddr;
+ vaddr len;
+ vaddr hitaddr;
+ MemTxAttrs hitattrs;
+ int flags; /* BP_* */
+ QTAILQ_ENTRY(CPUWatchpoint) entry;
+} CPUWatchpoint;
+
+#endif
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 1a6510f..e75ec13 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -22,9 +22,7 @@
#include "exec/cpu-common.h"
#include "exec/memory.h"
#include "exec/tswap.h"
-#include "qemu/thread.h"
#include "hw/core/cpu.h"
-#include "qemu/rcu.h"
/* some important defines:
*
@@ -38,16 +36,6 @@
#define BSWAP_NEEDED
#endif
-#if TARGET_LONG_SIZE == 4
-#define tswapl(s) tswap32(s)
-#define tswapls(s) tswap32s((uint32_t *)(s))
-#define bswaptls(s) bswap32s(s)
-#else
-#define tswapl(s) tswap64(s)
-#define tswapls(s) tswap64s((uint64_t *)(s))
-#define bswaptls(s) bswap64s(s)
-#endif
-
/* Target-endianness CPU memory access functions. These fit into the
* {ld,st}{type}{sign}{size}{endian}_p naming scheme described in bswap.h.
*/
@@ -77,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
@@ -391,6 +376,7 @@ static inline bool tlb_hit(uint64_t tlb_addr, vaddr addr)
#endif /* !CONFIG_USER_ONLY */
/* Validate correct placement of CPUArchState. */
+#include "cpu.h"
QEMU_BUILD_BUG_ON(offsetof(ArchCPU, parent_obj) != 0);
QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) != sizeof(CPUState));
diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
index 3915438..0dbef30 100644
--- a/include/exec/cpu-defs.h
+++ b/include/exec/cpu-defs.h
@@ -19,7 +19,7 @@
#ifndef CPU_DEFS_H
#define CPU_DEFS_H
-#ifndef NEED_CPU_H
+#ifndef COMPILING_PER_TARGET
#error cpu.h included from common code
#endif
diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h
index eb8f3f0..11ba377 100644
--- a/include/exec/cpu_ldst.h
+++ b/include/exec/cpu_ldst.h
@@ -1,5 +1,5 @@
/*
- * Software MMU support
+ * Software MMU support (per-target)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -62,21 +62,18 @@
#ifndef CPU_LDST_H
#define CPU_LDST_H
+#ifndef CONFIG_TCG
+#error Can only include this header with TCG
+#endif
+
#include "exec/memopidx.h"
+#include "exec/abi_ptr.h"
+#include "exec/mmu-access-type.h"
#include "qemu/int128.h"
-#include "cpu.h"
#if defined(CONFIG_USER_ONLY)
-/* sparc32plus has 64bit long but 32bit space address
- * this can make bad result with g2h() and h2g()
- */
-#if TARGET_VIRT_ADDR_SPACE_BITS <= 32
-typedef uint32_t abi_ptr;
-#define TARGET_ABI_FMT_ptr "%x"
-#else
-typedef uint64_t abi_ptr;
-#define TARGET_ABI_FMT_ptr "%"PRIx64
-#endif
+
+#include "user/guest-base.h"
#ifndef TARGET_TAGGED_ADDRESSES
static inline abi_ptr cpu_untagged_addr(CPUState *cs, abi_ptr x)
@@ -120,10 +117,8 @@ static inline bool guest_range_valid_untagged(abi_ulong start, abi_ulong len)
assert(h2g_valid(x)); \
h2g_nocheck(x); \
})
-#else
-typedef vaddr abi_ptr;
-#define TARGET_ABI_FMT_ptr VADDR_PRIx
-#endif
+
+#endif /* CONFIG_USER_ONLY */
uint32_t cpu_ldub_data(CPUArchState *env, abi_ptr ptr);
int cpu_ldsb_data(CPUArchState *env, abi_ptr ptr);
@@ -300,84 +295,6 @@ Int128 cpu_atomic_cmpxchgo_be_mmu(CPUArchState *env, abi_ptr addr,
Int128 cmpv, Int128 newv,
MemOpIdx oi, uintptr_t retaddr);
-#if defined(CONFIG_USER_ONLY)
-
-extern __thread uintptr_t helper_retaddr;
-
-static inline void set_helper_retaddr(uintptr_t ra)
-{
- helper_retaddr = ra;
- /*
- * Ensure that this write is visible to the SIGSEGV handler that
- * may be invoked due to a subsequent invalid memory operation.
- */
- signal_barrier();
-}
-
-static inline void clear_helper_retaddr(void)
-{
- /*
- * Ensure that previous memory operations have succeeded before
- * removing the data visible to the signal handler.
- */
- signal_barrier();
- helper_retaddr = 0;
-}
-
-#else
-
-#include "tcg/oversized-guest.h"
-
-static inline uint64_t tlb_read_idx(const CPUTLBEntry *entry,
- MMUAccessType access_type)
-{
- /* Do not rearrange the CPUTLBEntry structure members. */
- QEMU_BUILD_BUG_ON(offsetof(CPUTLBEntry, addr_read) !=
- MMU_DATA_LOAD * sizeof(uint64_t));
- QEMU_BUILD_BUG_ON(offsetof(CPUTLBEntry, addr_write) !=
- MMU_DATA_STORE * sizeof(uint64_t));
- QEMU_BUILD_BUG_ON(offsetof(CPUTLBEntry, addr_code) !=
- MMU_INST_FETCH * sizeof(uint64_t));
-
-#if TARGET_LONG_BITS == 32
- /* Use qatomic_read, in case of addr_write; only care about low bits. */
- const uint32_t *ptr = (uint32_t *)&entry->addr_idx[access_type];
- ptr += HOST_BIG_ENDIAN;
- return qatomic_read(ptr);
-#else
- const uint64_t *ptr = &entry->addr_idx[access_type];
-# if TCG_OVERSIZED_GUEST
- return *ptr;
-# else
- /* ofs might correspond to .addr_write, so use qatomic_read */
- return qatomic_read(ptr);
-# endif
-#endif
-}
-
-static inline uint64_t tlb_addr_write(const CPUTLBEntry *entry)
-{
- return tlb_read_idx(entry, MMU_DATA_STORE);
-}
-
-/* Find the TLB index corresponding to the mmu_idx + address pair. */
-static inline uintptr_t tlb_index(CPUState *cpu, uintptr_t mmu_idx,
- vaddr addr)
-{
- uintptr_t size_mask = cpu->neg.tlb.f[mmu_idx].mask >> CPU_TLB_ENTRY_BITS;
-
- return (addr >> TARGET_PAGE_BITS) & size_mask;
-}
-
-/* Find the TLB entry corresponding to the mmu_idx + address pair. */
-static inline CPUTLBEntry *tlb_entry(CPUState *cpu, uintptr_t mmu_idx,
- vaddr addr)
-{
- return &cpu->neg.tlb.f[mmu_idx].table[tlb_index(cpu, mmu_idx, addr)];
-}
-
-#endif /* defined(CONFIG_USER_ONLY) */
-
#if TARGET_BIG_ENDIAN
# define cpu_lduw_data cpu_lduw_be_data
# define cpu_ldsw_data cpu_ldsw_be_data
diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h
index 6da1462..ef18642 100644
--- a/include/exec/cputlb.h
+++ b/include/exec/cputlb.h
@@ -22,9 +22,14 @@
#include "exec/cpu-common.h"
+#ifdef CONFIG_TCG
+
#if !defined(CONFIG_USER_ONLY)
/* cputlb.c */
void tlb_protect_code(ram_addr_t ram_addr);
void tlb_unprotect_code(ram_addr_t ram_addr);
#endif
+
+#endif /* CONFIG_TCG */
+
#endif
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 3e53501..4c5e470 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -22,8 +22,10 @@
#include "cpu.h"
#if defined(CONFIG_USER_ONLY)
+#include "exec/abi_ptr.h"
#include "exec/cpu_ldst.h"
#endif
+#include "exec/mmu-access-type.h"
#include "exec/translation-block.h"
#include "qemu/clang-tsa.h"
@@ -654,7 +656,6 @@ static inline void mmap_unlock(void) {}
#define WITH_MMAP_LOCK_GUARD()
void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
-void tlb_set_dirty(CPUState *cpu, vaddr addr);
void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);
MemoryRegionSection *
diff --git a/include/exec/helper-gen.h.inc b/include/exec/helper-gen.h.inc
index c009641..d9fd3ed 100644
--- a/include/exec/helper-gen.h.inc
+++ b/include/exec/helper-gen.h.inc
@@ -8,7 +8,7 @@
#include "tcg/tcg.h"
#include "tcg/helper-info.h"
-#include "exec/helper-head.h"
+#include "exec/helper-head.h.inc"
#define DEF_HELPER_FLAGS_0(name, flags, ret) \
extern TCGHelperInfo glue(helper_info_, name); \
diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h.inc
index 28ceab0..5ef467a 100644
--- a/include/exec/helper-head.h
+++ b/include/exec/helper-head.h.inc
@@ -43,7 +43,7 @@
#define dh_ctype_noreturn G_NORETURN void
#define dh_ctype(t) dh_ctype_##t
-#ifdef NEED_CPU_H
+#ifdef COMPILING_PER_TARGET
# ifdef TARGET_LONG_BITS
# if TARGET_LONG_BITS == 32
# define dh_alias_tl i32
@@ -54,7 +54,7 @@
# endif
# endif
# define dh_ctype_tl target_ulong
-#endif
+#endif /* COMPILING_PER_TARGET */
/* We can't use glue() here because it falls foul of C preprocessor
recursive expansion rules. */
diff --git a/include/exec/helper-info.c.inc b/include/exec/helper-info.c.inc
index 530d2e6..c551736 100644
--- a/include/exec/helper-info.c.inc
+++ b/include/exec/helper-info.c.inc
@@ -7,7 +7,7 @@
#include "tcg/tcg.h"
#include "tcg/helper-info.h"
-#include "exec/helper-head.h"
+#include "exec/helper-head.h.inc"
/*
* Need one more level of indirection before stringification
diff --git a/include/exec/helper-proto.h.inc b/include/exec/helper-proto.h.inc
index c3aa666..f8e57e4 100644
--- a/include/exec/helper-proto.h.inc
+++ b/include/exec/helper-proto.h.inc
@@ -5,7 +5,7 @@
* Define HELPER_H for the header file to be expanded.
*/
-#include "exec/helper-head.h"
+#include "exec/helper-head.h.inc"
/*
* Work around an issue with --enable-lto, in which GCC's ipa-split pass
diff --git a/include/exec/memop.h b/include/exec/memop.h
index a86dc67..06417ff 100644
--- a/include/exec/memop.h
+++ b/include/exec/memop.h
@@ -35,7 +35,7 @@ typedef enum MemOp {
MO_LE = 0,
MO_BE = MO_BSWAP,
#endif
-#ifdef NEED_CPU_H
+#ifdef COMPILING_PER_TARGET
#if TARGET_BIG_ENDIAN
MO_TE = MO_BE,
#else
@@ -135,7 +135,7 @@ typedef enum MemOp {
MO_BESL = MO_BE | MO_SL,
MO_BESQ = MO_BE | MO_SQ,
-#ifdef NEED_CPU_H
+#ifdef COMPILING_PER_TARGET
MO_TEUW = MO_TE | MO_UW,
MO_TEUL = MO_TE | MO_UL,
MO_TEUQ = MO_TE | MO_UQ,
diff --git a/include/exec/memory.h b/include/exec/memory.h
index dbb1bad..dadb5cd 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -3107,7 +3107,7 @@ address_space_write_cached(MemoryRegionCache *cache, hwaddr addr,
MemTxResult address_space_set(AddressSpace *as, hwaddr addr,
uint8_t c, hwaddr len, MemTxAttrs attrs);
-#ifdef NEED_CPU_H
+#ifdef COMPILING_PER_TARGET
/* enum device_endian to MemOp. */
static inline MemOp devend_memop(enum device_endian end)
{
@@ -3125,7 +3125,7 @@ static inline MemOp devend_memop(enum device_endian end)
return (end == non_host_endianness) ? MO_BSWAP : 0;
#endif
}
-#endif
+#endif /* COMPILING_PER_TARGET */
/*
* Inhibit technologies that require discarding of pages in RAM blocks, e.g.,
diff --git a/include/exec/mmu-access-type.h b/include/exec/mmu-access-type.h
new file mode 100644
index 0000000..28bbb05
--- /dev/null
+++ b/include/exec/mmu-access-type.h
@@ -0,0 +1,18 @@
+/*
+ * QEMU MMU Access type definitions
+ *
+ * Copyright (c) 2012 SUSE LINUX Products GmbH
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef EXEC_MMU_ACCESS_TYPE_H
+#define EXEC_MMU_ACCESS_TYPE_H
+
+typedef enum MMUAccessType {
+ MMU_DATA_LOAD = 0,
+ MMU_DATA_STORE = 1,
+ MMU_INST_FETCH = 2
+#define MMU_ACCESS_COUNT 3
+} MMUAccessType;
+
+#endif
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index 07c8f86..891c44c 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -26,6 +26,7 @@
#include "exec/ramlist.h"
#include "exec/ramblock.h"
#include "exec/exec-all.h"
+#include "qemu/rcu.h"
extern uint64_t total_dirty_pages;
diff --git a/include/exec/translator.h b/include/exec/translator.h
index 2c4fb81..6cd937a 100644
--- a/include/exec/translator.h
+++ b/include/exec/translator.h
@@ -19,7 +19,10 @@
*/
#include "qemu/bswap.h"
-#include "exec/cpu_ldst.h" /* for abi_ptr */
+#include "exec/cpu-common.h"
+#include "exec/cpu-defs.h"
+#include "exec/abi_ptr.h"
+#include "cpu.h"
/**
* gen_intermediate_code
diff --git a/include/exec/tswap.h b/include/exec/tswap.h
index 68944a8..b7a4191 100644
--- a/include/exec/tswap.h
+++ b/include/exec/tswap.h
@@ -8,18 +8,28 @@
#ifndef TSWAP_H
#define TSWAP_H
-#include "hw/core/cpu.h"
#include "qemu/bswap.h"
+/**
+ * target_words_bigendian:
+ * Returns true if the (default) endianness of the target is big endian,
+ * false otherwise. Note that in target-specific code, you can use
+ * TARGET_BIG_ENDIAN directly instead. On the other hand, common
+ * code should normally never need to know about the endianness of the
+ * target, so please do *not* use this function unless you know very well
+ * what you are doing!
+ */
+bool target_words_bigendian(void);
+
/*
* If we're in target-specific code, we can hard-code the swapping
* condition, otherwise we have to do (slower) run-time checks.
*/
-#ifdef NEED_CPU_H
+#ifdef COMPILING_PER_TARGET
#define target_needs_bswap() (HOST_BIG_ENDIAN != TARGET_BIG_ENDIAN)
#else
#define target_needs_bswap() (target_words_bigendian() != HOST_BIG_ENDIAN)
-#endif
+#endif /* COMPILING_PER_TARGET */
static inline uint16_t tswap16(uint16_t s)
{
diff --git a/include/exec/user/abitypes.h b/include/exec/user/abitypes.h
index db4a670..3ec1969 100644
--- a/include/exec/user/abitypes.h
+++ b/include/exec/user/abitypes.h
@@ -1,7 +1,13 @@
#ifndef EXEC_USER_ABITYPES_H
#define EXEC_USER_ABITYPES_H
-#include "cpu.h"
+#ifndef CONFIG_USER_ONLY
+#error Cannot include this header from system emulation
+#endif
+
+#include "exec/cpu-defs.h"
+#include "exec/tswap.h"
+#include "user/tswap-target.h"
#ifdef TARGET_ABI32
#define TARGET_ABI_BITS 32
diff --git a/include/exec/user/guest-base.h b/include/exec/user/guest-base.h
deleted file mode 100644
index afe2ab7..0000000
--- a/include/exec/user/guest-base.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-/*
- * Declaration of guest_base.
- * Copyright (c) 2003 Fabrice Bellard
- */
-
-#ifndef EXEC_USER_GUEST_BASE_H
-#define EXEC_USER_GUEST_BASE_H
-
-extern uintptr_t guest_base;
-
-#endif
diff --git a/include/gdbstub/helpers.h b/include/gdbstub/helpers.h
index c573aef..26140ef 100644
--- a/include/gdbstub/helpers.h
+++ b/include/gdbstub/helpers.h
@@ -12,8 +12,12 @@
#ifndef _GDBSTUB_HELPERS_H_
#define _GDBSTUB_HELPERS_H_
-#ifdef NEED_CPU_H
-#include "cpu.h"
+#ifndef COMPILING_PER_TARGET
+#error "gdbstub helpers should only be included by target specific code"
+#endif
+
+#include "exec/tswap.h"
+#include "cpu-param.h"
/*
* The GDB remote protocol transfers values in target byte order. As
@@ -96,8 +100,4 @@ static inline uint8_t *gdb_get_reg_ptr(GByteArray *buf, int len)
#define ldtul_p(addr) ldl_p(addr)
#endif
-#else
-#error "gdbstub helpers should only be included by target specific code"
-#endif
-
#endif /* _GDBSTUB_HELPERS_H_ */
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index ec14f74..46b99a7 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -22,9 +22,11 @@
#include "hw/qdev-core.h"
#include "disas/dis-asm.h"
+#include "exec/breakpoint.h"
#include "exec/hwaddr.h"
#include "exec/vaddr.h"
#include "exec/memattrs.h"
+#include "exec/mmu-access-type.h"
#include "exec/tlb-common.h"
#include "qapi/qapi-types-run-state.h"
#include "qemu/bitmap.h"
@@ -80,13 +82,6 @@ DECLARE_CLASS_CHECKERS(CPUClass, CPU,
typedef struct ArchCPU CpuInstanceType; \
OBJECT_DECLARE_TYPE(ArchCPU, CpuClassType, CPU_MODULE_OBJ_NAME);
-typedef enum MMUAccessType {
- MMU_DATA_LOAD = 0,
- MMU_DATA_STORE = 1,
- MMU_INST_FETCH = 2
-#define MMU_ACCESS_COUNT 3
-} MMUAccessType;
-
typedef struct CPUWatchpoint CPUWatchpoint;
/* see accel-cpu.h */
@@ -353,21 +348,6 @@ typedef struct CPUNegativeOffsetState {
bool can_do_io;
} CPUNegativeOffsetState;
-typedef struct CPUBreakpoint {
- vaddr pc;
- int flags; /* BP_* */
- QTAILQ_ENTRY(CPUBreakpoint) entry;
-} CPUBreakpoint;
-
-struct CPUWatchpoint {
- vaddr vaddr;
- vaddr len;
- vaddr hitaddr;
- MemTxAttrs hitattrs;
- int flags; /* BP_* */
- QTAILQ_ENTRY(CPUWatchpoint) entry;
-};
-
struct KVMState;
struct kvm_run;
@@ -525,6 +505,7 @@ struct CPUState {
uint32_t kvm_fetch_index;
uint64_t dirty_pages;
int kvm_vcpu_stats_fd;
+ bool vcpu_dirty;
/* Use by accel-block: CPU is executing an ioctl() */
QemuLockCnt in_ioctl_lock;
@@ -546,8 +527,6 @@ struct CPUState {
int32_t exception_index;
AccelCPUState *accel;
- /* shared by kvm and hvf */
- bool vcpu_dirty;
/* Used to keep track of an outstanding cpu throttle thread for migration
* autoconverge
@@ -1169,20 +1148,9 @@ bool cpu_exec_realizefn(CPUState *cpu, Error **errp);
void cpu_exec_unrealizefn(CPUState *cpu);
void cpu_exec_reset_hold(CPUState *cpu);
-/**
- * target_words_bigendian:
- * Returns true if the (default) endianness of the target is big endian,
- * false otherwise. Note that in target-specific code, you can use
- * TARGET_BIG_ENDIAN directly instead. On the other hand, common
- * code should normally never need to know about the endianness of the
- * target, so please do *not* use this function unless you know very well
- * what you are doing!
- */
-bool target_words_bigendian(void);
-
const char *target_name(void);
-#ifdef NEED_CPU_H
+#ifdef COMPILING_PER_TARGET
#ifndef CONFIG_USER_ONLY
@@ -1197,7 +1165,7 @@ extern const VMStateDescription vmstate_cpu_common;
}
#endif /* !CONFIG_USER_ONLY */
-#endif /* NEED_CPU_H */
+#endif /* COMPILING_PER_TARGET */
#define UNASSIGNED_CPU_INDEX -1
#define UNASSIGNED_CLUSTER_INDEX -1
diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h
index dc1f16a..9387d38 100644
--- a/include/hw/core/tcg-cpu-ops.h
+++ b/include/hw/core/tcg-cpu-ops.h
@@ -10,7 +10,11 @@
#ifndef TCG_CPU_OPS_H
#define TCG_CPU_OPS_H
-#include "hw/core/cpu.h"
+#include "exec/breakpoint.h"
+#include "exec/hwaddr.h"
+#include "exec/memattrs.h"
+#include "exec/mmu-access-type.h"
+#include "exec/vaddr.h"
struct TCGCPUOps {
/**
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index c7053cd..f61edcf 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -32,7 +32,7 @@
#endif
#include "config-host.h"
-#ifdef NEED_CPU_H
+#ifdef COMPILING_PER_TARGET
#include CONFIG_TARGET
#else
#include "exec/poison.h"
diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h
index 12a96ce..41db748 100644
--- a/include/qemu/plugin.h
+++ b/include/qemu/plugin.h
@@ -13,6 +13,7 @@
#include "qemu/queue.h"
#include "qemu/option.h"
#include "qemu/plugin-event.h"
+#include "qemu/bitmap.h"
#include "exec/memopidx.h"
#include "hw/core/cpu.h"
diff --git a/include/semihosting/uaccess.h b/include/semihosting/uaccess.h
index 3963eaf..dd289af 100644
--- a/include/semihosting/uaccess.h
+++ b/include/semihosting/uaccess.h
@@ -14,7 +14,9 @@
#error Cannot include semihosting/uaccess.h from user emulation
#endif
-#include "cpu.h"
+#include "exec/cpu-common.h"
+#include "exec/cpu-defs.h"
+#include "exec/tswap.h"
#define get_user_u64(val, addr) \
({ uint64_t val_ = 0; \
diff --git a/include/sysemu/hvf.h b/include/sysemu/hvf.h
index 4a7c6af..730f927 100644
--- a/include/sysemu/hvf.h
+++ b/include/sysemu/hvf.h
@@ -16,7 +16,7 @@
#include "qemu/accel.h"
#include "qom/object.h"
-#ifdef NEED_CPU_H
+#ifdef COMPILING_PER_TARGET
#include "cpu.h"
#ifdef CONFIG_HVF
@@ -26,7 +26,7 @@ extern bool hvf_allowed;
#define hvf_enabled() 0
#endif /* !CONFIG_HVF */
-#endif /* NEED_CPU_H */
+#endif /* COMPILING_PER_TARGET */
#define TYPE_HVF_ACCEL ACCEL_CLASS_NAME("hvf")
@@ -34,7 +34,7 @@ typedef struct HVFState HVFState;
DECLARE_INSTANCE_CHECKER(HVFState, HVF_STATE,
TYPE_HVF_ACCEL)
-#ifdef NEED_CPU_H
+#ifdef COMPILING_PER_TARGET
struct hvf_sw_breakpoint {
vaddr pc;
vaddr saved_insn;
@@ -66,6 +66,6 @@ void hvf_arch_update_guest_debug(CPUState *cpu);
* Return whether the guest supports debugging.
*/
bool hvf_arch_supports_guest_debug(void);
-#endif /* NEED_CPU_H */
+#endif /* COMPILING_PER_TARGET */
#endif
diff --git a/include/sysemu/hvf_int.h b/include/sysemu/hvf_int.h
index 718bedd..4a327fd 100644
--- a/include/sysemu/hvf_int.h
+++ b/include/sysemu/hvf_int.h
@@ -55,6 +55,7 @@ struct AccelCPUState {
bool vtimer_masked;
sigset_t unblock_ipi_mask;
bool guest_debug_enabled;
+ bool dirty;
};
void assert_hvf_ok(hv_return_t ret);
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 47f9e8b..eaf801b 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -20,7 +20,7 @@
#include "qemu/accel.h"
#include "qom/object.h"
-#ifdef NEED_CPU_H
+#ifdef COMPILING_PER_TARGET
# ifdef CONFIG_KVM
# include <linux/kvm.h>
# define CONFIG_KVM_IS_POSSIBLE
@@ -210,7 +210,7 @@ bool kvm_arm_supports_user_irq(void);
int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr);
int kvm_on_sigbus(int code, void *addr);
-#ifdef NEED_CPU_H
+#ifdef COMPILING_PER_TARGET
#include "cpu.h"
void kvm_flush_coalesced_mmio_buffer(void);
@@ -435,7 +435,7 @@ void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len);
int kvm_physical_memory_addr_from_host(KVMState *s, void *ram_addr,
hwaddr *phys_addr);
-#endif /* NEED_CPU_H */
+#endif /* COMPILING_PER_TARGET */
void kvm_cpu_synchronize_state(CPUState *cpu);
diff --git a/include/sysemu/nvmm.h b/include/sysemu/nvmm.h
index be7bc9a..6971ddb 100644
--- a/include/sysemu/nvmm.h
+++ b/include/sysemu/nvmm.h
@@ -12,7 +12,7 @@
#ifndef QEMU_NVMM_H
#define QEMU_NVMM_H
-#ifdef NEED_CPU_H
+#ifdef COMPILING_PER_TARGET
#ifdef CONFIG_NVMM
@@ -24,6 +24,6 @@ int nvmm_enabled(void);
#endif /* CONFIG_NVMM */
-#endif /* NEED_CPU_H */
+#endif /* COMPILING_PER_TARGET */
#endif /* QEMU_NVMM_H */
diff --git a/include/sysemu/whpx.h b/include/sysemu/whpx.h
index 781ca5b..00ff409 100644
--- a/include/sysemu/whpx.h
+++ b/include/sysemu/whpx.h
@@ -15,7 +15,7 @@
#ifndef QEMU_WHPX_H
#define QEMU_WHPX_H
-#ifdef NEED_CPU_H
+#ifdef COMPILING_PER_TARGET
#ifdef CONFIG_WHPX
@@ -29,6 +29,6 @@ bool whpx_apic_in_platform(void);
#endif /* CONFIG_WHPX */
-#endif /* NEED_CPU_H */
+#endif /* COMPILING_PER_TARGET */
#endif /* QEMU_WHPX_H */
diff --git a/include/sysemu/xen.h b/include/sysemu/xen.h
index a9f591f..754ec2e6 100644
--- a/include/sysemu/xen.h
+++ b/include/sysemu/xen.h
@@ -16,13 +16,13 @@
#include "exec/cpu-common.h"
-#ifdef NEED_CPU_H
+#ifdef COMPILING_PER_TARGET
# ifdef CONFIG_XEN
# define CONFIG_XEN_IS_POSSIBLE
# endif
#else
# define CONFIG_XEN_IS_POSSIBLE
-#endif
+#endif /* COMPILING_PER_TARGET */
#ifdef CONFIG_XEN_IS_POSSIBLE
diff --git a/include/user/guest-base.h b/include/user/guest-base.h
new file mode 100644
index 0000000..055c1d1
--- /dev/null
+++ b/include/user/guest-base.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Declaration of guest_base.
+ * Copyright (c) 2003 Fabrice Bellard
+ */
+
+#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/include/user/tswap-target.h b/include/user/tswap-target.h
new file mode 100644
index 0000000..4719330
--- /dev/null
+++ b/include/user/tswap-target.h
@@ -0,0 +1,22 @@
+/*
+ * target-specific swap() definitions
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+#ifndef USER_TSWAP_H
+#define USER_TSWAP_H
+
+#include "exec/cpu-defs.h"
+#include "exec/tswap.h"
+
+#if TARGET_LONG_SIZE == 4
+#define tswapl(s) tswap32(s)
+#define bswaptls(s) bswap32s(s)
+#else
+#define tswapl(s) tswap64(s)
+#define bswaptls(s) bswap64s(s)
+#endif
+
+#endif