Skip to content

Commit

Permalink
exec/cpu: Extract page-protection definitions to page-protection.h
Browse files Browse the repository at this point in the history
Extract page-protection definitions from "exec/cpu-all.h"
to "exec/page-protection.h".

The list of files requiring the new header was generated
using:

$ git grep -wE \
  'PAGE_(READ|WRITE|EXEC|RWX|VALID|ANON|RESERVED|TARGET_.|PASSTHROUGH)'

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Acked-by: Nicholas Piggin <[email protected]>
Acked-by: Richard Henderson <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
philmd committed May 6, 2024
1 parent 7dd1259 commit 74781c0
Show file tree
Hide file tree
Showing 59 changed files with 100 additions and 30 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ F: include/exec/target_long.h
F: include/exec/helper*.h
F: include/exec/helper*.h.inc
F: include/exec/helper-info.c.inc
F: include/exec/page-protection.h
F: include/sysemu/cpus.h
F: include/sysemu/tcg.h
F: include/hw/core/tcg-cpu-ops.h
Expand Down
1 change: 1 addition & 0 deletions accel/tcg/cputlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "qemu/main-loop.h"
#include "hw/core/tcg-cpu-ops.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "exec/memory.h"
#include "exec/cpu_ldst.h"
#include "exec/cputlb.h"
Expand Down
1 change: 1 addition & 0 deletions accel/tcg/tb-maint.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "exec/cputlb.h"
#include "exec/log.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "exec/tb-flush.h"
#include "exec/translate-all.h"
#include "sysemu/tcg.h"
Expand Down
1 change: 1 addition & 0 deletions accel/tcg/user-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "qemu/rcu.h"
#include "exec/cpu_ldst.h"
#include "exec/translate-all.h"
#include "exec/page-protection.h"
#include "exec/helper-proto.h"
#include "qemu/atomic128.h"
#include "trace/trace-root.h"
Expand Down
1 change: 1 addition & 0 deletions bsd-user/bsd-mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include <fcntl.h>

#include "qemu-bsd.h"
#include "exec/page-protection.h"

extern struct bsd_shm_regions bsd_shm_regions[];
extern abi_ulong target_brk;
Expand Down
1 change: 1 addition & 0 deletions bsd-user/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
#include "exec/page-protection.h"

#include "qemu.h"

Expand Down
1 change: 1 addition & 0 deletions bsd-user/qemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ extern char **environ;
#include "target_os_signal.h"
#include "target.h"
#include "exec/gdbstub.h"
#include "exec/page-protection.h"
#include "qemu/clang-tsa.h"

#include "qemu-os.h"
Expand Down
1 change: 1 addition & 0 deletions bsd-user/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu.h"
#include "exec/page-protection.h"
#include "user/tswap-target.h"
#include "gdbstub/user.h"
#include "signal-common.h"
Expand Down
1 change: 1 addition & 0 deletions cpu-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "qapi/error.h"

#include "exec/target_page.h"
#include "exec/page-protection.h"
#include "hw/qdev-core.h"
#include "hw/qdev-properties.h"
#include "qemu/error-report.h"
Expand Down
1 change: 1 addition & 0 deletions hw/ppc/ppc440_bamboo.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "qemu/units.h"
#include "qemu/datadir.h"
#include "qemu/error-report.h"
#include "exec/page-protection.h"
#include "net/net.h"
#include "hw/pci/pci.h"
#include "hw/boards.h"
Expand Down
1 change: 1 addition & 0 deletions hw/ppc/sam460ex.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "kvm_ppc.h"
#include "sysemu/device_tree.h"
#include "sysemu/block-backend.h"
#include "exec/page-protection.h"
#include "hw/loader.h"
#include "elf.h"
#include "exec/memory.h"
Expand Down
1 change: 1 addition & 0 deletions hw/ppc/virtex_ml507.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "qemu/osdep.h"
#include "qemu/datadir.h"
#include "qemu/units.h"
#include "exec/page-protection.h"
#include "cpu.h"
#include "hw/sysbus.h"
#include "hw/char/serial.h"
Expand Down
1 change: 1 addition & 0 deletions include/exec/cpu-all.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#ifndef CPU_ALL_H
#define CPU_ALL_H

#include "exec/page-protection.h"
#include "exec/cpu-common.h"
#include "exec/memory.h"
#include "exec/tswap.h"
Expand Down
31 changes: 1 addition & 30 deletions include/exec/cpu-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#endif
#include "hw/core/cpu.h"
#include "tcg/debug-assert.h"
#include "exec/page-protection.h"

#define EXCP_INTERRUPT 0x10000 /* async interruption */
#define EXCP_HLT 0x10001 /* hlt instruction reached */
Expand Down Expand Up @@ -208,36 +209,6 @@ G_NORETURN void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc);
G_NORETURN void cpu_loop_exit(CPUState *cpu);
G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc);

/* same as PROT_xxx */
#define PAGE_READ 0x0001
#define PAGE_WRITE 0x0002
#define PAGE_EXEC 0x0004
#define PAGE_RWX (PAGE_READ | PAGE_WRITE | PAGE_EXEC)
#define PAGE_VALID 0x0008
/*
* Original state of the write flag (used when tracking self-modifying code)
*/
#define PAGE_WRITE_ORG 0x0010
/*
* Invalidate the TLB entry immediately, helpful for s390x
* Low-Address-Protection. Used with PAGE_WRITE in tlb_set_page_with_attrs()
*/
#define PAGE_WRITE_INV 0x0020
/* For use with page_set_flags: page is being replaced; target_data cleared. */
#define PAGE_RESET 0x0040
/* For linux-user, indicates that the page is MAP_ANON. */
#define PAGE_ANON 0x0080

/* Target-specific bits that will be used via page_get_flags(). */
#define PAGE_TARGET_1 0x0200
#define PAGE_TARGET_2 0x0400

/*
* For linux-user, indicates that the page is mapped with the same semantics
* in both guest and host.
*/
#define PAGE_PASSTHROUGH 0x0800

/* accel/tcg/cpu-exec.c */
int cpu_exec(CPUState *cpu);

Expand Down
41 changes: 41 additions & 0 deletions include/exec/page-protection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* QEMU page protection definitions.
*
* Copyright (c) 2003 Fabrice Bellard
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#ifndef EXEC_PAGE_PROT_COMMON_H
#define EXEC_PAGE_PROT_COMMON_H

/* same as PROT_xxx */
#define PAGE_READ 0x0001
#define PAGE_WRITE 0x0002
#define PAGE_EXEC 0x0004
#define PAGE_RWX (PAGE_READ | PAGE_WRITE | PAGE_EXEC)
#define PAGE_VALID 0x0008
/*
* Original state of the write flag (used when tracking self-modifying code)
*/
#define PAGE_WRITE_ORG 0x0010
/*
* Invalidate the TLB entry immediately, helpful for s390x
* Low-Address-Protection. Used with PAGE_WRITE in tlb_set_page_with_attrs()
*/
#define PAGE_WRITE_INV 0x0020
/* For use with page_set_flags: page is being replaced; target_data cleared. */
#define PAGE_RESET 0x0040
/* For linux-user, indicates that the page is MAP_ANON. */
#define PAGE_ANON 0x0080

/* Target-specific bits that will be used via page_get_flags(). */
#define PAGE_TARGET_1 0x0200
#define PAGE_TARGET_2 0x0400

/*
* For linux-user, indicates that the page is mapped with the same semantics
* in both guest and host.
*/
#define PAGE_PASSTHROUGH 0x0800

#endif
1 change: 1 addition & 0 deletions include/semihosting/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "exec/cpu-common.h"
#include "exec/cpu-defs.h"
#include "exec/tswap.h"
#include "exec/page-protection.h"

#define get_user_u64(val, addr) \
({ uint64_t val_ = 0; \
Expand Down
1 change: 1 addition & 0 deletions linux-user/arm/cpu_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "cpu_loop-common.h"
#include "signal-common.h"
#include "semihosting/common-semi.h"
#include "exec/page-protection.h"
#include "target/arm/syndrome.h"

#define get_user_code_u32(x, gaddr, env) \
Expand Down
1 change: 1 addition & 0 deletions linux-user/elfload.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "qemu.h"
#include "user/tswap-target.h"
#include "exec/page-protection.h"
#include "user/guest-base.h"
#include "user-internals.h"
#include "signal-common.h"
Expand Down
1 change: 1 addition & 0 deletions linux-user/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <sys/shm.h>
#include "trace.h"
#include "exec/log.h"
#include "exec/page-protection.h"
#include "qemu.h"
#include "user-internals.h"
#include "user-mmap.h"
Expand Down
1 change: 1 addition & 0 deletions linux-user/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "qemu/osdep.h"
#include "qemu/bitops.h"
#include "gdbstub/user.h"
#include "exec/page-protection.h"
#include "hw/core/tcg-cpu-ops.h"

#include <sys/ucontext.h>
Expand Down
1 change: 1 addition & 0 deletions linux-user/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "qemu/plugin.h"
#include "tcg/startup.h"
#include "target_mman.h"
#include "exec/page-protection.h"
#include <elf.h>
#include <endian.h>
#include <grp.h>
Expand Down
1 change: 1 addition & 0 deletions system/physmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#endif /* CONFIG_TCG */

#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "exec/target_page.h"
#include "hw/qdev-core.h"
#include "hw/qdev-properties.h"
Expand Down
1 change: 1 addition & 0 deletions target/alpha/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "fpu/softfloat-types.h"
#include "exec/helper-proto.h"
#include "qemu/qemu-print.h"
Expand Down
1 change: 1 addition & 0 deletions target/arm/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "cpu-qom.h"
#include "exec/cpu-defs.h"
#include "exec/gdbstub.h"
#include "exec/page-protection.h"
#include "qapi/qapi-types-common.h"
#include "target/arm/multiprocessing.h"
#include "target/arm/gtimer.h"
Expand Down
1 change: 1 addition & 0 deletions target/arm/ptw.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "qemu/range.h"
#include "qemu/main-loop.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "cpu.h"
#include "internals.h"
#include "cpu-features.h"
Expand Down
1 change: 1 addition & 0 deletions target/arm/tcg/m_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "qemu/bitops.h"
#include "qemu/log.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#ifdef CONFIG_TCG
#include "exec/cpu_ldst.h"
#include "semihosting/common-semi.h"
Expand Down
1 change: 1 addition & 0 deletions target/arm/tcg/mte_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "cpu.h"
#include "internals.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "exec/ram_addr.h"
#include "exec/cpu_ldst.h"
#include "exec/helper-proto.h"
Expand Down
1 change: 1 addition & 0 deletions target/arm/tcg/sve_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "cpu.h"
#include "internals.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "exec/helper-proto.h"
#include "tcg/tcg-gvec-desc.h"
#include "fpu/softfloat.h"
Expand Down
1 change: 1 addition & 0 deletions target/avr/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "cpu.h"
#include "hw/core/tcg-cpu-ops.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "exec/cpu_ldst.h"
#include "exec/address-spaces.h"
#include "exec/helper-proto.h"
Expand Down
1 change: 1 addition & 0 deletions target/cris/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "mmu.h"

#ifdef DEBUG
Expand Down
1 change: 1 addition & 0 deletions target/hppa/mem_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "exec/helper-proto.h"
#include "hw/core/cpu.h"
#include "trace.h"
Expand Down
1 change: 1 addition & 0 deletions target/hppa/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "disas/disas.h"
#include "qemu/host-utils.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "tcg/tcg-op.h"
#include "tcg/tcg-op-gvec.h"
#include "exec/helper-proto.h"
Expand Down
1 change: 1 addition & 0 deletions target/i386/tcg/sysemu/excp_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "cpu.h"
#include "exec/cpu_ldst.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "tcg/helper-tcg.h"

typedef struct TranslateParams {
Expand Down
1 change: 1 addition & 0 deletions target/loongarch/tcg/tlb_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "internals.h"
#include "exec/helper-proto.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "exec/cpu_ldst.h"
#include "exec/log.h"
#include "cpu-csr.h"
Expand Down
1 change: 1 addition & 0 deletions target/m68k/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "exec/gdbstub.h"
#include "exec/helper-proto.h"
#include "gdbstub/helpers.h"
Expand Down
1 change: 1 addition & 0 deletions target/microblaze/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "qemu/host-utils.h"
#include "exec/log.h"

Expand Down
1 change: 1 addition & 0 deletions target/microblaze/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"

static unsigned int tlb_decode_size(unsigned int f)
{
Expand Down
1 change: 1 addition & 0 deletions target/mips/sysemu/physaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "../internal.h"

static int is_seg_am_mapped(unsigned int am, bool eu, int mmu_idx)
Expand Down
1 change: 1 addition & 0 deletions target/mips/tcg/sysemu/tlb_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "cpu.h"
#include "internal.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "exec/cpu_ldst.h"
#include "exec/log.h"
#include "exec/helper-proto.h"
Expand Down
1 change: 1 addition & 0 deletions target/openrisc/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
#include "exec/page-protection.h"
#include "gdbstub/helpers.h"
#include "qemu/host-utils.h"
#include "hw/loader.h"
Expand Down
1 change: 1 addition & 0 deletions target/ppc/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "exec/breakpoint.h"
#include "hw/registerfields.h"
#include "exec/page-protection.h"

/* PM instructions */
typedef enum {
Expand Down
Loading

0 comments on commit 74781c0

Please sign in to comment.