Message ID | 20250424094653.35932-12-philmd@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | include: Remove "exec/exec-all.h" | expand |
On 24/04/2025 10:46, Philippe Mathieu-Daudé wrote: > Restrict iotlb_to_section(), address_space_translate_for_iotlb() > and memory_region_section_get_iotlb() to TCG. Declare them in > the new "accel/tcg/iommu.h" header. Declare iotlb_to_section() > using the MemoryRegionSection typedef. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > MAINTAINERS | 2 +- > include/accel/tcg/iommu.h | 41 +++++++++++++++++++++++++++++++++++++++ > include/exec/exec-all.h | 26 ------------------------- > accel/tcg/cputlb.c | 1 + > system/physmem.c | 5 +++++ > 5 files changed, 48 insertions(+), 27 deletions(-) > create mode 100644 include/accel/tcg/iommu.h > > diff --git a/MAINTAINERS b/MAINTAINERS > index 661a47db5ac..3a37cc73af7 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -168,7 +168,7 @@ F: include/exec/helper*.h.inc > F: include/exec/helper-info.c.inc > F: include/exec/page-protection.h > F: include/system/tcg.h > -F: include/accel/tcg/cpu-ops.h > +F: include/accel/tcg/ > F: host/include/*/host/cpuinfo.h > F: util/cpuinfo-*.c > F: include/tcg/ > diff --git a/include/accel/tcg/iommu.h b/include/accel/tcg/iommu.h > new file mode 100644 > index 00000000000..90cfd6c0ed1 > --- /dev/null > +++ b/include/accel/tcg/iommu.h > @@ -0,0 +1,41 @@ > +/* > + * TCG IOMMU translations. > + * > + * Copyright (c) 2003 Fabrice Bellard > + * SPDX-License-Identifier: LGPL-2.1-or-later > + */ > +#ifndef ACCEL_TCG_IOMMU_H > +#define ACCEL_TCG_IOMMU_H > + > +#ifdef CONFIG_USER_ONLY > +#error Cannot include accel/tcg/iommu.h from user emulation > +#endif > + > +#include "exec/hwaddr.h" > +#include "exec/memattrs.h" > + > +/** > + * iotlb_to_section: > + * @cpu: CPU performing the access > + * @index: TCG CPU IOTLB entry > + * > + * Given a TCG CPU IOTLB entry, return the MemoryRegionSection that > + * it refers to. @index will have been initially created and returned > + * by memory_region_section_get_iotlb(). > + */ > +MemoryRegionSection *iotlb_to_section(CPUState *cpu, > + hwaddr index, MemTxAttrs attrs); > + > +MemoryRegionSection *address_space_translate_for_iotlb(CPUState *cpu, > + int asidx, > + hwaddr addr, > + hwaddr *xlat, > + hwaddr *plen, > + MemTxAttrs attrs, > + int *prot); > + > +hwaddr memory_region_section_get_iotlb(CPUState *cpu, > + MemoryRegionSection *section); > + > +#endif > + > diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h > index 816274bf905..b9eb9bc4b63 100644 > --- a/include/exec/exec-all.h > +++ b/include/exec/exec-all.h > @@ -21,7 +21,6 @@ > #define EXEC_ALL_H > > #include "exec/hwaddr.h" > -#include "exec/memattrs.h" > #include "exec/mmu-access-type.h" > #include "exec/vaddr.h" > > @@ -121,29 +120,4 @@ int probe_access_full_mmu(CPUArchState *env, vaddr addr, int size, > #endif /* !CONFIG_USER_ONLY */ > #endif /* CONFIG_TCG */ > > -#if !defined(CONFIG_USER_ONLY) > - > -/** > - * iotlb_to_section: > - * @cpu: CPU performing the access > - * @index: TCG CPU IOTLB entry > - * > - * Given a TCG CPU IOTLB entry, return the MemoryRegionSection that > - * it refers to. @index will have been initially created and returned > - * by memory_region_section_get_iotlb(). > - */ > -struct MemoryRegionSection *iotlb_to_section(CPUState *cpu, > - hwaddr index, MemTxAttrs attrs); > -#endif > - > -#if !defined(CONFIG_USER_ONLY) > - > -MemoryRegionSection * > -address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr, > - hwaddr *xlat, hwaddr *plen, > - MemTxAttrs attrs, int *prot); > -hwaddr memory_region_section_get_iotlb(CPUState *cpu, > - MemoryRegionSection *section); > -#endif > - > #endif > diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c > index ca69128232c..d11989f5674 100644 > --- a/accel/tcg/cputlb.c > +++ b/accel/tcg/cputlb.c > @@ -20,6 +20,7 @@ > #include "qemu/osdep.h" > #include "qemu/main-loop.h" > #include "accel/tcg/cpu-ops.h" > +#include "accel/tcg/iommu.h" > #include "exec/exec-all.h" > #include "exec/page-protection.h" > #include "system/memory.h" > diff --git a/system/physmem.c b/system/physmem.c > index ccbeae241c4..f1ec0902c78 100644 > --- a/system/physmem.c > +++ b/system/physmem.c > @@ -29,6 +29,7 @@ > > #ifdef CONFIG_TCG > #include "accel/tcg/cpu-ops.h" > +#include "accel/tcg/iommu.h" > #endif /* CONFIG_TCG */ > > #include "exec/exec-all.h" > @@ -587,6 +588,8 @@ MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat, > return mr; > } > > +#ifdef CONFIG_TCG > + > typedef struct TCGIOMMUNotifier { > IOMMUNotifier n; > MemoryRegion *mr; > @@ -771,6 +774,8 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, > return section - d->map.sections; > } > > +#endif /* CONFIG_TCG */ > + > void cpu_address_space_init(CPUState *cpu, int asidx, > const char *prefix, MemoryRegion *mr) > { Following on from my comment on the previous patch, it looks like this is still IOTLB as opposed to IOMMU? ATB, Mark.
diff --git a/MAINTAINERS b/MAINTAINERS index 661a47db5ac..3a37cc73af7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -168,7 +168,7 @@ F: include/exec/helper*.h.inc F: include/exec/helper-info.c.inc F: include/exec/page-protection.h F: include/system/tcg.h -F: include/accel/tcg/cpu-ops.h +F: include/accel/tcg/ F: host/include/*/host/cpuinfo.h F: util/cpuinfo-*.c F: include/tcg/ diff --git a/include/accel/tcg/iommu.h b/include/accel/tcg/iommu.h new file mode 100644 index 00000000000..90cfd6c0ed1 --- /dev/null +++ b/include/accel/tcg/iommu.h @@ -0,0 +1,41 @@ +/* + * TCG IOMMU translations. + * + * Copyright (c) 2003 Fabrice Bellard + * SPDX-License-Identifier: LGPL-2.1-or-later + */ +#ifndef ACCEL_TCG_IOMMU_H +#define ACCEL_TCG_IOMMU_H + +#ifdef CONFIG_USER_ONLY +#error Cannot include accel/tcg/iommu.h from user emulation +#endif + +#include "exec/hwaddr.h" +#include "exec/memattrs.h" + +/** + * iotlb_to_section: + * @cpu: CPU performing the access + * @index: TCG CPU IOTLB entry + * + * Given a TCG CPU IOTLB entry, return the MemoryRegionSection that + * it refers to. @index will have been initially created and returned + * by memory_region_section_get_iotlb(). + */ +MemoryRegionSection *iotlb_to_section(CPUState *cpu, + hwaddr index, MemTxAttrs attrs); + +MemoryRegionSection *address_space_translate_for_iotlb(CPUState *cpu, + int asidx, + hwaddr addr, + hwaddr *xlat, + hwaddr *plen, + MemTxAttrs attrs, + int *prot); + +hwaddr memory_region_section_get_iotlb(CPUState *cpu, + MemoryRegionSection *section); + +#endif + diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 816274bf905..b9eb9bc4b63 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -21,7 +21,6 @@ #define EXEC_ALL_H #include "exec/hwaddr.h" -#include "exec/memattrs.h" #include "exec/mmu-access-type.h" #include "exec/vaddr.h" @@ -121,29 +120,4 @@ int probe_access_full_mmu(CPUArchState *env, vaddr addr, int size, #endif /* !CONFIG_USER_ONLY */ #endif /* CONFIG_TCG */ -#if !defined(CONFIG_USER_ONLY) - -/** - * iotlb_to_section: - * @cpu: CPU performing the access - * @index: TCG CPU IOTLB entry - * - * Given a TCG CPU IOTLB entry, return the MemoryRegionSection that - * it refers to. @index will have been initially created and returned - * by memory_region_section_get_iotlb(). - */ -struct MemoryRegionSection *iotlb_to_section(CPUState *cpu, - hwaddr index, MemTxAttrs attrs); -#endif - -#if !defined(CONFIG_USER_ONLY) - -MemoryRegionSection * -address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr, - hwaddr *xlat, hwaddr *plen, - MemTxAttrs attrs, int *prot); -hwaddr memory_region_section_get_iotlb(CPUState *cpu, - MemoryRegionSection *section); -#endif - #endif diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index ca69128232c..d11989f5674 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qemu/main-loop.h" #include "accel/tcg/cpu-ops.h" +#include "accel/tcg/iommu.h" #include "exec/exec-all.h" #include "exec/page-protection.h" #include "system/memory.h" diff --git a/system/physmem.c b/system/physmem.c index ccbeae241c4..f1ec0902c78 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -29,6 +29,7 @@ #ifdef CONFIG_TCG #include "accel/tcg/cpu-ops.h" +#include "accel/tcg/iommu.h" #endif /* CONFIG_TCG */ #include "exec/exec-all.h" @@ -587,6 +588,8 @@ MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat, return mr; } +#ifdef CONFIG_TCG + typedef struct TCGIOMMUNotifier { IOMMUNotifier n; MemoryRegion *mr; @@ -771,6 +774,8 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, return section - d->map.sections; } +#endif /* CONFIG_TCG */ + void cpu_address_space_init(CPUState *cpu, int asidx, const char *prefix, MemoryRegion *mr) {
Restrict iotlb_to_section(), address_space_translate_for_iotlb() and memory_region_section_get_iotlb() to TCG. Declare them in the new "accel/tcg/iommu.h" header. Declare iotlb_to_section() using the MemoryRegionSection typedef. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- MAINTAINERS | 2 +- include/accel/tcg/iommu.h | 41 +++++++++++++++++++++++++++++++++++++++ include/exec/exec-all.h | 26 ------------------------- accel/tcg/cputlb.c | 1 + system/physmem.c | 5 +++++ 5 files changed, 48 insertions(+), 27 deletions(-) create mode 100644 include/accel/tcg/iommu.h