exec: Build up 'cputlb.h' and 'ram_addr.h' headers
cover exec: Build up 'cputlb.h' and 'ram_addr.h' headers
Hi,
"exec/exec-all.h" and "exec/cpu-all.h" both contains a mess of unrelated APIs. More importantly, they contain target specific declarations, making any file including them to become target specific, thus not buildable in common meson sets.
This series first extract the CPU TLB API scattered in various headers, then similarly strengthen the ram_addr_t API. Doing so we figured extracting "user/guest-host.h" was necessary.
Before we have to include various missing headers to avoid compilation breakage when refactoring.
The relevant part of the diff-stat is:
include/exec/cpu-all.h | 59 +------------------- include/exec/cpu-common.h | 56 +------------------ include/exec/cpu_ldst.h | 73 +------------------------ include/exec/exec-all.h | 259 ------------------------------------------ include/exec/ram_addr.h | 56 ++----------------- include/sysemu/ram_addr.h | 129 ++++++++++++++++++++++++++++++++++++++ include/exec/cputlb.h | 310 ++++++++++++++++++++++++++++++++++++++++++ include/user/guest-host.h | 87 +++++++++++++++++++++++++++++
Hoping it makes sense!
Please review,
Phil.
Philippe Mathieu-Daudé (24):
exec/cpu-all: Include missing 'exec/cpu-defs.h' header exec/cpu-defs: Remove unnecessary headers exec/translation-block: Include missing 'exec/vaddr.h' header accel/tcg: Include missing 'exec/translation-block.h' header target/i386/helper: Include missing 'exec/translation-block.h' header target/rx/cpu: Include missing 'exec/translation-block.h' header system/watchpoint: Include missing 'exec/cpu-all.h' header linux-user/aarch64/mte: Include missing 'user/abitypes.h' header target/arm/mte: Restrict 'exec/ram_addr.h' to system emulation target/arm/cpu: Restrict cpu_untagged_addr() to user emulation
exec: Introduce 'user/guest-host.h' header
accel/tcg: Have tlb_vaddr_to_host() use vaddr type
exec: Declare tlb_reset_dirty*() in 'exec/cputlb.h'
exec: Declare tlb_init/destroy() in 'exec/cputlb.h'
exec: Declare tlb_set_page_full() in 'exec/cputlb.h'
exec: Declare tlb_set_page_with_attrs() in 'exec/cputlb.h'
exec: Declare tlb_set_page() in 'exec/cputlb.h'
exec: Declare tlb_flush*() in 'exec/cputlb.h'
exec: Declare tlb_hit*() in 'exec/cputlb.h'
exec: Declare tlb_vaddr_to_host() in 'exec/cputlb.h'
exec: Extract CPU physical memory API to 'sysemu/physmem-target.h' exec/cpu-common: Move ram_addr_t related methods to 'exec/ram_addr.h' exec/memory: Move qemu_map_ram_ptr() declaration to 'exec/ram_addr.h'
exec: Move 'ram_addr.h' header under sysemu/ namespace
MAINTAINERS | 3 +-
include/exec/cpu-all.h | 59 +---
include/exec/cpu-common.h | 56 +---
include/exec/cpu-defs.h | 8 -
include/exec/cpu_ldst.h | 73 +----
include/exec/cputlb.h | 310 +++++++++++++++++-
include/exec/exec-all.h | 259 ---------------
include/exec/memory.h | 2 +-
include/exec/translation-block.h | 3 +-
.../ram_addr.h => sysemu/physmem-target.h} | 56 +---
include/sysemu/ram_addr.h | 129 ++++++++
include/user/guest-host.h | 87 +++++
linux-user/aarch64/mte_user_helper.h | 2 +
target/arm/cpu.h | 5 +-
accel/kvm/kvm-all.c | 3 +-
accel/tcg/cpu-exec.c | 1 +
accel/tcg/cputlb.c | 28 +-
accel/tcg/tcg-accel-ops.c | 2 +
accel/tcg/translate-all.c | 3 +-
cpu-target.c | 1 +
hw/intc/armv7m_nvic.c | 2 +-
hw/ppc/spapr.c | 3 +-
hw/ppc/spapr_caps.c | 3 +-
hw/ppc/spapr_nested.c | 1 +
hw/ppc/spapr_pci.c | 3 +-
hw/remote/memory.c | 3 +-
hw/remote/proxy-memory-listener.c | 3 +-
hw/s390x/s390-stattrib-kvm.c | 3 +-
hw/s390x/s390-stattrib.c | 3 +-
hw/s390x/s390-virtio-ccw.c | 3 +-
hw/sh4/sh7750.c | 1 +
hw/vfio/common.c | 3 +-
hw/vfio/container.c | 3 +-
hw/vfio/iommufd.c | 3 +-
hw/vfio/migration.c | 3 +-
hw/vfio/spapr.c | 3 +-
hw/virtio/virtio-mem.c | 3 +-
migration/ram.c | 3 +-
plugins/api.c | 3 +-
system/memory.c | 3 +-
system/physmem.c | 4 +-
system/watchpoint.c | 3 +-
target/alpha/helper.c | 2 +-
target/alpha/sys_helper.c | 2 +-
target/arm/helper.c | 1 +
target/arm/tcg/helper-a64.c | 1 +
target/arm/tcg/mte_helper.c | 5 +-
target/avr/helper.c | 2 +-
target/hppa/mem_helper.c | 1 +
target/i386/helper.c | 2 +
target/i386/machine.c | 2 +-
target/i386/tcg/fpu_helper.c | 2 +-
target/i386/tcg/misc_helper.c | 2 +-
target/i386/tcg/sysemu/excp_helper.c | 2 +-
target/i386/tcg/sysemu/misc_helper.c | 2 +-
target/i386/tcg/sysemu/svm_helper.c | 2 +-
target/loongarch/tcg/csr_helper.c | 2 +-
target/loongarch/tcg/tlb_helper.c | 2 +-
target/m68k/helper.c | 2 +-
target/microblaze/helper.c | 2 +-
target/microblaze/mmu.c | 2 +-
target/mips/sysemu/cp0.c | 2 +-
target/mips/tcg/sysemu/cp0_helper.c | 2 +-
target/mips/tcg/sysemu/tlb_helper.c | 2 +-
target/openrisc/mmu.c | 2 +-
target/openrisc/sys_helper.c | 1 +
target/ppc/helper_regs.c | 2 +-
target/ppc/kvm.c | 3 +-
target/ppc/mem_helper.c | 1 +
target/ppc/misc_helper.c | 1 +
target/ppc/mmu_helper.c | 1 +
target/riscv/cpu_helper.c | 2 +-
target/riscv/csr.c | 1 +
target/riscv/op_helper.c | 1 +
target/riscv/pmp.c | 2 +-
target/rx/cpu.c | 3 +-
target/s390x/gdbstub.c | 2 +-
target/s390x/kvm/kvm.c | 3 +-
target/s390x/sigp.c | 2 +-
target/s390x/tcg/excp_helper.c | 1 +
target/s390x/tcg/mem_helper.c | 1 +
target/s390x/tcg/misc_helper.c | 1 +
target/sh4/helper.c | 2 +-
target/sparc/ldst_helper.c | 1 +
target/sparc/mmu_helper.c | 2 +-
target/tricore/helper.c | 2 +-
target/xtensa/helper.c | 2 +-
target/xtensa/mmu_helper.c | 1 +
88 files changed, 670 insertions(+), 566 deletions(-)
rename include/{exec/ram_addr.h => sysemu/physmem-target.h} (88%)
create mode 100644 include/sysemu/ram_addr.h
create mode 100644 include/user/guest-host.hSignature · 1 line
2.45.2
PATCH 1/24 exec/cpu-all: Include missing 'exec/cpu-defs.h' header
TARGET_PAGE_BITS is defined in "exec/cpu-defs.h".
Include it in order to avoid when refactoring:
In file included from ../../system/watchpoint.c:23:
include/exec/cpu-all.h:356:19: error: use of undeclared identifier 'TARGET_PAGE_BITS'
356 | QEMU_BUILD_BUG_ON(TLB_FLAGS_MASK & TLB_SLOW_FLAGS_MASK);
| ^--- include/exec/cpu-all.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/exec/cpu-all.h +1 -1
@@ -136,7 +136,7 @@ static inline void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val#endif /* page related stuff */ - +#include "exec/cpu-defs.h" #ifdef TARGET_PAGE_BITS_VARY # include "exec/page-vary.h" extern const TargetPageBits target_page;
Signature · 1 line
2.45.2
Re: [PATCH 01/24] exec/cpu-all: Include missing 'exec/cpu-defs.h' header
Quoted 18 lines · Philippe Mathieu-Daudé
TARGET_PAGE_BITSis defined in "exec/cpu-defs.h".
Include it in order to avoid when refactoring:In file included from
../../system/watchpoint.c:23:
include/exec/cpu-all.h:356:19: error: use of undeclared identifier 'TARGET_PAGE_BITS'356 | QEMU_BUILD_BUG_ON(TLB_FLAGS_MASK & TLB_SLOW_FLAGS_MASK); | ^Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cpu-all.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/exec/cpu-all.h +0
-0
include/exec/cpu-all.h static inline void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val · line 142
Quoted 8 lines
include/exec/cpu-all.h +1
-1@@ -136,7 +136,7 @@ static inline void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val#endif /* page related stuff */ - +#include "exec/cpu-defs.h" #ifdef TARGET_PAGE_BITS_VARY # include "exec/page-vary.h" extern const TargetPageBits target_page;
Re: [PATCH 01/24] exec/cpu-all: Include missing 'exec/cpu-defs.h' header
In reply to Philippe Mathieu-DaudéQuoted 1 line · Philippe Mathieu-Daudé
TARGET_PAGE_BITSis defined in "exec/cpu-defs.h".
Actually, it's rather defined in cpu-param.h, but that header gets included from cpu-defs.h, so the patch is fine. But maybe adjust the commit message to avoid confusion?
Thomas
Richard Henderson
Reviewed-byRe: [PATCH 01/24] exec/cpu-all: Include missing 'exec/cpu-defs.h' header
Quoted 4 lines · Thomas Huth
Quoted 1 line · Philippe Mathieu-Daudé
TARGET_PAGE_BITSis defined in "exec/cpu-defs.h".Actually, it's rather defined in
cpu-param.h, but that header gets included from cpu-defs.h, so the patch is fine. But maybe adjust the commit message to avoid confusion?
+1.
With that,
r~
PATCH 2/24 exec/cpu-defs: Remove unnecessary headers
In reply to Philippe Mathieu-Daudé"exec/cpu-defs.h" should be kept as minimal as possible; besides these includes don't seem necessay. Remove them.
--- include/exec/cpu-defs.h | 8 -------- 1 file changed, 8 deletions(-)
include/exec/cpu-defs.h +0 -8
@@ -23,14 +23,6 @@#error cpu.h included from common code#endif -#include "qemu/host-utils.h" -#include "qemu/thread.h" -#ifndef CONFIG_USER_ONLY -#include "exec/hwaddr.h" -#endif -#include "exec/memattrs.h" -#include "hw/core/cpu.h" -#include "cpu-param.h" #ifndef TARGET_LONG_BITS
Signature · 1 line
2.45.2
Re: [PATCH 02/24] exec/cpu-defs: Remove unnecessary headers
Quoted 17 lines · Philippe Mathieu-Daudé
"
exec/cpu-defs.h" should be kept as minimal as possible; besides these includes don't seem necessay. Remove them.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cpu-defs.h | 8 -------- 1 file changed, 8 deletions(-)include/exec/cpu-defs.h +0
-1@@ -23,14 +23,6 @@#error cpu.h included from common code#endif -#include "qemu/host-utils.h"
include/exec/cpu-defs.h line 28
Quoted 10 lines
include/exec/cpu-defs.h +0
-7-#include "qemu/thread.h" -#ifndef CONFIG_USER_ONLY -#include "exec/hwaddr.h" -#endif -#include "exec/memattrs.h" -#include "hw/core/cpu.h" -#include "cpu-param.h" #ifndef TARGET_LONG_BITS
Re: [PATCH 02/24] exec/cpu-defs: Remove unnecessary headers
In reply to Philippe Mathieu-DaudéQuoted 2 lines · Philippe Mathieu-Daudé
"
exec/cpu-defs.h" should be kept as minimal as possible; besides these includes don't seem necessay. Remove them.
s/necessay/necessary/
Quoted 4 lines
include/exec/cpu-defs.h line 32
Quoted 10 lines
include/exec/cpu-defs.h +0
-7@@ -23,14 +23,6 @@#error cpu.h included from common code#endif -#include "qemu/host-utils.h" -#include "qemu/thread.h" -#ifndef CONFIG_USER_ONLY -#include "exec/hwaddr.h" -#endif -#include "exec/memattrs.h" -#include "hw/core/cpu.h"
Seems to work. Good catch!
Re: [PATCH 02/24] exec/cpu-defs: Remove unnecessary headers
In reply to Philippe Mathieu-DaudéQuoted 7 lines · Philippe Mathieu-Daudé
"
exec/cpu-defs.h" should be kept as minimal as possible; besides these includes don't seem necessay. Remove them.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cpu-defs.h | 8 -------- 1 file changed, 8 deletions(-)
r~
PATCH 3/24 exec/translation-block: Include missing 'exec/vaddr.h' header
In reply to Philippe Mathieu-Daudé'vaddr' is declared in "exec/vaddr.h".
Include it in order to avoid when refactoring:
include/exec/translation-block.h:56:5: error: unknown type name 'vaddr'
56 | vaddr pc;
| ^--- include/exec/translation-block.h | 1 + 1 file changed, 1 insertion(+)
include/exec/translation-block.h +1 -0
@@ -9,6 +9,7 @@#include "qemu/thread.h" #include "exec/cpu-common.h" +#include "exec/vaddr.h" #ifdef CONFIG_USER_ONLY #include "qemu/interval-tree.h" #endif
Signature · 1 line
2.45.2
Re: [PATCH 03/24] exec/translation-block: Include missing 'exec/vaddr.h' header
Quoted 17 lines · Philippe Mathieu-Daudé
'vaddr' is declared in "
exec/vaddr.h".
Include it in order to avoid when refactoring:include/exec/translation-block.h:56:5: error: unknown type name 'vaddr' 56 | vaddr pc; | ^Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/translation-block.h | 1 + 1 file changed, 1 insertion(+)include/exec/translation-block.h +0
-0
include/exec/translation-block.h line 15
Quoted 7 lines
include/exec/translation-block.h +1
-0@@ -9,6 +9,7 @@#include "qemu/thread.h" #include "exec/cpu-common.h" +#include "exec/vaddr.h" #ifdef CONFIG_USER_ONLY #include "qemu/interval-tree.h" #endif
I'm a bit confused by commit message, but it seems that this series has some commits that will not compile. Is that something acceptable?
If it's ok,
Re: [PATCH 03/24] exec/translation-block: Include missing 'exec/vaddr.h' header
Quoted 13 lines · Pierrick Bouvier
Quoted 12 lines · Philippe Mathieu-Daudé
'vaddr' is declared in "
exec/vaddr.h".
Include it in order to avoid when refactoring:
include/exec/translation-block.h:56:5: error: unknown type name 'vaddr' 56 | vaddr pc;
| ^Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/exec/translation-block.h| 1 +1 file changed, 1 insertion(+)
Quoted 13 lines
include/exec/translation-block.h line 14
Quoted 11 lines
include/exec/translation-block.h +1
-0@@ -9,6 +9,7 @@ #include "qemu/thread.h" #include "exec/cpu-common.h" +#include "exec/vaddr.h" #ifdef CONFIG_USER_ONLY #include "qemu/interval-tree.h" #endifI'm a bit confused by commit message, but it seems that this series has some commits that will not compile. Is that something acceptable?
Because commits must be bisect-able, that is not acceptable.
I took a lot of care to make this series builable on each step, but might have missed something. Can you point me at the configuration used and broken patch?
I'll reword the commit description as:
---
'vaddr' type is declared in "exec/vaddr.h". "exec/translation-block.h" uses this type without including the corresponding header. It works because this header is indirectly included, but won't work when the other headers are refactored:
[error]
Explitly include "exec/vaddr.h" to avoid such problem in a few commits.
---
Does it clarify?
Quoted 3 lines
If it's ok,
Reviewed-by Pierrick Bouvier <[email protected]>
Re: [PATCH 03/24] exec/translation-block: Include missing 'exec/vaddr.h' header
Quoted 46 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Pierrick Bouvier
Quoted 13 lines · Philippe Mathieu-Daudé
'vaddr' is declared in "
exec/vaddr.h".
Include it in order to avoid when refactoring:
include/exec/translation-block.h:56:5: error: unknown type name
'vaddr'
56 | vaddr pc;
| ^Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/translation-block.h | 1 + 1 file changed, 1 insertion(+)Quoted 15 lines
include/exec/translation-block.h line 14
Quoted 12 lines
include/exec/translation-block.h +1
-0@@ -9,6 +9,7 @@ #include "qemu/thread.h" #include "exec/cpu-common.h" +#include "exec/vaddr.h" #ifdef CONFIG_USER_ONLY #include "qemu/interval-tree.h" #endifI'm a bit confused by commit message, but it seems that this series has some commits that will not compile. Is that something acceptable?
Because commits must be bisect-able, that is not acceptable.
I took a lot of care to make this series builable on each step, but might have missed something. Can you point me at the configuration used and broken patch?
I'll reword the commit description as:
---
'vaddr' type is declared in "exec/vaddr.h". "exec/translation-block.h" uses this type without including the corresponding header. It works because this header is indirectly included, but won't work when the other headers are refactored:
Quoted 8 lines
[error]Explitly include "
exec/vaddr.h" to avoid such problem in a few commits.
---Does it clarify?
Yes it's more clear like that. The commit message seemed to imply that you were fixing build one step at a time.
Quoted 4 lines
Quoted 3 lines
If it's ok,
Reviewed-by Pierrick Bouvier <[email protected]>
Thanks,
Pierrick
Re: [PATCH 03/24] exec/translation-block: Include missing 'exec/vaddr.h' header
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
'vaddr' is declared in "
exec/vaddr.h".
Include it in order to avoid when refactoring:include/exec/translation-block.h:56:5: error: unknown type name 'vaddr' 56 | vaddr pc; | ^Signed-off-by Philippe Mathieu-Daudé <[email protected]>
r~
Quoted 16 lines
--- include/exec/translation-block.h | 1 + 1 file changed, 1 insertion(+)include/exec/translation-block.h +1
-0@@ -9,6 +9,7 @@#include "qemu/thread.h" #include "exec/cpu-common.h" +#include "exec/vaddr.h" #ifdef CONFIG_USER_ONLY #include "qemu/interval-tree.h" #endif
PATCH 4/24 accel/tcg: Include missing 'exec/translation-block.h' header
In reply to Philippe Mathieu-DaudéTB compile flags are defined in "exec/translation-block.h". Include it in order to avoid when refactoring:
accel/tcg/tcg-accel-ops.c:62:36: error: use of undeclared identifier 'CF_CLUSTER_SHIFT'
62 | cflags = cpu->cluster_index << CF_CLUSTER_SHIFT;
| ^
accel/tcg/tcg-accel-ops.c:64:26: error: use of undeclared identifier 'CF_PARALLEL'
64 | cflags |= parallel ? CF_PARALLEL : 0;
| ^
accel/tcg/tcg-accel-ops.c:65:34: error: use of undeclared identifier 'CF_USE_ICOUNT'
65 | cflags |= icount_enabled() ? CF_USE_ICOUNT : 0;
| ^--- accel/tcg/tcg-accel-ops.c | 1 + 1 file changed, 1 insertion(+)
accel/tcg/tcg-accel-ops.c +1 -0
@@ -35,6 +35,7 @@#include "exec/exec-all.h" #include "exec/hwaddr.h" #include "exec/tb-flush.h" +#include "exec/translation-block.h" #include "gdbstub/enums.h" #include "hw/core/cpu.h"
Signature · 1 line
2.45.2
Re: [PATCH 04/24] accel/tcg: Include missing 'exec/translation-block.h' header
Quoted 23 lines · Philippe Mathieu-Daudé
TB compile flags are defined in "
exec/translation-block.h". Include it in order to avoid when refactoring:
accel/tcg/tcg-accel-ops.c:62:36: error: use of undeclared identifier 'CF_CLUSTER_SHIFT'62 | cflags = cpu->cluster_index << CF_CLUSTER_SHIFT; | ^ accel/tcg/tcg-accel-ops.c:64:26: error: use of undeclared identifier 'CF_PARALLEL' 64 | cflags |= parallel ? CF_PARALLEL : 0; | ^ accel/tcg/tcg-accel-ops.c:65:34: error: use of undeclared identifier 'CF_USE_ICOUNT' 65 | cflags |= icount_enabled() ? CF_USE_ICOUNT : 0; | ^Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- accel/tcg/tcg-accel-ops.c | 1 + 1 file changed, 1 insertion(+)accel/tcg/tcg-accel-ops.c +0
-0
accel/tcg/tcg-accel-ops.c line 41
Quoted 7 lines
accel/tcg/tcg-accel-ops.c +1
-0@@ -35,6 +35,7 @@#include "exec/exec-all.h" #include "exec/hwaddr.h" #include "exec/tb-flush.h" +#include "exec/translation-block.h" #include "gdbstub/enums.h" #include "hw/core/cpu.h"
Re: [PATCH 04/24] accel/tcg: Include missing 'exec/translation-block.h' header
In reply to Philippe Mathieu-DaudéQuoted 13 lines · Philippe Mathieu-Daudé
TB compile flags are defined in "
exec/translation-block.h". Include it in order to avoid when refactoring:
accel/tcg/tcg-accel-ops.c:62:36: error: use of undeclared identifier 'CF_CLUSTER_SHIFT'62 | cflags = cpu->cluster_index << CF_CLUSTER_SHIFT; | ^ accel/tcg/tcg-accel-ops.c:64:26: error: use of undeclared identifier 'CF_PARALLEL' 64 | cflags |= parallel ? CF_PARALLEL : 0; | ^ accel/tcg/tcg-accel-ops.c:65:34: error: use of undeclared identifier 'CF_USE_ICOUNT' 65 | cflags |= icount_enabled() ? CF_USE_ICOUNT : 0; | ^
Quoted 4 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- accel/tcg/tcg-accel-ops.c | 1 + 1 file changed, 1 insertion(+)
r~
Quoted 13 lines
accel/tcg/tcg-accel-ops.c +1
-0@@ -35,6 +35,7 @@#include "exec/exec-all.h" #include "exec/hwaddr.h" #include "exec/tb-flush.h" +#include "exec/translation-block.h" #include "gdbstub/enums.h" #include "hw/core/cpu.h"
PATCH 5/24 target/i386/helper: Include missing 'exec/translation-block.h' header
In reply to Philippe Mathieu-DaudéTB compile flags are defined in "exec/translation-block.h". Include it in order to avoid when refactoring:
target/i386/helper.c:536:28: error: use of undeclared identifier 'CF_PCREL'
536 | if (tcg_cflags_has(cs, CF_PCREL)) {
| ^--- target/i386/helper.c | 1 + 1 file changed, 1 insertion(+)
target/i386/helper.c +1 -0
@@ -21,6 +21,7 @@#include "qapi/qapi-events-run-state.h" #include "cpu.h" #include "exec/exec-all.h" +#include "exec/translation-block.h" #include "sysemu/runstate.h" #ifndef CONFIG_USER_ONLY #include "sysemu/hw_accel.h"
Signature · 1 line
2.45.2
Re: [PATCH 05/24] target/i386/helper: Include missing 'exec/translation-block.h' header
Quoted 17 lines · Philippe Mathieu-Daudé
TB compile flags are defined in "
exec/translation-block.h". Include it in order to avoid when refactoring:
target/i386/helper.c:536:28: error: use of undeclared identifier 'CF_PCREL'536 | if (tcg_cflags_has(cs, CF_PCREL)) { | ^Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/i386/helper.c | 1 + 1 file changed, 1 insertion(+)target/i386/helper.c +0
-0
target/i386/helper.c line 27
Quoted 7 lines
target/i386/helper.c +1
-0@@ -21,6 +21,7 @@#include "qapi/qapi-events-run-state.h" #include "cpu.h" #include "exec/exec-all.h" +#include "exec/translation-block.h" #include "sysemu/runstate.h" #ifndef CONFIG_USER_ONLY #include "sysemu/hw_accel.h"
Re: [PATCH 05/24] target/i386/helper: Include missing 'exec/translation-block.h' header
In reply to Philippe Mathieu-DaudéQuoted 17 lines · Philippe Mathieu-Daudé
TB compile flags are defined in "
exec/translation-block.h". Include it in order to avoid when refactoring:
target/i386/helper.c:536:28: error: use of undeclared identifier 'CF_PCREL'536 | if (tcg_cflags_has(cs, CF_PCREL)) { | ^Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/i386/helper.c | 1 + 1 file changed, 1 insertion(+)target/i386/helper.c +0
-0
target/i386/helper.c line 27
Quoted 7 lines
target/i386/helper.c +1
-0@@ -21,6 +21,7 @@#include "qapi/qapi-events-run-state.h" #include "cpu.h" #include "exec/exec-all.h" +#include "exec/translation-block.h" #include "sysemu/runstate.h" #ifndef CONFIG_USER_ONLY #include "sysemu/hw_accel.h"
Hmm. The usage there in get_memio_eip really ought to be using tb_cflags(tb) with the translation block found during unwinding. But none of the interfaces we provide from translate-all.c provide that.
Currently, tcg_cflags_has() is in exec/cpu-common.h. Perhaps we ought to have the include there, so that all uses of tcg_cflags_has are fixed at once, or perhaps tcg_cflags_has should be moved.
Anyway, just musing.
r~
PATCH 6/24 target/rx/cpu: Include missing 'exec/translation-block.h' header
In reply to Philippe Mathieu-DaudéThe TranslationBlock structure is declared in
"exec/translation-block.h", along with the TB
compile flag definitions. Include the header
in order to avoid when refactoring:
target/rx/cpu.c:50:42: error: use of undeclared identifier 'CF_PCREL'
50 | tcg_debug_assert(!tcg_cflags_has(cs, CF_PCREL));
| ^
target/rx/cpu.c:51:21: error: incomplete definition of type 'struct TranslationBlock'
51 | cpu->env.pc = tb->pc;
| ~~^
include/qemu/typedefs.h:116:16: note: forward declaration of 'struct TranslationBlock'
116 | typedef struct TranslationBlock TranslationBlock;
| ^--- target/rx/cpu.c | 1 + 1 file changed, 1 insertion(+)
target/rx/cpu.c +1 -0
@@ -23,6 +23,7 @@#include "migration/vmstate.h" #include "exec/exec-all.h" #include "exec/page-protection.h" +#include "exec/translation-block.h" #include "hw/loader.h" #include "fpu/softfloat.h" #include "tcg/debug-assert.h"
Signature · 1 line
2.45.2
Re: [PATCH 06/24] target/rx/cpu: Include missing 'exec/translation-block.h' header
Quoted 25 lines · Philippe Mathieu-Daudé
The TranslationBlock structure is declared in
"exec/translation-block.h", along with the TB
compile flag definitions. Include the header
in order to avoid when refactoring:
target/rx/cpu.c:50:42: error: use of undeclared identifier 'CF_PCREL'50 | tcg_debug_assert(!tcg_cflags_has(cs, CF_PCREL)); | ^ target/rx/cpu.c:51:21: error: incomplete definition of type 'struct TranslationBlock' 51 | cpu->env.pc = tb->pc; | ~~^ include/qemu/typedefs.h:116:16: note: forward declaration of 'struct TranslationBlock' 116 | typedef struct TranslationBlock TranslationBlock; | ^Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/rx/cpu.c | 1 + 1 file changed, 1 insertion(+)target/rx/cpu.c +0
-0
target/rx/cpu.c line 29
Quoted 7 lines
target/rx/cpu.c +1
-0@@ -23,6 +23,7 @@#include "migration/vmstate.h" #include "exec/exec-all.h" #include "exec/page-protection.h" +#include "exec/translation-block.h" #include "hw/loader.h" #include "fpu/softfloat.h" #include "tcg/debug-assert.h"
Re: [PATCH 06/24] target/rx/cpu: Include missing 'exec/translation-block.h' header
In reply to Philippe Mathieu-DaudéQuoted 15 lines · Philippe Mathieu-Daudé
The TranslationBlock structure is declared in
"exec/translation-block.h", along with the TB
compile flag definitions. Include the header
in order to avoid when refactoring:
target/rx/cpu.c:50:42: error: use of undeclared identifier 'CF_PCREL'50 | tcg_debug_assert(!tcg_cflags_has(cs, CF_PCREL)); | ^ target/rx/cpu.c:51:21: error: incomplete definition of type 'struct TranslationBlock' 51 | cpu->env.pc = tb->pc; | ~~^ include/qemu/typedefs.h:116:16: note: forward declaration of 'struct TranslationBlock' 116 | typedef struct TranslationBlock TranslationBlock; | ^
Quoted 5 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/rx/cpu.c | 1 + 1 file changed, 1 insertion(+)
r~
Quoted 12 lines
target/rx/cpu.c +1
-0@@ -23,6 +23,7 @@#include "migration/vmstate.h" #include "exec/exec-all.h" #include "exec/page-protection.h" +#include "exec/translation-block.h" #include "hw/loader.h" #include "fpu/softfloat.h" #include "tcg/debug-assert.h"
PATCH 7/24 system/watchpoint: Include missing 'exec/cpu-all.h' header
In reply to Philippe Mathieu-DaudéTARGET_PAGE_MASK is defined in "exec/cpu-all.h".
Include it in order to avoid when refactoring:
system/watchpoint.c:52:24: error: use of undeclared identifier 'TARGET_PAGE_MASK'
52 | in_page = -(addr | TARGET_PAGE_MASK);
| ^--- system/watchpoint.c | 1 + 1 file changed, 1 insertion(+)
system/watchpoint.c +1 -0
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qemu/error-report.h" #include "exec/exec-all.h" +#include "exec/cpu-all.h" #include "hw/core/cpu.h" /* Add a watchpoint. */
Signature · 1 line
2.45.2
Re: [PATCH 07/24] system/watchpoint: Include missing 'exec/cpu-all.h' header
Quoted 17 lines · Philippe Mathieu-Daudé
TARGET_PAGE_MASKis defined in "exec/cpu-all.h".
Include it in order to avoid when refactoring:
system/watchpoint.c:52:24: error: use of undeclared identifier 'TARGET_PAGE_MASK'52 | in_page = -(addr | TARGET_PAGE_MASK); | ^Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- system/watchpoint.c | 1 + 1 file changed, 1 insertion(+)system/watchpoint.c +0
-0
system/watchpoint.c line 26
Quoted 7 lines
system/watchpoint.c +1
-0@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qemu/error-report.h" #include "exec/exec-all.h" +#include "exec/cpu-all.h" #include "hw/core/cpu.h" /* Add a watchpoint. */
Re: [PATCH 07/24] system/watchpoint: Include missing 'exec/cpu-all.h' header
In reply to Philippe Mathieu-DaudéQuoted 17 lines · Philippe Mathieu-Daudé
TARGET_PAGE_MASKis defined in "exec/cpu-all.h".
Include it in order to avoid when refactoring:
system/watchpoint.c:52:24: error: use of undeclared identifier 'TARGET_PAGE_MASK'52 | in_page = -(addr | TARGET_PAGE_MASK); | ^Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- system/watchpoint.c | 1 + 1 file changed, 1 insertion(+)system/watchpoint.c +0
-0
system/watchpoint.c line 23
Quoted 4 lines
system/watchpoint.c +1
-0@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qemu/error-report.h" #include "exec/exec-all.h" +#include "exec/cpu-all.h"
This uses TARGET_PAGE_MASK to choose between flushing one page or the entire tlb. Better would be to use tlb_flush_range_by_mmuidx(..., ALL_MMUIDX_BITS) to flush exactly one or two pages.
That said, I've just noticed that tlb_flush_range_by_mmuidx does not properly handle addr+len that are not already page aligned. That can be fixed fairly easily.
r~
PATCH 8/24 linux-user/aarch64/mte: Include missing 'user/abitypes.h' header
In reply to Philippe Mathieu-Daudéabi_long type is defined in "user/abitypes.h".
Include it in order to avoid when refactoring:
linux-user/aarch64/mte_user_helper.h:30:42: error: unknown type name ‘abi_long’; did you mean ‘u_long’?
30 | void arm_set_mte_tcf0(CPUArchState *env, abi_long value);
| ^~~~~~~~
| u_long--- linux-user/aarch64/mte_user_helper.h | 2 ++ 1 file changed, 2 insertions(+)
linux-user/aarch64/mte_user_helper.h +2 -0
@@ -9,6 +9,8 @@#ifndef AARCH64_MTE_USER_HELPER_H #define AARCH64_MTE USER_HELPER_H +#include "user/abitypes.h" +#ifndef PR_MTE_TCF_SHIFT # define PR_MTE_TCF_SHIFT 1# define PR_MTE_TCF_NONE (0UL << PR_MTE_TCF_SHIFT)
Signature · 1 line
2.45.2
Re: [PATCH 08/24] linux-user/aarch64/mte: Include missing 'user/abitypes.h' header
Quoted 18 lines · Philippe Mathieu-Daudé
abi_longtype is defined in "user/abitypes.h".
Include it in order to avoid when refactoring:
linux-user/aarch64/mte_user_helper.h:30:42: error: unknown type name ‘abi_long’; did you mean ‘u_long’?30 | void arm_set_mte_tcf0(CPUArchState *env, abi_long value); | ^~~~~~~~ | u_longSigned-off-by Philippe Mathieu-Daudé <[email protected]>--- linux-user/aarch64/mte_user_helper.h | 2 ++ 1 file changed, 2 insertions(+)linux-user/aarch64/mte_user_helper.h +0
-0
linux-user/aarch64/mte_user_helper.h line 16
Quoted 8 lines
linux-user/aarch64/mte_user_helper.h +2
-0@@ -9,6 +9,8 @@#ifndef AARCH64_MTE_USER_HELPER_H #define AARCH64_MTE USER_HELPER_H +#include "user/abitypes.h" +#ifndef PR_MTE_TCF_SHIFT # define PR_MTE_TCF_SHIFT 1# define PR_MTE_TCF_NONE (0UL << PR_MTE_TCF_SHIFT)
Re: [PATCH 08/24] linux-user/aarch64/mte: Include missing 'user/abitypes.h' header
In reply to Philippe Mathieu-DaudéQuoted 18 lines · Philippe Mathieu-Daudé
abi_longtype is defined in "user/abitypes.h".
Include it in order to avoid when refactoring:
linux-user/aarch64/mte_user_helper.h:30:42: error: unknown type name ‘abi_long’; did you mean ‘u_long’?30 | void arm_set_mte_tcf0(CPUArchState *env, abi_long value); | ^~~~~~~~ | u_longSigned-off-by Philippe Mathieu-Daudé <[email protected]>--- linux-user/aarch64/mte_user_helper.h | 2 ++ 1 file changed, 2 insertions(+)linux-user/aarch64/mte_user_helper.h +0
-0
linux-user/aarch64/mte_user_helper.h line 16
Quoted 8 lines
linux-user/aarch64/mte_user_helper.h +2
-0@@ -9,6 +9,8 @@#ifndef AARCH64_MTE_USER_HELPER_H #define AARCH64_MTE USER_HELPER_H +#include "user/abitypes.h" +#ifndef PR_MTE_TCF_SHIFT # define PR_MTE_TCF_SHIFT 1# define PR_MTE_TCF_NONE (0UL << PR_MTE_TCF_SHIFT)
Or maybe just switch to uint64_t.
This is aarch64, so it's always going to be 64 bits. This is private between the prctl syscall and gdbstub.
r~
PATCH 9/24 target/arm/mte: Restrict 'exec/ram_addr.h' to system emulation
In reply to Philippe Mathieu-Daudé"exec/ram_addr.h" contains system specific declarations. Restrict its inclusion to sysemu to avoid build errors when refactoring.
--- target/arm/tcg/mte_helper.c | 2 ++ 1 file changed, 2 insertions(+)
target/arm/tcg/mte_helper.c +2 -0
@@ -23,7 +23,9 @@#include "internals.h" #include "exec/exec-all.h" #include "exec/page-protection.h" +#ifndef CONFIG_USER_ONLY #include "exec/ram_addr.h" +#endif #include "exec/cpu_ldst.h" #include "exec/helper-proto.h" #include "hw/core/tcg-cpu-ops.h"
Signature · 1 line
2.45.2
Re: [PATCH 09/24] target/arm/mte: Restrict 'exec/ram_addr.h' to system emulation
Quoted 14 lines · Philippe Mathieu-Daudé
"
exec/ram_addr.h" contains system specific declarations. Restrict its inclusion to sysemu to avoid build errors when refactoring.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/tcg/mte_helper.c | 2 ++ 1 file changed, 2 insertions(+)target/arm/tcg/mte_helper.c +0
-0
target/arm/tcg/mte_helper.c line 31
Quoted 9 lines
target/arm/tcg/mte_helper.c +2
-0@@ -23,7 +23,9 @@#include "internals.h" #include "exec/exec-all.h" #include "exec/page-protection.h" +#ifndef CONFIG_USER_ONLY #include "exec/ram_addr.h" +#endif #include "exec/cpu_ldst.h" #include "exec/helper-proto.h" #include "hw/core/tcg-cpu-ops.h"
Re: [PATCH 09/24] target/arm/mte: Restrict 'exec/ram_addr.h' to system emulation
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
"
exec/ram_addr.h" contains system specific declarations. Restrict its inclusion to sysemu to avoid build errors when refactoring.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/arm/tcg/mte_helper.c | 2 ++ 1 file changed, 2 insertions(+)
r~
PATCH 10/24 target/arm/cpu: Restrict cpu_untagged_addr() to user emulation
In reply to Philippe Mathieu-DaudéMove the #endif guard where it belongs to restrict the cpu_untagged_addr() implementation to user emulation.
--- target/arm/cpu.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
target/arm/cpu.h +3 -2
@@ -3355,8 +3355,8 @@ extern const uint64_t pred_esz_masks[5];#define TAG_GRANULE (1 << LOG2_TAG_GRANULE)#ifdef CONFIG_USER_ONLY +#define TARGET_PAGE_DATA_SIZE (TARGET_PAGE_SIZE >> (LOG2_TAG_GRANULE + 1)) -#endif #ifdef TARGET_TAGGED_ADDRESSES /**
@@ -3382,6 +3382,7 @@ static inline target_ulong cpu_untagged_addr(CPUState *cs, target_ulong x) }return x; } -#endif +#endif /* TARGET_TAGGED_ADDRESSES */ +#endif /* CONFIG_USER_ONLY */ #endif
Signature · 1 line
2.45.2
Re: [PATCH 10/24] target/arm/cpu: Restrict cpu_untagged_addr() to user emulation
Quoted 24 lines · Philippe Mathieu-Daudé
Move the #endif guard where it belongs to restrict the
cpu_untagged_addr()implementation to user emulation.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/cpu.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)target/arm/cpu.h +1
-1@@ -3355,8 +3355,8 @@ extern const uint64_t pred_esz_masks[5];#define TAG_GRANULE (1 << LOG2_TAG_GRANULE)#ifdef CONFIG_USER_ONLY +#define TARGET_PAGE_DATA_SIZE (TARGET_PAGE_SIZE >> (LOG2_TAG_GRANULE + 1)) -#endif #ifdef TARGET_TAGGED_ADDRESSES /**
target/arm/cpu.h static inline target_ulong cpu_untagged_addr(CPUState *cs, target_ulong x) · line 3388
Quoted 8 lines
target/arm/cpu.h +2
-1@@ -3382,6 +3382,7 @@ static inline target_ulong cpu_untagged_addr(CPUState *cs, target_ulong x) }return x; } -#endif +#endif /* TARGET_TAGGED_ADDRESSES */ +#endif /* CONFIG_USER_ONLY */ #endif
Re: [PATCH 10/24] target/arm/cpu: Restrict cpu_untagged_addr() to user emulation
In reply to Philippe Mathieu-DaudéQuoted 24 lines · Philippe Mathieu-Daudé
Move the #endif guard where it belongs to restrict the
cpu_untagged_addr()implementation to user emulation.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/cpu.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)target/arm/cpu.h +1
-1@@ -3355,8 +3355,8 @@ extern const uint64_t pred_esz_masks[5];#define TAG_GRANULE (1 << LOG2_TAG_GRANULE)#ifdef CONFIG_USER_ONLY +#define TARGET_PAGE_DATA_SIZE (TARGET_PAGE_SIZE >> (LOG2_TAG_GRANULE + 1)) -#endif #ifdef TARGET_TAGGED_ADDRESSES /**
target/arm/cpu.h static inline target_ulong cpu_untagged_addr(CPUState *cs, target_ulong x) · line 3388
Quoted 8 lines
target/arm/cpu.h +2
-1@@ -3382,6 +3382,7 @@ static inline target_ulong cpu_untagged_addr(CPUState *cs, target_ulong x) }return x; } -#endif +#endif /* TARGET_TAGGED_ADDRESSES */ +#endif /* CONFIG_USER_ONLY */ #endif
r~
PATCH 11/24 exec: Introduce 'user/guest-host.h' header
In reply to Philippe Mathieu-DaudéExtract all declarations related to 'guest from/to host' address translation to a new "user/guest-host.h" header.
--- include/exec/cpu-all.h | 34 +-------------- include/exec/cpu_ldst.h | 47 +-------------------- include/user/guest-host.h | 87 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 79 deletions(-) create mode 100644 include/user/guest-host.h
include/exec/cpu-all.h +1 -33
@@ -64,39 +64,7 @@/* MMU memory access macros */ -#if defined(CONFIG_USER_ONLY ) -#include "user/abitypes.h" - -/* -* If non-zero, the guest virtual address space is a contiguous subset -* of the host virtual address space, i.e. '-R reserved_va' is in effect -* either from the command-line or by default. The value is the last -* byte of the guest address space e.g. UINT32_MAX. -* -* If zero, the host and guest virtual address spaces are intermingled. -*/ -extern unsigned long reserved_va; - -/* -* Limit the guest addresses as best we can. -* -* When not using -R reserved_va, we cannot really limit the guest -* to less address space than the host. For 32-bit guests, this -* acts as a sanity check that we're not giving the guest an address -* that it cannot even represent. For 64-bit guests... the address -* might not be what the real kernel would give, but it is at least -* representable in the guest. -* -* TODO: Improve address allocation to avoid this problem, and to -* avoid setting bits at the top of guest addresses that might need -* to be used for tags. -*/ -#define GUEST_ADDR_MAX_ \ - ((MIN_CONST(TARGET_VIRT_ADDR_SPACE_BITS, TARGET_ABI_BITS) <= 32) ? \ - UINT32_MAX : ~0ul) -#define GUEST_ADDR_MAX (reserved_va ? : GUEST_ADDR_MAX_) - -#else +#if !defined(CONFIG_USER_ONLY )#include "exec/hwaddr.h"
include/exec/cpu_ldst.h +1 -46
53 lines not on this page · raw message
include/user/guest-host.h new file +87 -0
87 lines not on this page · raw message
Signature · 1 line
2.45.2
Re: [PATCH 11/24] exec: Introduce 'user/guest-host.h' header
Quoted 197 lines · Philippe Mathieu-Daudé
Extract all declarations related to 'guest from/to host' address translation to a new "
user/guest-host.h" header.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cpu-all.h | 34 +-------------- include/exec/cpu_ldst.h | 47 +-------------------- include/user/guest-host.h | 87 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 79 deletions(-)create mode 100644
include/user/guest-host.hinclude/exec/cpu-all.h +1
-33@@ -64,39 +64,7 @@/* MMU memory access macros */ -#if defined(CONFIG_USER_ONLY ) -#include "user/abitypes.h" - -/* -* If non-zero, the guest virtual address space is a contiguous subset -* of the host virtual address space, i.e. '-R reserved_va' is in effect -* either from the command-line or by default. The value is the last -* byte of the guest address space e.g. UINT32_MAX. -* -* If zero, the host and guest virtual address spaces are intermingled. -*/ -extern unsigned long reserved_va; - -/* -* Limit the guest addresses as best we can. -* -* When not using -R reserved_va, we cannot really limit the guest -* to less address space than the host. For 32-bit guests, this -* acts as a sanity check that we're not giving the guest an address -* that it cannot even represent. For 64-bit guests... the address -* might not be what the real kernel would give, but it is at least -* representable in the guest. -* -* TODO: Improve address allocation to avoid this problem, and to -* avoid setting bits at the top of guest addresses that might need -* to be used for tags. -*/ -#define GUEST_ADDR_MAX_ \ - ((MIN_CONST(TARGET_VIRT_ADDR_SPACE_BITS, TARGET_ABI_BITS) <= 32) ? \ - UINT32_MAX : ~0ul) -#define GUEST_ADDR_MAX (reserved_va ? : GUEST_ADDR_MAX_) - -#else +#if !defined(CONFIG_USER_ONLY )#include "exec/hwaddr.h" include/exec/cpu_ldst.h +1
-46@@ -72,52 +72,7 @@#include "qemu/int128.h" #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) -{ -return x; -} -#endif - -/* All direct uses of g2h and h2g need to go away for usermode softmmu. */ -static inline void *g2h_untagged (abi_ptr x) -{ -return (void *)((uintptr_t )(x) + guest_base); -} - -static inline void *g2h (CPUState *cs,abi_ptr x) -{ -return g2h_untagged (cpu_untagged_addr (cs, x)); -} - -static inline bool guest_addr_valid_untagged (abi_ulong x) -{ -return x <=GUEST_ADDR_MAX ; -} - -static inline bool guest_range_valid_untagged (abi_ulong start,abi_ulong len) -{ -return len -1 <=GUEST_ADDR_MAX && start <=GUEST_ADDR_MAX - len +1 ; -} - -#define h2g_valid (x) \ - (HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS || \ - (uintptr_t)(x) - guest_base <= GUEST_ADDR_MAX) - -#define h2g_nocheck (x) ({ \ - uintptr_t __ret = (uintptr_t)(x) - guest_base; \ - (abi_ptr)__ret; \ -}) - -#define h2g (x) ({ \ -/* Check if given address fits target address space */ \ -assert (h2g_valid (x)); \ -h2g_nocheck (x); \ -}) - +#include "user/guest-host.h" #endif /* CONFIG_USER_ONLY */ uint32_t cpu_ldub_data (CPUArchState *env,abi_ptr ptr);include/user/guest-host.h new file +77
-0@@ -0,0 +1,87 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* +* guest <-> host helpers. +* +* Copyright (c) 2003 Fabrice Bellard +*/ + +#ifndef USER_GUEST_HOST_H +#define USER_GUEST_HOST_H + +#include "user/abitypes.h" +#include "user/guest-base.h" +#include "cpu.h" + +/* +* If non-zero, the guest virtual address space is a contiguous subset +* of the host virtual address space, i.e. '-R reserved_va' is in effect +* either from the command-line or by default. The value is the last +* byte of the guest address space e.g. UINT32_MAX. +* +* If zero, the host and guest virtual address spaces are intermingled. +*/ +extern unsigned long reserved_va; + +/* +* Limit the guest addresses as best we can. +* +* When not using -R reserved_va, we cannot really limit the guest +* to less address space than the host. For 32-bit guests, this +* acts as a sanity check that we're not giving the guest an address +* that it cannot even represent. For 64-bit guests... the address +* might not be what the real kernel would give, but it is at least +* representable in the guest. +* +* TODO: Improve address allocation to avoid this problem, and to +* avoid setting bits at the top of guest addresses that might need +* to be used for tags. +*/ +#define GUEST_ADDR_MAX_ \ + ((MIN_CONST(TARGET_VIRT_ADDR_SPACE_BITS, TARGET_ABI_BITS) <= 32) ? \ + UINT32_MAX : ~0ul) +#define GUEST_ADDR_MAX (reserved_va ? : GUEST_ADDR_MAX_) + +#ifndef TARGET_TAGGED_ADDRESSES +static inline abi_ptr cpu_untagged_addr (CPUState *cs,abi_ptr x) +{ +return x; +} +#endif + +/* All direct uses of g2h and h2g need to go away for usermode softmmu. */ +static inline void *g2h_untagged (abi_ptr x) +{ +return (void *)((uintptr_t )(x) + guest_base); +} + +static inline void *g2h (CPUState *cs,abi_ptr x) +{ +return g2h_untagged (cpu_untagged_addr (cs, x)); +} + +static inline bool guest_addr_valid_untagged (abi_ulong x) +{ +return x <=GUEST_ADDR_MAX ; +} + +static inline bool guest_range_valid_untagged (abi_ulong start,abi_ulong len) +{ +return len -1 <=GUEST_ADDR_MAX && start <=GUEST_ADDR_MAX - len +1 ; +} + +#define h2g_valid (x) \ + (HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS || \ + (uintptr_t)(x) - guest_base <= GUEST_ADDR_MAX) + +#define h2g_nocheck (x) ({ \ + uintptr_t __ret = (uintptr_t)(x) - guest_base; \
include/user/guest-host.h line 87
Quoted 10 lines
include/user/guest-host.h new file +10
-0+ (abi_ptr )__ret; \ +}) + +#define h2g (x) ({ \ +/* Check if given address fits target address space */ \ +assert (h2g_valid (x)); \ +h2g_nocheck (x); \ +}) + +#endif
Re: [PATCH 11/24] exec: Introduce 'user/guest-host.h' header
In reply to Philippe Mathieu-DaudéQuoted 10 lines · Philippe Mathieu-Daudé
Extract all declarations related to 'guest from/to host' address translation to a new "
user/guest-host.h" header.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/exec/cpu-all.h | 34 +-------------- include/exec/cpu_ldst.h | 47 +-------------------- include/user/guest-host.h | 87 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 79 deletions(-)create mode 100644
include/user/guest-host.h
r~
PATCH 12/24 accel/tcg: Have tlb_vaddr_to_host() use vaddr type
In reply to Philippe Mathieu-Daudéabi_ptr is expected to be used in user emulation. tlb_vaddr_to_host() uses it, but can be used in system emulation. Replace the type by 'vaddr' which is equivalent on user emulation but also works on system.
--- include/exec/cpu_ldst.h | 3 ++- accel/tcg/cputlb.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
include/exec/cpu_ldst.h +2 -1
@@ -67,6 +67,7 @@#endif #include "exec/memopidx.h" +#include "exec/vaddr.h" #include "exec/abi_ptr.h" #include "exec/mmu-access-type.h" #include "qemu/int128.h"
@@ -330,7 +331,7 @@ static inline void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, return g2h(env_cpu(env), addr); }#else -void *tlb_vaddr_to_host (CPUArchState *env,abi_ptr addr, +void *tlb_vaddr_to_host (CPUArchState *env,vaddr addr,MMUAccessType access_type,int mmu_idx);#endif
accel/tcg/cputlb.c +1 -1
@@ -1504,7 +1504,7 @@ void *probe_access(CPUArchState *env, vaddr addr, int size,return host; } -void *tlb_vaddr_to_host (CPUArchState *env,abi_ptr addr, +void *tlb_vaddr_to_host (CPUArchState *env,vaddr addr,MMUAccessType access_type,int mmu_idx) {CPUTLBEntryFull *full;
Signature · 1 line
2.45.2
Re: [PATCH 12/24] accel/tcg: Have tlb_vaddr_to_host() use vaddr type
Quoted 38 lines · Philippe Mathieu-Daudé
abi_ptris expected to be used in user emulation.tlb_vaddr_to_host()uses it, but can be used in system emulation. Replace the type by 'vaddr' which is equivalent on user emulation but also works on system.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cpu_ldst.h | 3 ++- accel/tcg/cputlb.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)include/exec/cpu_ldst.h +2
-1@@ -67,6 +67,7 @@#endif #include "exec/memopidx.h" +#include "exec/vaddr.h" #include "exec/abi_ptr.h" #include "exec/mmu-access-type.h" #include "qemu/int128.h" @@ -330,7 +331,7 @@ static inline void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, return g2h(env_cpu(env), addr); }#else -void *tlb_vaddr_to_host (CPUArchState *env,abi_ptr addr, +void *tlb_vaddr_to_host (CPUArchState *env,vaddr addr,MMUAccessType access_type,int mmu_idx);#endif accel/tcg/cputlb.c +0
-0
accel/tcg/cputlb.c void *probe_access(CPUArchState *env, vaddr addr, int size, · line 1510
Quoted 8 lines
accel/tcg/cputlb.c +1
-1@@ -1504,7 +1504,7 @@ void *probe_access(CPUArchState *env, vaddr addr, int size,return host; } -void *tlb_vaddr_to_host (CPUArchState *env,abi_ptr addr, +void *tlb_vaddr_to_host (CPUArchState *env,vaddr addr,MMUAccessType access_type,int mmu_idx) {CPUTLBEntryFull *full;
Re: [PATCH 12/24] accel/tcg: Have tlb_vaddr_to_host() use vaddr type
In reply to Philippe Mathieu-DaudéQuoted 11 lines · Philippe Mathieu-Daudé
abi_ptris expected to be used in user emulation.tlb_vaddr_to_host()uses it, but can be used in system emulation. Replace the type by 'vaddr' which is equivalent on user emulation but also works on system.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cpu_ldst.h | 3 ++- accel/tcg/cputlb.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
r~
PATCH 13/24 exec: Declare tlb_reset_dirty*() in 'exec/cputlb.h'
In reply to Philippe Mathieu-DaudéMove CPU TLB related methods to "exec/cputlb.h".
--- include/exec/cputlb.h | 7 +++++++ include/exec/exec-all.h | 3 --- include/exec/ram_addr.h | 1 + system/physmem.c | 1 + 4 files changed, 9 insertions(+), 3 deletions(-)
include/exec/cputlb.h +7 -0
@@ -32,4 +32,11 @@ void tlb_unprotect_code(ram_addr_t ram_addr);#endif /* CONFIG_TCG */ +#ifndef CONFIG_USER_ONLY + +void tlb_reset_dirty (CPUState *cpu,ram_addr_t start1,ram_addr_t length); +void tlb_reset_dirty_range_all (ram_addr_t start,ram_addr_t length); + +#endif +#endif
include/exec/exec-all.h +0 -3
@@ -589,9 +589,6 @@ static inline void mmap_lock(void) {}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_reset_dirty_range_all (ram_addr_t start,ram_addr_t length); -MemoryRegionSection * address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr, hwaddr *xlat, hwaddr *plen,
include/exec/ram_addr.h +1 -0
@@ -23,6 +23,7 @@#include "cpu.h" #include "sysemu/xen.h" #include "sysemu/tcg.h" +#include "exec/cputlb.h" #include "exec/ramlist.h" #include "exec/ramblock.h" #include "exec/exec-all.h"
system/physmem.c +1 -0
@@ -32,6 +32,7 @@#endif /* CONFIG_TCG */ #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/target_page.h" #include "hw/qdev-core.h"
Signature · 1 line
2.45.2
Re: [PATCH 13/24] exec: Declare tlb_reset_dirty*() in 'exec/cputlb.h'
Quoted 57 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cputlb.h | 7 +++++++ include/exec/exec-all.h | 3 --- include/exec/ram_addr.h | 1 + system/physmem.c | 1 + 4 files changed, 9 insertions(+), 3 deletions(-)include/exec/cputlb.h +7
-0@@ -32,4 +32,11 @@ void tlb_unprotect_code(ram_addr_t ram_addr);#endif /* CONFIG_TCG */ +#ifndef CONFIG_USER_ONLY + +void tlb_reset_dirty (CPUState *cpu,ram_addr_t start1,ram_addr_t length); +void tlb_reset_dirty_range_all (ram_addr_t start,ram_addr_t length); + +#endif +#endif include/exec/exec-all.h +0
-3@@ -589,9 +589,6 @@ static inline void mmap_lock(void) {}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_reset_dirty_range_all (ram_addr_t start,ram_addr_t length); -MemoryRegionSection * address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr, hwaddr *xlat, hwaddr *plen,include/exec/ram_addr.h +1
-0@@ -23,6 +23,7 @@#include "cpu.h" #include "sysemu/xen.h" #include "sysemu/tcg.h" +#include "exec/cputlb.h" #include "exec/ramlist.h" #include "exec/ramblock.h" #include "exec/exec-all.h" system/physmem.c +0
-0
system/physmem.c line 38
Quoted 7 lines
system/physmem.c +1
-0@@ -32,6 +32,7 @@#endif /* CONFIG_TCG */ #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/target_page.h" #include "hw/qdev-core.h"
Re: [PATCH 13/24] exec: Declare tlb_reset_dirty*() in 'exec/cputlb.h'
In reply to Philippe Mathieu-DaudéQuoted 16 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cputlb.h | 7 +++++++ include/exec/exec-all.h | 3 --- include/exec/ram_addr.h | 1 + system/physmem.c | 1 + 4 files changed, 9 insertions(+), 3 deletions(-)include/exec/cputlb.h +0
-0@@ -32,4 +32,11 @@ void tlb_unprotect_code(ram_addr_t ram_addr);
include/exec/cputlb.h void tlb_unprotect_code(ram_addr_t ram_addr); · line 42
Quoted 10 lines
include/exec/cputlb.h +7
-0#endif /* CONFIG_TCG */ +#ifndef CONFIG_USER_ONLY + +void tlb_reset_dirty (CPUState *cpu,ram_addr_t start1,ram_addr_t length); +void tlb_reset_dirty_range_all (ram_addr_t start,ram_addr_t length); + +#endif +#endif
This can join the existing CONFIG_TCG, !CONFIG_USER_ONLY block above.
r~
Re: [PATCH 13/24] exec: Declare tlb_reset_dirty*() in 'exec/cputlb.h'
Quoted 20 lines · Richard Henderson
Quoted 19 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/exec/cputlb.h | 7 +++++++
include/exec/exec-all.h| 3 ---
include/exec/ram_addr.h| 1 +
system/physmem.c | 1 +4 files changed, 9 insertions(+), 3 deletions(-)include/exec/cputlb.h +3
-0@@ -32,4 +32,11 @@ void tlb_unprotect_code(ram_addr_t ram_addr); #endif /* CONFIG_TCG */ +#ifndef CONFIG_USER_ONLY + +void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t
Quoted 8 lines
include/exec/cputlb.h void tlb_unprotect_code(ram_addr_t ram_addr); · line 42
Quoted 6 lines
include/exec/cputlb.h +4
-0length); +void tlb_reset_dirty_range_all (ram_addr_t start,ram_addr_t length); + +#endif + #endifThis can join the existing
CONFIG_TCG, !CONFIG_USER_ONLY block above.
Actually they are used by all accelerators (thus prototype required), but elided at build time:
static inline
void cpu_physical_memory_dirty_bits_cleared(ram_addr_t start,
ram_addr_t length)
{
if (tcg_enabled()) {
tlb_reset_dirty_range_all(start, length);
}}
That said, we can probably to smth to improve that. I'll have a look.
PATCH 14/24 exec: Declare tlb_init/destroy() in 'exec/cputlb.h'
In reply to Philippe Mathieu-DaudéMove CPU TLB related methods to "exec/cputlb.h".
--- include/exec/cputlb.h | 28 +++++++++++++++++++++++----- include/exec/exec-all.h | 17 ----------------- accel/tcg/cpu-exec.c | 1 + 3 files changed, 24 insertions(+), 22 deletions(-)
include/exec/cputlb.h +23 -5
@@ -22,15 +22,33 @@#include "exec/cpu-common.h" -#ifdef CONFIG_TCG +#if defined(CONFIG_TCG ) && !defined(CONFIG_USER_ONLY ) + +/** +* tlb_init - initialize a CPU's TLB +* @cpu: CPU whose TLB should be initialized +*/ +void tlb_init (CPUState *cpu); + +/** +* tlb_destroy - destroy a CPU's TLB +* @cpu: CPU whose TLB should be destroyed +*/ +void tlb_destroy (CPUState *cpu); -#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 */ +#else + +static inline void tlb_init (CPUState *cpu) +{ +} +static inline void tlb_destroy (CPUState *cpu) +{ +} + +#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ #ifndef CONFIG_USER_ONLY
include/exec/exec-all.h +0 -17
@@ -47,17 +47,6 @@ static inline bool cpu_loop_exit_requested(CPUState *cpu) }#if !defined(CONFIG_USER_ONLY ) && defined(CONFIG_TCG ) -/* cputlb.c */ -/** -* tlb_init - initialize a CPU's TLB -* @cpu: CPU whose TLB should be initialized -*/ -void tlb_init (CPUState *cpu); -/** -* tlb_destroy - destroy a CPU's TLB -* @cpu: CPU whose TLB should be destroyed -*/ -void tlb_destroy (CPUState *cpu);/** * tlb_flush_page: * @cpu: CPU whose TLB should be flushed
@@ -242,12 +231,6 @@ void tlb_set_page(CPUState *cpu, vaddr addr, hwaddr paddr, int prot, int mmu_idx, vaddr size);#else -static inline void tlb_init (CPUState *cpu) -{ -} -static inline void tlb_destroy (CPUState *cpu) -{ -}static inline void tlb_flush_page (CPUState *cpu,vaddr addr) { }
accel/tcg/cpu-exec.c +1 -0
@@ -24,6 +24,7 @@#include "hw/core/tcg-cpu-ops.h" #include "trace.h" #include "disas/disas.h" +#include "exec/cputlb.h" #include "exec/exec-all.h" #include "tcg/tcg.h" #include "qemu/atomic.h"
Signature · 1 line
2.45.2
Re: [PATCH 14/24] exec: Declare tlb_init/destroy() in 'exec/cputlb.h'
Quoted 92 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cputlb.h | 28 +++++++++++++++++++++++----- include/exec/exec-all.h | 17 ----------------- accel/tcg/cpu-exec.c | 1 + 3 files changed, 24 insertions(+), 22 deletions(-)include/exec/cputlb.h +23
-5@@ -22,15 +22,33 @@#include "exec/cpu-common.h" -#ifdef CONFIG_TCG +#if defined(CONFIG_TCG ) && !defined(CONFIG_USER_ONLY ) + +/** +* tlb_init - initialize a CPU's TLB +* @cpu: CPU whose TLB should be initialized +*/ +void tlb_init (CPUState *cpu); + +/** +* tlb_destroy - destroy a CPU's TLB +* @cpu: CPU whose TLB should be destroyed +*/ +void tlb_destroy (CPUState *cpu); -#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 */ +#else + +static inline void tlb_init (CPUState *cpu) +{ +} +static inline void tlb_destroy (CPUState *cpu) +{ +} + +#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ #ifndef CONFIG_USER_ONLY include/exec/exec-all.h +0
-17@@ -47,17 +47,6 @@ static inline bool cpu_loop_exit_requested(CPUState *cpu) }#if !defined(CONFIG_USER_ONLY ) && defined(CONFIG_TCG ) -/* cputlb.c */ -/** -* tlb_init - initialize a CPU's TLB -* @cpu: CPU whose TLB should be initialized -*/ -void tlb_init (CPUState *cpu); -/** -* tlb_destroy - destroy a CPU's TLB -* @cpu: CPU whose TLB should be destroyed -*/ -void tlb_destroy (CPUState *cpu);/** * tlb_flush_page: * @cpu: CPU whose TLB should be flushed @@ -242,12 +231,6 @@ void tlb_set_page(CPUState *cpu, vaddr addr, hwaddr paddr, int prot, int mmu_idx, vaddr size);#else -static inline void tlb_init (CPUState *cpu) -{ -} -static inline void tlb_destroy (CPUState *cpu) -{ -}static inline void tlb_flush_page (CPUState *cpu,vaddr addr) { }accel/tcg/cpu-exec.c +0
-0
accel/tcg/cpu-exec.c line 30
Quoted 7 lines
accel/tcg/cpu-exec.c +1
-0@@ -24,6 +24,7 @@#include "hw/core/tcg-cpu-ops.h" #include "trace.h" #include "disas/disas.h" +#include "exec/cputlb.h" #include "exec/exec-all.h" #include "tcg/tcg.h" #include "qemu/atomic.h"
Re: [PATCH 14/24] exec: Declare tlb_init/destroy() in 'exec/cputlb.h'
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cputlb.h | 28 +++++++++++++++++++++++----- include/exec/exec-all.h | 17 ----------------- accel/tcg/cpu-exec.c | 1 + 3 files changed, 24 insertions(+), 22 deletions(-)
This is only within accel/tcg/. Better to move to accel/tcg/internal-common.h.
r~
Re: [PATCH 14/24] exec: Declare tlb_init/destroy() in 'exec/cputlb.h'
Quoted 11 lines · Richard Henderson
Quoted 8 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
include/exec/cputlb.h | 28 +++++++++++++++++++++++-----include/exec/exec-all.h| 17 ----------------- accel/tcg/cpu-exec.c | 1 +3 files changed, 24 insertions(+), 22 deletions(-)This is only within accel/tcg/. Better to move to
accel/tcg/internal-common.h.
Yeah, and IIRC this is also true for some other helpers. My thought was "better keep all the API public" but I don't remember why I decided to go this way, since this is of no use outside of accel/tcg/.
PATCH 15/24 exec: Declare tlb_set_page_full() in 'exec/cputlb.h'
In reply to Philippe Mathieu-DaudéMove CPU TLB related methods to "exec/cputlb.h".
--- include/exec/cputlb.h | 23 +++++++++++++++++++++++ include/exec/exec-all.h | 22 ---------------------- target/sparc/mmu_helper.c | 2 +- 3 files changed, 24 insertions(+), 23 deletions(-)
include/exec/cputlb.h +23 -0
@@ -21,6 +21,7 @@#define CPUTLB_H #include "exec/cpu-common.h" +#include "exec/vaddr.h" #if defined(CONFIG_TCG ) && !defined(CONFIG_USER_ONLY )
@@ -57,4 +58,26 @@ void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);#endif +/** +* tlb_set_page_full: +* @cpu: CPU context +* @mmu_idx: mmu index of the tlb to modify +* @addr: virtual address of the entry to add +* @full: the details of the tlb entry +* +* Add an entry to @cpu tlb index @mmu_idx. All of the fields of +* @full must be filled, except for xlat_section, and constitute +* the complete description of the translated page. +* +* This is generally called by the target tlb_fill function after +* having performed a successful page table walk to find the physical +* address and attributes for the translation. +* +* At most one entry for a given virtual address is permitted. Only a +* single TARGET_PAGE_SIZE region is mapped; @full->lg_page_size is only +* used by tlb_flush_page. +*/ +void tlb_set_page_full (CPUState *cpu,int mmu_idx,vaddr addr, +CPUTLBEntryFull *full); +#endif
include/exec/exec-all.h +0 -22
@@ -174,28 +174,6 @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu,uint16_t idxmap, unsigned bits); -/** -* tlb_set_page_full: -* @cpu: CPU context -* @mmu_idx: mmu index of the tlb to modify -* @addr: virtual address of the entry to add -* @full: the details of the tlb entry -* -* Add an entry to @cpu tlb index @mmu_idx. All of the fields of -* @full must be filled, except for xlat_section, and constitute -* the complete description of the translated page. -* -* This is generally called by the target tlb_fill function after -* having performed a successful page table walk to find the physical -* address and attributes for the translation. -* -* At most one entry for a given virtual address is permitted. Only a -* single TARGET_PAGE_SIZE region is mapped; @full->lg_page_size is only -* used by tlb_flush_page. -*/ -void tlb_set_page_full (CPUState *cpu,int mmu_idx,vaddr addr, -CPUTLBEntryFull *full); -/** * tlb_set_page_with_attrs: * @cpu: CPU to add this TLB entry for
target/sparc/mmu_helper.c +1 -1
@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "qemu/qemu-print.h" #include "trace.h"
Signature · 1 line
2.45.2
Re: [PATCH 15/24] exec: Declare tlb_set_page_full() in 'exec/cputlb.h'
Quoted 86 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cputlb.h | 23 +++++++++++++++++++++++ include/exec/exec-all.h | 22 ---------------------- target/sparc/mmu_helper.c | 2 +- 3 files changed, 24 insertions(+), 23 deletions(-)include/exec/cputlb.h +23
-0@@ -21,6 +21,7 @@#define CPUTLB_H #include "exec/cpu-common.h" +#include "exec/vaddr.h" #if defined(CONFIG_TCG ) && !defined(CONFIG_USER_ONLY )@@ -57,4 +58,26 @@ void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);#endif +/** +* tlb_set_page_full: +* @cpu: CPU context +* @mmu_idx: mmu index of the tlb to modify +* @addr: virtual address of the entry to add +* @full: the details of the tlb entry +* +* Add an entry to @cpu tlb index @mmu_idx. All of the fields of +* @full must be filled, except for xlat_section, and constitute +* the complete description of the translated page. +* +* This is generally called by the target tlb_fill function after +* having performed a successful page table walk to find the physical +* address and attributes for the translation. +* +* At most one entry for a given virtual address is permitted. Only a +* single TARGET_PAGE_SIZE region is mapped; @full->lg_page_size is only +* used by tlb_flush_page. +*/ +void tlb_set_page_full (CPUState *cpu,int mmu_idx,vaddr addr, +CPUTLBEntryFull *full); +#endif include/exec/exec-all.h +0
-22@@ -174,28 +174,6 @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu,uint16_t idxmap, unsigned bits); -/** -* tlb_set_page_full: -* @cpu: CPU context -* @mmu_idx: mmu index of the tlb to modify -* @addr: virtual address of the entry to add -* @full: the details of the tlb entry -* -* Add an entry to @cpu tlb index @mmu_idx. All of the fields of -* @full must be filled, except for xlat_section, and constitute -* the complete description of the translated page. -* -* This is generally called by the target tlb_fill function after -* having performed a successful page table walk to find the physical -* address and attributes for the translation. -* -* At most one entry for a given virtual address is permitted. Only a -* single TARGET_PAGE_SIZE region is mapped; @full->lg_page_size is only -* used by tlb_flush_page. -*/ -void tlb_set_page_full (CPUState *cpu,int mmu_idx,vaddr addr, -CPUTLBEntryFull *full); -/** * tlb_set_page_with_attrs: * @cpu: CPU to add this TLB entry for target/sparc/mmu_helper.c +0
-0
target/sparc/mmu_helper.c line 26
Quoted 8 lines
target/sparc/mmu_helper.c +1
-1@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "qemu/qemu-print.h" #include "trace.h"
Re: [PATCH 15/24] exec: Declare tlb_set_page_full() in 'exec/cputlb.h'
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cputlb.h | 23 +++++++++++++++++++++++ include/exec/exec-all.h | 22 ---------------------- target/sparc/mmu_helper.c | 2 +- 3 files changed, 24 insertions(+), 23 deletions(-)
FYI,
https://lore.kernel.org/qemu-devel/[email protected]/
unexports this (and related functions) entirely.
r~
PATCH 16/24 exec: Declare tlb_set_page_with_attrs() in 'exec/cputlb.h'
In reply to Philippe Mathieu-DaudéMove CPU TLB related methods to "exec/cputlb.h".
--- include/exec/cputlb.h | 28 ++++++++++++++++++++++++++++ include/exec/exec-all.h | 25 ------------------------- target/i386/tcg/sysemu/excp_helper.c | 2 +- target/microblaze/helper.c | 2 +- 4 files changed, 30 insertions(+), 27 deletions(-)
include/exec/cputlb.h +28 -0
@@ -21,6 +21,8 @@#define CPUTLB_H #include "exec/cpu-common.h" +#include "exec/hwaddr.h" +#include "exec/memattrs.h" #include "exec/vaddr.h" #if defined(CONFIG_TCG ) && !defined(CONFIG_USER_ONLY )
@@ -80,4 +82,30 @@ void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);void tlb_set_page_full (CPUState *cpu,int mmu_idx,vaddr addr,CPUTLBEntryFull *full); +/** +* tlb_set_page_with_attrs: +* @cpu: CPU to add this TLB entry for +* @addr: virtual address of page to add entry for +* @paddr: physical address of the page +* @attrs: memory transaction attributes +* @prot: access permissions (PAGE_READ/PAGE_WRITE/PAGE_EXEC bits) +* @mmu_idx: MMU index to insert TLB entry for +* @size: size of the page in bytes +* +* Add an entry to this CPU's TLB (a mapping from virtual address +* @addr to physical address @paddr) with the specified memory +* transaction attributes. This is generally called by the target CPU +* specific code after it has been called through the tlb_fill() +* entry point and performed a successful page table walk to find +* the physical address and attributes for the virtual address +* which provoked the TLB miss. +* +* At most one entry for a given virtual address is permitted. Only a +* single TARGET_PAGE_SIZE region is mapped; the supplied @size is only +* used by tlb_flush_page. +*/ +void tlb_set_page_with_attrs (CPUState *cpu,vaddr addr, +hwaddr paddr,MemTxAttrs attrs, +int prot,int mmu_idx,vaddr size); +#endif
include/exec/exec-all.h +0 -25
@@ -174,31 +174,6 @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu,uint16_t idxmap, unsigned bits); -/** -* tlb_set_page_with_attrs: -* @cpu: CPU to add this TLB entry for -* @addr: virtual address of page to add entry for -* @paddr: physical address of the page -* @attrs: memory transaction attributes -* @prot: access permissions (PAGE_READ/PAGE_WRITE/PAGE_EXEC bits) -* @mmu_idx: MMU index to insert TLB entry for -* @size: size of the page in bytes -* -* Add an entry to this CPU's TLB (a mapping from virtual address -* @addr to physical address @paddr) with the specified memory -* transaction attributes. This is generally called by the target CPU -* specific code after it has been called through the tlb_fill() -* entry point and performed a successful page table walk to find -* the physical address and attributes for the virtual address -* which provoked the TLB miss. -* -* At most one entry for a given virtual address is permitted. Only a -* single TARGET_PAGE_SIZE region is mapped; the supplied @size is only -* used by tlb_flush_page. -*/ -void tlb_set_page_with_attrs (CPUState *cpu,vaddr addr, -hwaddr paddr,MemTxAttrs attrs, -int prot,int mmu_idx,vaddr size);/* tlb_set_page: * * This function is equivalent to calling tlb_set_page_with_attrs()
target/i386/tcg/sysemu/excp_helper.c +1 -1
@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "exec/cpu_ldst.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "tcg/helper-tcg.h"
target/microblaze/helper.c +1 -1
@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "qemu/host-utils.h" #include "exec/log.h"
Signature · 1 line
2.45.2
Re: [PATCH 16/24] exec: Declare tlb_set_page_with_attrs() in 'exec/cputlb.h'
Quoted 108 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cputlb.h | 28 ++++++++++++++++++++++++++++ include/exec/exec-all.h | 25 ------------------------- target/i386/tcg/sysemu/excp_helper.c | 2 +- target/microblaze/helper.c | 2 +- 4 files changed, 30 insertions(+), 27 deletions(-)include/exec/cputlb.h +28
-0@@ -21,6 +21,8 @@#define CPUTLB_H #include "exec/cpu-common.h" +#include "exec/hwaddr.h" +#include "exec/memattrs.h" #include "exec/vaddr.h" #if defined(CONFIG_TCG ) && !defined(CONFIG_USER_ONLY )@@ -80,4 +82,30 @@ void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);void tlb_set_page_full (CPUState *cpu,int mmu_idx,vaddr addr,CPUTLBEntryFull *full); +/** +* tlb_set_page_with_attrs: +* @cpu: CPU to add this TLB entry for +* @addr: virtual address of page to add entry for +* @paddr: physical address of the page +* @attrs: memory transaction attributes +* @prot: access permissions (PAGE_READ/PAGE_WRITE/PAGE_EXEC bits) +* @mmu_idx: MMU index to insert TLB entry for +* @size: size of the page in bytes +* +* Add an entry to this CPU's TLB (a mapping from virtual address +* @addr to physical address @paddr) with the specified memory +* transaction attributes. This is generally called by the target CPU +* specific code after it has been called through the tlb_fill() +* entry point and performed a successful page table walk to find +* the physical address and attributes for the virtual address +* which provoked the TLB miss. +* +* At most one entry for a given virtual address is permitted. Only a +* single TARGET_PAGE_SIZE region is mapped; the supplied @size is only +* used by tlb_flush_page. +*/ +void tlb_set_page_with_attrs (CPUState *cpu,vaddr addr, +hwaddr paddr,MemTxAttrs attrs, +int prot,int mmu_idx,vaddr size); +#endif include/exec/exec-all.h +0
-25@@ -174,31 +174,6 @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu,uint16_t idxmap, unsigned bits); -/** -* tlb_set_page_with_attrs: -* @cpu: CPU to add this TLB entry for -* @addr: virtual address of page to add entry for -* @paddr: physical address of the page -* @attrs: memory transaction attributes -* @prot: access permissions (PAGE_READ/PAGE_WRITE/PAGE_EXEC bits) -* @mmu_idx: MMU index to insert TLB entry for -* @size: size of the page in bytes -* -* Add an entry to this CPU's TLB (a mapping from virtual address -* @addr to physical address @paddr) with the specified memory -* transaction attributes. This is generally called by the target CPU -* specific code after it has been called through the tlb_fill() -* entry point and performed a successful page table walk to find -* the physical address and attributes for the virtual address -* which provoked the TLB miss. -* -* At most one entry for a given virtual address is permitted. Only a -* single TARGET_PAGE_SIZE region is mapped; the supplied @size is only -* used by tlb_flush_page. -*/ -void tlb_set_page_with_attrs (CPUState *cpu,vaddr addr, -hwaddr paddr,MemTxAttrs attrs, -int prot,int mmu_idx,vaddr size);/* tlb_set_page: * * This function is equivalent to calling tlb_set_page_with_attrs() target/i386/tcg/sysemu/excp_helper.c +1
-1@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "exec/cpu_ldst.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "tcg/helper-tcg.h" target/microblaze/helper.c +0
-0
target/microblaze/helper.c line 26
Quoted 8 lines
target/microblaze/helper.c +1
-1@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "qemu/host-utils.h" #include "exec/log.h"
PATCH 17/24 exec: Declare tlb_set_page() in 'exec/cputlb.h'
In reply to Philippe Mathieu-DaudéMove CPU TLB related methods to "exec/cputlb.h".
--- include/exec/cputlb.h | 11 +++++++++++ include/exec/exec-all.h | 9 --------- 2 files changed, 11 insertions(+), 9 deletions(-)
include/exec/cputlb.h +11 -0
@@ -108,4 +108,15 @@ void tlb_set_page_with_attrs(CPUState *cpu, vaddr addr, hwaddr paddr, MemTxAttrs attrs, int prot, int mmu_idx, vaddr size); +/** +* tlb_set_page: +* +* This function is equivalent to calling tlb_set_page_with_attrs() +* with an @attrs argument of MEMTXATTRS_UNSPECIFIED. It's provided +* as a convenience for CPUs which don't use memory transaction attributes. +*/ +void tlb_set_page (CPUState *cpu,vaddr addr, +hwaddr paddr,int prot, +int mmu_idx,vaddr size); +#endif
include/exec/exec-all.h +0 -9
@@ -174,15 +174,6 @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu,uint16_t idxmap, unsigned bits); -/* tlb_set_page: -* -* This function is equivalent to calling tlb_set_page_with_attrs() -* with an @attrs argument of MEMTXATTRS_UNSPECIFIED. It's provided -* as a convenience for CPUs which don't use memory transaction attributes. -*/ -void tlb_set_page (CPUState *cpu,vaddr addr, -hwaddr paddr,int prot, -int mmu_idx,vaddr size);#else static inline void tlb_flush_page (CPUState *cpu,vaddr addr) {
Signature · 1 line
2.45.2
Re: [PATCH 17/24] exec: Declare tlb_set_page() in 'exec/cputlb.h'
Quoted 38 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cputlb.h | 11 +++++++++++ include/exec/exec-all.h | 9 --------- 2 files changed, 11 insertions(+), 9 deletions(-)include/exec/cputlb.h +11
-0@@ -108,4 +108,15 @@ void tlb_set_page_with_attrs(CPUState *cpu, vaddr addr, hwaddr paddr, MemTxAttrs attrs, int prot, int mmu_idx, vaddr size); +/** +* tlb_set_page: +* +* This function is equivalent to calling tlb_set_page_with_attrs() +* with an @attrs argument of MEMTXATTRS_UNSPECIFIED. It's provided +* as a convenience for CPUs which don't use memory transaction attributes. +*/ +void tlb_set_page (CPUState *cpu,vaddr addr, +hwaddr paddr,int prot, +int mmu_idx,vaddr size); +#endif include/exec/exec-all.h +0
-2@@ -174,15 +174,6 @@ void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu,uint16_t idxmap, unsigned bits); -/* tlb_set_page: -*
include/exec/exec-all.h void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, · line 179
Quoted 10 lines
include/exec/exec-all.h +0
-7-* This function is equivalent to calling tlb_set_page_with_attrs() -* with an @attrs argument of MEMTXATTRS_UNSPECIFIED. It's provided -* as a convenience for CPUs which don't use memory transaction attributes. -*/ -void tlb_set_page (CPUState *cpu,vaddr addr, -hwaddr paddr,int prot, -int mmu_idx,vaddr size);#else static inline void tlb_flush_page (CPUState *cpu,vaddr addr) {
PATCH 18/24 exec: Declare tlb_flush*() in 'exec/cputlb.h'
In reply to Philippe Mathieu-DaudéMove CPU TLB related methods to "exec/cputlb.h".
--- include/exec/cputlb.h | 187 +++++++++++++++++++++++++++ include/exec/exec-all.h | 183 -------------------------- accel/tcg/tcg-accel-ops.c | 1 + cpu-target.c | 1 + hw/intc/armv7m_nvic.c | 2 +- hw/ppc/spapr_nested.c | 1 + hw/sh4/sh7750.c | 1 + system/watchpoint.c | 2 +- target/alpha/helper.c | 2 +- target/alpha/sys_helper.c | 2 +- target/arm/helper.c | 1 + target/avr/helper.c | 2 +- target/hppa/mem_helper.c | 1 + target/i386/helper.c | 1 + target/i386/machine.c | 2 +- target/i386/tcg/fpu_helper.c | 2 +- target/i386/tcg/misc_helper.c | 2 +- target/i386/tcg/sysemu/misc_helper.c | 2 +- target/i386/tcg/sysemu/svm_helper.c | 2 +- target/loongarch/tcg/csr_helper.c | 2 +- target/loongarch/tcg/tlb_helper.c | 2 +- target/m68k/helper.c | 2 +- target/microblaze/mmu.c | 2 +- target/mips/sysemu/cp0.c | 2 +- target/mips/tcg/sysemu/cp0_helper.c | 2 +- target/mips/tcg/sysemu/tlb_helper.c | 2 +- target/openrisc/mmu.c | 2 +- target/openrisc/sys_helper.c | 1 + target/ppc/helper_regs.c | 2 +- target/ppc/misc_helper.c | 1 + target/ppc/mmu_helper.c | 1 + target/riscv/cpu_helper.c | 2 +- target/riscv/csr.c | 1 + target/riscv/op_helper.c | 1 + target/riscv/pmp.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/gdbstub.c | 2 +- target/s390x/sigp.c | 2 +- target/s390x/tcg/excp_helper.c | 1 + target/s390x/tcg/mem_helper.c | 1 + target/s390x/tcg/misc_helper.c | 1 + target/sh4/helper.c | 2 +- target/sparc/ldst_helper.c | 1 + target/tricore/helper.c | 2 +- target/xtensa/helper.c | 2 +- target/xtensa/mmu_helper.c | 1 + 46 files changed, 231 insertions(+), 210 deletions(-)
include/exec/cputlb.h +187 -0
@@ -39,6 +39,141 @@ void tlb_init(CPUState *cpu);*/ void tlb_destroy (CPUState *cpu); +/** +* tlb_flush_page: +* @cpu: CPU whose TLB should be flushed +* @addr: virtual address of page to be flushed +* +* Flush one page from the TLB of the specified CPU, for all +* MMU indexes. +*/ +void tlb_flush_page (CPUState *cpu,vaddr addr); + +/** +* tlb_flush_page_all_cpus_synced: +* @cpu: src CPU of the flush +* @addr: virtual address of page to be flushed +* +* Flush one page from the TLB of all CPUs, for all +* MMU indexes. +* +* When this function returns, no CPUs will subsequently perform +* translations using the flushed TLBs. +*/ +void tlb_flush_page_all_cpus_synced (CPUState *src,vaddr addr); + +/** +* tlb_flush: +* @cpu: CPU whose TLB should be flushed +* +* Flush the entire TLB for the specified CPU. Most CPU architectures +* allow the implementation to drop entries from the TLB at any time +* so this is generally safe. If more selective flushing is required +* use one of the other functions for efficiency. +*/ +void tlb_flush (CPUState *cpu); + +/** +* tlb_flush_all_cpus_synced: +* @cpu: src CPU of the flush +* +* Flush the entire TLB for all CPUs, for all MMU indexes. +* +* When this function returns, no CPUs will subsequently perform +* translations using the flushed TLBs. +*/ +void tlb_flush_all_cpus_synced (CPUState *src_cpu); + +/** +* tlb_flush_page_by_mmuidx: +* @cpu: CPU whose TLB should be flushed +* @addr: virtual address of page to be flushed +* @idxmap: bitmap of MMU indexes to flush +* +* Flush one page from the TLB of the specified CPU, for the specified +* MMU indexes. +*/ +void tlb_flush_page_by_mmuidx (CPUState *cpu,vaddr addr, +uint16_t idxmap); + +/** +* tlb_flush_page_by_mmuidx_all_cpus_synced: +* @cpu: Originating CPU of the flush +* @addr: virtual address of page to be flushed +* @idxmap: bitmap of MMU indexes to flush +* +* Flush one page from the TLB of all CPUs, for the specified +* MMU indexes. +* +* When this function returns, no CPUs will subsequently perform +* translations using the flushed TLBs. +*/ +void tlb_flush_page_by_mmuidx_all_cpus_synced (CPUState *cpu,vaddr addr, +uint16_t idxmap); + +/** +* tlb_flush_by_mmuidx: +* @cpu: CPU whose TLB should be flushed +* @wait: If true ensure synchronisation by exiting the cpu_loop +* @idxmap: bitmap of MMU indexes to flush +* +* Flush all entries from the TLB of the specified CPU, for the specified +* MMU indexes. +*/ +void tlb_flush_by_mmuidx (CPUState *cpu,uint16_t idxmap); + +/** +* tlb_flush_by_mmuidx_all_cpus_synced: +* @cpu: Originating CPU of the flush +* @idxmap: bitmap of MMU indexes to flush +* +* Flush all entries from the TLB of all CPUs, for the specified +* MMU indexes. +* +* When this function returns, no CPUs will subsequently perform +* translations using the flushed TLBs. +*/ +void tlb_flush_by_mmuidx_all_cpus_synced (CPUState *cpu,uint16_t idxmap); + +/** +* tlb_flush_page_bits_by_mmuidx +* @cpu: CPU whose TLB should be flushed +* @addr: virtual address of page to be flushed +* @idxmap: bitmap of mmu indexes to flush +* @bits: number of significant bits in address +* +* Similar to tlb_flush_page_mask, but with a bitmap of indexes. +*/ +void tlb_flush_page_bits_by_mmuidx (CPUState *cpu,vaddr addr, +uint16_t idxmap,unsigned bits); + +/* Similarly, with broadcast and syncing. */ +void tlb_flush_page_bits_by_mmuidx_all_cpus_synced (CPUState *cpu,vaddr addr, +uint16_t idxmap, +unsigned bits); + +/** +* tlb_flush_range_by_mmuidx +* @cpu: CPU whose TLB should be flushed +* @addr: virtual address of the start of the range to be flushed +* @len: length of range to be flushed +* @idxmap: bitmap of mmu indexes to flush +* @bits: number of significant bits in address +* +* For each mmuidx in @idxmap, flush all pages within [@addr,@addr+@len), +* comparing only the low @bits worth of each virtual page. +*/ +void tlb_flush_range_by_mmuidx (CPUState *cpu,vaddr addr, +vaddr len,uint16_t idxmap, +unsigned bits); + +/* Similarly, with broadcast and syncing. */ +void tlb_flush_range_by_mmuidx_all_cpus_synced (CPUState *cpu, +vaddr addr, +vaddr len, +uint16_t idxmap, +unsigned bits); +void tlb_protect_code (ram_addr_t ram_addr);void tlb_unprotect_code (ram_addr_t ram_addr);
@@ -50,6 +185,58 @@ static inline void tlb_init(CPUState *cpu)static inline void tlb_destroy (CPUState *cpu) { } +static inline void tlb_flush_page (CPUState *cpu,vaddr addr) +{ +} +static inline void tlb_flush_page_all_cpus_synced (CPUState *src,vaddr addr) +{ +} +static inline void tlb_flush (CPUState *cpu) +{ +} +static inline void tlb_flush_all_cpus_synced (CPUState *src_cpu) +{ +} +static inline void tlb_flush_page_by_mmuidx (CPUState *cpu, +vaddr addr,uint16_t idxmap) +{ +} + +static inline void tlb_flush_by_mmuidx (CPUState *cpu,uint16_t idxmap) +{ +} +static inline void tlb_flush_page_by_mmuidx_all_cpus_synced (CPUState *cpu, +vaddr addr, +uint16_t idxmap) +{ +} +static inline void tlb_flush_by_mmuidx_all_cpus_synced (CPUState *cpu, +uint16_t idxmap) +{ +} +static inline void tlb_flush_page_bits_by_mmuidx (CPUState *cpu, +vaddr addr, +uint16_t idxmap, +unsigned bits) +{ +} +static inline void +tlb_flush_page_bits_by_mmuidx_all_cpus_synced (CPUState *cpu,vaddr addr, +uint16_t idxmap,unsigned bits) +{ +} +static inline void tlb_flush_range_by_mmuidx (CPUState *cpu,vaddr addr, +vaddr len,uint16_t idxmap, +unsigned bits) +{ +} +static inline void tlb_flush_range_by_mmuidx_all_cpus_synced (CPUState *cpu, +vaddr addr, +vaddr len, +uint16_t idxmap, +unsigned bits) +{ +}#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
include/exec/exec-all.h +0 -183
189 lines not on this page · raw message
accel/tcg/tcg-accel-ops.c +1 -0
@@ -33,6 +33,7 @@#include "qemu/guest-random.h" #include "qemu/timer.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/hwaddr.h" #include "exec/tb-flush.h" #include "exec/translation-block.h"
cpu-target.c +1 -0
@@ -40,6 +40,7 @@#include "exec/replay-core.h" #include "exec/cpu-common.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/tb-flush.h" #include "exec/translate-all.h" #include "exec/log.h"
hw/intc/armv7m_nvic.c +1 -1
@@ -22,7 +22,7 @@#include "sysemu/runstate.h" #include "target/arm/cpu.h" #include "target/arm/cpu-features.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/memop.h" #include "qemu/log.h" #include "qemu/module.h"
hw/ppc/spapr_nested.c +1 -0
@@ -1,6 +1,7 @@#include "qemu/osdep.h" #include "qemu/cutils.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "helper_regs.h" #include "hw/ppc/ppc.h" #include "hw/ppc/spapr.h"
hw/sh4/sh7750.c +1 -0
@@ -36,6 +36,7 @@#include "hw/sh4/sh_intc.h" #include "hw/timer/tmu012.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "trace.h" typedef struct SH7750State {
system/watchpoint.c +1 -1
@@ -19,8 +19,8 @@#include "qemu/osdep.h" #include "qemu/error-report.h" -#include "exec/exec-all.h" #include "exec/cpu-all.h" +#include "exec/cputlb.h" #include "hw/core/cpu.h" /* Add a watchpoint. */
target/alpha/helper.c +1 -1
@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "fpu/softfloat-types.h" #include "exec/helper-proto.h"
target/alpha/sys_helper.c +1 -1
@@ -19,7 +19,7 @@#include "qemu/osdep.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/tb-flush.h" #include "exec/helper-proto.h" #include "sysemu/runstate.h"
target/arm/helper.c +1 -0
@@ -19,6 +19,7 @@#include "qemu/crc32c.h" #include "qemu/qemu-print.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include <zlib.h> /* for crc32 */ #include "hw/irq.h" #include "sysemu/cpu-timers.h"
target/avr/helper.c +1 -1
@@ -23,7 +23,7 @@#include "qemu/error-report.h" #include "cpu.h" #include "hw/core/tcg-cpu-ops.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/cpu_ldst.h" #include "exec/address-spaces.h"
target/hppa/mem_helper.c +1 -0
@@ -21,6 +21,7 @@#include "qemu/log.h" #include "cpu.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/helper-proto.h" #include "hw/core/cpu.h"
target/i386/helper.c +1 -0
@@ -21,6 +21,7 @@#include "qapi/qapi-events-run-state.h" #include "cpu.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/translation-block.h" #include "sysemu/runstate.h" #ifndef CONFIG_USER_ONLY
target/i386/machine.c +1 -1
@@ -1,6 +1,6 @@#include "qemu/osdep.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "hw/isa/isa.h" #include "migration/cpu.h" #include "kvm/hyperv.h"
target/i386/tcg/fpu_helper.c +1 -1
@@ -21,7 +21,7 @@#include <math.h> #include "cpu.h" #include "tcg-cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/cpu_ldst.h" #include "exec/helper-proto.h" #include "fpu/softfloat.h"
target/i386/tcg/misc_helper.c +1 -1
@@ -21,7 +21,7 @@#include "qemu/log.h" #include "cpu.h" #include "exec/helper-proto.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "helper-tcg.h" /*
target/i386/tcg/sysemu/misc_helper.c +1 -1
@@ -23,7 +23,7 @@#include "exec/helper-proto.h" #include "exec/cpu_ldst.h" #include "exec/address-spaces.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "tcg/helper-tcg.h" #include "hw/i386/apic.h"
target/i386/tcg/sysemu/svm_helper.c +1 -1
@@ -21,7 +21,7 @@#include "qemu/log.h" #include "cpu.h" #include "exec/helper-proto.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/cpu_ldst.h" #include "tcg/helper-tcg.h"
target/loongarch/tcg/csr_helper.c +1 -1
@@ -11,7 +11,7 @@#include "internals.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/cpu_ldst.h" #include "hw/irq.h" #include "cpu-csr.h"
target/loongarch/tcg/tlb_helper.c +1 -1
@@ -12,7 +12,7 @@#include "cpu.h" #include "internals.h" #include "exec/helper-proto.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/cpu_ldst.h" #include "exec/log.h"
target/m68k/helper.c +1 -1
@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/gdbstub.h" #include "exec/helper-proto.h"
target/microblaze/mmu.c +1 -1
@@ -21,7 +21,7 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" static unsigned int tlb_decode_size (unsigned int f)
target/mips/sysemu/cp0.c +1 -1
@@ -21,7 +21,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "internal.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" /* Called for updates to CP0_Status. */ void sync_c0_status (CPUMIPSState *env,CPUMIPSState *cpu,int tc)
target/mips/tcg/sysemu/cp0_helper.c +1 -1
@@ -27,7 +27,7 @@#include "internal.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" /* SMP helpers. */
target/mips/tcg/sysemu/tlb_helper.c +1 -1
@@ -21,7 +21,7 @@#include "cpu.h" #include "internal.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/cpu_ldst.h" #include "exec/log.h"
target/openrisc/mmu.c +1 -1
@@ -21,7 +21,7 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "gdbstub/helpers.h" #include "qemu/host-utils.h"
target/openrisc/sys_helper.c +1 -0
@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/helper-proto.h" #include "exception.h" #ifndef CONFIG_USER_ONLY
target/ppc/helper_regs.c +1 -1
@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "qemu/main-loop.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "sysemu/kvm.h" #include "sysemu/tcg.h" #include "helper_regs.h"
target/ppc/misc_helper.c +1 -0
@@ -21,6 +21,7 @@#include "qemu/log.h" #include "cpu.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/helper-proto.h" #include "qemu/error-report.h" #include "qemu/main-loop.h"
target/ppc/mmu_helper.c +1 -0
@@ -24,6 +24,7 @@#include "kvm_ppc.h" #include "mmu-hash64.h" #include "mmu-hash32.h" +#include "exec/cputlb.h" #include "exec/exec-all.h" #include "exec/page-protection.h" #include "exec/log.h"
target/riscv/cpu_helper.c +1 -1
@@ -23,7 +23,7 @@#include "cpu.h" #include "internals.h" #include "pmu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "instmap.h" #include "tcg/tcg-op.h"
target/riscv/csr.c +1 -0
@@ -25,6 +25,7 @@#include "pmu.h" #include "time_helper.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/tb-flush.h" #include "sysemu/cpu-timers.h" #include "qemu/guest-random.h"
target/riscv/op_helper.c +1 -0
@@ -22,6 +22,7 @@#include "cpu.h" #include "internals.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/cpu_ldst.h" #include "exec/helper-proto.h"
target/riscv/pmp.c +1 -1
@@ -24,7 +24,7 @@#include "qapi/error.h" #include "cpu.h" #include "trace.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" static bool pmp_write_cfg(CPURISCVState *env, uint32_t addr_index,
target/rx/cpu.c +1 -1
@@ -21,7 +21,7 @@#include "qapi/error.h" #include "cpu.h" #include "migration/vmstate.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/translation-block.h" #include "hw/loader.h"
target/s390x/gdbstub.c +1 -1
@@ -21,7 +21,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "s390x-internal.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/gdbstub.h" #include "gdbstub/helpers.h" #include "qemu/bitops.h"
target/s390x/sigp.c +1 -1
@@ -15,7 +15,7 @@#include "sysemu/hw_accel.h" #include "sysemu/runstate.h" #include "exec/address-spaces.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "sysemu/tcg.h" #include "trace.h" #include "qapi/qapi-types-machine.h"
target/s390x/tcg/excp_helper.c +1 -0
@@ -23,6 +23,7 @@#include "cpu.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "s390x-internal.h" #include "tcg_s390x.h" #ifndef CONFIG_USER_ONLY
target/s390x/tcg/mem_helper.c +1 -0
@@ -25,6 +25,7 @@#include "tcg_s390x.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/cpu_ldst.h" #include "hw/core/tcg-cpu-ops.h"
target/s390x/tcg/misc_helper.c +1 -0
@@ -27,6 +27,7 @@#include "exec/helper-proto.h" #include "qemu/timer.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/cpu_ldst.h" #include "qapi/error.h" #include "tcg_s390x.h"
target/sh4/helper.c +1 -1
@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/log.h"
target/sparc/ldst_helper.c +1 -0
@@ -24,6 +24,7 @@#include "tcg/tcg.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/cpu_ldst.h" #include "asi.h"
target/tricore/helper.c +1 -1
@@ -19,7 +19,7 @@#include "qemu/log.h" #include "hw/registerfields.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "fpu/softfloat-helpers.h" #include "qemu/qemu-print.h"
target/xtensa/helper.c +1 -1
@@ -28,7 +28,7 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "gdbstub/helpers.h" #include "exec/helper-proto.h" #include "qemu/error-report.h"
target/xtensa/mmu_helper.c +1 -0
@@ -33,6 +33,7 @@#include "exec/helper-proto.h" #include "qemu/host-utils.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #define XTENSA_MPU_SEGMENT_MASK 0x0000001f
Signature · 1 line
2.45.2
Re: [PATCH 18/24] exec: Declare tlb_flush*() in 'exec/cputlb.h'
Quoted 999 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cputlb.h | 187 +++++++++++++++++++++++++++ include/exec/exec-all.h | 183 -------------------------- accel/tcg/tcg-accel-ops.c | 1 + cpu-target.c | 1 + hw/intc/armv7m_nvic.c | 2 +- hw/ppc/spapr_nested.c | 1 + hw/sh4/sh7750.c | 1 + system/watchpoint.c | 2 +- target/alpha/helper.c | 2 +- target/alpha/sys_helper.c | 2 +- target/arm/helper.c | 1 + target/avr/helper.c | 2 +- target/hppa/mem_helper.c | 1 + target/i386/helper.c | 1 + target/i386/machine.c | 2 +- target/i386/tcg/fpu_helper.c | 2 +- target/i386/tcg/misc_helper.c | 2 +- target/i386/tcg/sysemu/misc_helper.c | 2 +- target/i386/tcg/sysemu/svm_helper.c | 2 +- target/loongarch/tcg/csr_helper.c | 2 +- target/loongarch/tcg/tlb_helper.c | 2 +- target/m68k/helper.c | 2 +- target/microblaze/mmu.c | 2 +- target/mips/sysemu/cp0.c | 2 +- target/mips/tcg/sysemu/cp0_helper.c | 2 +- target/mips/tcg/sysemu/tlb_helper.c | 2 +- target/openrisc/mmu.c | 2 +- target/openrisc/sys_helper.c | 1 + target/ppc/helper_regs.c | 2 +- target/ppc/misc_helper.c | 1 + target/ppc/mmu_helper.c | 1 + target/riscv/cpu_helper.c | 2 +- target/riscv/csr.c | 1 + target/riscv/op_helper.c | 1 + target/riscv/pmp.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/gdbstub.c | 2 +- target/s390x/sigp.c | 2 +- target/s390x/tcg/excp_helper.c | 1 + target/s390x/tcg/mem_helper.c | 1 + target/s390x/tcg/misc_helper.c | 1 + target/sh4/helper.c | 2 +- target/sparc/ldst_helper.c | 1 + target/tricore/helper.c | 2 +- target/xtensa/helper.c | 2 +- target/xtensa/mmu_helper.c | 1 + 46 files changed, 231 insertions(+), 210 deletions(-)include/exec/cputlb.h +187
-0@@ -39,6 +39,141 @@ void tlb_init(CPUState *cpu);*/ void tlb_destroy (CPUState *cpu); +/** +* tlb_flush_page: +* @cpu: CPU whose TLB should be flushed +* @addr: virtual address of page to be flushed +* +* Flush one page from the TLB of the specified CPU, for all +* MMU indexes. +*/ +void tlb_flush_page (CPUState *cpu,vaddr addr); + +/** +* tlb_flush_page_all_cpus_synced: +* @cpu: src CPU of the flush +* @addr: virtual address of page to be flushed +* +* Flush one page from the TLB of all CPUs, for all +* MMU indexes. +* +* When this function returns, no CPUs will subsequently perform +* translations using the flushed TLBs. +*/ +void tlb_flush_page_all_cpus_synced (CPUState *src,vaddr addr); + +/** +* tlb_flush: +* @cpu: CPU whose TLB should be flushed +* +* Flush the entire TLB for the specified CPU. Most CPU architectures +* allow the implementation to drop entries from the TLB at any time +* so this is generally safe. If more selective flushing is required +* use one of the other functions for efficiency. +*/ +void tlb_flush (CPUState *cpu); + +/** +* tlb_flush_all_cpus_synced: +* @cpu: src CPU of the flush +* +* Flush the entire TLB for all CPUs, for all MMU indexes. +* +* When this function returns, no CPUs will subsequently perform +* translations using the flushed TLBs. +*/ +void tlb_flush_all_cpus_synced (CPUState *src_cpu); + +/** +* tlb_flush_page_by_mmuidx: +* @cpu: CPU whose TLB should be flushed +* @addr: virtual address of page to be flushed +* @idxmap: bitmap of MMU indexes to flush +* +* Flush one page from the TLB of the specified CPU, for the specified +* MMU indexes. +*/ +void tlb_flush_page_by_mmuidx (CPUState *cpu,vaddr addr, +uint16_t idxmap); + +/** +* tlb_flush_page_by_mmuidx_all_cpus_synced: +* @cpu: Originating CPU of the flush +* @addr: virtual address of page to be flushed +* @idxmap: bitmap of MMU indexes to flush +* +* Flush one page from the TLB of all CPUs, for the specified +* MMU indexes. +* +* When this function returns, no CPUs will subsequently perform +* translations using the flushed TLBs. +*/ +void tlb_flush_page_by_mmuidx_all_cpus_synced (CPUState *cpu,vaddr addr, +uint16_t idxmap); + +/** +* tlb_flush_by_mmuidx: +* @cpu: CPU whose TLB should be flushed +* @wait: If true ensure synchronisation by exiting the cpu_loop +* @idxmap: bitmap of MMU indexes to flush +* +* Flush all entries from the TLB of the specified CPU, for the specified +* MMU indexes. +*/ +void tlb_flush_by_mmuidx (CPUState *cpu,uint16_t idxmap); + +/** +* tlb_flush_by_mmuidx_all_cpus_synced: +* @cpu: Originating CPU of the flush +* @idxmap: bitmap of MMU indexes to flush +* +* Flush all entries from the TLB of all CPUs, for the specified +* MMU indexes. +* +* When this function returns, no CPUs will subsequently perform +* translations using the flushed TLBs. +*/ +void tlb_flush_by_mmuidx_all_cpus_synced (CPUState *cpu,uint16_t idxmap); + +/** +* tlb_flush_page_bits_by_mmuidx +* @cpu: CPU whose TLB should be flushed +* @addr: virtual address of page to be flushed +* @idxmap: bitmap of mmu indexes to flush +* @bits: number of significant bits in address +* +* Similar to tlb_flush_page_mask, but with a bitmap of indexes. +*/ +void tlb_flush_page_bits_by_mmuidx (CPUState *cpu,vaddr addr, +uint16_t idxmap,unsigned bits); + +/* Similarly, with broadcast and syncing. */ +void tlb_flush_page_bits_by_mmuidx_all_cpus_synced (CPUState *cpu,vaddr addr, +uint16_t idxmap, +unsigned bits); + +/** +* tlb_flush_range_by_mmuidx +* @cpu: CPU whose TLB should be flushed +* @addr: virtual address of the start of the range to be flushed +* @len: length of range to be flushed +* @idxmap: bitmap of mmu indexes to flush +* @bits: number of significant bits in address +* +* For each mmuidx in @idxmap, flush all pages within [@addr,@addr+@len), +* comparing only the low @bits worth of each virtual page. +*/ +void tlb_flush_range_by_mmuidx (CPUState *cpu,vaddr addr, +vaddr len,uint16_t idxmap, +unsigned bits); + +/* Similarly, with broadcast and syncing. */ +void tlb_flush_range_by_mmuidx_all_cpus_synced (CPUState *cpu, +vaddr addr, +vaddr len, +uint16_t idxmap, +unsigned bits); +void tlb_protect_code (ram_addr_t ram_addr);void tlb_unprotect_code (ram_addr_t ram_addr);@@ -50,6 +185,58 @@ static inline void tlb_init(CPUState *cpu)static inline void tlb_destroy (CPUState *cpu) { } +static inline void tlb_flush_page (CPUState *cpu,vaddr addr) +{ +} +static inline void tlb_flush_page_all_cpus_synced (CPUState *src,vaddr addr) +{ +} +static inline void tlb_flush (CPUState *cpu) +{ +} +static inline void tlb_flush_all_cpus_synced (CPUState *src_cpu) +{ +} +static inline void tlb_flush_page_by_mmuidx (CPUState *cpu, +vaddr addr,uint16_t idxmap) +{ +} + +static inline void tlb_flush_by_mmuidx (CPUState *cpu,uint16_t idxmap) +{ +} +static inline void tlb_flush_page_by_mmuidx_all_cpus_synced (CPUState *cpu, +vaddr addr, +uint16_t idxmap) +{ +} +static inline void tlb_flush_by_mmuidx_all_cpus_synced (CPUState *cpu, +uint16_t idxmap) +{ +} +static inline void tlb_flush_page_bits_by_mmuidx (CPUState *cpu, +vaddr addr, +uint16_t idxmap, +unsigned bits) +{ +} +static inline void +tlb_flush_page_bits_by_mmuidx_all_cpus_synced (CPUState *cpu,vaddr addr, +uint16_t idxmap,unsigned bits) +{ +} +static inline void tlb_flush_range_by_mmuidx (CPUState *cpu,vaddr addr, +vaddr len,uint16_t idxmap, +unsigned bits) +{ +} +static inline void tlb_flush_range_by_mmuidx_all_cpus_synced (CPUState *cpu, +vaddr addr, +vaddr len, +uint16_t idxmap, +unsigned bits) +{ +}#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ include/exec/exec-all.h +0
-183@@ -46,189 +46,6 @@ static inline bool cpu_loop_exit_requested(CPUState *cpu)return (int32_t )qatomic_read (&cpu->neg.icount_decr.u32) <0 ; } -#if !defined(CONFIG_USER_ONLY ) && defined(CONFIG_TCG ) -/** -* tlb_flush_page: -* @cpu: CPU whose TLB should be flushed -* @addr: virtual address of page to be flushed -* -* Flush one page from the TLB of the specified CPU, for all -* MMU indexes. -*/ -void tlb_flush_page (CPUState *cpu,vaddr addr); -/** -* tlb_flush_page_all_cpus_synced: -* @cpu: src CPU of the flush -* @addr: virtual address of page to be flushed -* -* Flush one page from the TLB of all CPUs, for all -* MMU indexes. -* -* When this function returns, no CPUs will subsequently perform -* translations using the flushed TLBs. -*/ -void tlb_flush_page_all_cpus_synced (CPUState *src,vaddr addr); -/** -* tlb_flush: -* @cpu: CPU whose TLB should be flushed -* -* Flush the entire TLB for the specified CPU. Most CPU architectures -* allow the implementation to drop entries from the TLB at any time -* so this is generally safe. If more selective flushing is required -* use one of the other functions for efficiency. -*/ -void tlb_flush (CPUState *cpu); -/** -* tlb_flush_all_cpus_synced: -* @cpu: src CPU of the flush -* -* Flush the entire TLB for all CPUs, for all MMU indexes. -* -* When this function returns, no CPUs will subsequently perform -* translations using the flushed TLBs. -*/ -void tlb_flush_all_cpus_synced (CPUState *src_cpu); -/** -* tlb_flush_page_by_mmuidx: -* @cpu: CPU whose TLB should be flushed -* @addr: virtual address of page to be flushed -* @idxmap: bitmap of MMU indexes to flush -* -* Flush one page from the TLB of the specified CPU, for the specified -* MMU indexes. -*/ -void tlb_flush_page_by_mmuidx (CPUState *cpu,vaddr addr, -uint16_t idxmap); -/** -* tlb_flush_page_by_mmuidx_all_cpus_synced: -* @cpu: Originating CPU of the flush -* @addr: virtual address of page to be flushed -* @idxmap: bitmap of MMU indexes to flush -* -* Flush one page from the TLB of all CPUs, for the specified -* MMU indexes. -* -* When this function returns, no CPUs will subsequently perform -* translations using the flushed TLBs. -*/ -void tlb_flush_page_by_mmuidx_all_cpus_synced (CPUState *cpu,vaddr addr, -uint16_t idxmap); -/** -* tlb_flush_by_mmuidx: -* @cpu: CPU whose TLB should be flushed -* @wait: If true ensure synchronisation by exiting the cpu_loop -* @idxmap: bitmap of MMU indexes to flush -* -* Flush all entries from the TLB of the specified CPU, for the specified -* MMU indexes. -*/ -void tlb_flush_by_mmuidx (CPUState *cpu,uint16_t idxmap); -/** -* tlb_flush_by_mmuidx_all_cpus_synced: -* @cpu: Originating CPU of the flush -* @idxmap: bitmap of MMU indexes to flush -* -* Flush all entries from the TLB of all CPUs, for the specified -* MMU indexes. -* -* When this function returns, no CPUs will subsequently perform -* translations using the flushed TLBs. -*/ -void tlb_flush_by_mmuidx_all_cpus_synced (CPUState *cpu,uint16_t idxmap); - -/** -* tlb_flush_page_bits_by_mmuidx -* @cpu: CPU whose TLB should be flushed -* @addr: virtual address of page to be flushed -* @idxmap: bitmap of mmu indexes to flush -* @bits: number of significant bits in address -* -* Similar to tlb_flush_page_mask, but with a bitmap of indexes. -*/ -void tlb_flush_page_bits_by_mmuidx (CPUState *cpu,vaddr addr, -uint16_t idxmap,unsigned bits); - -/* Similarly, with broadcast and syncing. */ -void tlb_flush_page_bits_by_mmuidx_all_cpus_synced - (CPUState *cpu,vaddr addr,uint16_t idxmap,unsigned bits); - -/** -* tlb_flush_range_by_mmuidx -* @cpu: CPU whose TLB should be flushed -* @addr: virtual address of the start of the range to be flushed -* @len: length of range to be flushed -* @idxmap: bitmap of mmu indexes to flush -* @bits: number of significant bits in address -* -* For each mmuidx in @idxmap, flush all pages within [@addr,@addr+@len), -* comparing only the low @bits worth of each virtual page. -*/ -void tlb_flush_range_by_mmuidx (CPUState *cpu,vaddr addr, -vaddr len,uint16_t idxmap, -unsigned bits); - -/* Similarly, with broadcast and syncing. */ -void tlb_flush_range_by_mmuidx_all_cpus_synced (CPUState *cpu, -vaddr addr, -vaddr len, -uint16_t idxmap, -unsigned bits); - -#else -static inline void tlb_flush_page (CPUState *cpu,vaddr addr) -{ -} -static inline void tlb_flush_page_all_cpus_synced (CPUState *src,vaddr addr) -{ -} -static inline void tlb_flush (CPUState *cpu) -{ -} -static inline void tlb_flush_all_cpus_synced (CPUState *src_cpu) -{ -} -static inline void tlb_flush_page_by_mmuidx (CPUState *cpu, -vaddr addr,uint16_t idxmap) -{ -} - -static inline void tlb_flush_by_mmuidx (CPUState *cpu,uint16_t idxmap) -{ -} -static inline void tlb_flush_page_by_mmuidx_all_cpus_synced (CPUState *cpu, -vaddr addr, -uint16_t idxmap) -{ -} -static inline void tlb_flush_by_mmuidx_all_cpus_synced (CPUState *cpu, -uint16_t idxmap) -{ -} -static inline void tlb_flush_page_bits_by_mmuidx (CPUState *cpu, -vaddr addr, -uint16_t idxmap, -unsigned bits) -{ -} -static inline void -tlb_flush_page_bits_by_mmuidx_all_cpus_synced (CPUState *cpu,vaddr addr, -uint16_t idxmap,unsigned bits) -{ -} -static inline void tlb_flush_range_by_mmuidx (CPUState *cpu,vaddr addr, -vaddr len,uint16_t idxmap, -unsigned bits) -{ -} -static inline void tlb_flush_range_by_mmuidx_all_cpus_synced (CPUState *cpu, -vaddr addr, -vaddr len, -uint16_t idxmap, -unsigned bits) -{ -} -#endif -#if defined(CONFIG_TCG )/** accel/tcg/tcg-accel-ops.c +1
-0@@ -33,6 +33,7 @@#include "qemu/guest-random.h" #include "qemu/timer.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/hwaddr.h" #include "exec/tb-flush.h" #include "exec/translation-block.h" cpu-target.c +1
-0@@ -40,6 +40,7 @@#include "exec/replay-core.h" #include "exec/cpu-common.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/tb-flush.h" #include "exec/translate-all.h" #include "exec/log.h" hw/intc/armv7m_nvic.c +1
-1@@ -22,7 +22,7 @@#include "sysemu/runstate.h" #include "target/arm/cpu.h" #include "target/arm/cpu-features.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/memop.h" #include "qemu/log.h" #include "qemu/module.h" hw/ppc/spapr_nested.c +1
-0@@ -1,6 +1,7 @@#include "qemu/osdep.h" #include "qemu/cutils.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "helper_regs.h" #include "hw/ppc/ppc.h" #include "hw/ppc/spapr.h" hw/sh4/sh7750.c +1
-0@@ -36,6 +36,7 @@#include "hw/sh4/sh_intc.h" #include "hw/timer/tmu012.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "trace.h" typedef struct SH7750State {system/watchpoint.c +1
-1@@ -19,8 +19,8 @@#include "qemu/osdep.h" #include "qemu/error-report.h" -#include "exec/exec-all.h" #include "exec/cpu-all.h" +#include "exec/cputlb.h" #include "hw/core/cpu.h" /* Add a watchpoint. */ target/alpha/helper.c +1
-1@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "fpu/softfloat-types.h" #include "exec/helper-proto.h" target/alpha/sys_helper.c +1
-1@@ -19,7 +19,7 @@#include "qemu/osdep.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/tb-flush.h" #include "exec/helper-proto.h" #include "sysemu/runstate.h" target/arm/helper.c +1
-0@@ -19,6 +19,7 @@#include "qemu/crc32c.h" #include "qemu/qemu-print.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include <zlib.h> /* for crc32 */ #include "hw/irq.h" #include "sysemu/cpu-timers.h" target/avr/helper.c +1
-1@@ -23,7 +23,7 @@#include "qemu/error-report.h" #include "cpu.h" #include "hw/core/tcg-cpu-ops.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/cpu_ldst.h" #include "exec/address-spaces.h" target/hppa/mem_helper.c +1
-0@@ -21,6 +21,7 @@#include "qemu/log.h" #include "cpu.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/helper-proto.h" #include "hw/core/cpu.h" target/i386/helper.c +1
-0@@ -21,6 +21,7 @@#include "qapi/qapi-events-run-state.h" #include "cpu.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/translation-block.h" #include "sysemu/runstate.h" #ifndef CONFIG_USER_ONLY target/i386/machine.c +1
-1@@ -1,6 +1,6 @@#include "qemu/osdep.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "hw/isa/isa.h" #include "migration/cpu.h" #include "kvm/hyperv.h" target/i386/tcg/fpu_helper.c +1
-1@@ -21,7 +21,7 @@#include <math.h> #include "cpu.h" #include "tcg-cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/cpu_ldst.h" #include "exec/helper-proto.h" #include "fpu/softfloat.h" target/i386/tcg/misc_helper.c +1
-1@@ -21,7 +21,7 @@#include "qemu/log.h" #include "cpu.h" #include "exec/helper-proto.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "helper-tcg.h" /* target/i386/tcg/sysemu/misc_helper.c +1
-1@@ -23,7 +23,7 @@#include "exec/helper-proto.h" #include "exec/cpu_ldst.h" #include "exec/address-spaces.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "tcg/helper-tcg.h" #include "hw/i386/apic.h" target/i386/tcg/sysemu/svm_helper.c +1
-1@@ -21,7 +21,7 @@#include "qemu/log.h" #include "cpu.h" #include "exec/helper-proto.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/cpu_ldst.h" #include "tcg/helper-tcg.h" target/loongarch/tcg/csr_helper.c +1
-1@@ -11,7 +11,7 @@#include "internals.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/cpu_ldst.h" #include "hw/irq.h" #include "cpu-csr.h" target/loongarch/tcg/tlb_helper.c +1
-1@@ -12,7 +12,7 @@#include "cpu.h" #include "internals.h" #include "exec/helper-proto.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/cpu_ldst.h" #include "exec/log.h" target/m68k/helper.c +1
-1@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/gdbstub.h" #include "exec/helper-proto.h" target/microblaze/mmu.c +1
-1@@ -21,7 +21,7 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" static unsigned int tlb_decode_size (unsigned int f)target/mips/sysemu/cp0.c +1
-1@@ -21,7 +21,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "internal.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" /* Called for updates to CP0_Status. */ void sync_c0_status (CPUMIPSState *env,CPUMIPSState *cpu,int tc)target/mips/tcg/sysemu/cp0_helper.c +1
-1@@ -27,7 +27,7 @@#include "internal.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" /* SMP helpers. */ target/mips/tcg/sysemu/tlb_helper.c +1
-1@@ -21,7 +21,7 @@#include "cpu.h" #include "internal.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/cpu_ldst.h" #include "exec/log.h" target/openrisc/mmu.c +1
-1@@ -21,7 +21,7 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "gdbstub/helpers.h" #include "qemu/host-utils.h" target/openrisc/sys_helper.c +1
-0@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/helper-proto.h" #include "exception.h" #ifndef CONFIG_USER_ONLY target/ppc/helper_regs.c +1
-1@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "qemu/main-loop.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "sysemu/kvm.h" #include "sysemu/tcg.h" #include "helper_regs.h" target/ppc/misc_helper.c +1
-0@@ -21,6 +21,7 @@#include "qemu/log.h" #include "cpu.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/helper-proto.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" target/ppc/mmu_helper.c +1
-0@@ -24,6 +24,7 @@#include "kvm_ppc.h" #include "mmu-hash64.h" #include "mmu-hash32.h" +#include "exec/cputlb.h" #include "exec/exec-all.h" #include "exec/page-protection.h" #include "exec/log.h" target/riscv/cpu_helper.c +1
-1@@ -23,7 +23,7 @@#include "cpu.h" #include "internals.h" #include "pmu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "instmap.h" #include "tcg/tcg-op.h" target/riscv/csr.c +1
-0@@ -25,6 +25,7 @@#include "pmu.h" #include "time_helper.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/tb-flush.h" #include "sysemu/cpu-timers.h" #include "qemu/guest-random.h" target/riscv/op_helper.c +1
-0@@ -22,6 +22,7 @@#include "cpu.h" #include "internals.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/cpu_ldst.h" #include "exec/helper-proto.h" target/riscv/pmp.c +1
-1@@ -24,7 +24,7 @@#include "qapi/error.h" #include "cpu.h" #include "trace.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" static bool pmp_write_cfg(CPURISCVState *env, uint32_t addr_index,target/rx/cpu.c +1
-1@@ -21,7 +21,7 @@#include "qapi/error.h" #include "cpu.h" #include "migration/vmstate.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/translation-block.h" #include "hw/loader.h" target/s390x/gdbstub.c +1
-1@@ -21,7 +21,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "s390x-internal.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/gdbstub.h" #include "gdbstub/helpers.h" #include "qemu/bitops.h" target/s390x/sigp.c +1
-1@@ -15,7 +15,7 @@#include "sysemu/hw_accel.h" #include "sysemu/runstate.h" #include "exec/address-spaces.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "sysemu/tcg.h" #include "trace.h" #include "qapi/qapi-types-machine.h" target/s390x/tcg/excp_helper.c +1
-0@@ -23,6 +23,7 @@#include "cpu.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "s390x-internal.h" #include "tcg_s390x.h" #ifndef CONFIG_USER_ONLY target/s390x/tcg/mem_helper.c +1
-0@@ -25,6 +25,7 @@#include "tcg_s390x.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/cpu_ldst.h" #include "hw/core/tcg-cpu-ops.h" target/s390x/tcg/misc_helper.c +1
-0@@ -27,6 +27,7 @@#include "exec/helper-proto.h" #include "qemu/timer.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/cpu_ldst.h" #include "qapi/error.h" #include "tcg_s390x.h" target/sh4/helper.c +1
-1@@ -20,7 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/log.h" target/sparc/ldst_helper.c +1
-0@@ -24,6 +24,7 @@#include "tcg/tcg.h" #include "exec/helper-proto.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "exec/cpu_ldst.h" #include "asi.h" target/tricore/helper.c +1
-1@@ -19,7 +19,7 @@#include "qemu/log.h" #include "hw/registerfields.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #include "fpu/softfloat-helpers.h" #include "qemu/qemu-print.h" target/xtensa/helper.c +1
-1@@ -28,7 +28,7 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" -#include "exec/exec-all.h" +#include "exec/cputlb.h" #include "gdbstub/helpers.h" #include "exec/helper-proto.h" #include "qemu/error-report.h" target/xtensa/mmu_helper.c +0
-0
target/xtensa/mmu_helper.c line 39
Quoted 7 lines
target/xtensa/mmu_helper.c +1
-0@@ -33,6 +33,7 @@#include "exec/helper-proto.h" #include "qemu/host-utils.h" #include "exec/exec-all.h" +#include "exec/cputlb.h" #include "exec/page-protection.h" #define XTENSA_MPU_SEGMENT_MASK 0x0000001f
Re: [PATCH 18/24] exec: Declare tlb_flush*() in 'exec/cputlb.h'
In reply to Philippe Mathieu-DaudéQuoted 43 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cputlb.h | 187 +++++++++++++++++++++++++++ include/exec/exec-all.h | 183 -------------------------- accel/tcg/tcg-accel-ops.c | 1 + cpu-target.c | 1 + hw/intc/armv7m_nvic.c | 2 +- hw/ppc/spapr_nested.c | 1 + hw/sh4/sh7750.c | 1 + system/watchpoint.c | 2 +- target/alpha/helper.c | 2 +- target/alpha/sys_helper.c | 2 +- target/arm/helper.c | 1 + target/avr/helper.c | 2 +- target/hppa/mem_helper.c | 1 + target/i386/helper.c | 1 + target/i386/machine.c | 2 +- target/i386/tcg/fpu_helper.c | 2 +- target/i386/tcg/misc_helper.c | 2 +- target/i386/tcg/sysemu/misc_helper.c | 2 +- target/i386/tcg/sysemu/svm_helper.c | 2 +- target/loongarch/tcg/csr_helper.c | 2 +- target/loongarch/tcg/tlb_helper.c | 2 +- target/m68k/helper.c | 2 +- target/microblaze/mmu.c | 2 +- target/mips/sysemu/cp0.c | 2 +- target/mips/tcg/sysemu/cp0_helper.c | 2 +- target/mips/tcg/sysemu/tlb_helper.c | 2 +- target/openrisc/mmu.c | 2 +- target/openrisc/sys_helper.c | 1 + target/ppc/helper_regs.c | 2 +- target/ppc/misc_helper.c | 1 + target/ppc/mmu_helper.c | 1 + target/riscv/cpu_helper.c | 2 +- target/riscv/csr.c | 1 + target/riscv/op_helper.c | 1 + target/riscv/pmp.c | 2 +- target/rx/cpu.c | 2 +- target/s390x/gdbstub.c | 2 +- target/s390x/sigp.c | 2 +- target/s390x/tcg/excp_helper.c | 1 +
Quoted 8 lines
target/s390x/tcg/mem_helper.c | 1 + target/s390x/tcg/misc_helper.c | 1 + target/sh4/helper.c | 2 +- target/sparc/ldst_helper.c | 1 + target/tricore/helper.c | 2 +- target/xtensa/helper.c | 2 +- target/xtensa/mmu_helper.c | 1 + 46 files changed, 231 insertions(+), 210 deletions(-)
r~
PATCH 19/24 exec: Declare tlb_hit*() in 'exec/cputlb.h'
In reply to Philippe Mathieu-DaudéMove CPU TLB related methods to "exec/cputlb.h".
--- include/exec/cpu-all.h | 23 ----------------------- accel/tcg/cputlb.c | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 23 deletions(-)
include/exec/cpu-all.h +0 -23
@@ -323,29 +323,6 @@ static inline int cpu_mmu_index(CPUState *cs, bool ifetch)/* The two sets of flags must not overlap. */ QEMU_BUILD_BUG_ON (TLB_FLAGS_MASK &TLB_SLOW_FLAGS_MASK ); -/** -* tlb_hit_page: return true if page aligned @addr is a hit against the -* TLB entry @tlb_addr -* -* @addr: virtual address to test (must be page aligned) -* @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value) -*/ -static inline bool tlb_hit_page (uint64_t tlb_addr,vaddr addr) -{ -return addr == (tlb_addr & (TARGET_PAGE_MASK |TLB_INVALID_MASK )); -} - -/** -* tlb_hit: return true if @addr is a hit against the TLB entry @tlb_addr -* -* @addr: virtual address to test (need not be page aligned) -* @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value) -*/ -static inline bool tlb_hit (uint64_t tlb_addr,vaddr addr) -{ -return tlb_hit_page (tlb_addr, addr &TARGET_PAGE_MASK ); -} -#endif /* !CONFIG_USER_ONLY */ /* Validate correct placement of CPUArchState. */
accel/tcg/cputlb.c +23 -0
@@ -1220,6 +1220,29 @@ void tlb_set_page(CPUState *cpu, vaddr addr, prot, mmu_idx, size); } +/** +* tlb_hit_page: return true if page aligned @addr is a hit against the +* TLB entry @tlb_addr +* +* @addr: virtual address to test (must be page aligned) +* @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value) +*/ +static inline bool tlb_hit_page (uint64_t tlb_addr,vaddr addr) +{ +return addr == (tlb_addr & (TARGET_PAGE_MASK |TLB_INVALID_MASK )); +} + +/** +* tlb_hit: return true if @addr is a hit against the TLB entry @tlb_addr +* +* @addr: virtual address to test (need not be page aligned) +* @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value) +*/ +static inline bool tlb_hit (uint64_t tlb_addr,vaddr addr) +{ +return tlb_hit_page (tlb_addr, addr &TARGET_PAGE_MASK ); +} +/* * Note: tlb_fill_align() can trigger a resize of the TLB. * This means that all of the caller's prior references to the TLB table
Signature · 1 line
2.45.2
Re: [PATCH 19/24] exec: Declare tlb_hit*() in 'exec/cputlb.h'
Quoted 66 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cpu-all.h | 23 ----------------------- accel/tcg/cputlb.c | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 23 deletions(-)include/exec/cpu-all.h +0
-23@@ -323,29 +323,6 @@ static inline int cpu_mmu_index(CPUState *cs, bool ifetch)/* The two sets of flags must not overlap. */ QEMU_BUILD_BUG_ON (TLB_FLAGS_MASK &TLB_SLOW_FLAGS_MASK ); -/** -* tlb_hit_page: return true if page aligned @addr is a hit against the -* TLB entry @tlb_addr -* -* @addr: virtual address to test (must be page aligned) -* @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value) -*/ -static inline bool tlb_hit_page (uint64_t tlb_addr,vaddr addr) -{ -return addr == (tlb_addr & (TARGET_PAGE_MASK |TLB_INVALID_MASK )); -} - -/** -* tlb_hit: return true if @addr is a hit against the TLB entry @tlb_addr -* -* @addr: virtual address to test (need not be page aligned) -* @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value) -*/ -static inline bool tlb_hit (uint64_t tlb_addr,vaddr addr) -{ -return tlb_hit_page (tlb_addr, addr &TARGET_PAGE_MASK ); -} -#endif /* !CONFIG_USER_ONLY */ /* Validate correct placement of CPUArchState. */ accel/tcg/cputlb.c +16
-0@@ -1220,6 +1220,29 @@ void tlb_set_page(CPUState *cpu, vaddr addr, prot, mmu_idx, size); } +/** +* tlb_hit_page: return true if page aligned @addr is a hit against the +* TLB entry @tlb_addr +* +* @addr: virtual address to test (must be page aligned) +* @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value) +*/ +static inline bool tlb_hit_page (uint64_t tlb_addr,vaddr addr) +{ +return addr == (tlb_addr & (TARGET_PAGE_MASK |TLB_INVALID_MASK )); +} + +/** +* tlb_hit: return true if @addr is a hit against the TLB entry @tlb_addr +* +* @addr: virtual address to test (need not be page aligned)
accel/tcg/cputlb.c void tlb_set_page(CPUState *cpu, vaddr addr, · line 1248
Quoted 10 lines
accel/tcg/cputlb.c +7
-0+* @tlb_addr: TLB entry address (a CPUTLBEntry addr_read/write/code value) +*/ +static inline bool tlb_hit (uint64_t tlb_addr,vaddr addr) +{ +return tlb_hit_page (tlb_addr, addr &TARGET_PAGE_MASK ); +} +/* * Note: tlb_fill_align() can trigger a resize of the TLB. * This means that all of the caller's prior references to the TLB table
Re: [PATCH 19/24] exec: Declare tlb_hit*() in 'exec/cputlb.h'
In reply to Philippe Mathieu-DaudéQuoted 7 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cpu-all.h | 23 ----------------------- accel/tcg/cputlb.c | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 23 deletions(-)
These are not actually used outside of accel/tcg/cputlb.c.
r~
PATCH 20/24 exec: Declare tlb_vaddr_to_host() in 'exec/cputlb.h'
In reply to Philippe Mathieu-DaudéMove CPU TLB related methods to "exec/cputlb.h".
--- include/exec/cpu_ldst.h | 25 ------------------------- include/exec/cputlb.h | 26 ++++++++++++++++++++++++++ target/arm/tcg/helper-a64.c | 1 + target/ppc/mem_helper.c | 1 + 4 files changed, 28 insertions(+), 25 deletions(-)
include/exec/cpu_ldst.h +0 -25
@@ -69,7 +69,6 @@#include "exec/memopidx.h" #include "exec/vaddr.h" #include "exec/abi_ptr.h" -#include "exec/mmu-access-type.h" #include "qemu/int128.h" #if defined(CONFIG_USER_ONLY )
@@ -311,30 +310,6 @@ uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr);uint32_t cpu_ldl_code (CPUArchState *env,abi_ptr addr);uint64_t cpu_ldq_code (CPUArchState *env,abi_ptr addr); -/** -* tlb_vaddr_to_host: -* @env: CPUArchState -* @addr: guest virtual address to look up -* @access_type: 0 for read, 1 for write, 2 for execute -* @mmu_idx: MMU index to use for lookup -* -* Look up the specified guest virtual index in the TCG softmmu TLB. -* If we can translate a host virtual address suitable for direct RAM -* access, without causing a guest exception, then return it. -* Otherwise (TLB entry is for an I/O access, guest software -* TLB fill required, etc) return NULL. -*/ -#ifdef CONFIG_USER_ONLY -static inline void *tlb_vaddr_to_host (CPUArchState *env,abi_ptr addr, -MMUAccessType access_type,int mmu_idx) -{ -return g2h (env_cpu (env), addr); -} -#else -void *tlb_vaddr_to_host (CPUArchState *env,vaddr addr, -MMUAccessType access_type,int mmu_idx); -#endif -/* * For user-only, helpers that use guest to host address translation * must protect the actual host memory access by recording 'retaddr'
include/exec/cputlb.h +26 -0
@@ -20,6 +20,7 @@#ifndef CPUTLB_H #define CPUTLB_H +#include "exec/abi_ptr.h" #include "exec/cpu-common.h" #include "exec/hwaddr.h" #include "exec/memattrs.h"
@@ -306,4 +307,29 @@ void tlb_set_page(CPUState *cpu, vaddr addr, hwaddr paddr, int prot, int mmu_idx, vaddr size); +/** +* tlb_vaddr_to_host: +* @env: CPUArchState +* @addr: guest virtual address to look up +* @access_type: 0 for read, 1 for write, 2 for execute +* @mmu_idx: MMU index to use for lookup +* +* Look up the specified guest virtual index in the TCG softmmu TLB. +* If we can translate a host virtual address suitable for direct RAM +* access, without causing a guest exception, then return it. +* Otherwise (TLB entry is for an I/O access, guest software +* TLB fill required, etc) return NULL. +*/ +#ifdef CONFIG_USER_ONLY +#include "user/guest-host.h" +static inline void *tlb_vaddr_to_host (CPUArchState *env,abi_ptr addr, +MMUAccessType access_type,int mmu_idx) +{ +return g2h (env_cpu (env), addr); +} +#else +void *tlb_vaddr_to_host (CPUArchState *env,vaddr addr, +MMUAccessType access_type,int mmu_idx); +#endif +#endif
target/arm/tcg/helper-a64.c +1 -0
@@ -30,6 +30,7 @@#include "qemu/crc32c.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" +#include "exec/cputlb.h" #include "qemu/int128.h" #include "qemu/atomic128.h" #include "fpu/softfloat.h"
target/ppc/mem_helper.c +1 -0
@@ -24,6 +24,7 @@#include "exec/helper-proto.h" #include "helper_regs.h" #include "exec/cpu_ldst.h" +#include "exec/cputlb.h" #include "internal.h" #include "qemu/atomic128.h"
Signature · 1 line
2.45.2
Re: [PATCH 20/24] exec: Declare tlb_vaddr_to_host() in 'exec/cputlb.h'
Quoted 112 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cpu_ldst.h | 25 ------------------------- include/exec/cputlb.h | 26 ++++++++++++++++++++++++++ target/arm/tcg/helper-a64.c | 1 + target/ppc/mem_helper.c | 1 + 4 files changed, 28 insertions(+), 25 deletions(-)include/exec/cpu_ldst.h +0
-25@@ -69,7 +69,6 @@#include "exec/memopidx.h" #include "exec/vaddr.h" #include "exec/abi_ptr.h" -#include "exec/mmu-access-type.h" #include "qemu/int128.h" #if defined(CONFIG_USER_ONLY )@@ -311,30 +310,6 @@ uint32_t cpu_lduw_code(CPUArchState *env, abi_ptr addr);uint32_t cpu_ldl_code (CPUArchState *env,abi_ptr addr);uint64_t cpu_ldq_code (CPUArchState *env,abi_ptr addr); -/** -* tlb_vaddr_to_host: -* @env: CPUArchState -* @addr: guest virtual address to look up -* @access_type: 0 for read, 1 for write, 2 for execute -* @mmu_idx: MMU index to use for lookup -* -* Look up the specified guest virtual index in the TCG softmmu TLB. -* If we can translate a host virtual address suitable for direct RAM -* access, without causing a guest exception, then return it. -* Otherwise (TLB entry is for an I/O access, guest software -* TLB fill required, etc) return NULL. -*/ -#ifdef CONFIG_USER_ONLY -static inline void *tlb_vaddr_to_host (CPUArchState *env,abi_ptr addr, -MMUAccessType access_type,int mmu_idx) -{ -return g2h (env_cpu (env), addr); -} -#else -void *tlb_vaddr_to_host (CPUArchState *env,vaddr addr, -MMUAccessType access_type,int mmu_idx); -#endif -/* * For user-only, helpers that use guest to host address translation * must protect the actual host memory access by recording 'retaddr' include/exec/cputlb.h +26
-0@@ -20,6 +20,7 @@#ifndef CPUTLB_H #define CPUTLB_H +#include "exec/abi_ptr.h" #include "exec/cpu-common.h" #include "exec/hwaddr.h" #include "exec/memattrs.h" @@ -306,4 +307,29 @@ void tlb_set_page(CPUState *cpu, vaddr addr, hwaddr paddr, int prot, int mmu_idx, vaddr size); +/** +* tlb_vaddr_to_host: +* @env: CPUArchState +* @addr: guest virtual address to look up +* @access_type: 0 for read, 1 for write, 2 for execute +* @mmu_idx: MMU index to use for lookup +* +* Look up the specified guest virtual index in the TCG softmmu TLB. +* If we can translate a host virtual address suitable for direct RAM +* access, without causing a guest exception, then return it. +* Otherwise (TLB entry is for an I/O access, guest software +* TLB fill required, etc) return NULL. +*/ +#ifdef CONFIG_USER_ONLY +#include "user/guest-host.h" +static inline void *tlb_vaddr_to_host (CPUArchState *env,abi_ptr addr, +MMUAccessType access_type,int mmu_idx) +{ +return g2h (env_cpu (env), addr); +} +#else +void *tlb_vaddr_to_host (CPUArchState *env,vaddr addr, +MMUAccessType access_type,int mmu_idx); +#endif +#endif target/arm/tcg/helper-a64.c +1
-0@@ -30,6 +30,7 @@#include "qemu/crc32c.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" +#include "exec/cputlb.h" #include "qemu/int128.h" #include "qemu/atomic128.h" #include "fpu/softfloat.h" target/ppc/mem_helper.c +0
-0
target/ppc/mem_helper.c line 30
Quoted 7 lines
target/ppc/mem_helper.c +1
-0@@ -24,6 +24,7 @@#include "exec/helper-proto.h" #include "helper_regs.h" #include "exec/cpu_ldst.h" +#include "exec/cputlb.h" #include "internal.h" #include "qemu/atomic128.h"
Re: [PATCH 20/24] exec: Declare tlb_vaddr_to_host() in 'exec/cputlb.h'
In reply to Philippe Mathieu-DaudéQuoted 9 lines · Philippe Mathieu-Daudé
Move CPU TLB related methods to "
exec/cputlb.h".Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cpu_ldst.h | 25 ------------------------- include/exec/cputlb.h | 26 ++++++++++++++++++++++++++ target/arm/tcg/helper-a64.c | 1 + target/ppc/mem_helper.c | 1 + 4 files changed, 28 insertions(+), 25 deletions(-)
Hmm. I'm not sure about using cputlb.h here.
This is general-purpose guest->host translation, with or without a tlb. It's more similar to user/guest-host.h, but obviously not user specific.
I think cpu_ldst.h itself is ok, because that's guest->host translation combined with a memory operation. But I'm also fine if you want to create a completely new header. Perhaps probe-access.h? This is the oldest of the family of probing functions after all.
r~
PATCH 21/24 exec: Extract CPU physical memory API to 'sysemu/physmem-target.h'
In reply to Philippe Mathieu-DaudéIn order to keep "exec/ram_addr.h" focused on (target agnostic) methods related to the ram_addr_t type, move all (target specific) CPU physical memory API to a new "sysemu/physmem-target.h" header.
--- MAINTAINERS | 1 + include/exec/ram_addr.h | 483 +--------------------------- include/sysemu/physmem-target.h | 506 ++++++++++++++++++++++++++++++ accel/kvm/kvm-all.c | 1 + accel/tcg/cputlb.c | 1 + accel/tcg/translate-all.c | 1 + hw/ppc/spapr.c | 1 + hw/ppc/spapr_caps.c | 1 + hw/ppc/spapr_pci.c | 1 + hw/remote/memory.c | 1 + hw/remote/proxy-memory-listener.c | 1 + hw/s390x/s390-stattrib-kvm.c | 1 + hw/s390x/s390-stattrib.c | 1 + hw/s390x/s390-virtio-ccw.c | 1 + hw/vfio/common.c | 1 + hw/vfio/container.c | 1 + hw/vfio/iommufd.c | 1 + hw/vfio/migration.c | 1 + hw/vfio/spapr.c | 1 + hw/virtio/virtio-mem.c | 1 + migration/ram.c | 1 + plugins/api.c | 1 + system/memory.c | 1 + system/physmem.c | 1 + target/arm/tcg/mte_helper.c | 1 + target/ppc/kvm.c | 1 + target/s390x/kvm/kvm.c | 1 + 27 files changed, 532 insertions(+), 482 deletions(-) create mode 100644 include/sysemu/physmem-target.h
MAINTAINERS +1 -0
@@ -3027,6 +3027,7 @@ F: include/exec/memory.h F: include/exec/ram_addr.h F: include/exec/ramblock.h F: include/sysemu/memory_mapping.h +F: include/sysemu/physmem-target.h F: system/dma-helpers.c F: system/ioport.c F: system/memory.c
include/exec/ram_addr.h +1 -482
494 lines not on this page · raw message
include/sysemu/physmem-target.h new file +506 -0
506 lines not on this page · raw message
accel/kvm/kvm-all.c +1 -0
@@ -35,6 +35,7 @@#include "qemu/bswap.h" #include "exec/memory.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/event_notifier.h" #include "qemu/main-loop.h" #include "trace.h"
accel/tcg/cputlb.c +1 -0
@@ -28,6 +28,7 @@#include "exec/tb-flush.h" #include "exec/memory-internal.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "exec/mmu-access-type.h" #include "exec/tlb-common.h" #include "exec/vaddr.h"
accel/tcg/translate-all.c +1 -0
@@ -41,6 +41,7 @@#endif #else #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #endif #include "exec/cputlb.h"
hw/ppc/spapr.c +1 -0
@@ -75,6 +75,7 @@#include "hw/virtio/vhost-scsi-common.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "exec/confidential-guest-support.h" #include "hw/usb.h" #include "qemu/config-file.h"
hw/ppc/spapr_caps.c +1 -0
@@ -28,6 +28,7 @@#include "qapi/visitor.h" #include "sysemu/hw_accel.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "target/ppc/cpu.h" #include "target/ppc/mmu-hash64.h" #include "cpu-models.h"
hw/ppc/spapr_pci.c +1 -0
@@ -35,6 +35,7 @@#include "hw/ppc/spapr.h" #include "hw/pci-host/spapr.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include <libfdt.h> #include "trace.h" #include "qemu/error-report.h"
hw/remote/memory.c +1 -0
@@ -12,6 +12,7 @@#include "hw/remote/memory.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qapi/error.h" static void remote_sysmem_reset (void )
hw/remote/proxy-memory-listener.c +1 -0
@@ -13,6 +13,7 @@#include "exec/memory.h" #include "exec/cpu-common.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/remote/mpqemu-link.h"
hw/s390x/s390-stattrib-kvm.c +1 -0
@@ -16,6 +16,7 @@#include "qemu/error-report.h" #include "sysemu/kvm.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "kvm/kvm_s390x.h" #include "qapi/error.h"
hw/s390x/s390-stattrib.c +1 -0
@@ -17,6 +17,7 @@#include "hw/s390x/storage-attributes.h" #include "qemu/error-report.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "cpu.h"
hw/s390x/s390-virtio-ccw.c +1 -0
@@ -14,6 +14,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "exec/confidential-guest-support.h" #include "hw/boards.h" #include "hw/s390x/s390-virtio-hcall.h"
hw/vfio/common.c +1 -0
@@ -30,6 +30,7 @@#include "exec/address-spaces.h" #include "exec/memory.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "hw/hw.h" #include "qemu/error-report.h" #include "qemu/main-loop.h"
hw/vfio/container.c +1 -0
@@ -26,6 +26,7 @@#include "exec/address-spaces.h" #include "exec/memory.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/error-report.h" #include "qemu/range.h" #include "sysemu/reset.h"
hw/vfio/iommufd.c +1 -0
@@ -26,6 +26,7 @@#include "qemu/chardev_open.h" #include "pci.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" static int iommufd_cdev_map (const VFIOContainerBase *bcontainer,hwaddr iova,ram_addr_t size,void *vaddr,bool readonly)
hw/vfio/migration.c +1 -0
@@ -27,6 +27,7 @@#include "qapi/qapi-events-vfio.h" #include "exec/ramlist.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "pci.h" #include "trace.h" #include "hw/hw.h"
hw/vfio/spapr.c +1 -0
@@ -20,6 +20,7 @@#include "hw/vfio/vfio-common.h" #include "hw/hw.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "trace.h"
hw/virtio/virtio-mem.c +1 -0
@@ -25,6 +25,7 @@#include "qapi/error.h" #include "qapi/visitor.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "migration/misc.h" #include "hw/boards.h" #include "hw/qdev-properties.h"
migration/ram.c +1 -0
@@ -49,6 +49,7 @@#include "qapi/qmp/qerror.h" #include "trace.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "exec/target_page.h" #include "qemu/rcu_queue.h" #include "migration/colo.h"
plugins/api.c +1 -0
@@ -50,6 +50,7 @@#include "qapi/error.h" #include "migration/blocker.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/plugin-memory.h" #include "hw/boards.h" #else
system/memory.c +1 -0
@@ -27,6 +27,7 @@#include "exec/memory-internal.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "sysemu/kvm.h" #include "sysemu/runstate.h" #include "sysemu/tcg.h"
system/physmem.c +1 -0
@@ -67,6 +67,7 @@#include "exec/memory-internal.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/pmem.h"
target/arm/tcg/mte_helper.c +1 -0
@@ -25,6 +25,7 @@#include "exec/page-protection.h" #ifndef CONFIG_USER_ONLY #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #endif #include "exec/cpu_ldst.h" #include "exec/helper-proto.h"
target/ppc/kvm.c +1 -0
@@ -42,6 +42,7 @@#include "gdbstub/enums.h" #include "exec/memattrs.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "sysemu/hostmem.h" #include "qemu/cutils.h" #include "qemu/main-loop.h"
target/s390x/kvm/kvm.c +1 -0
@@ -42,6 +42,7 @@#include "sysemu/device_tree.h" #include "gdbstub/enums.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "trace.h" #include "hw/s390x/s390-pci-inst.h" #include "hw/s390x/s390-pci-bus.h"
Signature · 1 line
2.45.2
Re: [PATCH 21/24] exec: Extract CPU physical memory API to 'sysemu/physmem-target.h'
Quoted 10 lines · Philippe Mathieu-Daudé
In order to keep "
exec/ram_addr.h" focused on (target agnostic) methods related to theram_addr_ttype, move all (target specific) CPU physical memory API to a new "sysemu/physmem-target.h" header.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- MAINTAINERS | 1 + include/exec/ram_addr.h | 483 +--------------------------- include/sysemu/physmem-target.h | 506 ++++++++++++++++++++++++++++++
...
Quoted 16 lines
include/sysemu/physmem-target.h new file +10
-0@@ -0,0 +1,506 @@ +/* +* Declarations for cpu physical memory functions +* +* Copyright 2011 Red Hat, Inc. and/or its affiliates +* +* Authors: +* Avi Kivity <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or +* later. See the COPYING file in the top-level directory.
include/sysemu/physmem-target.h line 20
Quoted 10 lines
include/sysemu/physmem-target.h new file +10
-0+* +*/ + +/* +* This header is for use by exec.c and memory.c ONLY. Do not include it. +* The functions declared here will be removed soon. +*/ + +#ifndef RAM_ADDR_TARGET_H +#define RAM_ADDR_TARGET_H
PHYSMEM_TARGET_H.
Quoted 9 lines
include/sysemu/physmem-target.h new file +9
-0+ +#include "cpu.h" +#include "sysemu/xen.h" +#include "sysemu/tcg.h" +#include "exec/cputlb.h" +#include "exec/ram_addr.h" +#include "exec/ramlist.h" +#include "exec/ramblock.h" +#include "qemu/rcu.h"
Re: [PATCH 21/24] exec: Extract CPU physical memory API to 'sysemu/physmem-target.h'
In reply to Philippe Mathieu-DaudéQuoted 1,342 lines · Philippe Mathieu-Daudé
In order to keep "
exec/ram_addr.h" focused on (target agnostic) methods related to theram_addr_ttype, move all (target specific) CPU physical memory API to a new "sysemu/physmem-target.h" header.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- MAINTAINERS | 1 + include/exec/ram_addr.h | 483 +--------------------------- include/sysemu/physmem-target.h | 506 ++++++++++++++++++++++++++++++ accel/kvm/kvm-all.c | 1 + accel/tcg/cputlb.c | 1 + accel/tcg/translate-all.c | 1 + hw/ppc/spapr.c | 1 + hw/ppc/spapr_caps.c | 1 + hw/ppc/spapr_pci.c | 1 + hw/remote/memory.c | 1 + hw/remote/proxy-memory-listener.c | 1 + hw/s390x/s390-stattrib-kvm.c | 1 + hw/s390x/s390-stattrib.c | 1 + hw/s390x/s390-virtio-ccw.c | 1 + hw/vfio/common.c | 1 + hw/vfio/container.c | 1 + hw/vfio/iommufd.c | 1 + hw/vfio/migration.c | 1 + hw/vfio/spapr.c | 1 + hw/virtio/virtio-mem.c | 1 + migration/ram.c | 1 + plugins/api.c | 1 + system/memory.c | 1 + system/physmem.c | 1 + target/arm/tcg/mte_helper.c | 1 + target/ppc/kvm.c | 1 + target/s390x/kvm/kvm.c | 1 + 27 files changed, 532 insertions(+), 482 deletions(-)create mode 100644
include/sysemu/physmem-target.hMAINTAINERS +1
-0@@ -3027,6 +3027,7 @@ F: include/exec/memory.h F: include/exec/ram_addr.h F: include/exec/ramblock.h F: include/sysemu/memory_mapping.h +F: include/sysemu/physmem-target.h F: system/dma-helpers.c F: system/ioport.c F: system/memory.cinclude/exec/ram_addr.h +1
-482@@ -20,82 +20,6 @@#define RAM_ADDR_H #ifndef CONFIG_USER_ONLY -#include "cpu.h" -#include "sysemu/xen.h" -#include "sysemu/tcg.h" -#include "exec/cputlb.h" -#include "exec/ramlist.h" -#include "exec/ramblock.h" -#include "exec/exec-all.h" -#include "qemu/rcu.h" - -extern uint64_t total_dirty_pages; - -/** -* clear_bmap_size: calculate clear bitmap size -* -* @pages: number of guest pages -* @shift: guest page number shift -* -* Returns: number of bits for the clear bitmap -*/ -static inline long clear_bmap_size (uint64_t pages,uint8_t shift) -{ -return DIV_ROUND_UP (pages,1UL << shift); -} - -/** -* clear_bmap_set: set clear bitmap for the page range. Must be with -* bitmap_mutex held. -* -* @rb: the ramblock to operate on -* @start: the start page number -* @size: number of pages to set in the bitmap -* -* Returns: None -*/ -static inline void clear_bmap_set (RAMBlock *rb,uint64_t start, -uint64_t npages) -{ -uint8_t shift = rb->clear_bmap_shift; - -bitmap_set (rb->clear_bmap, start >> shift,clear_bmap_size (npages, shift)); -} - -/** -* clear_bmap_test_and_clear: test clear bitmap for the page, clear if set. -* Must be with bitmap_mutex held. -* -* @rb: the ramblock to operate on -* @page: the page number to check -* -* Returns: true if the bit was set, false otherwise -*/ -static inline bool clear_bmap_test_and_clear (RAMBlock *rb,uint64_t page) -{ -uint8_t shift = rb->clear_bmap_shift; - -return bitmap_test_and_clear (rb->clear_bmap, page >> shift,1 ); -} - -static inline bool offset_in_ramblock (RAMBlock *b,ram_addr_t offset) -{ -return (b && b->host && offset < b->used_length) ? true : false; -} - -static inline void *ramblock_ptr (RAMBlock *block,ram_addr_t offset) -{ -assert (offset_in_ramblock (block, offset)); -return (char *)block->host + offset; -} - -static inline unsigned long int ramblock_recv_bitmap_offset (void *host_addr, -RAMBlock *rb) -{ -uint64_t host_addr_offset = - (uint64_t )(uintptr_t )(host_addr - (void *)rb->host); -return host_addr_offset >>TARGET_PAGE_BITS ; -}bool ramblock_is_pmem (RAMBlock *rb);@@ -143,411 +67,6 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp);void qemu_ram_msync (RAMBlock *block,ram_addr_t start,ram_addr_t length); -/* Clear whole block of mem */ -static inline void qemu_ram_block_writeback (RAMBlock *block) -{ -qemu_ram_msync (block,0 , block->used_length); -} +#endif /* CONFIG_USER_ONLY */ -#define DIRTY_CLIENTS_ALL ((1 << DIRTY_MEMORY_NUM) - 1) -#define DIRTY_CLIENTS_NOCODE (DIRTY_CLIENTS_ALL & ~(1 << DIRTY_MEMORY_CODE)) - -static inline bool cpu_physical_memory_get_dirty (ram_addr_t start, -ram_addr_t length, -unsigned client) -{ -DirtyMemoryBlocks *blocks; -unsigned long end, page; -unsigned long idx, offset, base; -bool dirty = false; - -assert (client <DIRTY_MEMORY_NUM ); - - end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; - page = start >>TARGET_PAGE_BITS ; - - WITH_RCU_READ_LOCK_GUARD() { - blocks =qatomic_rcu_read (&ram_list.dirty_memory[client]); - - idx = page /DIRTY_MEMORY_BLOCK_SIZE ; - offset = page %DIRTY_MEMORY_BLOCK_SIZE ; - base = page - offset; -while (page < end) { -unsigned long next =MIN (end, base +DIRTY_MEMORY_BLOCK_SIZE ); -unsigned long num = next - base; -unsigned long found =find_next_bit (blocks->blocks[idx], - num, offset); -if (found < num) { - dirty = true; -break ; - } - - page = next; - idx++; - offset =0 ; - base +=DIRTY_MEMORY_BLOCK_SIZE ; - } - } - -return dirty; -} - -static inline bool cpu_physical_memory_all_dirty (ram_addr_t start, -ram_addr_t length, -unsigned client) -{ -DirtyMemoryBlocks *blocks; -unsigned long end, page; -unsigned long idx, offset, base; -bool dirty = true; - -assert (client <DIRTY_MEMORY_NUM ); - - end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; - page = start >>TARGET_PAGE_BITS ; - -RCU_READ_LOCK_GUARD (); - - blocks =qatomic_rcu_read (&ram_list.dirty_memory[client]); - - idx = page /DIRTY_MEMORY_BLOCK_SIZE ; - offset = page %DIRTY_MEMORY_BLOCK_SIZE ; - base = page - offset; -while (page < end) { -unsigned long next =MIN (end, base +DIRTY_MEMORY_BLOCK_SIZE ); -unsigned long num = next - base; -unsigned long found =find_next_zero_bit (blocks->blocks[idx], num, offset); -if (found < num) { - dirty = false; -break ; - } - - page = next; - idx++; - offset =0 ; - base +=DIRTY_MEMORY_BLOCK_SIZE ; - } - -return dirty; -} - -static inline bool cpu_physical_memory_get_dirty_flag (ram_addr_t addr, -unsigned client) -{ -return cpu_physical_memory_get_dirty (addr,1 , client); -} - -static inline bool cpu_physical_memory_is_clean (ram_addr_t addr) -{ -bool vga =cpu_physical_memory_get_dirty_flag (addr,DIRTY_MEMORY_VGA ); -bool code =cpu_physical_memory_get_dirty_flag (addr,DIRTY_MEMORY_CODE ); -bool migration = -cpu_physical_memory_get_dirty_flag (addr,DIRTY_MEMORY_MIGRATION ); -return !(vga && code && migration); -} - -static inline uint8_t cpu_physical_memory_range_includes_clean (ram_addr_t start, -ram_addr_t length, -uint8_t mask) -{ -uint8_t ret =0 ; - -if (mask & (1 <<DIRTY_MEMORY_VGA ) && - !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_VGA )) { - ret |= (1 <<DIRTY_MEMORY_VGA ); - } -if (mask & (1 <<DIRTY_MEMORY_CODE ) && - !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_CODE )) { - ret |= (1 <<DIRTY_MEMORY_CODE ); - } -if (mask & (1 <<DIRTY_MEMORY_MIGRATION ) && - !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_MIGRATION )) { - ret |= (1 <<DIRTY_MEMORY_MIGRATION ); - } -return ret; -} - -static inline void cpu_physical_memory_set_dirty_flag (ram_addr_t addr, -unsigned client) -{ -unsigned long page, idx, offset; -DirtyMemoryBlocks *blocks; - -assert (client <DIRTY_MEMORY_NUM ); - - page = addr >>TARGET_PAGE_BITS ; - idx = page /DIRTY_MEMORY_BLOCK_SIZE ; - offset = page %DIRTY_MEMORY_BLOCK_SIZE ; - -RCU_READ_LOCK_GUARD (); - - blocks =qatomic_rcu_read (&ram_list.dirty_memory[client]); - -set_bit_atomic (offset, blocks->blocks[idx]); -} - -static inline void cpu_physical_memory_set_dirty_range (ram_addr_t start, -ram_addr_t length, -uint8_t mask) -{ -DirtyMemoryBlocks *blocks[DIRTY_MEMORY_NUM ]; -unsigned long end, page; -unsigned long idx, offset, base; -int i; - -if (!mask && !xen_enabled ()) { -return ; - } - - end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; - page = start >>TARGET_PAGE_BITS ; - - WITH_RCU_READ_LOCK_GUARD() { -for (i =0 ; i <DIRTY_MEMORY_NUM ; i++) { - blocks[i] =qatomic_rcu_read (&ram_list.dirty_memory[i]); - } - - idx = page /DIRTY_MEMORY_BLOCK_SIZE ; - offset = page %DIRTY_MEMORY_BLOCK_SIZE ; - base = page - offset; -while (page < end) { -unsigned long next =MIN (end, base +DIRTY_MEMORY_BLOCK_SIZE ); - -if (likely (mask & (1 <<DIRTY_MEMORY_MIGRATION ))) { -bitmap_set_atomic (blocks[DIRTY_MEMORY_MIGRATION ]->blocks[idx], - offset, next - page); - } -if (unlikely (mask & (1 <<DIRTY_MEMORY_VGA ))) { -bitmap_set_atomic (blocks[DIRTY_MEMORY_VGA ]->blocks[idx], - offset, next - page); - } -if (unlikely (mask & (1 <<DIRTY_MEMORY_CODE ))) { -bitmap_set_atomic (blocks[DIRTY_MEMORY_CODE ]->blocks[idx], - offset, next - page); - } - - page = next; - idx++; - offset =0 ; - base +=DIRTY_MEMORY_BLOCK_SIZE ; - } - } - -xen_hvm_modified_memory (start, length); -} - -#if !defined(_WIN32) - -/* -* Contrary to cpu_physical_memory_sync_dirty_bitmap() this function returns -* the number of dirty pages in @bitmap passed as argument. On the other hand, -* cpu_physical_memory_sync_dirty_bitmap() returns newly dirtied pages that -* weren't set in the global migration bitmap. -*/ -static inline -uint64_t cpu_physical_memory_set_dirty_lebitmap (unsigned long *bitmap, -ram_addr_t start, -ram_addr_t pages) -{ -unsigned long i, j; -unsigned long page_number, c, nbits; -hwaddr addr; -ram_addr_t ram_addr; -uint64_t num_dirty =0 ; -unsigned long len = (pages +HOST_LONG_BITS -1 ) /HOST_LONG_BITS ; -unsigned long hpratio =qemu_real_host_page_size () /TARGET_PAGE_SIZE ; -unsigned long page =BIT_WORD (start >>TARGET_PAGE_BITS ); - -/* start address is aligned at the start of a word? */ -if ((((page *BITS_PER_LONG ) <<TARGET_PAGE_BITS ) == start) && - (hpratio ==1 )) { -unsigned long **blocks[DIRTY_MEMORY_NUM ]; -unsigned long idx; -unsigned long offset; -long k; -long nr =BITS_TO_LONGS (pages); - - idx = (start >>TARGET_PAGE_BITS ) /DIRTY_MEMORY_BLOCK_SIZE ; - offset =BIT_WORD ((start >>TARGET_PAGE_BITS ) % -DIRTY_MEMORY_BLOCK_SIZE ); - - WITH_RCU_READ_LOCK_GUARD() { -for (i =0 ; i <DIRTY_MEMORY_NUM ; i++) { - blocks[i] = -qatomic_rcu_read (&ram_list.dirty_memory[i])->blocks; - } - -for (k =0 ; k < nr; k++) { -if (bitmap[k]) { -unsigned long temp =leul_to_cpu (bitmap[k]); - - nbits =ctpopl (temp); -qatomic_or (&blocks[DIRTY_MEMORY_VGA ][idx][offset], temp); - -if (global_dirty_tracking) { -qatomic_or ( - &blocks[DIRTY_MEMORY_MIGRATION ][idx][offset], - temp); -if (unlikely ( - global_dirty_tracking &GLOBAL_DIRTY_DIRTY_RATE )) { - total_dirty_pages += nbits; - } - } - - num_dirty += nbits; - -if (tcg_enabled ()) { -qatomic_or (&blocks[DIRTY_MEMORY_CODE ][idx][offset], - temp); - } - } - -if (++offset >=BITS_TO_LONGS (DIRTY_MEMORY_BLOCK_SIZE )) { - offset =0 ; - idx++; - } - } - } - -xen_hvm_modified_memory (start, pages <<TARGET_PAGE_BITS ); - }else { -uint8_t clients =tcg_enabled () ?DIRTY_CLIENTS_ALL :DIRTY_CLIENTS_NOCODE ; - -if (!global_dirty_tracking) { - clients &= ~(1 <<DIRTY_MEMORY_MIGRATION ); - } - -/* -* bitmap-traveling is faster than memory-traveling (for addr...) -* especially when most of the memory is not dirty. -*/ -for (i =0 ; i < len; i++) { -if (bitmap[i] !=0 ) { - c =leul_to_cpu (bitmap[i]); - nbits =ctpopl (c); -if (unlikely (global_dirty_tracking &GLOBAL_DIRTY_DIRTY_RATE )) { - total_dirty_pages += nbits; - } - num_dirty += nbits; -do { - j =ctzl (c); - c &= ~(1ul << j); - page_number = (i *HOST_LONG_BITS + j) * hpratio; - addr = page_number *TARGET_PAGE_SIZE ; - ram_addr = start + addr; -cpu_physical_memory_set_dirty_range (ram_addr, -TARGET_PAGE_SIZE * hpratio, clients); - }while (c !=0 ); - } - } - } - -return num_dirty; -} -#endif /* not _WIN32 */ - -static inline void cpu_physical_memory_dirty_bits_cleared (ram_addr_t start, -ram_addr_t length) -{ -if (tcg_enabled ()) { -tlb_reset_dirty_range_all (start, length); - } - -} -bool cpu_physical_memory_test_and_clear_dirty (ram_addr_t start, -ram_addr_t length, -unsigned client); - -DirtyBitmapSnapshot *cpu_physical_memory_snapshot_and_clear_dirty - (MemoryRegion *mr,hwaddr offset,hwaddr length,unsigned client); - -bool cpu_physical_memory_snapshot_get_dirty (DirtyBitmapSnapshot *snap, -ram_addr_t start, -ram_addr_t length); - -static inline void cpu_physical_memory_clear_dirty_range (ram_addr_t start, -ram_addr_t length) -{ -cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_MIGRATION ); -cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_VGA ); -cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_CODE ); -} - - -/* Called with RCU critical section */ -static inline -uint64_t cpu_physical_memory_sync_dirty_bitmap (RAMBlock *rb, -ram_addr_t start, -ram_addr_t length) -{ -ram_addr_t addr; -unsigned long word =BIT_WORD ((start + rb->offset) >>TARGET_PAGE_BITS ); -uint64_t num_dirty =0 ; -unsigned long *dest = rb->bmap; - -/* start address and length is aligned at the start of a word? */ -if (((word *BITS_PER_LONG ) <<TARGET_PAGE_BITS ) == - (start + rb->offset) && - !(length & ((BITS_PER_LONG <<TARGET_PAGE_BITS ) -1 ))) { -int k; -int nr =BITS_TO_LONGS (length >>TARGET_PAGE_BITS ); -unsigned long *const *src; -unsigned long idx = (word *BITS_PER_LONG ) /DIRTY_MEMORY_BLOCK_SIZE ; -unsigned long offset =BIT_WORD ((word *BITS_PER_LONG ) % -DIRTY_MEMORY_BLOCK_SIZE ); -unsigned long page =BIT_WORD (start >>TARGET_PAGE_BITS ); - - src =qatomic_rcu_read ( - &ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION ])->blocks; - -for (k = page; k < page + nr; k++) { -if (src[idx][offset]) { -unsigned long bits =qatomic_xchg (&src[idx][offset],0 ); -unsigned long new_dirty; - new_dirty = ~dest[k]; - dest[k] |= bits; - new_dirty &= bits; - num_dirty +=ctpopl (new_dirty); - } - -if (++offset >=BITS_TO_LONGS (DIRTY_MEMORY_BLOCK_SIZE )) { - offset =0 ; - idx++; - } - } -if (num_dirty) { -cpu_physical_memory_dirty_bits_cleared (start, length); - } - -if (rb->clear_bmap) { -/* -* Postpone the dirty bitmap clear to the point before we -* really send the pages, also we will split the clear -* dirty procedure into smaller chunks. -*/ -clear_bmap_set (rb, start >>TARGET_PAGE_BITS , - length >>TARGET_PAGE_BITS ); - }else { -/* Slow path - still do that in a huge chunk */ -memory_region_clear_dirty_bitmap (rb->mr, start, length); - } - }else { -ram_addr_t offset = rb->offset; - -for (addr =0 ; addr < length; addr +=TARGET_PAGE_SIZE ) { -if (cpu_physical_memory_test_and_clear_dirty ( - start + addr + offset, -TARGET_PAGE_SIZE , -DIRTY_MEMORY_MIGRATION )) { -long k = (start + addr) >>TARGET_PAGE_BITS ; -if (!test_and_set_bit (k, dest)) { - num_dirty++; - } - } - } - } - -return num_dirty; -} -#endif #endif include/sysemu/physmem-target.h new file +506
-0@@ -0,0 +1,506 @@ +/* +* Declarations for cpu physical memory functions +* +* Copyright 2011 Red Hat, Inc. and/or its affiliates +* +* Authors: +* Avi Kivity <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or +* later. See the COPYING file in the top-level directory. +* +*/ + +/* +* This header is for use by exec.c and memory.c ONLY. Do not include it. +* The functions declared here will be removed soon. +*/ + +#ifndef RAM_ADDR_TARGET_H +#define RAM_ADDR_TARGET_H + +#include "cpu.h" +#include "sysemu/xen.h" +#include "sysemu/tcg.h" +#include "exec/cputlb.h" +#include "exec/ram_addr.h" +#include "exec/ramlist.h" +#include "exec/ramblock.h" +#include "qemu/rcu.h" + +extern uint64_t total_dirty_pages; + +/** +* clear_bmap_size: calculate clear bitmap size +* +* @pages: number of guest pages +* @shift: guest page number shift +* +* Returns: number of bits for the clear bitmap +*/ +static inline long clear_bmap_size (uint64_t pages,uint8_t shift) +{ +return DIV_ROUND_UP (pages,1UL << shift); +} + +/** +* clear_bmap_set: set clear bitmap for the page range. Must be with +* bitmap_mutex held. +* +* @rb: the ramblock to operate on +* @start: the start page number +* @size: number of pages to set in the bitmap +* +* Returns: None +*/ +static inline void clear_bmap_set (RAMBlock *rb,uint64_t start, +uint64_t npages) +{ +uint8_t shift = rb->clear_bmap_shift; + +bitmap_set (rb->clear_bmap, start >> shift,clear_bmap_size (npages, shift)); +} + +/** +* clear_bmap_test_and_clear: test clear bitmap for the page, clear if set. +* Must be with bitmap_mutex held. +* +* @rb: the ramblock to operate on +* @page: the page number to check +* +* Returns: true if the bit was set, false otherwise +*/ +static inline bool clear_bmap_test_and_clear (RAMBlock *rb,uint64_t page) +{ +uint8_t shift = rb->clear_bmap_shift; + +return bitmap_test_and_clear (rb->clear_bmap, page >> shift,1 ); +} + +static inline bool offset_in_ramblock (RAMBlock *b,ram_addr_t offset) +{ +return (b && b->host && offset < b->used_length) ? true : false; +} + +static inline void *ramblock_ptr (RAMBlock *block,ram_addr_t offset) +{ +assert (offset_in_ramblock (block, offset)); +return (char *)block->host + offset; +} + +static inline unsigned long int ramblock_recv_bitmap_offset (void *host_addr, +RAMBlock *rb) +{ +uint64_t host_addr_offset = + (uint64_t )(uintptr_t )(host_addr - (void *)rb->host); +return host_addr_offset >>TARGET_PAGE_BITS ; +} + +/* Clear whole block of mem */ +static inline void qemu_ram_block_writeback (RAMBlock *block) +{ +qemu_ram_msync (block,0 , block->used_length); +} + +#define DIRTY_CLIENTS_ALL ((1 << DIRTY_MEMORY_NUM) - 1) +#define DIRTY_CLIENTS_NOCODE (DIRTY_CLIENTS_ALL & ~(1 << DIRTY_MEMORY_CODE)) + +static inline bool cpu_physical_memory_get_dirty (ram_addr_t start, +ram_addr_t length, +unsigned client) +{ +DirtyMemoryBlocks *blocks; +unsigned long end, page; +unsigned long idx, offset, base; +bool dirty = false; + +assert (client <DIRTY_MEMORY_NUM ); + + end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; + page = start >>TARGET_PAGE_BITS ; + + WITH_RCU_READ_LOCK_GUARD() { + blocks =qatomic_rcu_read (&ram_list.dirty_memory[client]); + + idx = page /DIRTY_MEMORY_BLOCK_SIZE ; + offset = page %DIRTY_MEMORY_BLOCK_SIZE ; + base = page - offset; +while (page < end) { +unsigned long next =MIN (end, base +DIRTY_MEMORY_BLOCK_SIZE ); +unsigned long num = next - base; +unsigned long found =find_next_bit (blocks->blocks[idx], + num, offset); +if (found < num) { + dirty = true; +break ; + } + + page = next; + idx++; + offset =0 ; + base +=DIRTY_MEMORY_BLOCK_SIZE ; + } + } + +return dirty; +} + +static inline bool cpu_physical_memory_all_dirty (ram_addr_t start, +ram_addr_t length, +unsigned client) +{ +DirtyMemoryBlocks *blocks; +unsigned long end, page; +unsigned long idx, offset, base; +bool dirty = true; + +assert (client <DIRTY_MEMORY_NUM ); + + end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; + page = start >>TARGET_PAGE_BITS ; + +RCU_READ_LOCK_GUARD (); + + blocks =qatomic_rcu_read (&ram_list.dirty_memory[client]); + + idx = page /DIRTY_MEMORY_BLOCK_SIZE ; + offset = page %DIRTY_MEMORY_BLOCK_SIZE ; + base = page - offset; +while (page < end) { +unsigned long next =MIN (end, base +DIRTY_MEMORY_BLOCK_SIZE ); +unsigned long num = next - base; +unsigned long found =find_next_zero_bit (blocks->blocks[idx], num, offset); +if (found < num) { + dirty = false; +break ; + } + + page = next; + idx++; + offset =0 ; + base +=DIRTY_MEMORY_BLOCK_SIZE ; + } + +return dirty; +} + +static inline bool cpu_physical_memory_get_dirty_flag (ram_addr_t addr, +unsigned client) +{ +return cpu_physical_memory_get_dirty (addr,1 , client); +} + +static inline bool cpu_physical_memory_is_clean (ram_addr_t addr) +{ +bool vga =cpu_physical_memory_get_dirty_flag (addr,DIRTY_MEMORY_VGA ); +bool code =cpu_physical_memory_get_dirty_flag (addr,DIRTY_MEMORY_CODE ); +bool migration = +cpu_physical_memory_get_dirty_flag (addr,DIRTY_MEMORY_MIGRATION ); +return !(vga && code && migration); +} + +static inline uint8_t cpu_physical_memory_range_includes_clean (ram_addr_t start, +ram_addr_t length, +uint8_t mask) +{ +uint8_t ret =0 ; + +if (mask & (1 <<DIRTY_MEMORY_VGA ) && + !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_VGA )) { + ret |= (1 <<DIRTY_MEMORY_VGA ); + } +if (mask & (1 <<DIRTY_MEMORY_CODE ) && + !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_CODE )) { + ret |= (1 <<DIRTY_MEMORY_CODE ); + } +if (mask & (1 <<DIRTY_MEMORY_MIGRATION ) && + !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_MIGRATION )) { + ret |= (1 <<DIRTY_MEMORY_MIGRATION ); + } +return ret; +} + +static inline void cpu_physical_memory_set_dirty_flag (ram_addr_t addr, +unsigned client) +{ +unsigned long page, idx, offset; +DirtyMemoryBlocks *blocks; + +assert (client <DIRTY_MEMORY_NUM ); + + page = addr >>TARGET_PAGE_BITS ; + idx = page /DIRTY_MEMORY_BLOCK_SIZE ; + offset = page %DIRTY_MEMORY_BLOCK_SIZE ; + +RCU_READ_LOCK_GUARD (); + + blocks =qatomic_rcu_read (&ram_list.dirty_memory[client]); + +set_bit_atomic (offset, blocks->blocks[idx]); +} + +static inline void cpu_physical_memory_set_dirty_range (ram_addr_t start, +ram_addr_t length, +uint8_t mask) +{ +DirtyMemoryBlocks *blocks[DIRTY_MEMORY_NUM ]; +unsigned long end, page; +unsigned long idx, offset, base; +int i; + +if (!mask && !xen_enabled ()) { +return ; + } + + end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; + page = start >>TARGET_PAGE_BITS ; + + WITH_RCU_READ_LOCK_GUARD() { +for (i =0 ; i <DIRTY_MEMORY_NUM ; i++) { + blocks[i] =qatomic_rcu_read (&ram_list.dirty_memory[i]); + } + + idx = page /DIRTY_MEMORY_BLOCK_SIZE ; + offset = page %DIRTY_MEMORY_BLOCK_SIZE ; + base = page - offset; +while (page < end) { +unsigned long next =MIN (end, base +DIRTY_MEMORY_BLOCK_SIZE ); + +if (likely (mask & (1 <<DIRTY_MEMORY_MIGRATION ))) { +bitmap_set_atomic (blocks[DIRTY_MEMORY_MIGRATION ]->blocks[idx], + offset, next - page); + } +if (unlikely (mask & (1 <<DIRTY_MEMORY_VGA ))) { +bitmap_set_atomic (blocks[DIRTY_MEMORY_VGA ]->blocks[idx], + offset, next - page); + } +if (unlikely (mask & (1 <<DIRTY_MEMORY_CODE ))) { +bitmap_set_atomic (blocks[DIRTY_MEMORY_CODE ]->blocks[idx], + offset, next - page); + } + + page = next; + idx++; + offset =0 ; + base +=DIRTY_MEMORY_BLOCK_SIZE ; + } + } + +xen_hvm_modified_memory (start, length); +} + +#if !defined(_WIN32) + +/* +* Contrary to cpu_physical_memory_sync_dirty_bitmap() this function returns +* the number of dirty pages in @bitmap passed as argument. On the other hand, +* cpu_physical_memory_sync_dirty_bitmap() returns newly dirtied pages that +* weren't set in the global migration bitmap. +*/ +static inline +uint64_t cpu_physical_memory_set_dirty_lebitmap (unsigned long *bitmap, +ram_addr_t start, +ram_addr_t pages) +{ +unsigned long i, j; +unsigned long page_number, c, nbits; +hwaddr addr; +ram_addr_t ram_addr; +uint64_t num_dirty =0 ; +unsigned long len = (pages +HOST_LONG_BITS -1 ) /HOST_LONG_BITS ; +unsigned long hpratio =qemu_real_host_page_size () /TARGET_PAGE_SIZE ; +unsigned long page =BIT_WORD (start >>TARGET_PAGE_BITS ); + +/* start address is aligned at the start of a word? */ +if ((((page *BITS_PER_LONG ) <<TARGET_PAGE_BITS ) == start) && + (hpratio ==1 )) { +unsigned long **blocks[DIRTY_MEMORY_NUM ]; +unsigned long idx; +unsigned long offset; +long k; +long nr =BITS_TO_LONGS (pages); + + idx = (start >>TARGET_PAGE_BITS ) /DIRTY_MEMORY_BLOCK_SIZE ; + offset =BIT_WORD ((start >>TARGET_PAGE_BITS ) % +DIRTY_MEMORY_BLOCK_SIZE ); + + WITH_RCU_READ_LOCK_GUARD() { +for (i =0 ; i <DIRTY_MEMORY_NUM ; i++) { + blocks[i] = +qatomic_rcu_read (&ram_list.dirty_memory[i])->blocks; + } + +for (k =0 ; k < nr; k++) { +if (bitmap[k]) { +unsigned long temp =leul_to_cpu (bitmap[k]); + + nbits =ctpopl (temp); +qatomic_or (&blocks[DIRTY_MEMORY_VGA ][idx][offset], temp); + +if (global_dirty_tracking) { +qatomic_or ( + &blocks[DIRTY_MEMORY_MIGRATION ][idx][offset], + temp); +if (unlikely ( + global_dirty_tracking &GLOBAL_DIRTY_DIRTY_RATE )) { + total_dirty_pages += nbits; + } + } + + num_dirty += nbits; + +if (tcg_enabled ()) { +qatomic_or (&blocks[DIRTY_MEMORY_CODE ][idx][offset], + temp); + } + } + +if (++offset >=BITS_TO_LONGS (DIRTY_MEMORY_BLOCK_SIZE )) { + offset =0 ; + idx++; + } + } + } + +xen_hvm_modified_memory (start, pages <<TARGET_PAGE_BITS ); + }else { +uint8_t clients =tcg_enabled () ?DIRTY_CLIENTS_ALL :DIRTY_CLIENTS_NOCODE ; + +if (!global_dirty_tracking) { + clients &= ~(1 <<DIRTY_MEMORY_MIGRATION ); + } + +/* +* bitmap-traveling is faster than memory-traveling (for addr...) +* especially when most of the memory is not dirty. +*/ +for (i =0 ; i < len; i++) { +if (bitmap[i] !=0 ) { + c =leul_to_cpu (bitmap[i]); + nbits =ctpopl (c); +if (unlikely (global_dirty_tracking &GLOBAL_DIRTY_DIRTY_RATE )) { + total_dirty_pages += nbits; + } + num_dirty += nbits; +do { + j =ctzl (c); + c &= ~(1ul << j); + page_number = (i *HOST_LONG_BITS + j) * hpratio; + addr = page_number *TARGET_PAGE_SIZE ; + ram_addr = start + addr; +cpu_physical_memory_set_dirty_range (ram_addr, +TARGET_PAGE_SIZE * hpratio, clients); + }while (c !=0 ); + } + } + } + +return num_dirty; +} +#endif /* not _WIN32 */ + +static inline void cpu_physical_memory_dirty_bits_cleared (ram_addr_t start, +ram_addr_t length) +{ +if (tcg_enabled ()) { +tlb_reset_dirty_range_all (start, length); + } + +} +bool cpu_physical_memory_test_and_clear_dirty (ram_addr_t start, +ram_addr_t length, +unsigned client); + +DirtyBitmapSnapshot *cpu_physical_memory_snapshot_and_clear_dirty + (MemoryRegion *mr,hwaddr offset,hwaddr length,unsigned client); + +bool cpu_physical_memory_snapshot_get_dirty (DirtyBitmapSnapshot *snap, +ram_addr_t start, +ram_addr_t length); + +static inline void cpu_physical_memory_clear_dirty_range (ram_addr_t start, +ram_addr_t length) +{ +cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_MIGRATION ); +cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_VGA ); +cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_CODE ); +} + + +/* Called with RCU critical section */ +static inline +uint64_t cpu_physical_memory_sync_dirty_bitmap (RAMBlock *rb, +ram_addr_t start, +ram_addr_t length) +{ +ram_addr_t addr; +unsigned long word =BIT_WORD ((start + rb->offset) >>TARGET_PAGE_BITS ); +uint64_t num_dirty =0 ; +unsigned long *dest = rb->bmap; + +/* start address and length is aligned at the start of a word? */ +if (((word *BITS_PER_LONG ) <<TARGET_PAGE_BITS ) == + (start + rb->offset) && + !(length & ((BITS_PER_LONG <<TARGET_PAGE_BITS ) -1 ))) { +int k; +int nr =BITS_TO_LONGS (length >>TARGET_PAGE_BITS ); +unsigned long *const *src; +unsigned long idx = (word *BITS_PER_LONG ) /DIRTY_MEMORY_BLOCK_SIZE ; +unsigned long offset =BIT_WORD ((word *BITS_PER_LONG ) % +DIRTY_MEMORY_BLOCK_SIZE ); +unsigned long page =BIT_WORD (start >>TARGET_PAGE_BITS ); + + src =qatomic_rcu_read ( + &ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION ])->blocks; + +for (k = page; k < page + nr; k++) { +if (src[idx][offset]) { +unsigned long bits =qatomic_xchg (&src[idx][offset],0 ); +unsigned long new_dirty; + new_dirty = ~dest[k]; + dest[k] |= bits; + new_dirty &= bits; + num_dirty +=ctpopl (new_dirty); + } + +if (++offset >=BITS_TO_LONGS (DIRTY_MEMORY_BLOCK_SIZE )) { + offset =0 ; + idx++; + } + } +if (num_dirty) { +cpu_physical_memory_dirty_bits_cleared (start, length); + } + +if (rb->clear_bmap) { +/* +* Postpone the dirty bitmap clear to the point before we +* really send the pages, also we will split the clear +* dirty procedure into smaller chunks. +*/ +clear_bmap_set (rb, start >>TARGET_PAGE_BITS , + length >>TARGET_PAGE_BITS ); + }else { +/* Slow path - still do that in a huge chunk */ +memory_region_clear_dirty_bitmap (rb->mr, start, length); + } + }else { +ram_addr_t offset = rb->offset; + +for (addr =0 ; addr < length; addr +=TARGET_PAGE_SIZE ) { +if (cpu_physical_memory_test_and_clear_dirty ( + start + addr + offset, +TARGET_PAGE_SIZE , +DIRTY_MEMORY_MIGRATION )) { +long k = (start + addr) >>TARGET_PAGE_BITS ; +if (!test_and_set_bit (k, dest)) { + num_dirty++; + } + } + } + } + +return num_dirty; +} + +#endif accel/kvm/kvm-all.c +1
-0@@ -35,6 +35,7 @@#include "qemu/bswap.h" #include "exec/memory.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/event_notifier.h" #include "qemu/main-loop.h" #include "trace.h" accel/tcg/cputlb.c +1
-0@@ -28,6 +28,7 @@#include "exec/tb-flush.h" #include "exec/memory-internal.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "exec/mmu-access-type.h" #include "exec/tlb-common.h" #include "exec/vaddr.h" accel/tcg/translate-all.c +1
-0@@ -41,6 +41,7 @@#endif #else #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #endif #include "exec/cputlb.h" hw/ppc/spapr.c +1
-0@@ -75,6 +75,7 @@#include "hw/virtio/vhost-scsi-common.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "exec/confidential-guest-support.h" #include "hw/usb.h" #include "qemu/config-file.h" hw/ppc/spapr_caps.c +1
-0@@ -28,6 +28,7 @@#include "qapi/visitor.h" #include "sysemu/hw_accel.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "target/ppc/cpu.h" #include "target/ppc/mmu-hash64.h" #include "cpu-models.h" hw/ppc/spapr_pci.c +1
-0@@ -35,6 +35,7 @@#include "hw/ppc/spapr.h" #include "hw/pci-host/spapr.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include <libfdt.h> #include "trace.h" #include "qemu/error-report.h" hw/remote/memory.c +1
-0@@ -12,6 +12,7 @@#include "hw/remote/memory.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qapi/error.h" static void remote_sysmem_reset (void )hw/remote/proxy-memory-listener.c +1
-0@@ -13,6 +13,7 @@#include "exec/memory.h" #include "exec/cpu-common.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/remote/mpqemu-link.h" hw/s390x/s390-stattrib-kvm.c +1
-0@@ -16,6 +16,7 @@#include "qemu/error-report.h" #include "sysemu/kvm.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "kvm/kvm_s390x.h" #include "qapi/error.h" hw/s390x/s390-stattrib.c +1
-0@@ -17,6 +17,7 @@#include "hw/s390x/storage-attributes.h" #include "qemu/error-report.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "cpu.h" hw/s390x/s390-virtio-ccw.c +1
-0@@ -14,6 +14,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "exec/confidential-guest-support.h" #include "hw/boards.h" #include "hw/s390x/s390-virtio-hcall.h" hw/vfio/common.c +1
-0@@ -30,6 +30,7 @@#include "exec/address-spaces.h" #include "exec/memory.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "hw/hw.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" hw/vfio/container.c +1
-0@@ -26,6 +26,7 @@#include "exec/address-spaces.h" #include "exec/memory.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/error-report.h" #include "qemu/range.h" #include "sysemu/reset.h" hw/vfio/iommufd.c +1
-0@@ -26,6 +26,7 @@#include "qemu/chardev_open.h" #include "pci.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" static int iommufd_cdev_map (const VFIOContainerBase *bcontainer,hwaddr iova,ram_addr_t size,void *vaddr,bool readonly)hw/vfio/migration.c +1
-0@@ -27,6 +27,7 @@#include "qapi/qapi-events-vfio.h" #include "exec/ramlist.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "pci.h" #include "trace.h" #include "hw/hw.h" hw/vfio/spapr.c +1
-0@@ -20,6 +20,7 @@#include "hw/vfio/vfio-common.h" #include "hw/hw.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "trace.h" hw/virtio/virtio-mem.c +1
-0@@ -25,6 +25,7 @@#include "qapi/error.h" #include "qapi/visitor.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "migration/misc.h" #include "hw/boards.h" #include "hw/qdev-properties.h" migration/ram.c +1
-0@@ -49,6 +49,7 @@#include "qapi/qmp/qerror.h" #include "trace.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "exec/target_page.h" #include "qemu/rcu_queue.h" #include "migration/colo.h" plugins/api.c +1
-0@@ -50,6 +50,7 @@#include "qapi/error.h" #include "migration/blocker.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/plugin-memory.h" #include "hw/boards.h" #else system/memory.c +1
-0@@ -27,6 +27,7 @@#include "exec/memory-internal.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "sysemu/kvm.h" #include "sysemu/runstate.h" #include "sysemu/tcg.h" system/physmem.c +1
-0@@ -67,6 +67,7 @@#include "exec/memory-internal.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/pmem.h" target/arm/tcg/mte_helper.c +1
-0@@ -25,6 +25,7 @@#include "exec/page-protection.h" #ifndef CONFIG_USER_ONLY #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #endif #include "exec/cpu_ldst.h" #include "exec/helper-proto.h" target/ppc/kvm.c +1
-0@@ -42,6 +42,7 @@#include "gdbstub/enums.h" #include "exec/memattrs.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "sysemu/hostmem.h" #include "qemu/cutils.h" #include "qemu/main-loop.h" target/s390x/kvm/kvm.c +0
-0
target/s390x/kvm/kvm.c line 48
Quoted 7 lines
target/s390x/kvm/kvm.c +1
-0@@ -42,6 +42,7 @@#include "sysemu/device_tree.h" #include "gdbstub/enums.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "trace.h" #include "hw/s390x/s390-pci-inst.h" #include "hw/s390x/s390-pci-bus.h"
With the fix on header guard,
Re: [PATCH 21/24] exec: Extract CPU physical memory API to 'sysemu/physmem-target.h'
In reply to Philippe Mathieu-DaudéQuoted 6 lines · Philippe Mathieu-Daudé
In order to keep "
exec/ram_addr.h" focused on (target agnostic) methods related to theram_addr_ttype, move all (target specific) CPU physical memory API to a new "sysemu/physmem-target.h" header.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Some of these functions are huge.
I really can't imagine that we need to keep them all inline.
What's their individual distribution of usage?
r~
Quoted 1,343 lines
--- MAINTAINERS | 1 + include/exec/ram_addr.h | 483 +--------------------------- include/sysemu/physmem-target.h | 506 ++++++++++++++++++++++++++++++ accel/kvm/kvm-all.c | 1 + accel/tcg/cputlb.c | 1 + accel/tcg/translate-all.c | 1 + hw/ppc/spapr.c | 1 + hw/ppc/spapr_caps.c | 1 + hw/ppc/spapr_pci.c | 1 + hw/remote/memory.c | 1 + hw/remote/proxy-memory-listener.c | 1 + hw/s390x/s390-stattrib-kvm.c | 1 + hw/s390x/s390-stattrib.c | 1 + hw/s390x/s390-virtio-ccw.c | 1 + hw/vfio/common.c | 1 + hw/vfio/container.c | 1 + hw/vfio/iommufd.c | 1 + hw/vfio/migration.c | 1 + hw/vfio/spapr.c | 1 + hw/virtio/virtio-mem.c | 1 + migration/ram.c | 1 + plugins/api.c | 1 + system/memory.c | 1 + system/physmem.c | 1 + target/arm/tcg/mte_helper.c | 1 + target/ppc/kvm.c | 1 + target/s390x/kvm/kvm.c | 1 + 27 files changed, 532 insertions(+), 482 deletions(-)create mode 100644
include/sysemu/physmem-target.hMAINTAINERS +1
-0@@ -3027,6 +3027,7 @@ F: include/exec/memory.h F: include/exec/ram_addr.h F: include/exec/ramblock.h F: include/sysemu/memory_mapping.h +F: include/sysemu/physmem-target.h F: system/dma-helpers.c F: system/ioport.c F: system/memory.cinclude/exec/ram_addr.h +1
-482@@ -20,82 +20,6 @@#define RAM_ADDR_H #ifndef CONFIG_USER_ONLY -#include "cpu.h" -#include "sysemu/xen.h" -#include "sysemu/tcg.h" -#include "exec/cputlb.h" -#include "exec/ramlist.h" -#include "exec/ramblock.h" -#include "exec/exec-all.h" -#include "qemu/rcu.h" - -extern uint64_t total_dirty_pages; - -/** -* clear_bmap_size: calculate clear bitmap size -* -* @pages: number of guest pages -* @shift: guest page number shift -* -* Returns: number of bits for the clear bitmap -*/ -static inline long clear_bmap_size (uint64_t pages,uint8_t shift) -{ -return DIV_ROUND_UP (pages,1UL << shift); -} - -/** -* clear_bmap_set: set clear bitmap for the page range. Must be with -* bitmap_mutex held. -* -* @rb: the ramblock to operate on -* @start: the start page number -* @size: number of pages to set in the bitmap -* -* Returns: None -*/ -static inline void clear_bmap_set (RAMBlock *rb,uint64_t start, -uint64_t npages) -{ -uint8_t shift = rb->clear_bmap_shift; - -bitmap_set (rb->clear_bmap, start >> shift,clear_bmap_size (npages, shift)); -} - -/** -* clear_bmap_test_and_clear: test clear bitmap for the page, clear if set. -* Must be with bitmap_mutex held. -* -* @rb: the ramblock to operate on -* @page: the page number to check -* -* Returns: true if the bit was set, false otherwise -*/ -static inline bool clear_bmap_test_and_clear (RAMBlock *rb,uint64_t page) -{ -uint8_t shift = rb->clear_bmap_shift; - -return bitmap_test_and_clear (rb->clear_bmap, page >> shift,1 ); -} - -static inline bool offset_in_ramblock (RAMBlock *b,ram_addr_t offset) -{ -return (b && b->host && offset < b->used_length) ? true : false; -} - -static inline void *ramblock_ptr (RAMBlock *block,ram_addr_t offset) -{ -assert (offset_in_ramblock (block, offset)); -return (char *)block->host + offset; -} - -static inline unsigned long int ramblock_recv_bitmap_offset (void *host_addr, -RAMBlock *rb) -{ -uint64_t host_addr_offset = - (uint64_t )(uintptr_t )(host_addr - (void *)rb->host); -return host_addr_offset >>TARGET_PAGE_BITS ; -}bool ramblock_is_pmem (RAMBlock *rb);@@ -143,411 +67,6 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp);void qemu_ram_msync (RAMBlock *block,ram_addr_t start,ram_addr_t length); -/* Clear whole block of mem */ -static inline void qemu_ram_block_writeback (RAMBlock *block) -{ -qemu_ram_msync (block,0 , block->used_length); -} +#endif /* CONFIG_USER_ONLY */ -#define DIRTY_CLIENTS_ALL ((1 << DIRTY_MEMORY_NUM) - 1) -#define DIRTY_CLIENTS_NOCODE (DIRTY_CLIENTS_ALL & ~(1 << DIRTY_MEMORY_CODE)) - -static inline bool cpu_physical_memory_get_dirty (ram_addr_t start, -ram_addr_t length, -unsigned client) -{ -DirtyMemoryBlocks *blocks; -unsigned long end, page; -unsigned long idx, offset, base; -bool dirty = false; - -assert (client <DIRTY_MEMORY_NUM ); - - end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; - page = start >>TARGET_PAGE_BITS ; - - WITH_RCU_READ_LOCK_GUARD() { - blocks =qatomic_rcu_read (&ram_list.dirty_memory[client]); - - idx = page /DIRTY_MEMORY_BLOCK_SIZE ; - offset = page %DIRTY_MEMORY_BLOCK_SIZE ; - base = page - offset; -while (page < end) { -unsigned long next =MIN (end, base +DIRTY_MEMORY_BLOCK_SIZE ); -unsigned long num = next - base; -unsigned long found =find_next_bit (blocks->blocks[idx], - num, offset); -if (found < num) { - dirty = true; -break ; - } - - page = next; - idx++; - offset =0 ; - base +=DIRTY_MEMORY_BLOCK_SIZE ; - } - } - -return dirty; -} - -static inline bool cpu_physical_memory_all_dirty (ram_addr_t start, -ram_addr_t length, -unsigned client) -{ -DirtyMemoryBlocks *blocks; -unsigned long end, page; -unsigned long idx, offset, base; -bool dirty = true; - -assert (client <DIRTY_MEMORY_NUM ); - - end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; - page = start >>TARGET_PAGE_BITS ; - -RCU_READ_LOCK_GUARD (); - - blocks =qatomic_rcu_read (&ram_list.dirty_memory[client]); - - idx = page /DIRTY_MEMORY_BLOCK_SIZE ; - offset = page %DIRTY_MEMORY_BLOCK_SIZE ; - base = page - offset; -while (page < end) { -unsigned long next =MIN (end, base +DIRTY_MEMORY_BLOCK_SIZE ); -unsigned long num = next - base; -unsigned long found =find_next_zero_bit (blocks->blocks[idx], num, offset); -if (found < num) { - dirty = false; -break ; - } - - page = next; - idx++; - offset =0 ; - base +=DIRTY_MEMORY_BLOCK_SIZE ; - } - -return dirty; -} - -static inline bool cpu_physical_memory_get_dirty_flag (ram_addr_t addr, -unsigned client) -{ -return cpu_physical_memory_get_dirty (addr,1 , client); -} - -static inline bool cpu_physical_memory_is_clean (ram_addr_t addr) -{ -bool vga =cpu_physical_memory_get_dirty_flag (addr,DIRTY_MEMORY_VGA ); -bool code =cpu_physical_memory_get_dirty_flag (addr,DIRTY_MEMORY_CODE ); -bool migration = -cpu_physical_memory_get_dirty_flag (addr,DIRTY_MEMORY_MIGRATION ); -return !(vga && code && migration); -} - -static inline uint8_t cpu_physical_memory_range_includes_clean (ram_addr_t start, -ram_addr_t length, -uint8_t mask) -{ -uint8_t ret =0 ; - -if (mask & (1 <<DIRTY_MEMORY_VGA ) && - !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_VGA )) { - ret |= (1 <<DIRTY_MEMORY_VGA ); - } -if (mask & (1 <<DIRTY_MEMORY_CODE ) && - !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_CODE )) { - ret |= (1 <<DIRTY_MEMORY_CODE ); - } -if (mask & (1 <<DIRTY_MEMORY_MIGRATION ) && - !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_MIGRATION )) { - ret |= (1 <<DIRTY_MEMORY_MIGRATION ); - } -return ret; -} - -static inline void cpu_physical_memory_set_dirty_flag (ram_addr_t addr, -unsigned client) -{ -unsigned long page, idx, offset; -DirtyMemoryBlocks *blocks; - -assert (client <DIRTY_MEMORY_NUM ); - - page = addr >>TARGET_PAGE_BITS ; - idx = page /DIRTY_MEMORY_BLOCK_SIZE ; - offset = page %DIRTY_MEMORY_BLOCK_SIZE ; - -RCU_READ_LOCK_GUARD (); - - blocks =qatomic_rcu_read (&ram_list.dirty_memory[client]); - -set_bit_atomic (offset, blocks->blocks[idx]); -} - -static inline void cpu_physical_memory_set_dirty_range (ram_addr_t start, -ram_addr_t length, -uint8_t mask) -{ -DirtyMemoryBlocks *blocks[DIRTY_MEMORY_NUM ]; -unsigned long end, page; -unsigned long idx, offset, base; -int i; - -if (!mask && !xen_enabled ()) { -return ; - } - - end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; - page = start >>TARGET_PAGE_BITS ; - - WITH_RCU_READ_LOCK_GUARD() { -for (i =0 ; i <DIRTY_MEMORY_NUM ; i++) { - blocks[i] =qatomic_rcu_read (&ram_list.dirty_memory[i]); - } - - idx = page /DIRTY_MEMORY_BLOCK_SIZE ; - offset = page %DIRTY_MEMORY_BLOCK_SIZE ; - base = page - offset; -while (page < end) { -unsigned long next =MIN (end, base +DIRTY_MEMORY_BLOCK_SIZE ); - -if (likely (mask & (1 <<DIRTY_MEMORY_MIGRATION ))) { -bitmap_set_atomic (blocks[DIRTY_MEMORY_MIGRATION ]->blocks[idx], - offset, next - page); - } -if (unlikely (mask & (1 <<DIRTY_MEMORY_VGA ))) { -bitmap_set_atomic (blocks[DIRTY_MEMORY_VGA ]->blocks[idx], - offset, next - page); - } -if (unlikely (mask & (1 <<DIRTY_MEMORY_CODE ))) { -bitmap_set_atomic (blocks[DIRTY_MEMORY_CODE ]->blocks[idx], - offset, next - page); - } - - page = next; - idx++; - offset =0 ; - base +=DIRTY_MEMORY_BLOCK_SIZE ; - } - } - -xen_hvm_modified_memory (start, length); -} - -#if !defined(_WIN32) - -/* -* Contrary to cpu_physical_memory_sync_dirty_bitmap() this function returns -* the number of dirty pages in @bitmap passed as argument. On the other hand, -* cpu_physical_memory_sync_dirty_bitmap() returns newly dirtied pages that -* weren't set in the global migration bitmap. -*/ -static inline -uint64_t cpu_physical_memory_set_dirty_lebitmap (unsigned long *bitmap, -ram_addr_t start, -ram_addr_t pages) -{ -unsigned long i, j; -unsigned long page_number, c, nbits; -hwaddr addr; -ram_addr_t ram_addr; -uint64_t num_dirty =0 ; -unsigned long len = (pages +HOST_LONG_BITS -1 ) /HOST_LONG_BITS ; -unsigned long hpratio =qemu_real_host_page_size () /TARGET_PAGE_SIZE ; -unsigned long page =BIT_WORD (start >>TARGET_PAGE_BITS ); - -/* start address is aligned at the start of a word? */ -if ((((page *BITS_PER_LONG ) <<TARGET_PAGE_BITS ) == start) && - (hpratio ==1 )) { -unsigned long **blocks[DIRTY_MEMORY_NUM ]; -unsigned long idx; -unsigned long offset; -long k; -long nr =BITS_TO_LONGS (pages); - - idx = (start >>TARGET_PAGE_BITS ) /DIRTY_MEMORY_BLOCK_SIZE ; - offset =BIT_WORD ((start >>TARGET_PAGE_BITS ) % -DIRTY_MEMORY_BLOCK_SIZE ); - - WITH_RCU_READ_LOCK_GUARD() { -for (i =0 ; i <DIRTY_MEMORY_NUM ; i++) { - blocks[i] = -qatomic_rcu_read (&ram_list.dirty_memory[i])->blocks; - } - -for (k =0 ; k < nr; k++) { -if (bitmap[k]) { -unsigned long temp =leul_to_cpu (bitmap[k]); - - nbits =ctpopl (temp); -qatomic_or (&blocks[DIRTY_MEMORY_VGA ][idx][offset], temp); - -if (global_dirty_tracking) { -qatomic_or ( - &blocks[DIRTY_MEMORY_MIGRATION ][idx][offset], - temp); -if (unlikely ( - global_dirty_tracking &GLOBAL_DIRTY_DIRTY_RATE )) { - total_dirty_pages += nbits; - } - } - - num_dirty += nbits; - -if (tcg_enabled ()) { -qatomic_or (&blocks[DIRTY_MEMORY_CODE ][idx][offset], - temp); - } - } - -if (++offset >=BITS_TO_LONGS (DIRTY_MEMORY_BLOCK_SIZE )) { - offset =0 ; - idx++; - } - } - } - -xen_hvm_modified_memory (start, pages <<TARGET_PAGE_BITS ); - }else { -uint8_t clients =tcg_enabled () ?DIRTY_CLIENTS_ALL :DIRTY_CLIENTS_NOCODE ; - -if (!global_dirty_tracking) { - clients &= ~(1 <<DIRTY_MEMORY_MIGRATION ); - } - -/* -* bitmap-traveling is faster than memory-traveling (for addr...) -* especially when most of the memory is not dirty. -*/ -for (i =0 ; i < len; i++) { -if (bitmap[i] !=0 ) { - c =leul_to_cpu (bitmap[i]); - nbits =ctpopl (c); -if (unlikely (global_dirty_tracking &GLOBAL_DIRTY_DIRTY_RATE )) { - total_dirty_pages += nbits; - } - num_dirty += nbits; -do { - j =ctzl (c); - c &= ~(1ul << j); - page_number = (i *HOST_LONG_BITS + j) * hpratio; - addr = page_number *TARGET_PAGE_SIZE ; - ram_addr = start + addr; -cpu_physical_memory_set_dirty_range (ram_addr, -TARGET_PAGE_SIZE * hpratio, clients); - }while (c !=0 ); - } - } - } - -return num_dirty; -} -#endif /* not _WIN32 */ - -static inline void cpu_physical_memory_dirty_bits_cleared (ram_addr_t start, -ram_addr_t length) -{ -if (tcg_enabled ()) { -tlb_reset_dirty_range_all (start, length); - } - -} -bool cpu_physical_memory_test_and_clear_dirty (ram_addr_t start, -ram_addr_t length, -unsigned client); - -DirtyBitmapSnapshot *cpu_physical_memory_snapshot_and_clear_dirty - (MemoryRegion *mr,hwaddr offset,hwaddr length,unsigned client); - -bool cpu_physical_memory_snapshot_get_dirty (DirtyBitmapSnapshot *snap, -ram_addr_t start, -ram_addr_t length); - -static inline void cpu_physical_memory_clear_dirty_range (ram_addr_t start, -ram_addr_t length) -{ -cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_MIGRATION ); -cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_VGA ); -cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_CODE ); -} - - -/* Called with RCU critical section */ -static inline -uint64_t cpu_physical_memory_sync_dirty_bitmap (RAMBlock *rb, -ram_addr_t start, -ram_addr_t length) -{ -ram_addr_t addr; -unsigned long word =BIT_WORD ((start + rb->offset) >>TARGET_PAGE_BITS ); -uint64_t num_dirty =0 ; -unsigned long *dest = rb->bmap; - -/* start address and length is aligned at the start of a word? */ -if (((word *BITS_PER_LONG ) <<TARGET_PAGE_BITS ) == - (start + rb->offset) && - !(length & ((BITS_PER_LONG <<TARGET_PAGE_BITS ) -1 ))) { -int k; -int nr =BITS_TO_LONGS (length >>TARGET_PAGE_BITS ); -unsigned long *const *src; -unsigned long idx = (word *BITS_PER_LONG ) /DIRTY_MEMORY_BLOCK_SIZE ; -unsigned long offset =BIT_WORD ((word *BITS_PER_LONG ) % -DIRTY_MEMORY_BLOCK_SIZE ); -unsigned long page =BIT_WORD (start >>TARGET_PAGE_BITS ); - - src =qatomic_rcu_read ( - &ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION ])->blocks; - -for (k = page; k < page + nr; k++) { -if (src[idx][offset]) { -unsigned long bits =qatomic_xchg (&src[idx][offset],0 ); -unsigned long new_dirty; - new_dirty = ~dest[k]; - dest[k] |= bits; - new_dirty &= bits; - num_dirty +=ctpopl (new_dirty); - } - -if (++offset >=BITS_TO_LONGS (DIRTY_MEMORY_BLOCK_SIZE )) { - offset =0 ; - idx++; - } - } -if (num_dirty) { -cpu_physical_memory_dirty_bits_cleared (start, length); - } - -if (rb->clear_bmap) { -/* -* Postpone the dirty bitmap clear to the point before we -* really send the pages, also we will split the clear -* dirty procedure into smaller chunks. -*/ -clear_bmap_set (rb, start >>TARGET_PAGE_BITS , - length >>TARGET_PAGE_BITS ); - }else { -/* Slow path - still do that in a huge chunk */ -memory_region_clear_dirty_bitmap (rb->mr, start, length); - } - }else { -ram_addr_t offset = rb->offset; - -for (addr =0 ; addr < length; addr +=TARGET_PAGE_SIZE ) { -if (cpu_physical_memory_test_and_clear_dirty ( - start + addr + offset, -TARGET_PAGE_SIZE , -DIRTY_MEMORY_MIGRATION )) { -long k = (start + addr) >>TARGET_PAGE_BITS ; -if (!test_and_set_bit (k, dest)) { - num_dirty++; - } - } - } - } - -return num_dirty; -} -#endif #endif include/sysemu/physmem-target.h new file +506
-0@@ -0,0 +1,506 @@ +/* +* Declarations for cpu physical memory functions +* +* Copyright 2011 Red Hat, Inc. and/or its affiliates +* +* Authors: +* Avi Kivity <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or +* later. See the COPYING file in the top-level directory. +* +*/ + +/* +* This header is for use by exec.c and memory.c ONLY. Do not include it. +* The functions declared here will be removed soon. +*/ + +#ifndef RAM_ADDR_TARGET_H +#define RAM_ADDR_TARGET_H + +#include "cpu.h" +#include "sysemu/xen.h" +#include "sysemu/tcg.h" +#include "exec/cputlb.h" +#include "exec/ram_addr.h" +#include "exec/ramlist.h" +#include "exec/ramblock.h" +#include "qemu/rcu.h" + +extern uint64_t total_dirty_pages; + +/** +* clear_bmap_size: calculate clear bitmap size +* +* @pages: number of guest pages +* @shift: guest page number shift +* +* Returns: number of bits for the clear bitmap +*/ +static inline long clear_bmap_size (uint64_t pages,uint8_t shift) +{ +return DIV_ROUND_UP (pages,1UL << shift); +} + +/** +* clear_bmap_set: set clear bitmap for the page range. Must be with +* bitmap_mutex held. +* +* @rb: the ramblock to operate on +* @start: the start page number +* @size: number of pages to set in the bitmap +* +* Returns: None +*/ +static inline void clear_bmap_set (RAMBlock *rb,uint64_t start, +uint64_t npages) +{ +uint8_t shift = rb->clear_bmap_shift; + +bitmap_set (rb->clear_bmap, start >> shift,clear_bmap_size (npages, shift)); +} + +/** +* clear_bmap_test_and_clear: test clear bitmap for the page, clear if set. +* Must be with bitmap_mutex held. +* +* @rb: the ramblock to operate on +* @page: the page number to check +* +* Returns: true if the bit was set, false otherwise +*/ +static inline bool clear_bmap_test_and_clear (RAMBlock *rb,uint64_t page) +{ +uint8_t shift = rb->clear_bmap_shift; + +return bitmap_test_and_clear (rb->clear_bmap, page >> shift,1 ); +} + +static inline bool offset_in_ramblock (RAMBlock *b,ram_addr_t offset) +{ +return (b && b->host && offset < b->used_length) ? true : false; +} + +static inline void *ramblock_ptr (RAMBlock *block,ram_addr_t offset) +{ +assert (offset_in_ramblock (block, offset)); +return (char *)block->host + offset; +} + +static inline unsigned long int ramblock_recv_bitmap_offset (void *host_addr, +RAMBlock *rb) +{ +uint64_t host_addr_offset = + (uint64_t )(uintptr_t )(host_addr - (void *)rb->host); +return host_addr_offset >>TARGET_PAGE_BITS ; +} + +/* Clear whole block of mem */ +static inline void qemu_ram_block_writeback (RAMBlock *block) +{ +qemu_ram_msync (block,0 , block->used_length); +} + +#define DIRTY_CLIENTS_ALL ((1 << DIRTY_MEMORY_NUM) - 1) +#define DIRTY_CLIENTS_NOCODE (DIRTY_CLIENTS_ALL & ~(1 << DIRTY_MEMORY_CODE)) + +static inline bool cpu_physical_memory_get_dirty (ram_addr_t start, +ram_addr_t length, +unsigned client) +{ +DirtyMemoryBlocks *blocks; +unsigned long end, page; +unsigned long idx, offset, base; +bool dirty = false; + +assert (client <DIRTY_MEMORY_NUM ); + + end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; + page = start >>TARGET_PAGE_BITS ; + + WITH_RCU_READ_LOCK_GUARD() { + blocks =qatomic_rcu_read (&ram_list.dirty_memory[client]); + + idx = page /DIRTY_MEMORY_BLOCK_SIZE ; + offset = page %DIRTY_MEMORY_BLOCK_SIZE ; + base = page - offset; +while (page < end) { +unsigned long next =MIN (end, base +DIRTY_MEMORY_BLOCK_SIZE ); +unsigned long num = next - base; +unsigned long found =find_next_bit (blocks->blocks[idx], + num, offset); +if (found < num) { + dirty = true; +break ; + } + + page = next; + idx++; + offset =0 ; + base +=DIRTY_MEMORY_BLOCK_SIZE ; + } + } + +return dirty; +} + +static inline bool cpu_physical_memory_all_dirty (ram_addr_t start, +ram_addr_t length, +unsigned client) +{ +DirtyMemoryBlocks *blocks; +unsigned long end, page; +unsigned long idx, offset, base; +bool dirty = true; + +assert (client <DIRTY_MEMORY_NUM ); + + end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; + page = start >>TARGET_PAGE_BITS ; + +RCU_READ_LOCK_GUARD (); + + blocks =qatomic_rcu_read (&ram_list.dirty_memory[client]); + + idx = page /DIRTY_MEMORY_BLOCK_SIZE ; + offset = page %DIRTY_MEMORY_BLOCK_SIZE ; + base = page - offset; +while (page < end) { +unsigned long next =MIN (end, base +DIRTY_MEMORY_BLOCK_SIZE ); +unsigned long num = next - base; +unsigned long found =find_next_zero_bit (blocks->blocks[idx], num, offset); +if (found < num) { + dirty = false; +break ; + } + + page = next; + idx++; + offset =0 ; + base +=DIRTY_MEMORY_BLOCK_SIZE ; + } + +return dirty; +} + +static inline bool cpu_physical_memory_get_dirty_flag (ram_addr_t addr, +unsigned client) +{ +return cpu_physical_memory_get_dirty (addr,1 , client); +} + +static inline bool cpu_physical_memory_is_clean (ram_addr_t addr) +{ +bool vga =cpu_physical_memory_get_dirty_flag (addr,DIRTY_MEMORY_VGA ); +bool code =cpu_physical_memory_get_dirty_flag (addr,DIRTY_MEMORY_CODE ); +bool migration = +cpu_physical_memory_get_dirty_flag (addr,DIRTY_MEMORY_MIGRATION ); +return !(vga && code && migration); +} + +static inline uint8_t cpu_physical_memory_range_includes_clean (ram_addr_t start, +ram_addr_t length, +uint8_t mask) +{ +uint8_t ret =0 ; + +if (mask & (1 <<DIRTY_MEMORY_VGA ) && + !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_VGA )) { + ret |= (1 <<DIRTY_MEMORY_VGA ); + } +if (mask & (1 <<DIRTY_MEMORY_CODE ) && + !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_CODE )) { + ret |= (1 <<DIRTY_MEMORY_CODE ); + } +if (mask & (1 <<DIRTY_MEMORY_MIGRATION ) && + !cpu_physical_memory_all_dirty (start, length,DIRTY_MEMORY_MIGRATION )) { + ret |= (1 <<DIRTY_MEMORY_MIGRATION ); + } +return ret; +} + +static inline void cpu_physical_memory_set_dirty_flag (ram_addr_t addr, +unsigned client) +{ +unsigned long page, idx, offset; +DirtyMemoryBlocks *blocks; + +assert (client <DIRTY_MEMORY_NUM ); + + page = addr >>TARGET_PAGE_BITS ; + idx = page /DIRTY_MEMORY_BLOCK_SIZE ; + offset = page %DIRTY_MEMORY_BLOCK_SIZE ; + +RCU_READ_LOCK_GUARD (); + + blocks =qatomic_rcu_read (&ram_list.dirty_memory[client]); + +set_bit_atomic (offset, blocks->blocks[idx]); +} + +static inline void cpu_physical_memory_set_dirty_range (ram_addr_t start, +ram_addr_t length, +uint8_t mask) +{ +DirtyMemoryBlocks *blocks[DIRTY_MEMORY_NUM ]; +unsigned long end, page; +unsigned long idx, offset, base; +int i; + +if (!mask && !xen_enabled ()) { +return ; + } + + end =TARGET_PAGE_ALIGN (start + length) >>TARGET_PAGE_BITS ; + page = start >>TARGET_PAGE_BITS ; + + WITH_RCU_READ_LOCK_GUARD() { +for (i =0 ; i <DIRTY_MEMORY_NUM ; i++) { + blocks[i] =qatomic_rcu_read (&ram_list.dirty_memory[i]); + } + + idx = page /DIRTY_MEMORY_BLOCK_SIZE ; + offset = page %DIRTY_MEMORY_BLOCK_SIZE ; + base = page - offset; +while (page < end) { +unsigned long next =MIN (end, base +DIRTY_MEMORY_BLOCK_SIZE ); + +if (likely (mask & (1 <<DIRTY_MEMORY_MIGRATION ))) { +bitmap_set_atomic (blocks[DIRTY_MEMORY_MIGRATION ]->blocks[idx], + offset, next - page); + } +if (unlikely (mask & (1 <<DIRTY_MEMORY_VGA ))) { +bitmap_set_atomic (blocks[DIRTY_MEMORY_VGA ]->blocks[idx], + offset, next - page); + } +if (unlikely (mask & (1 <<DIRTY_MEMORY_CODE ))) { +bitmap_set_atomic (blocks[DIRTY_MEMORY_CODE ]->blocks[idx], + offset, next - page); + } + + page = next; + idx++; + offset =0 ; + base +=DIRTY_MEMORY_BLOCK_SIZE ; + } + } + +xen_hvm_modified_memory (start, length); +} + +#if !defined(_WIN32) + +/* +* Contrary to cpu_physical_memory_sync_dirty_bitmap() this function returns +* the number of dirty pages in @bitmap passed as argument. On the other hand, +* cpu_physical_memory_sync_dirty_bitmap() returns newly dirtied pages that +* weren't set in the global migration bitmap. +*/ +static inline +uint64_t cpu_physical_memory_set_dirty_lebitmap (unsigned long *bitmap, +ram_addr_t start, +ram_addr_t pages) +{ +unsigned long i, j; +unsigned long page_number, c, nbits; +hwaddr addr; +ram_addr_t ram_addr; +uint64_t num_dirty =0 ; +unsigned long len = (pages +HOST_LONG_BITS -1 ) /HOST_LONG_BITS ; +unsigned long hpratio =qemu_real_host_page_size () /TARGET_PAGE_SIZE ; +unsigned long page =BIT_WORD (start >>TARGET_PAGE_BITS ); + +/* start address is aligned at the start of a word? */ +if ((((page *BITS_PER_LONG ) <<TARGET_PAGE_BITS ) == start) && + (hpratio ==1 )) { +unsigned long **blocks[DIRTY_MEMORY_NUM ]; +unsigned long idx; +unsigned long offset; +long k; +long nr =BITS_TO_LONGS (pages); + + idx = (start >>TARGET_PAGE_BITS ) /DIRTY_MEMORY_BLOCK_SIZE ; + offset =BIT_WORD ((start >>TARGET_PAGE_BITS ) % +DIRTY_MEMORY_BLOCK_SIZE ); + + WITH_RCU_READ_LOCK_GUARD() { +for (i =0 ; i <DIRTY_MEMORY_NUM ; i++) { + blocks[i] = +qatomic_rcu_read (&ram_list.dirty_memory[i])->blocks; + } + +for (k =0 ; k < nr; k++) { +if (bitmap[k]) { +unsigned long temp =leul_to_cpu (bitmap[k]); + + nbits =ctpopl (temp); +qatomic_or (&blocks[DIRTY_MEMORY_VGA ][idx][offset], temp); + +if (global_dirty_tracking) { +qatomic_or ( + &blocks[DIRTY_MEMORY_MIGRATION ][idx][offset], + temp); +if (unlikely ( + global_dirty_tracking &GLOBAL_DIRTY_DIRTY_RATE )) { + total_dirty_pages += nbits; + } + } + + num_dirty += nbits; + +if (tcg_enabled ()) { +qatomic_or (&blocks[DIRTY_MEMORY_CODE ][idx][offset], + temp); + } + } + +if (++offset >=BITS_TO_LONGS (DIRTY_MEMORY_BLOCK_SIZE )) { + offset =0 ; + idx++; + } + } + } + +xen_hvm_modified_memory (start, pages <<TARGET_PAGE_BITS ); + }else { +uint8_t clients =tcg_enabled () ?DIRTY_CLIENTS_ALL :DIRTY_CLIENTS_NOCODE ; + +if (!global_dirty_tracking) { + clients &= ~(1 <<DIRTY_MEMORY_MIGRATION ); + } + +/* +* bitmap-traveling is faster than memory-traveling (for addr...) +* especially when most of the memory is not dirty. +*/ +for (i =0 ; i < len; i++) { +if (bitmap[i] !=0 ) { + c =leul_to_cpu (bitmap[i]); + nbits =ctpopl (c); +if (unlikely (global_dirty_tracking &GLOBAL_DIRTY_DIRTY_RATE )) { + total_dirty_pages += nbits; + } + num_dirty += nbits; +do { + j =ctzl (c); + c &= ~(1ul << j); + page_number = (i *HOST_LONG_BITS + j) * hpratio; + addr = page_number *TARGET_PAGE_SIZE ; + ram_addr = start + addr; +cpu_physical_memory_set_dirty_range (ram_addr, +TARGET_PAGE_SIZE * hpratio, clients); + }while (c !=0 ); + } + } + } + +return num_dirty; +} +#endif /* not _WIN32 */ + +static inline void cpu_physical_memory_dirty_bits_cleared (ram_addr_t start, +ram_addr_t length) +{ +if (tcg_enabled ()) { +tlb_reset_dirty_range_all (start, length); + } + +} +bool cpu_physical_memory_test_and_clear_dirty (ram_addr_t start, +ram_addr_t length, +unsigned client); + +DirtyBitmapSnapshot *cpu_physical_memory_snapshot_and_clear_dirty + (MemoryRegion *mr,hwaddr offset,hwaddr length,unsigned client); + +bool cpu_physical_memory_snapshot_get_dirty (DirtyBitmapSnapshot *snap, +ram_addr_t start, +ram_addr_t length); + +static inline void cpu_physical_memory_clear_dirty_range (ram_addr_t start, +ram_addr_t length) +{ +cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_MIGRATION ); +cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_VGA ); +cpu_physical_memory_test_and_clear_dirty (start, length,DIRTY_MEMORY_CODE ); +} + + +/* Called with RCU critical section */ +static inline +uint64_t cpu_physical_memory_sync_dirty_bitmap (RAMBlock *rb, +ram_addr_t start, +ram_addr_t length) +{ +ram_addr_t addr; +unsigned long word =BIT_WORD ((start + rb->offset) >>TARGET_PAGE_BITS ); +uint64_t num_dirty =0 ; +unsigned long *dest = rb->bmap; + +/* start address and length is aligned at the start of a word? */ +if (((word *BITS_PER_LONG ) <<TARGET_PAGE_BITS ) == + (start + rb->offset) && + !(length & ((BITS_PER_LONG <<TARGET_PAGE_BITS ) -1 ))) { +int k; +int nr =BITS_TO_LONGS (length >>TARGET_PAGE_BITS ); +unsigned long *const *src; +unsigned long idx = (word *BITS_PER_LONG ) /DIRTY_MEMORY_BLOCK_SIZE ; +unsigned long offset =BIT_WORD ((word *BITS_PER_LONG ) % +DIRTY_MEMORY_BLOCK_SIZE ); +unsigned long page =BIT_WORD (start >>TARGET_PAGE_BITS ); + + src =qatomic_rcu_read ( + &ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION ])->blocks; + +for (k = page; k < page + nr; k++) { +if (src[idx][offset]) { +unsigned long bits =qatomic_xchg (&src[idx][offset],0 ); +unsigned long new_dirty; + new_dirty = ~dest[k]; + dest[k] |= bits; + new_dirty &= bits; + num_dirty +=ctpopl (new_dirty); + } + +if (++offset >=BITS_TO_LONGS (DIRTY_MEMORY_BLOCK_SIZE )) { + offset =0 ; + idx++; + } + } +if (num_dirty) { +cpu_physical_memory_dirty_bits_cleared (start, length); + } + +if (rb->clear_bmap) { +/* +* Postpone the dirty bitmap clear to the point before we +* really send the pages, also we will split the clear +* dirty procedure into smaller chunks. +*/ +clear_bmap_set (rb, start >>TARGET_PAGE_BITS , + length >>TARGET_PAGE_BITS ); + }else { +/* Slow path - still do that in a huge chunk */ +memory_region_clear_dirty_bitmap (rb->mr, start, length); + } + }else { +ram_addr_t offset = rb->offset; + +for (addr =0 ; addr < length; addr +=TARGET_PAGE_SIZE ) { +if (cpu_physical_memory_test_and_clear_dirty ( + start + addr + offset, +TARGET_PAGE_SIZE , +DIRTY_MEMORY_MIGRATION )) { +long k = (start + addr) >>TARGET_PAGE_BITS ; +if (!test_and_set_bit (k, dest)) { + num_dirty++; + } + } + } + } + +return num_dirty; +} + +#endif accel/kvm/kvm-all.c +1
-0@@ -35,6 +35,7 @@#include "qemu/bswap.h" #include "exec/memory.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/event_notifier.h" #include "qemu/main-loop.h" #include "trace.h" accel/tcg/cputlb.c +1
-0@@ -28,6 +28,7 @@#include "exec/tb-flush.h" #include "exec/memory-internal.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "exec/mmu-access-type.h" #include "exec/tlb-common.h" #include "exec/vaddr.h" accel/tcg/translate-all.c +1
-0@@ -41,6 +41,7 @@#endif #else #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #endif #include "exec/cputlb.h" hw/ppc/spapr.c +1
-0@@ -75,6 +75,7 @@#include "hw/virtio/vhost-scsi-common.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "exec/confidential-guest-support.h" #include "hw/usb.h" #include "qemu/config-file.h" hw/ppc/spapr_caps.c +1
-0@@ -28,6 +28,7 @@#include "qapi/visitor.h" #include "sysemu/hw_accel.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "target/ppc/cpu.h" #include "target/ppc/mmu-hash64.h" #include "cpu-models.h" hw/ppc/spapr_pci.c +1
-0@@ -35,6 +35,7 @@#include "hw/ppc/spapr.h" #include "hw/pci-host/spapr.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include <libfdt.h> #include "trace.h" #include "qemu/error-report.h" hw/remote/memory.c +1
-0@@ -12,6 +12,7 @@#include "hw/remote/memory.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qapi/error.h" static void remote_sysmem_reset (void )hw/remote/proxy-memory-listener.c +1
-0@@ -13,6 +13,7 @@#include "exec/memory.h" #include "exec/cpu-common.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/remote/mpqemu-link.h" hw/s390x/s390-stattrib-kvm.c +1
-0@@ -16,6 +16,7 @@#include "qemu/error-report.h" #include "sysemu/kvm.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "kvm/kvm_s390x.h" #include "qapi/error.h" hw/s390x/s390-stattrib.c +1
-0@@ -17,6 +17,7 @@#include "hw/s390x/storage-attributes.h" #include "qemu/error-report.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "cpu.h" hw/s390x/s390-virtio-ccw.c +1
-0@@ -14,6 +14,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "exec/confidential-guest-support.h" #include "hw/boards.h" #include "hw/s390x/s390-virtio-hcall.h" hw/vfio/common.c +1
-0@@ -30,6 +30,7 @@#include "exec/address-spaces.h" #include "exec/memory.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "hw/hw.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" hw/vfio/container.c +1
-0@@ -26,6 +26,7 @@#include "exec/address-spaces.h" #include "exec/memory.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/error-report.h" #include "qemu/range.h" #include "sysemu/reset.h" hw/vfio/iommufd.c +1
-0@@ -26,6 +26,7 @@#include "qemu/chardev_open.h" #include "pci.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" static int iommufd_cdev_map (const VFIOContainerBase *bcontainer,hwaddr iova,ram_addr_t size,void *vaddr,bool readonly)hw/vfio/migration.c +1
-0@@ -27,6 +27,7 @@#include "qapi/qapi-events-vfio.h" #include "exec/ramlist.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "pci.h" #include "trace.h" #include "hw/hw.h" hw/vfio/spapr.c +1
-0@@ -20,6 +20,7 @@#include "hw/vfio/vfio-common.h" #include "hw/hw.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "trace.h" hw/virtio/virtio-mem.c +1
-0@@ -25,6 +25,7 @@#include "qapi/error.h" #include "qapi/visitor.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "migration/misc.h" #include "hw/boards.h" #include "hw/qdev-properties.h" migration/ram.c +1
-0@@ -49,6 +49,7 @@#include "qapi/qmp/qerror.h" #include "trace.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "exec/target_page.h" #include "qemu/rcu_queue.h" #include "migration/colo.h" plugins/api.c +1
-0@@ -50,6 +50,7 @@#include "qapi/error.h" #include "migration/blocker.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/plugin-memory.h" #include "hw/boards.h" #else system/memory.c +1
-0@@ -27,6 +27,7 @@#include "exec/memory-internal.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "sysemu/kvm.h" #include "sysemu/runstate.h" #include "sysemu/tcg.h" system/physmem.c +1
-0@@ -67,6 +67,7 @@#include "exec/memory-internal.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "qemu/pmem.h" target/arm/tcg/mte_helper.c +1
-0@@ -25,6 +25,7 @@#include "exec/page-protection.h" #ifndef CONFIG_USER_ONLY #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #endif #include "exec/cpu_ldst.h" #include "exec/helper-proto.h" target/ppc/kvm.c +1
-0@@ -42,6 +42,7 @@#include "gdbstub/enums.h" #include "exec/memattrs.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "sysemu/hostmem.h" #include "qemu/cutils.h" #include "qemu/main-loop.h" target/s390x/kvm/kvm.c +1
-0@@ -42,6 +42,7 @@#include "sysemu/device_tree.h" #include "gdbstub/enums.h" #include "exec/ram_addr.h" +#include "sysemu/physmem-target.h" #include "trace.h" #include "hw/s390x/s390-pci-inst.h" #include "hw/s390x/s390-pci-bus.h"
PATCH 22/24 exec/cpu-common: Move ram_addr_t related methods to 'exec/ram_addr.h'
In reply to Philippe Mathieu-DaudéMove methods related to the ram_addr_t type to
the specific "exec/ram_addr.h" header.
--- include/exec/cpu-common.h | 56 +------------------------------- include/exec/ram_addr.h | 56 ++++++++++++++++++++++++++++++++ include/exec/translation-block.h | 2 +- 3 files changed, 58 insertions(+), 56 deletions(-)
include/exec/cpu-common.h +1 -55
@@ -54,61 +54,7 @@ enum device_endian {#define DEVICE_HOST_ENDIAN DEVICE_LITTLE_ENDIAN#endif -/* address in the RAM (different from a physical address) */ -#if defined(CONFIG_XEN_BACKEND ) -typedef uint64_t ram_addr_t ; -# define RAM_ADDR_MAX UINT64_MAX -# define RAM_ADDR_FMT "%" PRIx64 -#else -typedef uintptr_t ram_addr_t ; -# define RAM_ADDR_MAX UINTPTR_MAX -# define RAM_ADDR_FMT "%" PRIxPTR -#endif - -/* memory API */ - -void qemu_ram_remap (ram_addr_t addr,ram_addr_t length); -/* This should not be used by devices. */ -ram_addr_t qemu_ram_addr_from_host (void *ptr); -ram_addr_t qemu_ram_addr_from_host_nofail (void *ptr); -RAMBlock *qemu_ram_block_by_name (const char *name); - -/* -* Translates a host ptr back to a RAMBlock and an offset in that RAMBlock. -* -* @ptr: The host pointer to translate. -* @round_offset: Whether to round the result offset down to a target page -* @offset: Will be set to the offset within the returned RAMBlock. -* -* Returns: RAMBlock (or NULL if not found) -* -* By the time this function returns, the returned pointer is not protected -* by RCU anymore. If the caller is not within an RCU critical section and -* does not hold the BQL, it must have other means of protecting the -* pointer, such as a reference to the memory region that owns the RAMBlock. -*/ -RAMBlock *qemu_ram_block_from_host (void *ptr,bool round_offset, -ram_addr_t *offset); -ram_addr_t qemu_ram_block_host_offset (RAMBlock *rb,void *host); -void qemu_ram_set_idstr (RAMBlock *block,const char *name,DeviceState *dev); -void qemu_ram_unset_idstr (RAMBlock *block); -const char *qemu_ram_get_idstr (RAMBlock *rb); -void *qemu_ram_get_host_addr (RAMBlock *rb); -ram_addr_t qemu_ram_get_offset (RAMBlock *rb); -ram_addr_t qemu_ram_get_used_length (RAMBlock *rb); -ram_addr_t qemu_ram_get_max_length (RAMBlock *rb); -bool qemu_ram_is_shared (RAMBlock *rb); -bool qemu_ram_is_noreserve (RAMBlock *rb); -bool qemu_ram_is_uf_zeroable (RAMBlock *rb); -void qemu_ram_set_uf_zeroable (RAMBlock *rb); -bool qemu_ram_is_migratable (RAMBlock *rb); -void qemu_ram_set_migratable (RAMBlock *rb); -void qemu_ram_unset_migratable (RAMBlock *rb); -bool qemu_ram_is_named_file (RAMBlock *rb); -int qemu_ram_get_fd (RAMBlock *rb); - -size_t qemu_ram_pagesize (RAMBlock *block); -size_t qemu_ram_pagesize_largest (void ); +#include "exec/ram_addr.h" /** * cpu_address_space_init:
include/exec/ram_addr.h +56 -0
62 lines not on this page · raw message
include/exec/translation-block.h +1 -1
@@ -8,7 +8,7 @@#define EXEC_TRANSLATION_BLOCK_H #include "qemu/thread.h" -#include "exec/cpu-common.h" +#include "exec/ram_addr.h" #include "exec/vaddr.h" #ifdef CONFIG_USER_ONLY #include "qemu/interval-tree.h"
Signature · 1 line
2.45.2
Re: [PATCH 22/24] exec/cpu-common: Move ram_addr_t related methods to 'exec/ram_addr.h'
Quoted 149 lines · Philippe Mathieu-Daudé
Move methods related to the
ram_addr_ttype to
the specific "exec/ram_addr.h" header.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/cpu-common.h | 56 +------------------------------- include/exec/ram_addr.h | 56 ++++++++++++++++++++++++++++++++ include/exec/translation-block.h | 2 +- 3 files changed, 58 insertions(+), 56 deletions(-)include/exec/cpu-common.h +1
-55@@ -54,61 +54,7 @@ enum device_endian {#define DEVICE_HOST_ENDIAN DEVICE_LITTLE_ENDIAN#endif -/* address in the RAM (different from a physical address) */ -#if defined(CONFIG_XEN_BACKEND ) -typedef uint64_t ram_addr_t ; -# define RAM_ADDR_MAX UINT64_MAX -# define RAM_ADDR_FMT "%" PRIx64 -#else -typedef uintptr_t ram_addr_t ; -# define RAM_ADDR_MAX UINTPTR_MAX -# define RAM_ADDR_FMT "%" PRIxPTR -#endif - -/* memory API */ - -void qemu_ram_remap (ram_addr_t addr,ram_addr_t length); -/* This should not be used by devices. */ -ram_addr_t qemu_ram_addr_from_host (void *ptr); -ram_addr_t qemu_ram_addr_from_host_nofail (void *ptr); -RAMBlock *qemu_ram_block_by_name (const char *name); - -/* -* Translates a host ptr back to a RAMBlock and an offset in that RAMBlock. -* -* @ptr: The host pointer to translate. -* @round_offset: Whether to round the result offset down to a target page -* @offset: Will be set to the offset within the returned RAMBlock. -* -* Returns: RAMBlock (or NULL if not found) -* -* By the time this function returns, the returned pointer is not protected -* by RCU anymore. If the caller is not within an RCU critical section and -* does not hold the BQL, it must have other means of protecting the -* pointer, such as a reference to the memory region that owns the RAMBlock. -*/ -RAMBlock *qemu_ram_block_from_host (void *ptr,bool round_offset, -ram_addr_t *offset); -ram_addr_t qemu_ram_block_host_offset (RAMBlock *rb,void *host); -void qemu_ram_set_idstr (RAMBlock *block,const char *name,DeviceState *dev); -void qemu_ram_unset_idstr (RAMBlock *block); -const char *qemu_ram_get_idstr (RAMBlock *rb); -void *qemu_ram_get_host_addr (RAMBlock *rb); -ram_addr_t qemu_ram_get_offset (RAMBlock *rb); -ram_addr_t qemu_ram_get_used_length (RAMBlock *rb); -ram_addr_t qemu_ram_get_max_length (RAMBlock *rb); -bool qemu_ram_is_shared (RAMBlock *rb); -bool qemu_ram_is_noreserve (RAMBlock *rb); -bool qemu_ram_is_uf_zeroable (RAMBlock *rb); -void qemu_ram_set_uf_zeroable (RAMBlock *rb); -bool qemu_ram_is_migratable (RAMBlock *rb); -void qemu_ram_set_migratable (RAMBlock *rb); -void qemu_ram_unset_migratable (RAMBlock *rb); -bool qemu_ram_is_named_file (RAMBlock *rb); -int qemu_ram_get_fd (RAMBlock *rb); - -size_t qemu_ram_pagesize (RAMBlock *block); -size_t qemu_ram_pagesize_largest (void ); +#include "exec/ram_addr.h" /** * cpu_address_space_init: include/exec/ram_addr.h +56
-0@@ -21,6 +21,62 @@#ifndef CONFIG_USER_ONLY +/* address in the RAM (different from a physical address) */ +#if defined(CONFIG_XEN_BACKEND ) +typedef uint64_t ram_addr_t ; +# define RAM_ADDR_MAX UINT64_MAX +# define RAM_ADDR_FMT "%" PRIx64 +#else +typedef uintptr_t ram_addr_t ; +# define RAM_ADDR_MAX UINTPTR_MAX +# define RAM_ADDR_FMT "%" PRIxPTR +#endif + +/* memory API */ + +void qemu_ram_remap (ram_addr_t addr,ram_addr_t length); +/* This should not be used by devices. */ +ram_addr_t qemu_ram_addr_from_host (void *ptr); +ram_addr_t qemu_ram_addr_from_host_nofail (void *ptr); +RAMBlock *qemu_ram_block_by_name (const char *name); + +/* +* Translates a host ptr back to a RAMBlock and an offset in that RAMBlock. +* +* @ptr: The host pointer to translate. +* @round_offset: Whether to round the result offset down to a target page +* @offset: Will be set to the offset within the returned RAMBlock. +* +* Returns: RAMBlock (or NULL if not found) +* +* By the time this function returns, the returned pointer is not protected +* by RCU anymore. If the caller is not within an RCU critical section and +* does not hold the BQL, it must have other means of protecting the +* pointer, such as a reference to the memory region that owns the RAMBlock. +*/ +RAMBlock *qemu_ram_block_from_host (void *ptr,bool round_offset, +ram_addr_t *offset); +ram_addr_t qemu_ram_block_host_offset (RAMBlock *rb,void *host); +void qemu_ram_set_idstr (RAMBlock *block,const char *name,DeviceState *dev); +void qemu_ram_unset_idstr (RAMBlock *block); +const char *qemu_ram_get_idstr (RAMBlock *rb); +void *qemu_ram_get_host_addr (RAMBlock *rb); +ram_addr_t qemu_ram_get_offset (RAMBlock *rb); +ram_addr_t qemu_ram_get_used_length (RAMBlock *rb); +ram_addr_t qemu_ram_get_max_length (RAMBlock *rb); +bool qemu_ram_is_shared (RAMBlock *rb); +bool qemu_ram_is_noreserve (RAMBlock *rb); +bool qemu_ram_is_uf_zeroable (RAMBlock *rb); +void qemu_ram_set_uf_zeroable (RAMBlock *rb); +bool qemu_ram_is_migratable (RAMBlock *rb); +void qemu_ram_set_migratable (RAMBlock *rb); +void qemu_ram_unset_migratable (RAMBlock *rb); +bool qemu_ram_is_named_file (RAMBlock *rb); +int qemu_ram_get_fd (RAMBlock *rb); + +size_t qemu_ram_pagesize (RAMBlock *block); +size_t qemu_ram_pagesize_largest (void ); +bool ramblock_is_pmem (RAMBlock *rb);long qemu_minrampagesize (void );include/exec/translation-block.h +0
-0
include/exec/translation-block.h line 14
Quoted 8 lines
include/exec/translation-block.h +1
-1@@ -8,7 +8,7 @@#define EXEC_TRANSLATION_BLOCK_H #include "qemu/thread.h" -#include "exec/cpu-common.h" +#include "exec/ram_addr.h" #include "exec/vaddr.h" #ifdef CONFIG_USER_ONLY #include "qemu/interval-tree.h"
Re: [PATCH 22/24] exec/cpu-common: Move ram_addr_t related methods to 'exec/ram_addr.h'
In reply to Philippe Mathieu-DaudéQuoted 9 lines · Philippe Mathieu-Daudé
Move methods related to the
ram_addr_ttype to
the specific "exec/ram_addr.h" header.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/exec/cpu-common.h | 56 +------------------------------- include/exec/ram_addr.h | 56 ++++++++++++++++++++++++++++++++ include/exec/translation-block.h | 2 +- 3 files changed, 58 insertions(+), 56 deletions(-)
r~
PATCH 23/24 exec/memory: Move qemu_map_ram_ptr() declaration to 'exec/ram_addr.h'
In reply to Philippe Mathieu-Daudé--- include/exec/memory.h | 2 +- include/exec/ram_addr.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
include/exec/memory.h +1 -1
@@ -28,6 +28,7 @@#include "qemu/notify.h" #include "qom/object.h" #include "qemu/rcu.h" +#include "exec/ram_addr.h" #define RAM_ADDR_INVALID (~(ram_addr_t)0)
@@ -2973,7 +2974,6 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, MemTxAttrs attrs, void *buf, hwaddr len, hwaddr addr1, hwaddr l, MemoryRegion *mr); -void *qemu_map_ram_ptr (RAMBlock *ram_block,ram_addr_t addr);/* Internal functions, part of the implementation of address_space_read_cached * and address_space_write_cached. */
include/exec/ram_addr.h +1 -0
@@ -73,6 +73,7 @@ void qemu_ram_set_migratable(RAMBlock *rb);void qemu_ram_unset_migratable (RAMBlock *rb);bool qemu_ram_is_named_file (RAMBlock *rb);int qemu_ram_get_fd (RAMBlock *rb); +void *qemu_map_ram_ptr (RAMBlock *ram_block,ram_addr_t addr);size_t qemu_ram_pagesize (RAMBlock *block);size_t qemu_ram_pagesize_largest (void );
Signature · 1 line
2.45.2
Re: [PATCH 23/24] exec/memory: Move qemu_map_ram_ptr() declaration to 'exec/ram_addr.h'
Quoted 31 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/memory.h | 2 +- include/exec/ram_addr.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)include/exec/memory.h +1
-1@@ -28,6 +28,7 @@#include "qemu/notify.h" #include "qom/object.h" #include "qemu/rcu.h" +#include "exec/ram_addr.h" #define RAM_ADDR_INVALID (~(ram_addr_t)0)@@ -2973,7 +2974,6 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, MemTxAttrs attrs, void *buf, hwaddr len, hwaddr addr1, hwaddr l, MemoryRegion *mr); -void *qemu_map_ram_ptr (RAMBlock *ram_block,ram_addr_t addr);/* Internal functions, part of the implementation of address_space_read_cached * and address_space_write_cached. */ include/exec/ram_addr.h +0
-0
include/exec/ram_addr.h void qemu_ram_set_migratable(RAMBlock *rb); · line 79
Quoted 7 lines
include/exec/ram_addr.h +1
-0@@ -73,6 +73,7 @@ void qemu_ram_set_migratable(RAMBlock *rb);void qemu_ram_unset_migratable (RAMBlock *rb);bool qemu_ram_is_named_file (RAMBlock *rb);int qemu_ram_get_fd (RAMBlock *rb); +void *qemu_map_ram_ptr (RAMBlock *ram_block,ram_addr_t addr);size_t qemu_ram_pagesize (RAMBlock *block);size_t qemu_ram_pagesize_largest (void );
Re: [PATCH 23/24] exec/memory: Move qemu_map_ram_ptr() declaration to 'exec/ram_addr.h'
In reply to Philippe Mathieu-DaudéQuoted 5 lines · Philippe Mathieu-Daudé
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/exec/memory.h | 2 +- include/exec/ram_addr.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
r~
Quoted 33 lines
include/exec/memory.h +1
-1@@ -28,6 +28,7 @@#include "qemu/notify.h" #include "qom/object.h" #include "qemu/rcu.h" +#include "exec/ram_addr.h" #define RAM_ADDR_INVALID (~(ram_addr_t)0)@@ -2973,7 +2974,6 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, MemTxAttrs attrs, void *buf, hwaddr len, hwaddr addr1, hwaddr l, MemoryRegion *mr); -void *qemu_map_ram_ptr (RAMBlock *ram_block,ram_addr_t addr);/* Internal functions, part of the implementation of address_space_read_cached * and address_space_write_cached. */ include/exec/ram_addr.h +1
-0@@ -73,6 +73,7 @@ void qemu_ram_set_migratable(RAMBlock *rb);void qemu_ram_unset_migratable (RAMBlock *rb);bool qemu_ram_is_named_file (RAMBlock *rb);int qemu_ram_get_fd (RAMBlock *rb); +void *qemu_map_ram_ptr (RAMBlock *ram_block,ram_addr_t addr);size_t qemu_ram_pagesize (RAMBlock *block);size_t qemu_ram_pagesize_largest (void );
PATCH 24/24 exec: Move 'ram_addr.h' header under sysemu/ namespace
In reply to Philippe Mathieu-Daudé"ram_addr.h" contains declarations specific to system emulation, move it under the sysemu/ directory to clarify the API namespace.
---
MAINTAINERS | 2 +-
include/exec/cpu-common.h | 2 +-
include/exec/memory.h | 2 +-
include/exec/translation-block.h | 2 +-
include/sysemu/physmem-target.h | 2 +-
include/{exec => sysemu}/ram_addr.h | 0
accel/kvm/kvm-all.c | 2 +-
accel/tcg/cputlb.c | 2 +-
accel/tcg/translate-all.c | 2 +-
hw/ppc/spapr.c | 2 +-
hw/ppc/spapr_caps.c | 2 +-
hw/ppc/spapr_pci.c | 2 +-
hw/remote/memory.c | 2 +-
hw/remote/proxy-memory-listener.c | 2 +-
hw/s390x/s390-stattrib-kvm.c | 2 +-
hw/s390x/s390-stattrib.c | 2 +-
hw/s390x/s390-virtio-ccw.c | 2 +-
hw/vfio/common.c | 2 +-
hw/vfio/container.c | 2 +-
hw/vfio/iommufd.c | 2 +-
hw/vfio/migration.c | 2 +-
hw/vfio/spapr.c | 2 +-
hw/virtio/virtio-mem.c | 2 +-
migration/ram.c | 2 +-
plugins/api.c | 2 +-
system/memory.c | 2 +-
system/physmem.c | 2 +-
target/arm/tcg/mte_helper.c | 2 +-
target/ppc/kvm.c | 2 +-
target/s390x/kvm/kvm.c | 2 +-
30 files changed, 29 insertions(+), 29 deletions(-)
rename include/{exec => sysemu}/ram_addr.h (100%)MAINTAINERS +1 -1
@@ -3024,10 +3024,10 @@ S: Supported F: include/exec/ioport.h F: include/exec/memop.h F: include/exec/memory.h -F: include/exec/ram_addr.h F: include/exec/ramblock.h F: include/sysemu/memory_mapping.h F: include/sysemu/physmem-target.h +F: include/sysemu/ram_addr.h F: system/dma-helpers.c F: system/ioport.c F: system/memory.c
include/exec/cpu-common.h +1 -1
@@ -54,7 +54,7 @@ enum device_endian {#define DEVICE_HOST_ENDIAN DEVICE_LITTLE_ENDIAN#endif -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" /** * cpu_address_space_init:
include/exec/memory.h +1 -1
@@ -28,7 +28,7 @@#include "qemu/notify.h" #include "qom/object.h" #include "qemu/rcu.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #define RAM_ADDR_INVALID (~(ram_addr_t)0)
include/exec/translation-block.h +1 -1
@@ -8,7 +8,7 @@#define EXEC_TRANSLATION_BLOCK_H #include "qemu/thread.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "exec/vaddr.h" #ifdef CONFIG_USER_ONLY #include "qemu/interval-tree.h"
include/sysemu/physmem-target.h +1 -1
@@ -23,7 +23,7 @@#include "sysemu/xen.h" #include "sysemu/tcg.h" #include "exec/cputlb.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "exec/ramlist.h" #include "exec/ramblock.h" #include "qemu/rcu.h"
include/sysemu/ram_addr.h renamed from include/exec/ram_addr.h +0 -0
accel/kvm/kvm-all.c +1 -1
@@ -34,7 +34,7 @@#include "sysemu/accel-blocker.h" #include "qemu/bswap.h" #include "exec/memory.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qemu/event_notifier.h" #include "qemu/main-loop.h"
accel/tcg/cputlb.c +1 -1
@@ -27,7 +27,7 @@#include "exec/cputlb.h" #include "exec/tb-flush.h" #include "exec/memory-internal.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "exec/mmu-access-type.h" #include "exec/tlb-common.h"
accel/tcg/translate-all.c +1 -1
@@ -40,7 +40,7 @@#endif #endif #else -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #endif
hw/ppc/spapr.c +1 -1
@@ -74,7 +74,7 @@#include "hw/virtio/virtio-scsi.h" #include "hw/virtio/vhost-scsi-common.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "exec/confidential-guest-support.h" #include "hw/usb.h"
hw/ppc/spapr_caps.c +1 -1
@@ -27,7 +27,7 @@#include "qapi/error.h" #include "qapi/visitor.h" #include "sysemu/hw_accel.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "target/ppc/cpu.h" #include "target/ppc/mmu-hash64.h"
hw/ppc/spapr_pci.c +1 -1
@@ -34,7 +34,7 @@#include "hw/pci/pci_host.h" #include "hw/ppc/spapr.h" #include "hw/pci-host/spapr.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include <libfdt.h> #include "trace.h"
hw/remote/memory.c +1 -1
@@ -11,7 +11,7 @@#include "qemu/osdep.h" #include "hw/remote/memory.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qapi/error.h"
hw/remote/proxy-memory-listener.c +1 -1
@@ -12,7 +12,7 @@#include "qemu/range.h" #include "exec/memory.h" #include "exec/cpu-common.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qapi/error.h" #include "qemu/error-report.h"
hw/s390x/s390-stattrib-kvm.c +1 -1
@@ -15,7 +15,7 @@#include "hw/s390x/storage-attributes.h" #include "qemu/error-report.h" #include "sysemu/kvm.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "kvm/kvm_s390x.h" #include "qapi/error.h"
hw/s390x/s390-stattrib.c +1 -1
@@ -16,7 +16,7 @@#include "hw/qdev-properties.h" #include "hw/s390x/storage-attributes.h" #include "qemu/error-report.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h"
hw/s390x/s390-virtio-ccw.c +1 -1
@@ -13,7 +13,7 @@#include "qemu/osdep.h" #include "qapi/error.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "exec/confidential-guest-support.h" #include "hw/boards.h"
hw/vfio/common.c +1 -1
@@ -29,7 +29,7 @@#include "hw/vfio/pci.h" #include "exec/address-spaces.h" #include "exec/memory.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "hw/hw.h" #include "qemu/error-report.h"
hw/vfio/container.c +1 -1
@@ -25,7 +25,7 @@#include "hw/vfio/vfio-common.h" #include "exec/address-spaces.h" #include "exec/memory.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qemu/error-report.h" #include "qemu/range.h"
hw/vfio/iommufd.c +1 -1
@@ -25,7 +25,7 @@#include "qemu/cutils.h" #include "qemu/chardev_open.h" #include "pci.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" static int iommufd_cdev_map(const VFIOContainerBase *bcontainer, hwaddr iova,
hw/vfio/migration.c +1 -1
@@ -26,7 +26,7 @@#include "qapi/error.h" #include "qapi/qapi-events-vfio.h" #include "exec/ramlist.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "pci.h" #include "trace.h"
hw/vfio/spapr.c +1 -1
@@ -19,7 +19,7 @@#include "hw/vfio/vfio-common.h" #include "hw/hw.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qemu/error-report.h" #include "qapi/error.h"
hw/virtio/virtio-mem.c +1 -1
@@ -24,7 +24,7 @@#include "hw/virtio/virtio-mem.h" #include "qapi/error.h" #include "qapi/visitor.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "migration/misc.h" #include "hw/boards.h"
migration/ram.c +1 -1
@@ -48,7 +48,7 @@#include "qapi/qapi-commands-migration.h" #include "qapi/qmp/qerror.h" #include "trace.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "exec/target_page.h" #include "qemu/rcu_queue.h"
plugins/api.c +1 -1
@@ -49,7 +49,7 @@#ifndef CONFIG_USER_ONLY #include "qapi/error.h" #include "migration/blocker.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qemu/plugin-memory.h" #include "hw/boards.h"
system/memory.c +1 -1
@@ -26,7 +26,7 @@#include "trace.h" #include "exec/memory-internal.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "sysemu/kvm.h" #include "sysemu/runstate.h"
system/physmem.c +1 -1
@@ -66,7 +66,7 @@#include "sysemu/replay.h" #include "exec/memory-internal.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qemu/pmem.h"
target/arm/tcg/mte_helper.c +1 -1
@@ -24,7 +24,7 @@#include "exec/exec-all.h" #include "exec/page-protection.h" #ifndef CONFIG_USER_ONLY -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #endif #include "exec/cpu_ldst.h"
target/ppc/kvm.c +1 -1
@@ -41,7 +41,7 @@#include "trace.h" #include "gdbstub/enums.h" #include "exec/memattrs.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "sysemu/hostmem.h" #include "qemu/cutils.h"
target/s390x/kvm/kvm.c +1 -1
@@ -41,7 +41,7 @@#include "sysemu/runstate.h" #include "sysemu/device_tree.h" #include "gdbstub/enums.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "trace.h" #include "hw/s390x/s390-pci-inst.h"
Signature · 1 line
2.45.2
Re: [PATCH 24/24] exec: Move 'ram_addr.h' header under sysemu/ namespace
Quoted 414 lines · Philippe Mathieu-Daudé
"
ram_addr.h" contains declarations specific to system emulation, move it under the sysemu/ directory to clarify the API namespace.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- MAINTAINERS | 2 +- include/exec/cpu-common.h | 2 +- include/exec/memory.h | 2 +- include/exec/translation-block.h | 2 +- include/sysemu/physmem-target.h | 2 +- include/{exec => sysemu}/ram_addr.h | 0 accel/kvm/kvm-all.c | 2 +- accel/tcg/cputlb.c | 2 +- accel/tcg/translate-all.c | 2 +- hw/ppc/spapr.c | 2 +- hw/ppc/spapr_caps.c | 2 +- hw/ppc/spapr_pci.c | 2 +- hw/remote/memory.c | 2 +- hw/remote/proxy-memory-listener.c | 2 +- hw/s390x/s390-stattrib-kvm.c | 2 +- hw/s390x/s390-stattrib.c | 2 +- hw/s390x/s390-virtio-ccw.c | 2 +- hw/vfio/common.c | 2 +- hw/vfio/container.c | 2 +- hw/vfio/iommufd.c | 2 +- hw/vfio/migration.c | 2 +- hw/vfio/spapr.c | 2 +- hw/virtio/virtio-mem.c | 2 +- migration/ram.c | 2 +- plugins/api.c | 2 +- system/memory.c | 2 +- system/physmem.c | 2 +- target/arm/tcg/mte_helper.c | 2 +- target/ppc/kvm.c | 2 +- target/s390x/kvm/kvm.c | 2 +- 30 files changed, 29 insertions(+), 29 deletions(-)rename
include/{exec=>sysemu}/ram_addr.h(100%)MAINTAINERS +1
-1@@ -3024,10 +3024,10 @@ S: Supported F: include/exec/ioport.h F: include/exec/memop.h F: include/exec/memory.h -F: include/exec/ram_addr.h F: include/exec/ramblock.h F: include/sysemu/memory_mapping.h F: include/sysemu/physmem-target.h +F: include/sysemu/ram_addr.h F: system/dma-helpers.c F: system/ioport.c F: system/memory.cinclude/exec/cpu-common.h +1
-1@@ -54,7 +54,7 @@ enum device_endian {#define DEVICE_HOST_ENDIAN DEVICE_LITTLE_ENDIAN#endif -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" /** * cpu_address_space_init: include/exec/memory.h +1
-1@@ -28,7 +28,7 @@#include "qemu/notify.h" #include "qom/object.h" #include "qemu/rcu.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #define RAM_ADDR_INVALID (~(ram_addr_t)0)include/exec/translation-block.h +1
-1@@ -8,7 +8,7 @@#define EXEC_TRANSLATION_BLOCK_H #include "qemu/thread.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "exec/vaddr.h" #ifdef CONFIG_USER_ONLY #include "qemu/interval-tree.h" include/sysemu/physmem-target.h +1
-1@@ -23,7 +23,7 @@#include "sysemu/xen.h" #include "sysemu/tcg.h" #include "exec/cputlb.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "exec/ramlist.h" #include "exec/ramblock.h" #include "qemu/rcu.h" include/sysemu/ram_addr.h renamed from include/exec/ram_addr.h +0
-0accel/kvm/kvm-all.c +1
-1@@ -34,7 +34,7 @@#include "sysemu/accel-blocker.h" #include "qemu/bswap.h" #include "exec/memory.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qemu/event_notifier.h" #include "qemu/main-loop.h" accel/tcg/cputlb.c +1
-1@@ -27,7 +27,7 @@#include "exec/cputlb.h" #include "exec/tb-flush.h" #include "exec/memory-internal.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "exec/mmu-access-type.h" #include "exec/tlb-common.h" accel/tcg/translate-all.c +1
-1@@ -40,7 +40,7 @@#endif #endif #else -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #endif hw/ppc/spapr.c +1
-1@@ -74,7 +74,7 @@#include "hw/virtio/virtio-scsi.h" #include "hw/virtio/vhost-scsi-common.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "exec/confidential-guest-support.h" #include "hw/usb.h" hw/ppc/spapr_caps.c +1
-1@@ -27,7 +27,7 @@#include "qapi/error.h" #include "qapi/visitor.h" #include "sysemu/hw_accel.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "target/ppc/cpu.h" #include "target/ppc/mmu-hash64.h" hw/ppc/spapr_pci.c +1
-1@@ -34,7 +34,7 @@#include "hw/pci/pci_host.h" #include "hw/ppc/spapr.h" #include "hw/pci-host/spapr.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include <libfdt.h> #include "trace.h" hw/remote/memory.c +1
-1@@ -11,7 +11,7 @@#include "qemu/osdep.h" #include "hw/remote/memory.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qapi/error.h" hw/remote/proxy-memory-listener.c +1
-1@@ -12,7 +12,7 @@#include "qemu/range.h" #include "exec/memory.h" #include "exec/cpu-common.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qapi/error.h" #include "qemu/error-report.h" hw/s390x/s390-stattrib-kvm.c +1
-1@@ -15,7 +15,7 @@#include "hw/s390x/storage-attributes.h" #include "qemu/error-report.h" #include "sysemu/kvm.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "kvm/kvm_s390x.h" #include "qapi/error.h" hw/s390x/s390-stattrib.c +1
-1@@ -16,7 +16,7 @@#include "hw/qdev-properties.h" #include "hw/s390x/storage-attributes.h" #include "qemu/error-report.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" hw/s390x/s390-virtio-ccw.c +1
-1@@ -13,7 +13,7 @@#include "qemu/osdep.h" #include "qapi/error.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "exec/confidential-guest-support.h" #include "hw/boards.h" hw/vfio/common.c +1
-1@@ -29,7 +29,7 @@#include "hw/vfio/pci.h" #include "exec/address-spaces.h" #include "exec/memory.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "hw/hw.h" #include "qemu/error-report.h" hw/vfio/container.c +1
-1@@ -25,7 +25,7 @@#include "hw/vfio/vfio-common.h" #include "exec/address-spaces.h" #include "exec/memory.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qemu/error-report.h" #include "qemu/range.h" hw/vfio/iommufd.c +1
-1@@ -25,7 +25,7 @@#include "qemu/cutils.h" #include "qemu/chardev_open.h" #include "pci.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" static int iommufd_cdev_map(const VFIOContainerBase *bcontainer, hwaddr iova,hw/vfio/migration.c +1
-1@@ -26,7 +26,7 @@#include "qapi/error.h" #include "qapi/qapi-events-vfio.h" #include "exec/ramlist.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "pci.h" #include "trace.h" hw/vfio/spapr.c +1
-1@@ -19,7 +19,7 @@#include "hw/vfio/vfio-common.h" #include "hw/hw.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qemu/error-report.h" #include "qapi/error.h" hw/virtio/virtio-mem.c +1
-1@@ -24,7 +24,7 @@#include "hw/virtio/virtio-mem.h" #include "qapi/error.h" #include "qapi/visitor.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "migration/misc.h" #include "hw/boards.h" migration/ram.c +1
-1@@ -48,7 +48,7 @@#include "qapi/qapi-commands-migration.h" #include "qapi/qmp/qerror.h" #include "trace.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "exec/target_page.h" #include "qemu/rcu_queue.h" plugins/api.c +1
-1@@ -49,7 +49,7 @@#ifndef CONFIG_USER_ONLY #include "qapi/error.h" #include "migration/blocker.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qemu/plugin-memory.h" #include "hw/boards.h" system/memory.c +1
-1@@ -26,7 +26,7 @@#include "trace.h" #include "exec/memory-internal.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "sysemu/kvm.h" #include "sysemu/runstate.h" system/physmem.c +1
-1@@ -66,7 +66,7 @@#include "sysemu/replay.h" #include "exec/memory-internal.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "qemu/pmem.h" target/arm/tcg/mte_helper.c +1
-1@@ -24,7 +24,7 @@#include "exec/exec-all.h" #include "exec/page-protection.h" #ifndef CONFIG_USER_ONLY -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #endif #include "exec/cpu_ldst.h" target/ppc/kvm.c +1
-1@@ -41,7 +41,7 @@#include "trace.h" #include "gdbstub/enums.h" #include "exec/memattrs.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "sysemu/hostmem.h" #include "qemu/cutils.h" target/s390x/kvm/kvm.c +0
-0
target/s390x/kvm/kvm.c line 47
Quoted 8 lines
target/s390x/kvm/kvm.c +1
-1@@ -41,7 +41,7 @@#include "sysemu/runstate.h" #include "sysemu/device_tree.h" #include "gdbstub/enums.h" -#include "exec/ram_addr.h" +#include "sysemu/ram_addr.h" #include "sysemu/physmem-target.h" #include "trace.h" #include "hw/s390x/s390-pci-inst.h"
Re: [PATCH 24/24] exec: Move 'ram_addr.h' header under sysemu/ namespace
In reply to Philippe Mathieu-DaudéQuoted 36 lines · Philippe Mathieu-Daudé
"
ram_addr.h" contains declarations specific to system emulation, move it under the sysemu/ directory to clarify the API namespace.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- MAINTAINERS | 2 +- include/exec/cpu-common.h | 2 +- include/exec/memory.h | 2 +- include/exec/translation-block.h | 2 +- include/sysemu/physmem-target.h | 2 +- include/{exec => sysemu}/ram_addr.h | 0 accel/kvm/kvm-all.c | 2 +- accel/tcg/cputlb.c | 2 +- accel/tcg/translate-all.c | 2 +- hw/ppc/spapr.c | 2 +- hw/ppc/spapr_caps.c | 2 +- hw/ppc/spapr_pci.c | 2 +- hw/remote/memory.c | 2 +- hw/remote/proxy-memory-listener.c | 2 +- hw/s390x/s390-stattrib-kvm.c | 2 +- hw/s390x/s390-stattrib.c | 2 +- hw/s390x/s390-virtio-ccw.c | 2 +- hw/vfio/common.c | 2 +- hw/vfio/container.c | 2 +- hw/vfio/iommufd.c | 2 +- hw/vfio/migration.c | 2 +- hw/vfio/spapr.c | 2 +- hw/virtio/virtio-mem.c | 2 +- migration/ram.c | 2 +- plugins/api.c | 2 +- system/memory.c | 2 +- system/physmem.c | 2 +- target/arm/tcg/mte_helper.c | 2 +- target/ppc/kvm.c | 2 +- target/s390x/kvm/kvm.c | 2 +- 30 files changed, 29 insertions(+), 29 deletions(-)
Quoted 1 line
rename
include/{exec=>sysemu}/ram_addr.h(100%)
r~