1
target-arm queue. This has the "plumb txattrs through various
1
Hi; here's the latest batch of arm changes. The big thing
2
bits of exec.c" patches, and a collection of bug fixes from
2
in here is the SMMUv3 changes to add stage-2 translation support.
3
various people.
4
3
5
thanks
4
thanks
6
-- PMM
5
-- PMM
7
6
7
The following changes since commit aa9bbd865502ed517624ab6fe7d4b5d89ca95e43:
8
8
9
9
Merge tag 'pull-ppc-20230528' of https://gitlab.com/danielhb/qemu into staging (2023-05-29 14:31:52 -0700)
10
The following changes since commit a3ac12fba028df90f7b3dbec924995c126c41022:
11
12
Merge remote-tracking branch 'remotes/ehabkost/tags/numa-next-pull-request' into staging (2018-05-31 11:12:36 +0100)
13
10
14
are available in the Git repository at:
11
are available in the Git repository at:
15
12
16
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180531
13
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230530
17
14
18
for you to fetch changes up to 49d1dca0520ea71bc21867fab6647f474fcf857b:
15
for you to fetch changes up to b03d0d4f531a8b867e0aac1fab0b876903015680:
19
16
20
KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice (2018-05-31 14:52:53 +0100)
17
docs: sbsa: correct graphics card name (2023-05-30 13:32:46 +0100)
21
18
22
----------------------------------------------------------------
19
----------------------------------------------------------------
23
target-arm queue:
20
target-arm queue:
24
* target/arm: Honour FPCR.FZ in FRECPX
21
* fsl-imx6: Add SNVS support for i.MX6 boards
25
* MAINTAINERS: Add entries for newer MPS2 boards and devices
22
* smmuv3: Add support for stage 2 translations
26
* hw/intc/arm_gicv3: Fix APxR<n> register dispatching
23
* hw/dma/xilinx_axidma: Check DMASR.HALTED to prevent infinite loop
27
* arm_gicv3_kvm: fix bug in writing zero bits back to the in-kernel
24
* hw/arm/xlnx-zynqmp: fix unsigned error when checking the RPUs number
28
GIC state
25
* cleanups for recent Kconfig changes
29
* tcg: Fix helper function vs host abi for float16
26
* target/arm: Explicitly select short-format FSR for M-profile
30
* arm: fix qemu crash on startup with -bios option
27
* tests/qtest: Run arm-specific tests only if the required machine is available
31
* arm: fix malloc type mismatch
28
* hw/arm/sbsa-ref: add GIC node into DT
32
* xlnx-zdma: Correct mem leaks and memset to zero on desc unaligned errors
29
* docs: sbsa: correct graphics card name
33
* Correct CPACR reset value for v7 cores
30
* Update copyright dates to 2023
34
* memory.h: Improve IOMMU related documentation
35
* exec: Plumb transaction attributes through various functions in
36
preparation for allowing IOMMUs to see them
37
* vmstate.h: Provide VMSTATE_BOOL_SUB_ARRAY
38
* ARM: ACPI: Fix use-after-free due to memory realloc
39
* KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice
40
31
41
----------------------------------------------------------------
32
----------------------------------------------------------------
42
Francisco Iglesias (1):
33
Clément Chigot (1):
43
xlnx-zdma: Correct mem leaks and memset to zero on desc unaligned errors
34
hw/arm/xlnx-zynqmp: fix unsigned error when checking the RPUs number
44
35
45
Igor Mammedov (1):
36
Enze Li (1):
46
arm: fix qemu crash on startup with -bios option
37
Update copyright dates to 2023
47
38
48
Jan Kiszka (1):
39
Fabiano Rosas (3):
49
hw/intc/arm_gicv3: Fix APxR<n> register dispatching
40
target/arm: Explain why we need to select ARM_V7M
41
arm/Kconfig: Keep Kconfig default entries in default.mak as documentation
42
arm/Kconfig: Make TCG dependence explicit
50
43
51
Paolo Bonzini (1):
44
Marcin Juszkiewicz (2):
52
arm: fix malloc type mismatch
45
hw/arm/sbsa-ref: add GIC node into DT
46
docs: sbsa: correct graphics card name
53
47
54
Peter Maydell (17):
48
Mostafa Saleh (10):
55
target/arm: Honour FPCR.FZ in FRECPX
49
hw/arm/smmuv3: Add missing fields for IDR0
56
MAINTAINERS: Add entries for newer MPS2 boards and devices
50
hw/arm/smmuv3: Update translation config to hold stage-2
57
Correct CPACR reset value for v7 cores
51
hw/arm/smmuv3: Refactor stage-1 PTW
58
memory.h: Improve IOMMU related documentation
52
hw/arm/smmuv3: Add page table walk for stage-2
59
Make tb_invalidate_phys_addr() take a MemTxAttrs argument
53
hw/arm/smmuv3: Parse STE config for stage-2
60
Make address_space_translate{, _cached}() take a MemTxAttrs argument
54
hw/arm/smmuv3: Make TLB lookup work for stage-2
61
Make address_space_map() take a MemTxAttrs argument
55
hw/arm/smmuv3: Add VMID to TLB tagging
62
Make address_space_access_valid() take a MemTxAttrs argument
56
hw/arm/smmuv3: Add CMDs related to stage-2
63
Make flatview_extend_translation() take a MemTxAttrs argument
57
hw/arm/smmuv3: Add stage-2 support in iova notifier
64
Make memory_region_access_valid() take a MemTxAttrs argument
58
hw/arm/smmuv3: Add knob to choose translation stage and enable stage-2
65
Make MemoryRegion valid.accepts callback take a MemTxAttrs argument
66
Make flatview_access_valid() take a MemTxAttrs argument
67
Make flatview_translate() take a MemTxAttrs argument
68
Make address_space_get_iotlb_entry() take a MemTxAttrs argument
69
Make flatview_do_translate() take a MemTxAttrs argument
70
Make address_space_translate_iommu take a MemTxAttrs argument
71
vmstate.h: Provide VMSTATE_BOOL_SUB_ARRAY
72
59
73
Richard Henderson (1):
60
Peter Maydell (1):
74
tcg: Fix helper function vs host abi for float16
61
target/arm: Explicitly select short-format FSR for M-profile
75
62
76
Shannon Zhao (3):
63
Thomas Huth (1):
77
arm_gicv3_kvm: increase clroffset accordingly
64
tests/qtest: Run arm-specific tests only if the required machine is available
78
ARM: ACPI: Fix use-after-free due to memory realloc
79
KVM: GIC: Fix memory leak due to calling kvm_init_irq_routing twice
80
65
81
include/exec/exec-all.h | 5 +-
66
Tommy Wu (1):
82
include/exec/helper-head.h | 2 +-
67
hw/dma/xilinx_axidma: Check DMASR.HALTED to prevent infinite loop.
83
include/exec/memory-internal.h | 3 +-
84
include/exec/memory.h | 128 +++++++++++++++++++++++++++++++++++------
85
include/migration/vmstate.h | 3 +
86
include/sysemu/dma.h | 6 +-
87
accel/tcg/translate-all.c | 4 +-
88
exec.c | 95 ++++++++++++++++++------------
89
hw/arm/boot.c | 18 +++---
90
hw/arm/virt-acpi-build.c | 20 +++++--
91
hw/dma/xlnx-zdma.c | 10 +++-
92
hw/hppa/dino.c | 3 +-
93
hw/intc/arm_gic_kvm.c | 1 -
94
hw/intc/arm_gicv3_cpuif.c | 12 ++--
95
hw/intc/arm_gicv3_kvm.c | 2 +-
96
hw/nvram/fw_cfg.c | 12 ++--
97
hw/s390x/s390-pci-inst.c | 3 +-
98
hw/scsi/esp.c | 3 +-
99
hw/vfio/common.c | 3 +-
100
hw/virtio/vhost.c | 3 +-
101
hw/xen/xen_pt_msi.c | 3 +-
102
memory.c | 12 ++--
103
memory_ldst.inc.c | 18 +++---
104
target/arm/gdbstub.c | 3 +-
105
target/arm/helper-a64.c | 41 +++++++------
106
target/arm/helper.c | 90 ++++++++++++++++-------------
107
target/ppc/mmu-hash64.c | 3 +-
108
target/riscv/helper.c | 2 +-
109
target/s390x/diag.c | 6 +-
110
target/s390x/excp_helper.c | 3 +-
111
target/s390x/mmu_helper.c | 3 +-
112
target/s390x/sigp.c | 3 +-
113
target/xtensa/op_helper.c | 3 +-
114
MAINTAINERS | 9 ++-
115
34 files changed, 353 insertions(+), 182 deletions(-)
116
68
69
Vitaly Cheptsov (1):
70
fsl-imx6: Add SNVS support for i.MX6 boards
71
72
docs/conf.py | 2 +-
73
docs/system/arm/sbsa.rst | 2 +-
74
configs/devices/aarch64-softmmu/default.mak | 6 +
75
configs/devices/arm-softmmu/default.mak | 40 ++++
76
hw/arm/smmu-internal.h | 37 +++
77
hw/arm/smmuv3-internal.h | 12 +-
78
include/hw/arm/fsl-imx6.h | 2 +
79
include/hw/arm/smmu-common.h | 45 +++-
80
include/hw/arm/smmuv3.h | 4 +
81
include/qemu/help-texts.h | 2 +-
82
hw/arm/fsl-imx6.c | 8 +
83
hw/arm/sbsa-ref.c | 19 +-
84
hw/arm/smmu-common.c | 209 ++++++++++++++--
85
hw/arm/smmuv3.c | 357 ++++++++++++++++++++++++----
86
hw/arm/xlnx-zynqmp.c | 2 +-
87
hw/dma/xilinx_axidma.c | 11 +-
88
target/arm/tcg/tlb_helper.c | 13 +-
89
hw/arm/Kconfig | 123 ++++++----
90
hw/arm/trace-events | 14 +-
91
target/arm/Kconfig | 3 +
92
tests/qtest/meson.build | 7 +-
93
21 files changed, 773 insertions(+), 145 deletions(-)
94
diff view generated by jsdifflib
Deleted patch
1
The FRECPX instructions should (like most other floating point operations)
2
honour the FPCR.FZ bit which specifies whether input denormals should
3
be flushed to zero (or FZ16 for the half-precision version).
4
We forgot to implement this, which doesn't affect the results (since
5
the calculation doesn't actually care about the mantissa bits) but did
6
mean we were failing to set the FPSR.IDC bit.
7
1
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20180521172712.19930-1-peter.maydell@linaro.org
11
---
12
target/arm/helper-a64.c | 6 ++++++
13
1 file changed, 6 insertions(+)
14
15
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper-a64.c
18
+++ b/target/arm/helper-a64.c
19
@@ -XXX,XX +XXX,XX @@ float16 HELPER(frecpx_f16)(float16 a, void *fpstp)
20
return nan;
21
}
22
23
+ a = float16_squash_input_denormal(a, fpst);
24
+
25
val16 = float16_val(a);
26
sbit = 0x8000 & val16;
27
exp = extract32(val16, 10, 5);
28
@@ -XXX,XX +XXX,XX @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp)
29
return nan;
30
}
31
32
+ a = float32_squash_input_denormal(a, fpst);
33
+
34
val32 = float32_val(a);
35
sbit = 0x80000000ULL & val32;
36
exp = extract32(val32, 23, 8);
37
@@ -XXX,XX +XXX,XX @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp)
38
return nan;
39
}
40
41
+ a = float64_squash_input_denormal(a, fpst);
42
+
43
val64 = float64_val(a);
44
sbit = 0x8000000000000000ULL & val64;
45
exp = extract64(float64_val(a), 52, 11);
46
--
47
2.17.1
48
49
diff view generated by jsdifflib
Deleted patch
1
Add entries to MAINTAINERS to cover the newer MPS2 boards and
2
the new devices they use.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20180518153157.14899-1-peter.maydell@linaro.org
6
---
7
MAINTAINERS | 9 +++++++--
8
1 file changed, 7 insertions(+), 2 deletions(-)
9
10
diff --git a/MAINTAINERS b/MAINTAINERS
11
index XXXXXXX..XXXXXXX 100644
12
--- a/MAINTAINERS
13
+++ b/MAINTAINERS
14
@@ -XXX,XX +XXX,XX @@ F: hw/timer/cmsdk-apb-timer.c
15
F: include/hw/timer/cmsdk-apb-timer.h
16
F: hw/char/cmsdk-apb-uart.c
17
F: include/hw/char/cmsdk-apb-uart.h
18
+F: hw/misc/tz-ppc.c
19
+F: include/hw/misc/tz-ppc.h
20
21
ARM cores
22
M: Peter Maydell <peter.maydell@linaro.org>
23
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
24
L: qemu-arm@nongnu.org
25
S: Maintained
26
F: hw/arm/mps2.c
27
-F: hw/misc/mps2-scc.c
28
-F: include/hw/misc/mps2-scc.h
29
+F: hw/arm/mps2-tz.c
30
+F: hw/misc/mps2-*.c
31
+F: include/hw/misc/mps2-*.h
32
+F: hw/arm/iotkit.c
33
+F: include/hw/arm/iotkit.h
34
35
Musicpal
36
M: Jan Kiszka <jan.kiszka@web.de>
37
--
38
2.17.1
39
40
diff view generated by jsdifflib
1
From: Shannon Zhao <zhaoshenglong@huawei.com>
1
From: Vitaly Cheptsov <cheptsov@ispras.ru>
2
2
3
It forgot to increase clroffset during the loop. So it only clear the
3
SNVS is supported on both i.MX6 and i.MX6UL and is needed
4
first 4 bytes.
4
to support shutdown on the board.
5
5
6
Fixes: 367b9f527becdd20ddf116e17a3c0c2bbc486920
6
Cc: Peter Maydell <peter.maydell@linaro.org> (odd fixer:SABRELITE / i.MX6)
7
Cc: qemu-stable@nongnu.org
7
Cc: Jean-Christophe Dubois <jcd@tribudubois.net> (reviewer:SABRELITE / i.MX6)
8
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
8
Cc: qemu-arm@nongnu.org (open list:SABRELITE / i.MX6)
9
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Cc: qemu-devel@nongnu.org (open list:All patches CC here)
10
Message-id: 1527047633-12368-1-git-send-email-zhaoshenglong@huawei.com
10
Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru>
11
Message-id: 20230515095015.66860-1-cheptsov@ispras.ru
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
---
14
hw/intc/arm_gicv3_kvm.c | 1 +
15
include/hw/arm/fsl-imx6.h | 2 ++
15
1 file changed, 1 insertion(+)
16
hw/arm/fsl-imx6.c | 8 ++++++++
17
2 files changed, 10 insertions(+)
16
18
17
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
19
diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h
18
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/intc/arm_gicv3_kvm.c
21
--- a/include/hw/arm/fsl-imx6.h
20
+++ b/hw/intc/arm_gicv3_kvm.c
22
+++ b/include/hw/arm/fsl-imx6.h
21
@@ -XXX,XX +XXX,XX @@ static void kvm_dist_putbmp(GICv3State *s, uint32_t offset,
23
@@ -XXX,XX +XXX,XX @@
22
if (clroffset != 0) {
24
#include "hw/cpu/a9mpcore.h"
23
reg = 0;
25
#include "hw/misc/imx6_ccm.h"
24
kvm_gicd_access(s, clroffset, &reg, true);
26
#include "hw/misc/imx6_src.h"
25
+ clroffset += 4;
27
+#include "hw/misc/imx7_snvs.h"
26
}
28
#include "hw/watchdog/wdt_imx2.h"
27
reg = *gic_bmp_ptr32(bmp, irq);
29
#include "hw/char/imx_serial.h"
28
kvm_gicd_access(s, offset, &reg, true);
30
#include "hw/timer/imx_gpt.h"
31
@@ -XXX,XX +XXX,XX @@ struct FslIMX6State {
32
A9MPPrivState a9mpcore;
33
IMX6CCMState ccm;
34
IMX6SRCState src;
35
+ IMX7SNVSState snvs;
36
IMXSerialState uart[FSL_IMX6_NUM_UARTS];
37
IMXGPTState gpt;
38
IMXEPITState epit[FSL_IMX6_NUM_EPITS];
39
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/hw/arm/fsl-imx6.c
42
+++ b/hw/arm/fsl-imx6.c
43
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6_init(Object *obj)
44
45
object_initialize_child(obj, "src", &s->src, TYPE_IMX6_SRC);
46
47
+ object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS);
48
+
49
for (i = 0; i < FSL_IMX6_NUM_UARTS; i++) {
50
snprintf(name, NAME_SIZE, "uart%d", i + 1);
51
object_initialize_child(obj, name, &s->uart[i], TYPE_IMX_SERIAL);
52
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
53
qdev_get_gpio_in(DEVICE(&s->a9mpcore),
54
FSL_IMX6_ENET_MAC_1588_IRQ));
55
56
+ /*
57
+ * SNVS
58
+ */
59
+ sysbus_realize(SYS_BUS_DEVICE(&s->snvs), &error_abort);
60
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX6_SNVSHP_ADDR);
61
+
62
/*
63
* Watchdog
64
*/
29
--
65
--
30
2.17.1
66
2.34.1
31
32
diff view generated by jsdifflib
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
1
From: Mostafa Saleh <smostafa@google.com>
2
add MemTxAttrs as an argument to address_space_translate_iommu().
3
2
3
In preparation for adding stage-2 support.
4
Add IDR0 fields related to stage-2.
5
6
VMID16: 16-bit VMID supported.
7
S2P: Stage-2 translation supported.
8
9
They are described in 6.3.1 SMMU_IDR0.
10
11
No functional change intended.
12
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Eric Auger <eric.auger@redhat.com>
15
Signed-off-by: Mostafa Saleh <smostafa@google.com>
16
Tested-by: Eric Auger <eric.auger@redhat.com>
17
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
18
Message-id: 20230516203327.2051088-2-smostafa@google.com
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180521140402.23318-14-peter.maydell@linaro.org
8
---
20
---
9
exec.c | 8 +++++---
21
hw/arm/smmuv3-internal.h | 2 ++
10
1 file changed, 5 insertions(+), 3 deletions(-)
22
1 file changed, 2 insertions(+)
11
23
12
diff --git a/exec.c b/exec.c
24
diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h
13
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
14
--- a/exec.c
26
--- a/hw/arm/smmuv3-internal.h
15
+++ b/exec.c
27
+++ b/hw/arm/smmuv3-internal.h
16
@@ -XXX,XX +XXX,XX @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x
28
@@ -XXX,XX +XXX,XX @@ typedef enum SMMUTranslationStatus {
17
* @is_write: whether the translation operation is for write
29
/* MMIO Registers */
18
* @is_mmio: whether this can be MMIO, set true if it can
30
19
* @target_as: the address space targeted by the IOMMU
31
REG32(IDR0, 0x0)
20
+ * @attrs: transaction attributes
32
+ FIELD(IDR0, S2P, 0 , 1)
21
*
33
FIELD(IDR0, S1P, 1 , 1)
22
* This function is called from RCU critical section. It is the common
34
FIELD(IDR0, TTF, 2 , 2)
23
* part of flatview_do_translate and address_space_translate_cached.
35
FIELD(IDR0, COHACC, 4 , 1)
24
@@ -XXX,XX +XXX,XX @@ static MemoryRegionSection address_space_translate_iommu(IOMMUMemoryRegion *iomm
36
FIELD(IDR0, ASID16, 12, 1)
25
hwaddr *page_mask_out,
37
+ FIELD(IDR0, VMID16, 18, 1)
26
bool is_write,
38
FIELD(IDR0, TTENDIAN, 21, 2)
27
bool is_mmio,
39
FIELD(IDR0, STALL_MODEL, 24, 2)
28
- AddressSpace **target_as)
40
FIELD(IDR0, TERM_MODEL, 26, 1)
29
+ AddressSpace **target_as,
30
+ MemTxAttrs attrs)
31
{
32
MemoryRegionSection *section;
33
hwaddr page_mask = (hwaddr)-1;
34
@@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv,
35
return address_space_translate_iommu(iommu_mr, xlat,
36
plen_out, page_mask_out,
37
is_write, is_mmio,
38
- target_as);
39
+ target_as, attrs);
40
}
41
if (page_mask_out) {
42
/* Not behind an IOMMU, use default page size. */
43
@@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate_cached(
44
45
section = address_space_translate_iommu(iommu_mr, xlat, plen,
46
NULL, is_write, true,
47
- &target_as);
48
+ &target_as, attrs);
49
return section.mr;
50
}
51
52
--
41
--
53
2.17.1
42
2.34.1
54
55
diff view generated by jsdifflib
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
1
From: Mostafa Saleh <smostafa@google.com>
2
add MemTxAttrs as an argument to flatview_do_translate().
3
2
3
In preparation for adding stage-2 support, add a S2 config
4
struct(SMMUS2Cfg), composed of the following fields and embedded in
5
the main SMMUTransCfg:
6
-tsz: Size of IPA input region (S2T0SZ)
7
-sl0: Start level of translation (S2SL0)
8
-affd: AF Fault Disable (S2AFFD)
9
-record_faults: Record fault events (S2R)
10
-granule_sz: Granule page shift (based on S2TG)
11
-vmid: Virtual Machine ID (S2VMID)
12
-vttb: Address of translation table base (S2TTB)
13
-eff_ps: Effective PA output range (based on S2PS)
14
15
They will be used in the next patches in stage-2 address translation.
16
17
The fields in SMMUS2Cfg, are reordered to make the shared and stage-1
18
fields next to each other, this reordering didn't change the struct
19
size (104 bytes before and after).
20
21
Stage-1 only fields: aa64, asid, tt, ttb, tbi, record_faults, oas.
22
oas is stage-1 output address size. However, it is used to check
23
input address in case stage-1 is unimplemented or bypassed according
24
to SMMUv3 manual IHI0070.E "3.4. Address sizes"
25
26
Shared fields: stage, disabled, bypassed, aborted, iotlb_*.
27
28
No functional change intended.
29
30
Reviewed-by: Eric Auger <eric.auger@redhat.com>
31
Signed-off-by: Mostafa Saleh <smostafa@google.com>
32
Tested-by: Eric Auger <eric.auger@redhat.com>
33
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
34
Message-id: 20230516203327.2051088-3-smostafa@google.com
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
35
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180521140402.23318-13-peter.maydell@linaro.org
8
---
36
---
9
exec.c | 9 ++++++---
37
include/hw/arm/smmu-common.h | 22 +++++++++++++++++++---
10
1 file changed, 6 insertions(+), 3 deletions(-)
38
1 file changed, 19 insertions(+), 3 deletions(-)
11
39
12
diff --git a/exec.c b/exec.c
40
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
13
index XXXXXXX..XXXXXXX 100644
41
index XXXXXXX..XXXXXXX 100644
14
--- a/exec.c
42
--- a/include/hw/arm/smmu-common.h
15
+++ b/exec.c
43
+++ b/include/hw/arm/smmu-common.h
16
@@ -XXX,XX +XXX,XX @@ unassigned:
44
@@ -XXX,XX +XXX,XX @@ typedef struct SMMUTLBEntry {
17
* @is_write: whether the translation operation is for write
45
uint8_t granule;
18
* @is_mmio: whether this can be MMIO, set true if it can
46
} SMMUTLBEntry;
19
* @target_as: the address space targeted by the IOMMU
47
20
+ * @attrs: memory transaction attributes
48
+/* Stage-2 configuration. */
21
*
49
+typedef struct SMMUS2Cfg {
22
* This function is called from RCU critical section
50
+ uint8_t tsz; /* Size of IPA input region (S2T0SZ) */
51
+ uint8_t sl0; /* Start level of translation (S2SL0) */
52
+ bool affd; /* AF Fault Disable (S2AFFD) */
53
+ bool record_faults; /* Record fault events (S2R) */
54
+ uint8_t granule_sz; /* Granule page shift (based on S2TG) */
55
+ uint8_t eff_ps; /* Effective PA output range (based on S2PS) */
56
+ uint16_t vmid; /* Virtual Machine ID (S2VMID) */
57
+ uint64_t vttb; /* Address of translation table base (S2TTB) */
58
+} SMMUS2Cfg;
59
+
60
/*
61
* Generic structure populated by derived SMMU devices
62
* after decoding the configuration information and used as
63
* input to the page table walk
23
*/
64
*/
24
@@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv,
65
typedef struct SMMUTransCfg {
25
hwaddr *page_mask_out,
66
+ /* Shared fields between stage-1 and stage-2. */
26
bool is_write,
67
int stage; /* translation stage */
27
bool is_mmio,
68
- bool aa64; /* arch64 or aarch32 translation table */
28
- AddressSpace **target_as)
69
bool disabled; /* smmu is disabled */
29
+ AddressSpace **target_as,
70
bool bypassed; /* translation is bypassed */
30
+ MemTxAttrs attrs)
71
bool aborted; /* translation is aborted */
31
{
72
+ uint32_t iotlb_hits; /* counts IOTLB hits */
32
MemoryRegionSection *section;
73
+ uint32_t iotlb_misses; /* counts IOTLB misses*/
33
IOMMUMemoryRegion *iommu_mr;
74
+ /* Used by stage-1 only. */
34
@@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
75
+ bool aa64; /* arch64 or aarch32 translation table */
35
* but page mask.
76
bool record_faults; /* record fault events */
36
*/
77
uint64_t ttb; /* TT base address */
37
section = flatview_do_translate(address_space_to_flatview(as), addr, &xlat,
78
uint8_t oas; /* output address width */
38
- NULL, &page_mask, is_write, false, &as);
79
uint8_t tbi; /* Top Byte Ignore */
39
+ NULL, &page_mask, is_write, false, &as,
80
uint16_t asid;
40
+ attrs);
81
SMMUTransTableInfo tt[2];
41
82
- uint32_t iotlb_hits; /* counts IOTLB hits for this asid */
42
/* Illegal translation */
83
- uint32_t iotlb_misses; /* counts IOTLB misses for this asid */
43
if (section.mr == &io_mem_unassigned) {
84
+ /* Used by stage-2 only. */
44
@@ -XXX,XX +XXX,XX @@ MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat,
85
+ struct SMMUS2Cfg s2cfg;
45
86
} SMMUTransCfg;
46
/* This can be MMIO, so setup MMIO bit. */
87
47
section = flatview_do_translate(fv, addr, xlat, plen, NULL,
88
typedef struct SMMUDevice {
48
- is_write, true, &as);
49
+ is_write, true, &as, attrs);
50
mr = section.mr;
51
52
if (xen_enabled() && memory_access_is_direct(mr, is_write)) {
53
--
89
--
54
2.17.1
90
2.34.1
55
56
diff view generated by jsdifflib
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
1
From: Mostafa Saleh <smostafa@google.com>
2
add MemTxAttrs as an argument to the MemoryRegion valid.accepts
3
callback. We'll need this for subpage_accepts().
4
2
5
We could take the approach we used with the read and write
3
In preparation for adding stage-2 support, rename smmu_ptw_64 to
6
callbacks and add new a new _with_attrs version, but since there
4
smmu_ptw_64_s1 and refactor some of the code so it can be reused in
7
are so few implementations of the accepts hook we just change
5
stage-2 page table walk.
8
them all.
9
6
7
Remove AA64 check from PTW as decode_cd already ensures that AA64 is
8
used, otherwise it faults with C_BAD_CD.
9
10
A stage member is added to SMMUPTWEventInfo to differentiate
11
between stage-1 and stage-2 ptw faults.
12
13
Add stage argument to trace_smmu_ptw_level be consistent with other
14
trace events.
15
16
Signed-off-by: Mostafa Saleh <smostafa@google.com>
17
Reviewed-by: Eric Auger <eric.auger@redhat.com>
18
Tested-by: Eric Auger <eric.auger@redhat.com>
19
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
20
Message-id: 20230516203327.2051088-4-smostafa@google.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20180521140402.23318-9-peter.maydell@linaro.org
14
---
22
---
15
include/exec/memory.h | 3 ++-
23
include/hw/arm/smmu-common.h | 16 +++++++++++++---
16
exec.c | 9 ++++++---
24
hw/arm/smmu-common.c | 27 ++++++++++-----------------
17
hw/hppa/dino.c | 3 ++-
25
hw/arm/smmuv3.c | 2 ++
18
hw/nvram/fw_cfg.c | 12 ++++++++----
26
hw/arm/trace-events | 2 +-
19
hw/scsi/esp.c | 3 ++-
27
4 files changed, 26 insertions(+), 21 deletions(-)
20
hw/xen/xen_pt_msi.c | 3 ++-
21
memory.c | 5 +++--
22
7 files changed, 25 insertions(+), 13 deletions(-)
23
28
24
diff --git a/include/exec/memory.h b/include/exec/memory.h
29
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
25
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
26
--- a/include/exec/memory.h
31
--- a/include/hw/arm/smmu-common.h
27
+++ b/include/exec/memory.h
32
+++ b/include/hw/arm/smmu-common.h
28
@@ -XXX,XX +XXX,XX @@ struct MemoryRegionOps {
33
@@ -XXX,XX +XXX,XX @@
29
* as a machine check exception).
34
#include "hw/pci/pci.h"
30
*/
35
#include "qom/object.h"
31
bool (*accepts)(void *opaque, hwaddr addr,
36
32
- unsigned size, bool is_write);
37
-#define SMMU_PCI_BUS_MAX 256
33
+ unsigned size, bool is_write,
38
-#define SMMU_PCI_DEVFN_MAX 256
34
+ MemTxAttrs attrs);
39
-#define SMMU_PCI_DEVFN(sid) (sid & 0xFF)
35
} valid;
40
+#define SMMU_PCI_BUS_MAX 256
36
/* Internal implementation constraints: */
41
+#define SMMU_PCI_DEVFN_MAX 256
37
struct {
42
+#define SMMU_PCI_DEVFN(sid) (sid & 0xFF)
38
diff --git a/exec.c b/exec.c
43
+
44
+/* VMSAv8-64 Translation constants and functions */
45
+#define VMSA_LEVELS 4
46
+
47
+#define VMSA_STRIDE(gran) ((gran) - VMSA_LEVELS + 1)
48
+#define VMSA_BIT_LVL(isz, strd, lvl) ((isz) - (strd) * \
49
+ (VMSA_LEVELS - (lvl)))
50
+#define VMSA_IDXMSK(isz, strd, lvl) ((1ULL << \
51
+ VMSA_BIT_LVL(isz, strd, lvl)) - 1)
52
53
/*
54
* Page table walk error types
55
@@ -XXX,XX +XXX,XX @@ typedef enum {
56
} SMMUPTWEventType;
57
58
typedef struct SMMUPTWEventInfo {
59
+ int stage;
60
SMMUPTWEventType type;
61
dma_addr_t addr; /* fetched address that induced an abort, if any */
62
} SMMUPTWEventInfo;
63
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
39
index XXXXXXX..XXXXXXX 100644
64
index XXXXXXX..XXXXXXX 100644
40
--- a/exec.c
65
--- a/hw/arm/smmu-common.c
41
+++ b/exec.c
66
+++ b/hw/arm/smmu-common.c
42
@@ -XXX,XX +XXX,XX @@ static void notdirty_mem_write(void *opaque, hwaddr ram_addr,
67
@@ -XXX,XX +XXX,XX @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova)
43
}
68
}
44
69
45
static bool notdirty_mem_accepts(void *opaque, hwaddr addr,
70
/**
46
- unsigned size, bool is_write)
71
- * smmu_ptw_64 - VMSAv8-64 Walk of the page tables for a given IOVA
47
+ unsigned size, bool is_write,
72
+ * smmu_ptw_64_s1 - VMSAv8-64 Walk of the page tables for a given IOVA
48
+ MemTxAttrs attrs)
73
* @cfg: translation config
74
* @iova: iova to translate
75
* @perm: access type
76
@@ -XXX,XX +XXX,XX @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova)
77
* Upon success, @tlbe is filled with translated_addr and entry
78
* permission rights.
79
*/
80
-static int smmu_ptw_64(SMMUTransCfg *cfg,
81
- dma_addr_t iova, IOMMUAccessFlags perm,
82
- SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info)
83
+static int smmu_ptw_64_s1(SMMUTransCfg *cfg,
84
+ dma_addr_t iova, IOMMUAccessFlags perm,
85
+ SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info)
49
{
86
{
50
return is_write;
87
dma_addr_t baseaddr, indexmask;
88
int stage = cfg->stage;
89
@@ -XXX,XX +XXX,XX @@ static int smmu_ptw_64(SMMUTransCfg *cfg,
90
}
91
92
granule_sz = tt->granule_sz;
93
- stride = granule_sz - 3;
94
+ stride = VMSA_STRIDE(granule_sz);
95
inputsize = 64 - tt->tsz;
96
level = 4 - (inputsize - 4) / stride;
97
- indexmask = (1ULL << (inputsize - (stride * (4 - level)))) - 1;
98
+ indexmask = VMSA_IDXMSK(inputsize, stride, level);
99
baseaddr = extract64(tt->ttb, 0, 48);
100
baseaddr &= ~indexmask;
101
102
- while (level <= 3) {
103
+ while (level < VMSA_LEVELS) {
104
uint64_t subpage_size = 1ULL << level_shift(level, granule_sz);
105
uint64_t mask = subpage_size - 1;
106
uint32_t offset = iova_level_offset(iova, inputsize, level, granule_sz);
107
@@ -XXX,XX +XXX,XX @@ static int smmu_ptw_64(SMMUTransCfg *cfg,
108
if (get_pte(baseaddr, offset, &pte, info)) {
109
goto error;
110
}
111
- trace_smmu_ptw_level(level, iova, subpage_size,
112
+ trace_smmu_ptw_level(stage, level, iova, subpage_size,
113
baseaddr, offset, pte);
114
115
if (is_invalid_pte(pte) || is_reserved_pte(pte, level)) {
116
@@ -XXX,XX +XXX,XX @@ static int smmu_ptw_64(SMMUTransCfg *cfg,
117
info->type = SMMU_PTW_ERR_TRANSLATION;
118
119
error:
120
+ info->stage = 1;
121
tlbe->entry.perm = IOMMU_NONE;
122
return -EINVAL;
51
}
123
}
52
@@ -XXX,XX +XXX,XX @@ static MemTxResult subpage_write(void *opaque, hwaddr addr,
124
@@ -XXX,XX +XXX,XX @@ error:
125
int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm,
126
SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info)
127
{
128
- if (!cfg->aa64) {
129
- /*
130
- * This code path is not entered as we check this while decoding
131
- * the configuration data in the derived SMMU model.
132
- */
133
- g_assert_not_reached();
134
- }
135
-
136
- return smmu_ptw_64(cfg, iova, perm, tlbe, info);
137
+ return smmu_ptw_64_s1(cfg, iova, perm, tlbe, info);
53
}
138
}
54
139
55
static bool subpage_accepts(void *opaque, hwaddr addr,
140
/**
56
- unsigned len, bool is_write)
141
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
57
+ unsigned len, bool is_write,
58
+ MemTxAttrs attrs)
59
{
60
subpage_t *subpage = opaque;
61
#if defined(DEBUG_SUBPAGE)
62
@@ -XXX,XX +XXX,XX @@ static void readonly_mem_write(void *opaque, hwaddr addr,
63
}
64
65
static bool readonly_mem_accepts(void *opaque, hwaddr addr,
66
- unsigned size, bool is_write)
67
+ unsigned size, bool is_write,
68
+ MemTxAttrs attrs)
69
{
70
return is_write;
71
}
72
diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
73
index XXXXXXX..XXXXXXX 100644
142
index XXXXXXX..XXXXXXX 100644
74
--- a/hw/hppa/dino.c
143
--- a/hw/arm/smmuv3.c
75
+++ b/hw/hppa/dino.c
144
+++ b/hw/arm/smmuv3.c
76
@@ -XXX,XX +XXX,XX @@ static void gsc_to_pci_forwarding(DinoState *s)
145
@@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr,
77
}
146
cached_entry = g_new0(SMMUTLBEntry, 1);
78
147
79
static bool dino_chip_mem_valid(void *opaque, hwaddr addr,
148
if (smmu_ptw(cfg, aligned_addr, flag, cached_entry, &ptw_info)) {
80
- unsigned size, bool is_write)
149
+ /* All faults from PTW has S2 field. */
81
+ unsigned size, bool is_write,
150
+ event.u.f_walk_eabt.s2 = (ptw_info.stage == 2);
82
+ MemTxAttrs attrs)
151
g_free(cached_entry);
83
{
152
switch (ptw_info.type) {
84
switch (addr) {
153
case SMMU_PTW_ERR_WALK_EABT:
85
case DINO_IAR0:
154
diff --git a/hw/arm/trace-events b/hw/arm/trace-events
86
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
87
index XXXXXXX..XXXXXXX 100644
155
index XXXXXXX..XXXXXXX 100644
88
--- a/hw/nvram/fw_cfg.c
156
--- a/hw/arm/trace-events
89
+++ b/hw/nvram/fw_cfg.c
157
+++ b/hw/arm/trace-events
90
@@ -XXX,XX +XXX,XX @@ static void fw_cfg_dma_mem_write(void *opaque, hwaddr addr,
158
@@ -XXX,XX +XXX,XX @@ virt_acpi_setup(void) "No fw cfg or ACPI disabled. Bailing out."
91
}
159
92
160
# smmu-common.c
93
static bool fw_cfg_dma_mem_valid(void *opaque, hwaddr addr,
161
smmu_add_mr(const char *name) "%s"
94
- unsigned size, bool is_write)
162
-smmu_ptw_level(int level, uint64_t iova, size_t subpage_size, uint64_t baseaddr, uint32_t offset, uint64_t pte) "level=%d iova=0x%"PRIx64" subpage_sz=0x%zx baseaddr=0x%"PRIx64" offset=%d => pte=0x%"PRIx64
95
+ unsigned size, bool is_write,
163
+smmu_ptw_level(int stage, int level, uint64_t iova, size_t subpage_size, uint64_t baseaddr, uint32_t offset, uint64_t pte) "stage=%d level=%d iova=0x%"PRIx64" subpage_sz=0x%zx baseaddr=0x%"PRIx64" offset=%d => pte=0x%"PRIx64
96
+ MemTxAttrs attrs)
164
smmu_ptw_invalid_pte(int stage, int level, uint64_t baseaddr, uint64_t pteaddr, uint32_t offset, uint64_t pte) "stage=%d level=%d base@=0x%"PRIx64" pte@=0x%"PRIx64" offset=%d pte=0x%"PRIx64
97
{
165
smmu_ptw_page_pte(int stage, int level, uint64_t iova, uint64_t baseaddr, uint64_t pteaddr, uint64_t pte, uint64_t address) "stage=%d level=%d iova=0x%"PRIx64" base@=0x%"PRIx64" pte@=0x%"PRIx64" pte=0x%"PRIx64" page address = 0x%"PRIx64
98
return !is_write || ((size == 4 && (addr == 0 || addr == 4)) ||
166
smmu_ptw_block_pte(int stage, int level, uint64_t baseaddr, uint64_t pteaddr, uint64_t pte, uint64_t iova, uint64_t gpa, int bsize_mb) "stage=%d level=%d base@=0x%"PRIx64" pte@=0x%"PRIx64" pte=0x%"PRIx64" iova=0x%"PRIx64" block address = 0x%"PRIx64" block size = %d MiB"
99
(size == 8 && addr == 0));
100
}
101
102
static bool fw_cfg_data_mem_valid(void *opaque, hwaddr addr,
103
- unsigned size, bool is_write)
104
+ unsigned size, bool is_write,
105
+ MemTxAttrs attrs)
106
{
107
return addr == 0;
108
}
109
@@ -XXX,XX +XXX,XX @@ static void fw_cfg_ctl_mem_write(void *opaque, hwaddr addr,
110
}
111
112
static bool fw_cfg_ctl_mem_valid(void *opaque, hwaddr addr,
113
- unsigned size, bool is_write)
114
+ unsigned size, bool is_write,
115
+ MemTxAttrs attrs)
116
{
117
return is_write && size == 2;
118
}
119
@@ -XXX,XX +XXX,XX @@ static void fw_cfg_comb_write(void *opaque, hwaddr addr,
120
}
121
122
static bool fw_cfg_comb_valid(void *opaque, hwaddr addr,
123
- unsigned size, bool is_write)
124
+ unsigned size, bool is_write,
125
+ MemTxAttrs attrs)
126
{
127
return (size == 1) || (is_write && size == 2);
128
}
129
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
130
index XXXXXXX..XXXXXXX 100644
131
--- a/hw/scsi/esp.c
132
+++ b/hw/scsi/esp.c
133
@@ -XXX,XX +XXX,XX @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val)
134
}
135
136
static bool esp_mem_accepts(void *opaque, hwaddr addr,
137
- unsigned size, bool is_write)
138
+ unsigned size, bool is_write,
139
+ MemTxAttrs attrs)
140
{
141
return (size == 1) || (is_write && size == 4);
142
}
143
diff --git a/hw/xen/xen_pt_msi.c b/hw/xen/xen_pt_msi.c
144
index XXXXXXX..XXXXXXX 100644
145
--- a/hw/xen/xen_pt_msi.c
146
+++ b/hw/xen/xen_pt_msi.c
147
@@ -XXX,XX +XXX,XX @@ static uint64_t pci_msix_read(void *opaque, hwaddr addr,
148
}
149
150
static bool pci_msix_accepts(void *opaque, hwaddr addr,
151
- unsigned size, bool is_write)
152
+ unsigned size, bool is_write,
153
+ MemTxAttrs attrs)
154
{
155
return !(addr & (size - 1));
156
}
157
diff --git a/memory.c b/memory.c
158
index XXXXXXX..XXXXXXX 100644
159
--- a/memory.c
160
+++ b/memory.c
161
@@ -XXX,XX +XXX,XX @@ static void unassigned_mem_write(void *opaque, hwaddr addr,
162
}
163
164
static bool unassigned_mem_accepts(void *opaque, hwaddr addr,
165
- unsigned size, bool is_write)
166
+ unsigned size, bool is_write,
167
+ MemTxAttrs attrs)
168
{
169
return false;
170
}
171
@@ -XXX,XX +XXX,XX @@ bool memory_region_access_valid(MemoryRegion *mr,
172
access_size = MAX(MIN(size, access_size_max), access_size_min);
173
for (i = 0; i < size; i += access_size) {
174
if (!mr->ops->valid.accepts(mr->opaque, addr + i, access_size,
175
- is_write)) {
176
+ is_write, attrs)) {
177
return false;
178
}
179
}
180
--
167
--
181
2.17.1
168
2.34.1
182
183
diff view generated by jsdifflib
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
1
From: Mostafa Saleh <smostafa@google.com>
2
add MemTxAttrs as an argument to flatview_translate(); all its
2
3
callers now have attrs available.
3
In preparation for adding stage-2 support, add Stage-2 PTW code.
4
4
Only Aarch64 format is supported as stage-1.
5
6
Nesting stage-1 and stage-2 is not supported right now.
7
8
HTTU is not supported, SW is expected to maintain the Access flag.
9
This is described in the SMMUv3 manual(IHI 0070.E.a)
10
"5.2. Stream Table Entry" in "[181] S2AFFD".
11
This flag determines the behavior on access of a stage-2 page whose
12
descriptor has AF == 0:
13
- 0b0: An Access flag fault occurs (stall not supported).
14
- 0b1: An Access flag fault never occurs.
15
An Access fault takes priority over a Permission fault.
16
17
There are 3 address size checks for stage-2 according to
18
(IHI 0070.E.a) in "3.4. Address sizes".
19
- As nesting is not supported, input address is passed directly to
20
stage-2, and is checked against IAS.
21
We use cfg->oas to hold the OAS when stage-1 is not used, this is set
22
in the next patch.
23
This check is done outside of smmu_ptw_64_s2 as it is not part of
24
stage-2(it throws stage-1 fault), and the stage-2 function shouldn't
25
change it's behavior when nesting is supported.
26
When nesting is supported and we figure out how to combine TLB for
27
stage-1 and stage-2 we can move this check into the stage-1 function
28
as described in ARM DDI0487I.a in pseudocode
29
aarch64/translation/vmsa_translation/AArch64.S1Translate
30
aarch64/translation/vmsa_translation/AArch64.S1DisabledOutput
31
32
- Input to stage-2 is checked against s2t0sz, and throws stage-2
33
transaltion fault if exceeds it.
34
35
- Output of stage-2 is checked against effective PA output range.
36
37
Reviewed-by: Eric Auger <eric.auger@redhat.com>
38
Signed-off-by: Mostafa Saleh <smostafa@google.com>
39
Tested-by: Eric Auger <eric.auger@redhat.com>
40
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
41
Message-id: 20230516203327.2051088-5-smostafa@google.com
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
42
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180521140402.23318-11-peter.maydell@linaro.org
9
---
43
---
10
include/exec/memory.h | 7 ++++---
44
hw/arm/smmu-internal.h | 35 ++++++++++
11
exec.c | 17 +++++++++--------
45
hw/arm/smmu-common.c | 142 ++++++++++++++++++++++++++++++++++++++++-
12
2 files changed, 13 insertions(+), 11 deletions(-)
46
2 files changed, 176 insertions(+), 1 deletion(-)
13
47
14
diff --git a/include/exec/memory.h b/include/exec/memory.h
48
diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h
15
index XXXXXXX..XXXXXXX 100644
49
index XXXXXXX..XXXXXXX 100644
16
--- a/include/exec/memory.h
50
--- a/hw/arm/smmu-internal.h
17
+++ b/include/exec/memory.h
51
+++ b/hw/arm/smmu-internal.h
18
@@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
52
@@ -XXX,XX +XXX,XX @@
19
*/
53
#define PTE_APTABLE(pte) \
20
MemoryRegion *flatview_translate(FlatView *fv,
54
(extract64(pte, 61, 2))
21
hwaddr addr, hwaddr *xlat,
55
22
- hwaddr *len, bool is_write);
56
+#define PTE_AF(pte) \
23
+ hwaddr *len, bool is_write,
57
+ (extract64(pte, 10, 1))
24
+ MemTxAttrs attrs);
58
/*
25
59
* TODO: At the moment all transactions are considered as privileged (EL1)
26
static inline MemoryRegion *address_space_translate(AddressSpace *as,
60
* as IOMMU translation callback does not pass user/priv attributes.
27
hwaddr addr, hwaddr *xlat,
61
@@ -XXX,XX +XXX,XX @@
28
@@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate(AddressSpace *as,
62
#define is_permission_fault(ap, perm) \
29
MemTxAttrs attrs)
63
(((perm) & IOMMU_WO) && ((ap) & 0x2))
64
65
+#define is_permission_fault_s2(s2ap, perm) \
66
+ (!(((s2ap) & (perm)) == (perm)))
67
+
68
#define PTE_AP_TO_PERM(ap) \
69
(IOMMU_ACCESS_FLAG(true, !((ap) & 0x2)))
70
71
@@ -XXX,XX +XXX,XX @@ uint64_t iova_level_offset(uint64_t iova, int inputsize,
72
MAKE_64BIT_MASK(0, gsz - 3);
73
}
74
75
+/* FEAT_LPA2 and FEAT_TTST are not implemented. */
76
+static inline int get_start_level(int sl0 , int granule_sz)
77
+{
78
+ /* ARM DDI0487I.a: Table D8-12. */
79
+ if (granule_sz == 12) {
80
+ return 2 - sl0;
81
+ }
82
+ /* ARM DDI0487I.a: Table D8-22 and Table D8-31. */
83
+ return 3 - sl0;
84
+}
85
+
86
+/*
87
+ * Index in a concatenated first level stage-2 page table.
88
+ * ARM DDI0487I.a: D8.2.2 Concatenated translation tables.
89
+ */
90
+static inline int pgd_concat_idx(int start_level, int granule_sz,
91
+ dma_addr_t ipa)
92
+{
93
+ uint64_t ret;
94
+ /*
95
+ * Get the number of bits handled by next levels, then any extra bits in
96
+ * the address should index the concatenated tables. This relation can be
97
+ * deduced from tables in ARM DDI0487I.a: D8.2.7-9
98
+ */
99
+ int shift = level_shift(start_level - 1, granule_sz);
100
+
101
+ ret = ipa >> shift;
102
+ return ret;
103
+}
104
+
105
#define SMMU_IOTLB_ASID(key) ((key).asid)
106
107
typedef struct SMMUIOTLBPageInvInfo {
108
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
109
index XXXXXXX..XXXXXXX 100644
110
--- a/hw/arm/smmu-common.c
111
+++ b/hw/arm/smmu-common.c
112
@@ -XXX,XX +XXX,XX @@ error:
113
return -EINVAL;
114
}
115
116
+/**
117
+ * smmu_ptw_64_s2 - VMSAv8-64 Walk of the page tables for a given ipa
118
+ * for stage-2.
119
+ * @cfg: translation config
120
+ * @ipa: ipa to translate
121
+ * @perm: access type
122
+ * @tlbe: SMMUTLBEntry (out)
123
+ * @info: handle to an error info
124
+ *
125
+ * Return 0 on success, < 0 on error. In case of error, @info is filled
126
+ * and tlbe->perm is set to IOMMU_NONE.
127
+ * Upon success, @tlbe is filled with translated_addr and entry
128
+ * permission rights.
129
+ */
130
+static int smmu_ptw_64_s2(SMMUTransCfg *cfg,
131
+ dma_addr_t ipa, IOMMUAccessFlags perm,
132
+ SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info)
133
+{
134
+ const int stage = 2;
135
+ int granule_sz = cfg->s2cfg.granule_sz;
136
+ /* ARM DDI0487I.a: Table D8-7. */
137
+ int inputsize = 64 - cfg->s2cfg.tsz;
138
+ int level = get_start_level(cfg->s2cfg.sl0, granule_sz);
139
+ int stride = VMSA_STRIDE(granule_sz);
140
+ int idx = pgd_concat_idx(level, granule_sz, ipa);
141
+ /*
142
+ * Get the ttb from concatenated structure.
143
+ * The offset is the idx * size of each ttb(number of ptes * (sizeof(pte))
144
+ */
145
+ uint64_t baseaddr = extract64(cfg->s2cfg.vttb, 0, 48) + (1 << stride) *
146
+ idx * sizeof(uint64_t);
147
+ dma_addr_t indexmask = VMSA_IDXMSK(inputsize, stride, level);
148
+
149
+ baseaddr &= ~indexmask;
150
+
151
+ /*
152
+ * On input, a stage 2 Translation fault occurs if the IPA is outside the
153
+ * range configured by the relevant S2T0SZ field of the STE.
154
+ */
155
+ if (ipa >= (1ULL << inputsize)) {
156
+ info->type = SMMU_PTW_ERR_TRANSLATION;
157
+ goto error;
158
+ }
159
+
160
+ while (level < VMSA_LEVELS) {
161
+ uint64_t subpage_size = 1ULL << level_shift(level, granule_sz);
162
+ uint64_t mask = subpage_size - 1;
163
+ uint32_t offset = iova_level_offset(ipa, inputsize, level, granule_sz);
164
+ uint64_t pte, gpa;
165
+ dma_addr_t pte_addr = baseaddr + offset * sizeof(pte);
166
+ uint8_t s2ap;
167
+
168
+ if (get_pte(baseaddr, offset, &pte, info)) {
169
+ goto error;
170
+ }
171
+ trace_smmu_ptw_level(stage, level, ipa, subpage_size,
172
+ baseaddr, offset, pte);
173
+ if (is_invalid_pte(pte) || is_reserved_pte(pte, level)) {
174
+ trace_smmu_ptw_invalid_pte(stage, level, baseaddr,
175
+ pte_addr, offset, pte);
176
+ break;
177
+ }
178
+
179
+ if (is_table_pte(pte, level)) {
180
+ baseaddr = get_table_pte_address(pte, granule_sz);
181
+ level++;
182
+ continue;
183
+ } else if (is_page_pte(pte, level)) {
184
+ gpa = get_page_pte_address(pte, granule_sz);
185
+ trace_smmu_ptw_page_pte(stage, level, ipa,
186
+ baseaddr, pte_addr, pte, gpa);
187
+ } else {
188
+ uint64_t block_size;
189
+
190
+ gpa = get_block_pte_address(pte, level, granule_sz,
191
+ &block_size);
192
+ trace_smmu_ptw_block_pte(stage, level, baseaddr,
193
+ pte_addr, pte, ipa, gpa,
194
+ block_size >> 20);
195
+ }
196
+
197
+ /*
198
+ * If S2AFFD and PTE.AF are 0 => fault. (5.2. Stream Table Entry)
199
+ * An Access fault takes priority over a Permission fault.
200
+ */
201
+ if (!PTE_AF(pte) && !cfg->s2cfg.affd) {
202
+ info->type = SMMU_PTW_ERR_ACCESS;
203
+ goto error;
204
+ }
205
+
206
+ s2ap = PTE_AP(pte);
207
+ if (is_permission_fault_s2(s2ap, perm)) {
208
+ info->type = SMMU_PTW_ERR_PERMISSION;
209
+ goto error;
210
+ }
211
+
212
+ /*
213
+ * The address output from the translation causes a stage 2 Address
214
+ * Size fault if it exceeds the effective PA output range.
215
+ */
216
+ if (gpa >= (1ULL << cfg->s2cfg.eff_ps)) {
217
+ info->type = SMMU_PTW_ERR_ADDR_SIZE;
218
+ goto error;
219
+ }
220
+
221
+ tlbe->entry.translated_addr = gpa;
222
+ tlbe->entry.iova = ipa & ~mask;
223
+ tlbe->entry.addr_mask = mask;
224
+ tlbe->entry.perm = s2ap;
225
+ tlbe->level = level;
226
+ tlbe->granule = granule_sz;
227
+ return 0;
228
+ }
229
+ info->type = SMMU_PTW_ERR_TRANSLATION;
230
+
231
+error:
232
+ info->stage = 2;
233
+ tlbe->entry.perm = IOMMU_NONE;
234
+ return -EINVAL;
235
+}
236
+
237
/**
238
* smmu_ptw - Walk the page tables for an IOVA, according to @cfg
239
*
240
@@ -XXX,XX +XXX,XX @@ error:
241
int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm,
242
SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info)
30
{
243
{
31
return flatview_translate(address_space_to_flatview(as),
244
- return smmu_ptw_64_s1(cfg, iova, perm, tlbe, info);
32
- addr, xlat, len, is_write);
245
+ if (cfg->stage == 1) {
33
+ addr, xlat, len, is_write, attrs);
246
+ return smmu_ptw_64_s1(cfg, iova, perm, tlbe, info);
247
+ } else if (cfg->stage == 2) {
248
+ /*
249
+ * If bypassing stage 1(or unimplemented), the input address is passed
250
+ * directly to stage 2 as IPA. If the input address of a transaction
251
+ * exceeds the size of the IAS, a stage 1 Address Size fault occurs.
252
+ * For AA64, IAS = OAS according to (IHI 0070.E.a) "3.4 Address sizes"
253
+ */
254
+ if (iova >= (1ULL << cfg->oas)) {
255
+ info->type = SMMU_PTW_ERR_ADDR_SIZE;
256
+ info->stage = 1;
257
+ tlbe->entry.perm = IOMMU_NONE;
258
+ return -EINVAL;
259
+ }
260
+
261
+ return smmu_ptw_64_s2(cfg, iova, perm, tlbe, info);
262
+ }
263
+
264
+ g_assert_not_reached();
34
}
265
}
35
266
36
/* address_space_access_valid: check for validity of accessing an address
267
/**
37
@@ -XXX,XX +XXX,XX @@ MemTxResult address_space_read(AddressSpace *as, hwaddr addr,
38
rcu_read_lock();
39
fv = address_space_to_flatview(as);
40
l = len;
41
- mr = flatview_translate(fv, addr, &addr1, &l, false);
42
+ mr = flatview_translate(fv, addr, &addr1, &l, false, attrs);
43
if (len == l && memory_access_is_direct(mr, false)) {
44
ptr = qemu_map_ram_ptr(mr->ram_block, addr1);
45
memcpy(buf, ptr, len);
46
diff --git a/exec.c b/exec.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/exec.c
49
+++ b/exec.c
50
@@ -XXX,XX +XXX,XX @@ iotlb_fail:
51
52
/* Called from RCU critical section */
53
MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat,
54
- hwaddr *plen, bool is_write)
55
+ hwaddr *plen, bool is_write,
56
+ MemTxAttrs attrs)
57
{
58
MemoryRegion *mr;
59
MemoryRegionSection section;
60
@@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr,
61
}
62
63
l = len;
64
- mr = flatview_translate(fv, addr, &addr1, &l, true);
65
+ mr = flatview_translate(fv, addr, &addr1, &l, true, attrs);
66
}
67
68
return result;
69
@@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
70
MemTxResult result = MEMTX_OK;
71
72
l = len;
73
- mr = flatview_translate(fv, addr, &addr1, &l, true);
74
+ mr = flatview_translate(fv, addr, &addr1, &l, true, attrs);
75
result = flatview_write_continue(fv, addr, attrs, buf, len,
76
addr1, l, mr);
77
78
@@ -XXX,XX +XXX,XX @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr,
79
}
80
81
l = len;
82
- mr = flatview_translate(fv, addr, &addr1, &l, false);
83
+ mr = flatview_translate(fv, addr, &addr1, &l, false, attrs);
84
}
85
86
return result;
87
@@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr,
88
MemoryRegion *mr;
89
90
l = len;
91
- mr = flatview_translate(fv, addr, &addr1, &l, false);
92
+ mr = flatview_translate(fv, addr, &addr1, &l, false, attrs);
93
return flatview_read_continue(fv, addr, attrs, buf, len,
94
addr1, l, mr);
95
}
96
@@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
97
98
while (len > 0) {
99
l = len;
100
- mr = flatview_translate(fv, addr, &xlat, &l, is_write);
101
+ mr = flatview_translate(fv, addr, &xlat, &l, is_write, attrs);
102
if (!memory_access_is_direct(mr, is_write)) {
103
l = memory_access_size(mr, l, addr);
104
if (!memory_region_access_valid(mr, xlat, l, is_write, attrs)) {
105
@@ -XXX,XX +XXX,XX @@ flatview_extend_translation(FlatView *fv, hwaddr addr,
106
107
len = target_len;
108
this_mr = flatview_translate(fv, addr, &xlat,
109
- &len, is_write);
110
+ &len, is_write, attrs);
111
if (this_mr != mr || xlat != base + done) {
112
return done;
113
}
114
@@ -XXX,XX +XXX,XX @@ void *address_space_map(AddressSpace *as,
115
l = len;
116
rcu_read_lock();
117
fv = address_space_to_flatview(as);
118
- mr = flatview_translate(fv, addr, &xlat, &l, is_write);
119
+ mr = flatview_translate(fv, addr, &xlat, &l, is_write, attrs);
120
121
if (!memory_access_is_direct(mr, is_write)) {
122
if (atomic_xchg(&bounce.in_use, true)) {
123
--
268
--
124
2.17.1
269
2.34.1
125
126
diff view generated by jsdifflib
1
In commit f0aff255700 we made cpacr_write() enforce that some CPACR
1
From: Mostafa Saleh <smostafa@google.com>
2
bits are RAZ/WI and some are RAO/WI for ARMv7 cores. Unfortunately
2
3
we forgot to also update the register's reset value. The effect
3
Parse stage-2 configuration from STE and populate it in SMMUS2Cfg.
4
was that (a) a guest that read CPACR on reset would not see ones in
4
Validity of field values are checked when possible.
5
the RAO bits, and (b) if you did a migration before the guest did
5
6
a write to the CPACR then the migration would fail because the
6
Only AA64 tables are supported and Small Translation Tables (STT) are
7
destination would enforce the RAO bits and then complain that they
7
not supported.
8
didn't match the zero value from the source.
8
9
9
According to SMMUv3 UM(IHI0070E) "5.2 Stream Table Entry": All fields
10
Implement reset for the CPACR using a custom reset function
10
with an S2 prefix (with the exception of S2VMID) are IGNORED when
11
that just calls cpacr_write(), to avoid having to duplicate
11
stage-2 bypasses translation (Config[1] == 0).
12
the logic for which bits are RAO.
12
13
13
Which means that VMID can be used(for TLB tagging) even if stage-2 is
14
This bug would affect migration for TCG CPUs which are ARMv7
14
bypassed, so we parse it unconditionally when S2P exists. Otherwise
15
with VFP but without one of Neon or VFPv3.
15
it is set to -1.(only S1P)
16
16
17
Reported-by: Cédric Le Goater <clg@kaod.org>
17
As stall is not supported, if S2S is set the translation would abort.
18
For S2R, we reuse the same code used for stage-1 with flag
19
record_faults. However when nested translation is supported we would
20
need to separate stage-1 and stage-2 faults.
21
22
Fix wrong shift in STE_S2HD, STE_S2HA, STE_S2S.
23
24
Signed-off-by: Mostafa Saleh <smostafa@google.com>
25
Tested-by: Eric Auger <eric.auger@redhat.com>
26
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
27
Reviewed-by: Eric Auger <eric.auger@redhat.com>
28
Message-id: 20230516203327.2051088-6-smostafa@google.com
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
29
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Tested-by: Cédric Le Goater <clg@kaod.org>
20
Message-id: 20180522173713.26282-1-peter.maydell@linaro.org
21
---
30
---
22
target/arm/helper.c | 10 +++++++++-
31
hw/arm/smmuv3-internal.h | 10 +-
23
1 file changed, 9 insertions(+), 1 deletion(-)
32
include/hw/arm/smmu-common.h | 1 +
24
33
include/hw/arm/smmuv3.h | 3 +
25
diff --git a/target/arm/helper.c b/target/arm/helper.c
34
hw/arm/smmuv3.c | 181 +++++++++++++++++++++++++++++++++--
35
4 files changed, 185 insertions(+), 10 deletions(-)
36
37
diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h
26
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
27
--- a/target/arm/helper.c
39
--- a/hw/arm/smmuv3-internal.h
28
+++ b/target/arm/helper.c
40
+++ b/hw/arm/smmuv3-internal.h
29
@@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri,
41
@@ -XXX,XX +XXX,XX @@ typedef struct CD {
30
env->cp15.cpacr_el1 = value;
42
#define STE_S2TG(x) extract32((x)->word[5], 14, 2)
43
#define STE_S2PS(x) extract32((x)->word[5], 16, 3)
44
#define STE_S2AA64(x) extract32((x)->word[5], 19, 1)
45
-#define STE_S2HD(x) extract32((x)->word[5], 24, 1)
46
-#define STE_S2HA(x) extract32((x)->word[5], 25, 1)
47
-#define STE_S2S(x) extract32((x)->word[5], 26, 1)
48
+#define STE_S2ENDI(x) extract32((x)->word[5], 20, 1)
49
+#define STE_S2AFFD(x) extract32((x)->word[5], 21, 1)
50
+#define STE_S2HD(x) extract32((x)->word[5], 23, 1)
51
+#define STE_S2HA(x) extract32((x)->word[5], 24, 1)
52
+#define STE_S2S(x) extract32((x)->word[5], 25, 1)
53
+#define STE_S2R(x) extract32((x)->word[5], 26, 1)
54
+
55
#define STE_CTXPTR(x) \
56
({ \
57
unsigned long addr; \
58
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
59
index XXXXXXX..XXXXXXX 100644
60
--- a/include/hw/arm/smmu-common.h
61
+++ b/include/hw/arm/smmu-common.h
62
@@ -XXX,XX +XXX,XX @@
63
64
/* VMSAv8-64 Translation constants and functions */
65
#define VMSA_LEVELS 4
66
+#define VMSA_MAX_S2_CONCAT 16
67
68
#define VMSA_STRIDE(gran) ((gran) - VMSA_LEVELS + 1)
69
#define VMSA_BIT_LVL(isz, strd, lvl) ((isz) - (strd) * \
70
diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h
71
index XXXXXXX..XXXXXXX 100644
72
--- a/include/hw/arm/smmuv3.h
73
+++ b/include/hw/arm/smmuv3.h
74
@@ -XXX,XX +XXX,XX @@ struct SMMUv3Class {
75
#define TYPE_ARM_SMMUV3 "arm-smmuv3"
76
OBJECT_DECLARE_TYPE(SMMUv3State, SMMUv3Class, ARM_SMMUV3)
77
78
+#define STAGE1_SUPPORTED(s) FIELD_EX32(s->idr[0], IDR0, S1P)
79
+#define STAGE2_SUPPORTED(s) FIELD_EX32(s->idr[0], IDR0, S2P)
80
+
81
#endif
82
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
83
index XXXXXXX..XXXXXXX 100644
84
--- a/hw/arm/smmuv3.c
85
+++ b/hw/arm/smmuv3.c
86
@@ -XXX,XX +XXX,XX @@
87
#include "smmuv3-internal.h"
88
#include "smmu-internal.h"
89
90
+#define PTW_RECORD_FAULT(cfg) (((cfg)->stage == 1) ? (cfg)->record_faults : \
91
+ (cfg)->s2cfg.record_faults)
92
+
93
/**
94
* smmuv3_trigger_irq - pulse @irq if enabled and update
95
* GERROR register in case of GERROR interrupt
96
@@ -XXX,XX +XXX,XX @@ static int smmu_get_cd(SMMUv3State *s, STE *ste, uint32_t ssid,
97
return 0;
31
}
98
}
32
99
33
+static void cpacr_reset(CPUARMState *env, const ARMCPRegInfo *ri)
100
+/*
101
+ * Max valid value is 39 when SMMU_IDR3.STT == 0.
102
+ * In architectures after SMMUv3.0:
103
+ * - If STE.S2TG selects a 4KB or 16KB granule, the minimum valid value for this
104
+ * field is MAX(16, 64-IAS)
105
+ * - If STE.S2TG selects a 64KB granule, the minimum valid value for this field
106
+ * is (64-IAS).
107
+ * As we only support AA64, IAS = OAS.
108
+ */
109
+static bool s2t0sz_valid(SMMUTransCfg *cfg)
34
+{
110
+{
35
+ /* Call cpacr_write() so that we reset with the correct RAO bits set
111
+ if (cfg->s2cfg.tsz > 39) {
36
+ * for our CPU features.
112
+ return false;
113
+ }
114
+
115
+ if (cfg->s2cfg.granule_sz == 16) {
116
+ return (cfg->s2cfg.tsz >= 64 - oas2bits(SMMU_IDR5_OAS));
117
+ }
118
+
119
+ return (cfg->s2cfg.tsz >= MAX(64 - oas2bits(SMMU_IDR5_OAS), 16));
120
+}
121
+
122
+/*
123
+ * Return true if s2 page table config is valid.
124
+ * This checks with the configured start level, ias_bits and granularity we can
125
+ * have a valid page table as described in ARM ARM D8.2 Translation process.
126
+ * The idea here is to see for the highest possible number of IPA bits, how
127
+ * many concatenated tables we would need, if it is more than 16, then this is
128
+ * not possible.
129
+ */
130
+static bool s2_pgtable_config_valid(uint8_t sl0, uint8_t t0sz, uint8_t gran)
131
+{
132
+ int level = get_start_level(sl0, gran);
133
+ uint64_t ipa_bits = 64 - t0sz;
134
+ uint64_t max_ipa = (1ULL << ipa_bits) - 1;
135
+ int nr_concat = pgd_concat_idx(level, gran, max_ipa) + 1;
136
+
137
+ return nr_concat <= VMSA_MAX_S2_CONCAT;
138
+}
139
+
140
+static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *ste)
141
+{
142
+ cfg->stage = 2;
143
+
144
+ if (STE_S2AA64(ste) == 0x0) {
145
+ qemu_log_mask(LOG_UNIMP,
146
+ "SMMUv3 AArch32 tables not supported\n");
147
+ g_assert_not_reached();
148
+ }
149
+
150
+ switch (STE_S2TG(ste)) {
151
+ case 0x0: /* 4KB */
152
+ cfg->s2cfg.granule_sz = 12;
153
+ break;
154
+ case 0x1: /* 64KB */
155
+ cfg->s2cfg.granule_sz = 16;
156
+ break;
157
+ case 0x2: /* 16KB */
158
+ cfg->s2cfg.granule_sz = 14;
159
+ break;
160
+ default:
161
+ qemu_log_mask(LOG_GUEST_ERROR,
162
+ "SMMUv3 bad STE S2TG: %x\n", STE_S2TG(ste));
163
+ goto bad_ste;
164
+ }
165
+
166
+ cfg->s2cfg.vttb = STE_S2TTB(ste);
167
+
168
+ cfg->s2cfg.sl0 = STE_S2SL0(ste);
169
+ /* FEAT_TTST not supported. */
170
+ if (cfg->s2cfg.sl0 == 0x3) {
171
+ qemu_log_mask(LOG_UNIMP, "SMMUv3 S2SL0 = 0x3 has no meaning!\n");
172
+ goto bad_ste;
173
+ }
174
+
175
+ /* For AA64, The effective S2PS size is capped to the OAS. */
176
+ cfg->s2cfg.eff_ps = oas2bits(MIN(STE_S2PS(ste), SMMU_IDR5_OAS));
177
+ /*
178
+ * It is ILLEGAL for the address in S2TTB to be outside the range
179
+ * described by the effective S2PS value.
37
+ */
180
+ */
38
+ cpacr_write(env, ri, 0);
181
+ if (cfg->s2cfg.vttb & ~(MAKE_64BIT_MASK(0, cfg->s2cfg.eff_ps))) {
182
+ qemu_log_mask(LOG_GUEST_ERROR,
183
+ "SMMUv3 S2TTB too large 0x%lx, effective PS %d bits\n",
184
+ cfg->s2cfg.vttb, cfg->s2cfg.eff_ps);
185
+ goto bad_ste;
186
+ }
187
+
188
+ cfg->s2cfg.tsz = STE_S2T0SZ(ste);
189
+
190
+ if (!s2t0sz_valid(cfg)) {
191
+ qemu_log_mask(LOG_GUEST_ERROR, "SMMUv3 bad STE S2T0SZ = %d\n",
192
+ cfg->s2cfg.tsz);
193
+ goto bad_ste;
194
+ }
195
+
196
+ if (!s2_pgtable_config_valid(cfg->s2cfg.sl0, cfg->s2cfg.tsz,
197
+ cfg->s2cfg.granule_sz)) {
198
+ qemu_log_mask(LOG_GUEST_ERROR,
199
+ "SMMUv3 STE stage 2 config not valid!\n");
200
+ goto bad_ste;
201
+ }
202
+
203
+ /* Only LE supported(IDR0.TTENDIAN). */
204
+ if (STE_S2ENDI(ste)) {
205
+ qemu_log_mask(LOG_GUEST_ERROR,
206
+ "SMMUv3 STE_S2ENDI only supports LE!\n");
207
+ goto bad_ste;
208
+ }
209
+
210
+ cfg->s2cfg.affd = STE_S2AFFD(ste);
211
+
212
+ cfg->s2cfg.record_faults = STE_S2R(ste);
213
+ /* As stall is not supported. */
214
+ if (STE_S2S(ste)) {
215
+ qemu_log_mask(LOG_UNIMP, "SMMUv3 Stall not implemented!\n");
216
+ goto bad_ste;
217
+ }
218
+
219
+ /* This is still here as stage 2 has not been fully enabled yet. */
220
+ qemu_log_mask(LOG_UNIMP, "SMMUv3 does not support stage 2 yet\n");
221
+ goto bad_ste;
222
+
223
+ return 0;
224
+
225
+bad_ste:
226
+ return -EINVAL;
39
+}
227
+}
40
+
228
+
41
static CPAccessResult cpacr_access(CPUARMState *env, const ARMCPRegInfo *ri,
229
/* Returns < 0 in case of invalid STE, 0 otherwise */
42
bool isread)
230
static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg,
231
STE *ste, SMMUEventInfo *event)
43
{
232
{
44
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = {
233
uint32_t config;
45
{ .name = "CPACR", .state = ARM_CP_STATE_BOTH, .opc0 = 3,
234
+ int ret;
46
.crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access,
235
47
.access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1),
236
if (!STE_VALID(ste)) {
48
- .resetvalue = 0, .writefn = cpacr_write },
237
if (!event->inval_ste_allowed) {
49
+ .resetfn = cpacr_reset, .writefn = cpacr_write },
238
@@ -XXX,XX +XXX,XX @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg,
50
REGINFO_SENTINEL
239
return 0;
51
};
240
}
52
241
242
- if (STE_CFG_S2_ENABLED(config)) {
243
- qemu_log_mask(LOG_UNIMP, "SMMUv3 does not support stage 2 yet\n");
244
+ /*
245
+ * If a stage is enabled in SW while not advertised, throw bad ste
246
+ * according to user manual(IHI0070E) "5.2 Stream Table Entry".
247
+ */
248
+ if (!STAGE1_SUPPORTED(s) && STE_CFG_S1_ENABLED(config)) {
249
+ qemu_log_mask(LOG_GUEST_ERROR, "SMMUv3 S1 used but not supported.\n");
250
goto bad_ste;
251
}
252
+ if (!STAGE2_SUPPORTED(s) && STE_CFG_S2_ENABLED(config)) {
253
+ qemu_log_mask(LOG_GUEST_ERROR, "SMMUv3 S2 used but not supported.\n");
254
+ goto bad_ste;
255
+ }
256
+
257
+ if (STAGE2_SUPPORTED(s)) {
258
+ /* VMID is considered even if s2 is disabled. */
259
+ cfg->s2cfg.vmid = STE_S2VMID(ste);
260
+ } else {
261
+ /* Default to -1 */
262
+ cfg->s2cfg.vmid = -1;
263
+ }
264
+
265
+ if (STE_CFG_S2_ENABLED(config)) {
266
+ /*
267
+ * Stage-1 OAS defaults to OAS even if not enabled as it would be used
268
+ * in input address check for stage-2.
269
+ */
270
+ cfg->oas = oas2bits(SMMU_IDR5_OAS);
271
+ ret = decode_ste_s2_cfg(cfg, ste);
272
+ if (ret) {
273
+ goto bad_ste;
274
+ }
275
+ }
276
277
if (STE_S1CDMAX(ste) != 0) {
278
qemu_log_mask(LOG_UNIMP,
279
@@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr,
280
if (cached_entry) {
281
if ((flag & IOMMU_WO) && !(cached_entry->entry.perm & IOMMU_WO)) {
282
status = SMMU_TRANS_ERROR;
283
- if (cfg->record_faults) {
284
+ /*
285
+ * We know that the TLB only contains either stage-1 or stage-2 as
286
+ * nesting is not supported. So it is sufficient to check the
287
+ * translation stage to know the TLB stage for now.
288
+ */
289
+ event.u.f_walk_eabt.s2 = (cfg->stage == 2);
290
+ if (PTW_RECORD_FAULT(cfg)) {
291
event.type = SMMU_EVT_F_PERMISSION;
292
event.u.f_permission.addr = addr;
293
event.u.f_permission.rnw = flag & 0x1;
294
@@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr,
295
event.u.f_walk_eabt.addr2 = ptw_info.addr;
296
break;
297
case SMMU_PTW_ERR_TRANSLATION:
298
- if (cfg->record_faults) {
299
+ if (PTW_RECORD_FAULT(cfg)) {
300
event.type = SMMU_EVT_F_TRANSLATION;
301
event.u.f_translation.addr = addr;
302
event.u.f_translation.rnw = flag & 0x1;
303
}
304
break;
305
case SMMU_PTW_ERR_ADDR_SIZE:
306
- if (cfg->record_faults) {
307
+ if (PTW_RECORD_FAULT(cfg)) {
308
event.type = SMMU_EVT_F_ADDR_SIZE;
309
event.u.f_addr_size.addr = addr;
310
event.u.f_addr_size.rnw = flag & 0x1;
311
}
312
break;
313
case SMMU_PTW_ERR_ACCESS:
314
- if (cfg->record_faults) {
315
+ if (PTW_RECORD_FAULT(cfg)) {
316
event.type = SMMU_EVT_F_ACCESS;
317
event.u.f_access.addr = addr;
318
event.u.f_access.rnw = flag & 0x1;
319
}
320
break;
321
case SMMU_PTW_ERR_PERMISSION:
322
- if (cfg->record_faults) {
323
+ if (PTW_RECORD_FAULT(cfg)) {
324
event.type = SMMU_EVT_F_PERMISSION;
325
event.u.f_permission.addr = addr;
326
event.u.f_permission.rnw = flag & 0x1;
53
--
327
--
54
2.17.1
328
2.34.1
55
56
diff view generated by jsdifflib
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
1
From: Mostafa Saleh <smostafa@google.com>
2
add MemTxAttrs as an argument to address_space_map().
3
Its callers either have an attrs value to hand, or don't care
4
and can use MEMTXATTRS_UNSPECIFIED.
5
2
3
Right now, either stage-1 or stage-2 are supported, this simplifies
4
how we can deal with TLBs.
5
This patch makes TLB lookup work if stage-2 is enabled instead of
6
stage-1.
7
TLB lookup is done before a PTW, if a valid entry is found we won't
8
do the PTW.
9
To be able to do TLB lookup, we need the correct tagging info, as
10
granularity and input size, so we get this based on the supported
11
translation stage. The TLB entries are added correctly from each
12
stage PTW.
13
14
When nested translation is supported, this would need to change, for
15
example if we go with a combined TLB implementation, we would need to
16
use the min of the granularities in TLB.
17
18
As stage-2 shouldn't be tagged by ASID, it will be set to -1 if S1P
19
is not enabled.
20
21
Signed-off-by: Mostafa Saleh <smostafa@google.com>
22
Reviewed-by: Eric Auger <eric.auger@redhat.com>
23
Tested-by: Eric Auger <eric.auger@redhat.com>
24
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
25
Message-id: 20230516203327.2051088-7-smostafa@google.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180521140402.23318-5-peter.maydell@linaro.org
10
---
27
---
11
include/exec/memory.h | 3 ++-
28
hw/arm/smmuv3.c | 44 +++++++++++++++++++++++++++++++++-----------
12
include/sysemu/dma.h | 3 ++-
29
1 file changed, 33 insertions(+), 11 deletions(-)
13
exec.c | 6 ++++--
14
target/ppc/mmu-hash64.c | 3 ++-
15
4 files changed, 10 insertions(+), 5 deletions(-)
16
30
17
diff --git a/include/exec/memory.h b/include/exec/memory.h
31
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
18
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
19
--- a/include/exec/memory.h
33
--- a/hw/arm/smmuv3.c
20
+++ b/include/exec/memory.h
34
+++ b/hw/arm/smmuv3.c
21
@@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_
35
@@ -XXX,XX +XXX,XX @@ static int smmuv3_decode_config(IOMMUMemoryRegion *mr, SMMUTransCfg *cfg,
22
* @addr: address within that address space
36
STE ste;
23
* @plen: pointer to length of buffer; updated on return
37
CD cd;
24
* @is_write: indicates the transfer direction
38
25
+ * @attrs: memory attributes
39
+ /* ASID defaults to -1 (if s1 is not supported). */
26
*/
40
+ cfg->asid = -1;
27
void *address_space_map(AddressSpace *as, hwaddr addr,
41
+
28
- hwaddr *plen, bool is_write);
42
ret = smmu_find_ste(s, sid, &ste, event);
29
+ hwaddr *plen, bool is_write, MemTxAttrs attrs);
43
if (ret) {
30
44
return ret;
31
/* address_space_unmap: Unmaps a memory region previously mapped by address_space_map()
45
@@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr,
32
*
46
.addr_mask = ~(hwaddr)0,
33
diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
47
.perm = IOMMU_NONE,
34
index XXXXXXX..XXXXXXX 100644
48
};
35
--- a/include/sysemu/dma.h
49
+ /*
36
+++ b/include/sysemu/dma.h
50
+ * Combined attributes used for TLB lookup, as only one stage is supported,
37
@@ -XXX,XX +XXX,XX @@ static inline void *dma_memory_map(AddressSpace *as,
51
+ * it will hold attributes based on the enabled stage.
38
hwaddr xlen = *len;
52
+ */
39
void *p;
53
+ SMMUTransTableInfo tt_combined;
40
54
41
- p = address_space_map(as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE);
55
qemu_mutex_lock(&s->mutex);
42
+ p = address_space_map(as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE,
56
43
+ MEMTXATTRS_UNSPECIFIED);
57
@@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr,
44
*len = xlen;
58
goto epilogue;
45
return p;
46
}
47
diff --git a/exec.c b/exec.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/exec.c
50
+++ b/exec.c
51
@@ -XXX,XX +XXX,XX @@ flatview_extend_translation(FlatView *fv, hwaddr addr,
52
void *address_space_map(AddressSpace *as,
53
hwaddr addr,
54
hwaddr *plen,
55
- bool is_write)
56
+ bool is_write,
57
+ MemTxAttrs attrs)
58
{
59
hwaddr len = *plen;
60
hwaddr l, xlat;
61
@@ -XXX,XX +XXX,XX @@ void *cpu_physical_memory_map(hwaddr addr,
62
hwaddr *plen,
63
int is_write)
64
{
65
- return address_space_map(&address_space_memory, addr, plen, is_write);
66
+ return address_space_map(&address_space_memory, addr, plen, is_write,
67
+ MEMTXATTRS_UNSPECIFIED);
68
}
69
70
void cpu_physical_memory_unmap(void *buffer, hwaddr len,
71
diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c
72
index XXXXXXX..XXXXXXX 100644
73
--- a/target/ppc/mmu-hash64.c
74
+++ b/target/ppc/mmu-hash64.c
75
@@ -XXX,XX +XXX,XX @@ const ppc_hash_pte64_t *ppc_hash64_map_hptes(PowerPCCPU *cpu,
76
return NULL;
77
}
59
}
78
60
79
- hptes = address_space_map(CPU(cpu)->as, base + pte_offset, &plen, false);
61
- tt = select_tt(cfg, addr);
80
+ hptes = address_space_map(CPU(cpu)->as, base + pte_offset, &plen, false,
62
- if (!tt) {
81
+ MEMTXATTRS_UNSPECIFIED);
63
- if (cfg->record_faults) {
82
if (plen < (n * HASH_PTE_SIZE_64)) {
64
- event.type = SMMU_EVT_F_TRANSLATION;
83
hw_error("%s: Unable to map all requested HPTEs\n", __func__);
65
- event.u.f_translation.addr = addr;
84
}
66
- event.u.f_translation.rnw = flag & 0x1;
67
+ if (cfg->stage == 1) {
68
+ /* Select stage1 translation table. */
69
+ tt = select_tt(cfg, addr);
70
+ if (!tt) {
71
+ if (cfg->record_faults) {
72
+ event.type = SMMU_EVT_F_TRANSLATION;
73
+ event.u.f_translation.addr = addr;
74
+ event.u.f_translation.rnw = flag & 0x1;
75
+ }
76
+ status = SMMU_TRANS_ERROR;
77
+ goto epilogue;
78
}
79
- status = SMMU_TRANS_ERROR;
80
- goto epilogue;
81
- }
82
+ tt_combined.granule_sz = tt->granule_sz;
83
+ tt_combined.tsz = tt->tsz;
84
85
- page_mask = (1ULL << (tt->granule_sz)) - 1;
86
+ } else {
87
+ /* Stage2. */
88
+ tt_combined.granule_sz = cfg->s2cfg.granule_sz;
89
+ tt_combined.tsz = cfg->s2cfg.tsz;
90
+ }
91
+ /*
92
+ * TLB lookup looks for granule and input size for a translation stage,
93
+ * as only one stage is supported right now, choose the right values
94
+ * from the configuration.
95
+ */
96
+ page_mask = (1ULL << tt_combined.granule_sz) - 1;
97
aligned_addr = addr & ~page_mask;
98
99
- cached_entry = smmu_iotlb_lookup(bs, cfg, tt, aligned_addr);
100
+ cached_entry = smmu_iotlb_lookup(bs, cfg, &tt_combined, aligned_addr);
101
if (cached_entry) {
102
if ((flag & IOMMU_WO) && !(cached_entry->entry.perm & IOMMU_WO)) {
103
status = SMMU_TRANS_ERROR;
85
--
104
--
86
2.17.1
105
2.34.1
87
88
diff view generated by jsdifflib
1
From: Francisco Iglesias <frasse.iglesias@gmail.com>
1
From: Mostafa Saleh <smostafa@google.com>
2
2
3
Coverity found that the string return by 'object_get_canonical_path' was not
3
Allow TLB to be tagged with VMID.
4
being freed at two locations in the model (CID 1391294 and CID 1391293) and
4
5
also that a memset was being called with a value greater than the max of a byte
5
If stage-1 is only supported, VMID is set to -1 and ignored from STE
6
on the second argument (CID 1391286). This patch corrects this by adding the
6
and CMD_TLBI_NH* cmds.
7
freeing of the strings and also changing to memset to zero instead on
7
8
descriptor unaligned errors.
8
Update smmu_iotlb_insert trace event to have vmid.
9
9
10
Signed-off-by: Francisco Iglesias <frasse.iglesias@gmail.com>
10
Signed-off-by: Mostafa Saleh <smostafa@google.com>
11
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
11
Reviewed-by: Eric Auger <eric.auger@redhat.com>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Tested-by: Eric Auger <eric.auger@redhat.com>
13
Message-id: 20180528184859.3530-1-frasse.iglesias@gmail.com
13
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
14
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Message-id: 20230516203327.2051088-8-smostafa@google.com
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
16
---
17
hw/dma/xlnx-zdma.c | 10 +++++++---
17
hw/arm/smmu-internal.h | 2 ++
18
1 file changed, 7 insertions(+), 3 deletions(-)
18
include/hw/arm/smmu-common.h | 5 +++--
19
19
hw/arm/smmu-common.c | 36 ++++++++++++++++++++++--------------
20
diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c
20
hw/arm/smmuv3.c | 12 +++++++++---
21
index XXXXXXX..XXXXXXX 100644
21
hw/arm/trace-events | 6 +++---
22
--- a/hw/dma/xlnx-zdma.c
22
5 files changed, 39 insertions(+), 22 deletions(-)
23
+++ b/hw/dma/xlnx-zdma.c
23
24
@@ -XXX,XX +XXX,XX @@ static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t addr, void *buf)
24
diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h
25
qemu_log_mask(LOG_GUEST_ERROR,
25
index XXXXXXX..XXXXXXX 100644
26
"zdma: unaligned descriptor at %" PRIx64,
26
--- a/hw/arm/smmu-internal.h
27
addr);
27
+++ b/hw/arm/smmu-internal.h
28
- memset(buf, 0xdeadbeef, sizeof(XlnxZDMADescr));
28
@@ -XXX,XX +XXX,XX @@ static inline int pgd_concat_idx(int start_level, int granule_sz,
29
+ memset(buf, 0x0, sizeof(XlnxZDMADescr));
29
}
30
s->error = true;
30
31
#define SMMU_IOTLB_ASID(key) ((key).asid)
32
+#define SMMU_IOTLB_VMID(key) ((key).vmid)
33
34
typedef struct SMMUIOTLBPageInvInfo {
35
int asid;
36
+ int vmid;
37
uint64_t iova;
38
uint64_t mask;
39
} SMMUIOTLBPageInvInfo;
40
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
41
index XXXXXXX..XXXXXXX 100644
42
--- a/include/hw/arm/smmu-common.h
43
+++ b/include/hw/arm/smmu-common.h
44
@@ -XXX,XX +XXX,XX @@ typedef struct SMMUPciBus {
45
typedef struct SMMUIOTLBKey {
46
uint64_t iova;
47
uint16_t asid;
48
+ uint16_t vmid;
49
uint8_t tg;
50
uint8_t level;
51
} SMMUIOTLBKey;
52
@@ -XXX,XX +XXX,XX @@ IOMMUMemoryRegion *smmu_iommu_mr(SMMUState *s, uint32_t sid);
53
SMMUTLBEntry *smmu_iotlb_lookup(SMMUState *bs, SMMUTransCfg *cfg,
54
SMMUTransTableInfo *tt, hwaddr iova);
55
void smmu_iotlb_insert(SMMUState *bs, SMMUTransCfg *cfg, SMMUTLBEntry *entry);
56
-SMMUIOTLBKey smmu_get_iotlb_key(uint16_t asid, uint64_t iova,
57
+SMMUIOTLBKey smmu_get_iotlb_key(uint16_t asid, uint16_t vmid, uint64_t iova,
58
uint8_t tg, uint8_t level);
59
void smmu_iotlb_inv_all(SMMUState *s);
60
void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid);
61
-void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova,
62
+void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova,
63
uint8_t tg, uint64_t num_pages, uint8_t ttl);
64
65
/* Unmap the range of all the notifiers registered to any IOMMU mr */
66
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
67
index XXXXXXX..XXXXXXX 100644
68
--- a/hw/arm/smmu-common.c
69
+++ b/hw/arm/smmu-common.c
70
@@ -XXX,XX +XXX,XX @@ static guint smmu_iotlb_key_hash(gconstpointer v)
71
72
/* Jenkins hash */
73
a = b = c = JHASH_INITVAL + sizeof(*key);
74
- a += key->asid + key->level + key->tg;
75
+ a += key->asid + key->vmid + key->level + key->tg;
76
b += extract64(key->iova, 0, 32);
77
c += extract64(key->iova, 32, 32);
78
79
@@ -XXX,XX +XXX,XX @@ static gboolean smmu_iotlb_key_equal(gconstpointer v1, gconstpointer v2)
80
SMMUIOTLBKey *k1 = (SMMUIOTLBKey *)v1, *k2 = (SMMUIOTLBKey *)v2;
81
82
return (k1->asid == k2->asid) && (k1->iova == k2->iova) &&
83
- (k1->level == k2->level) && (k1->tg == k2->tg);
84
+ (k1->level == k2->level) && (k1->tg == k2->tg) &&
85
+ (k1->vmid == k2->vmid);
86
}
87
88
-SMMUIOTLBKey smmu_get_iotlb_key(uint16_t asid, uint64_t iova,
89
+SMMUIOTLBKey smmu_get_iotlb_key(uint16_t asid, uint16_t vmid, uint64_t iova,
90
uint8_t tg, uint8_t level)
91
{
92
- SMMUIOTLBKey key = {.asid = asid, .iova = iova, .tg = tg, .level = level};
93
+ SMMUIOTLBKey key = {.asid = asid, .vmid = vmid, .iova = iova,
94
+ .tg = tg, .level = level};
95
96
return key;
97
}
98
@@ -XXX,XX +XXX,XX @@ SMMUTLBEntry *smmu_iotlb_lookup(SMMUState *bs, SMMUTransCfg *cfg,
99
uint64_t mask = subpage_size - 1;
100
SMMUIOTLBKey key;
101
102
- key = smmu_get_iotlb_key(cfg->asid, iova & ~mask, tg, level);
103
+ key = smmu_get_iotlb_key(cfg->asid, cfg->s2cfg.vmid,
104
+ iova & ~mask, tg, level);
105
entry = g_hash_table_lookup(bs->iotlb, &key);
106
if (entry) {
107
break;
108
@@ -XXX,XX +XXX,XX @@ SMMUTLBEntry *smmu_iotlb_lookup(SMMUState *bs, SMMUTransCfg *cfg,
109
110
if (entry) {
111
cfg->iotlb_hits++;
112
- trace_smmu_iotlb_lookup_hit(cfg->asid, iova,
113
+ trace_smmu_iotlb_lookup_hit(cfg->asid, cfg->s2cfg.vmid, iova,
114
cfg->iotlb_hits, cfg->iotlb_misses,
115
100 * cfg->iotlb_hits /
116
(cfg->iotlb_hits + cfg->iotlb_misses));
117
} else {
118
cfg->iotlb_misses++;
119
- trace_smmu_iotlb_lookup_miss(cfg->asid, iova,
120
+ trace_smmu_iotlb_lookup_miss(cfg->asid, cfg->s2cfg.vmid, iova,
121
cfg->iotlb_hits, cfg->iotlb_misses,
122
100 * cfg->iotlb_hits /
123
(cfg->iotlb_hits + cfg->iotlb_misses));
124
@@ -XXX,XX +XXX,XX @@ void smmu_iotlb_insert(SMMUState *bs, SMMUTransCfg *cfg, SMMUTLBEntry *new)
125
smmu_iotlb_inv_all(bs);
126
}
127
128
- *key = smmu_get_iotlb_key(cfg->asid, new->entry.iova, tg, new->level);
129
- trace_smmu_iotlb_insert(cfg->asid, new->entry.iova, tg, new->level);
130
+ *key = smmu_get_iotlb_key(cfg->asid, cfg->s2cfg.vmid, new->entry.iova,
131
+ tg, new->level);
132
+ trace_smmu_iotlb_insert(cfg->asid, cfg->s2cfg.vmid, new->entry.iova,
133
+ tg, new->level);
134
g_hash_table_insert(bs->iotlb, key, new);
135
}
136
137
@@ -XXX,XX +XXX,XX @@ static gboolean smmu_hash_remove_by_asid(gpointer key, gpointer value,
138
139
return SMMU_IOTLB_ASID(*iotlb_key) == asid;
140
}
141
-
142
-static gboolean smmu_hash_remove_by_asid_iova(gpointer key, gpointer value,
143
+static gboolean smmu_hash_remove_by_asid_vmid_iova(gpointer key, gpointer value,
144
gpointer user_data)
145
{
146
SMMUTLBEntry *iter = (SMMUTLBEntry *)value;
147
@@ -XXX,XX +XXX,XX @@ static gboolean smmu_hash_remove_by_asid_iova(gpointer key, gpointer value,
148
if (info->asid >= 0 && info->asid != SMMU_IOTLB_ASID(iotlb_key)) {
31
return false;
149
return false;
32
}
150
}
33
@@ -XXX,XX +XXX,XX @@ static uint64_t zdma_read(void *opaque, hwaddr addr, unsigned size)
151
+ if (info->vmid >= 0 && info->vmid != SMMU_IOTLB_VMID(iotlb_key)) {
34
RegisterInfo *r = &s->regs_info[addr / 4];
152
+ return false;
35
153
+ }
36
if (!r->data) {
154
return ((info->iova & ~entry->addr_mask) == entry->iova) ||
37
+ gchar *path = object_get_canonical_path(OBJECT(s));
155
((entry->iova & ~info->mask) == info->iova);
38
qemu_log("%s: Decode error: read from %" HWADDR_PRIx "\n",
156
}
39
- object_get_canonical_path(OBJECT(s)),
157
40
+ path,
158
-void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova,
41
addr);
159
+void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova,
42
+ g_free(path);
160
uint8_t tg, uint64_t num_pages, uint8_t ttl)
43
ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, INV_APB, true);
161
{
44
zdma_ch_imr_update_irq(s);
162
/* if tg is not set we use 4KB range invalidation */
45
return 0;
163
uint8_t granule = tg ? tg * 2 + 10 : 12;
46
@@ -XXX,XX +XXX,XX @@ static void zdma_write(void *opaque, hwaddr addr, uint64_t value,
164
47
RegisterInfo *r = &s->regs_info[addr / 4];
165
if (ttl && (num_pages == 1) && (asid >= 0)) {
48
166
- SMMUIOTLBKey key = smmu_get_iotlb_key(asid, iova, tg, ttl);
49
if (!r->data) {
167
+ SMMUIOTLBKey key = smmu_get_iotlb_key(asid, vmid, iova, tg, ttl);
50
+ gchar *path = object_get_canonical_path(OBJECT(s));
168
51
qemu_log("%s: Decode error: write to %" HWADDR_PRIx "=%" PRIx64 "\n",
169
if (g_hash_table_remove(s->iotlb, &key)) {
52
- object_get_canonical_path(OBJECT(s)),
170
return;
53
+ path,
171
@@ -XXX,XX +XXX,XX @@ void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova,
54
addr, value);
172
55
+ g_free(path);
173
SMMUIOTLBPageInvInfo info = {
56
ARRAY_FIELD_DP32(s->regs, ZDMA_CH_ISR, INV_APB, true);
174
.asid = asid, .iova = iova,
57
zdma_ch_imr_update_irq(s);
175
+ .vmid = vmid,
176
.mask = (num_pages * 1 << granule) - 1};
177
178
g_hash_table_foreach_remove(s->iotlb,
179
- smmu_hash_remove_by_asid_iova,
180
+ smmu_hash_remove_by_asid_vmid_iova,
181
&info);
182
}
183
184
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
185
index XXXXXXX..XXXXXXX 100644
186
--- a/hw/arm/smmuv3.c
187
+++ b/hw/arm/smmuv3.c
188
@@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
189
{
190
dma_addr_t end, addr = CMD_ADDR(cmd);
191
uint8_t type = CMD_TYPE(cmd);
192
- uint16_t vmid = CMD_VMID(cmd);
193
+ int vmid = -1;
194
uint8_t scale = CMD_SCALE(cmd);
195
uint8_t num = CMD_NUM(cmd);
196
uint8_t ttl = CMD_TTL(cmd);
197
@@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
198
uint64_t num_pages;
199
uint8_t granule;
200
int asid = -1;
201
+ SMMUv3State *smmuv3 = ARM_SMMUV3(s);
202
+
203
+ /* Only consider VMID if stage-2 is supported. */
204
+ if (STAGE2_SUPPORTED(smmuv3)) {
205
+ vmid = CMD_VMID(cmd);
206
+ }
207
208
if (type == SMMU_CMD_TLBI_NH_VA) {
209
asid = CMD_ASID(cmd);
210
@@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
211
if (!tg) {
212
trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, 1, ttl, leaf);
213
smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1);
214
- smmu_iotlb_inv_iova(s, asid, addr, tg, 1, ttl);
215
+ smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl);
58
return;
216
return;
217
}
218
219
@@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
220
num_pages = (mask + 1) >> granule;
221
trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf);
222
smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages);
223
- smmu_iotlb_inv_iova(s, asid, addr, tg, num_pages, ttl);
224
+ smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl);
225
addr += mask + 1;
226
}
227
}
228
diff --git a/hw/arm/trace-events b/hw/arm/trace-events
229
index XXXXXXX..XXXXXXX 100644
230
--- a/hw/arm/trace-events
231
+++ b/hw/arm/trace-events
232
@@ -XXX,XX +XXX,XX @@ smmu_iotlb_inv_all(void) "IOTLB invalidate all"
233
smmu_iotlb_inv_asid(uint16_t asid) "IOTLB invalidate asid=%d"
234
smmu_iotlb_inv_iova(uint16_t asid, uint64_t addr) "IOTLB invalidate asid=%d addr=0x%"PRIx64
235
smmu_inv_notifiers_mr(const char *name) "iommu mr=%s"
236
-smmu_iotlb_lookup_hit(uint16_t asid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache HIT asid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d"
237
-smmu_iotlb_lookup_miss(uint16_t asid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache MISS asid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d"
238
-smmu_iotlb_insert(uint16_t asid, uint64_t addr, uint8_t tg, uint8_t level) "IOTLB ++ asid=%d addr=0x%"PRIx64" tg=%d level=%d"
239
+smmu_iotlb_lookup_hit(uint16_t asid, uint16_t vmid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache HIT asid=%d vmid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d"
240
+smmu_iotlb_lookup_miss(uint16_t asid, uint16_t vmid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache MISS asid=%d vmid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d"
241
+smmu_iotlb_insert(uint16_t asid, uint16_t vmid, uint64_t addr, uint8_t tg, uint8_t level) "IOTLB ++ asid=%d vmid=%d addr=0x%"PRIx64" tg=%d level=%d"
242
243
# smmuv3.c
244
smmuv3_read_mmio(uint64_t addr, uint64_t val, unsigned size, uint32_t r) "addr: 0x%"PRIx64" val:0x%"PRIx64" size: 0x%x(%d)"
59
--
245
--
60
2.17.1
246
2.34.1
61
62
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Mostafa Saleh <smostafa@google.com>
2
2
3
Depending on the host abi, float16, aka uint16_t, values are
3
CMD_TLBI_S2_IPA: As S1+S2 is not enabled, for now this can be the
4
passed and returned either zero-extended in the host register
4
same as CMD_TLBI_NH_VAA.
5
or with garbage at the top of the host register.
5
6
6
CMD_TLBI_S12_VMALL: Added new function to invalidate TLB by VMID.
7
The tcg code generator has so far been assuming garbage, as that
7
8
matches the x86 abi, but this is incorrect for other host abis.
8
For stage-1 only commands, add a check to throw CERROR_ILL if used
9
Further, target/arm has so far been assuming zero-extended results,
9
when stage-1 is not supported.
10
so that it may store the 16-bit value into a 32-bit slot with the
10
11
high 16-bits already clear.
11
Reviewed-by: Eric Auger <eric.auger@redhat.com>
12
12
Signed-off-by: Mostafa Saleh <smostafa@google.com>
13
Rectify both problems by mapping "f16" in the helper definition
13
Tested-by: Eric Auger <eric.auger@redhat.com>
14
to uint32_t instead of (a typedef for) uint16_t. This forces
14
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
15
the host compiler to assume garbage in the upper 16 bits on input
15
Message-id: 20230516203327.2051088-9-smostafa@google.com
16
and to zero-extend the result on output.
17
18
Cc: qemu-stable@nongnu.org
19
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
20
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
21
Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com>
22
Message-id: 20180522175629.24932-1-richard.henderson@linaro.org
23
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
---
17
---
26
include/exec/helper-head.h | 2 +-
18
include/hw/arm/smmu-common.h | 1 +
27
target/arm/helper-a64.c | 35 +++++++++--------
19
hw/arm/smmu-common.c | 16 +++++++++++
28
target/arm/helper.c | 80 +++++++++++++++++++-------------------
20
hw/arm/smmuv3.c | 55 ++++++++++++++++++++++++++++++------
29
3 files changed, 59 insertions(+), 58 deletions(-)
21
hw/arm/trace-events | 4 ++-
30
22
4 files changed, 67 insertions(+), 9 deletions(-)
31
diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h
23
32
index XXXXXXX..XXXXXXX 100644
24
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
33
--- a/include/exec/helper-head.h
25
index XXXXXXX..XXXXXXX 100644
34
+++ b/include/exec/helper-head.h
26
--- a/include/hw/arm/smmu-common.h
35
@@ -XXX,XX +XXX,XX @@
27
+++ b/include/hw/arm/smmu-common.h
36
#define dh_ctype_int int
28
@@ -XXX,XX +XXX,XX @@ SMMUIOTLBKey smmu_get_iotlb_key(uint16_t asid, uint16_t vmid, uint64_t iova,
37
#define dh_ctype_i64 uint64_t
29
uint8_t tg, uint8_t level);
38
#define dh_ctype_s64 int64_t
30
void smmu_iotlb_inv_all(SMMUState *s);
39
-#define dh_ctype_f16 float16
31
void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid);
40
+#define dh_ctype_f16 uint32_t
32
+void smmu_iotlb_inv_vmid(SMMUState *s, uint16_t vmid);
41
#define dh_ctype_f32 float32
33
void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova,
42
#define dh_ctype_f64 float64
34
uint8_t tg, uint64_t num_pages, uint8_t ttl);
43
#define dh_ctype_ptr void *
35
44
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
36
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
45
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
46
--- a/target/arm/helper-a64.c
38
--- a/hw/arm/smmu-common.c
47
+++ b/target/arm/helper-a64.c
39
+++ b/hw/arm/smmu-common.c
48
@@ -XXX,XX +XXX,XX @@ static inline uint32_t float_rel_to_flags(int res)
40
@@ -XXX,XX +XXX,XX @@ static gboolean smmu_hash_remove_by_asid(gpointer key, gpointer value,
49
return flags;
41
42
return SMMU_IOTLB_ASID(*iotlb_key) == asid;
50
}
43
}
51
44
+
52
-uint64_t HELPER(vfp_cmph_a64)(float16 x, float16 y, void *fp_status)
45
+static gboolean smmu_hash_remove_by_vmid(gpointer key, gpointer value,
53
+uint64_t HELPER(vfp_cmph_a64)(uint32_t x, uint32_t y, void *fp_status)
46
+ gpointer user_data)
47
+{
48
+ uint16_t vmid = *(uint16_t *)user_data;
49
+ SMMUIOTLBKey *iotlb_key = (SMMUIOTLBKey *)key;
50
+
51
+ return SMMU_IOTLB_VMID(*iotlb_key) == vmid;
52
+}
53
+
54
static gboolean smmu_hash_remove_by_asid_vmid_iova(gpointer key, gpointer value,
55
gpointer user_data)
54
{
56
{
55
return float_rel_to_flags(float16_compare_quiet(x, y, fp_status));
57
@@ -XXX,XX +XXX,XX @@ void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid)
58
g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_asid, &asid);
56
}
59
}
57
60
58
-uint64_t HELPER(vfp_cmpeh_a64)(float16 x, float16 y, void *fp_status)
61
+inline void smmu_iotlb_inv_vmid(SMMUState *s, uint16_t vmid)
59
+uint64_t HELPER(vfp_cmpeh_a64)(uint32_t x, uint32_t y, void *fp_status)
62
+{
60
{
63
+ trace_smmu_iotlb_inv_vmid(vmid);
61
return float_rel_to_flags(float16_compare(x, y, fp_status));
64
+ g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_vmid, &vmid);
62
}
65
+}
63
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_cgt_f64)(float64 a, float64 b, void *fpstp)
66
+
64
#define float64_three make_float64(0x4008000000000000ULL)
67
/* VMSAv8-64 Translation */
65
#define float64_one_point_five make_float64(0x3FF8000000000000ULL)
68
66
69
/**
67
-float16 HELPER(recpsf_f16)(float16 a, float16 b, void *fpstp)
70
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
68
+uint32_t HELPER(recpsf_f16)(uint32_t a, uint32_t b, void *fpstp)
71
index XXXXXXX..XXXXXXX 100644
69
{
72
--- a/hw/arm/smmuv3.c
70
float_status *fpst = fpstp;
73
+++ b/hw/arm/smmuv3.c
71
74
@@ -XXX,XX +XXX,XX @@ static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova,
72
@@ -XXX,XX +XXX,XX @@ float64 HELPER(recpsf_f64)(float64 a, float64 b, void *fpstp)
73
return float64_muladd(a, b, float64_two, 0, fpst);
74
}
75
76
-float16 HELPER(rsqrtsf_f16)(float16 a, float16 b, void *fpstp)
77
+uint32_t HELPER(rsqrtsf_f16)(uint32_t a, uint32_t b, void *fpstp)
78
{
79
float_status *fpst = fpstp;
80
81
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_addlp_u16)(uint64_t a)
82
}
83
84
/* Floating-point reciprocal exponent - see FPRecpX in ARM ARM */
85
-float16 HELPER(frecpx_f16)(float16 a, void *fpstp)
86
+uint32_t HELPER(frecpx_f16)(uint32_t a, void *fpstp)
87
{
88
float_status *fpst = fpstp;
89
uint16_t val16, sbit;
90
@@ -XXX,XX +XXX,XX @@ void HELPER(casp_be_parallel)(CPUARMState *env, uint32_t rs, uint64_t addr,
91
#define ADVSIMD_HELPER(name, suffix) HELPER(glue(glue(advsimd_, name), suffix))
92
93
#define ADVSIMD_HALFOP(name) \
94
-float16 ADVSIMD_HELPER(name, h)(float16 a, float16 b, void *fpstp) \
95
+uint32_t ADVSIMD_HELPER(name, h)(uint32_t a, uint32_t b, void *fpstp) \
96
{ \
97
float_status *fpst = fpstp; \
98
return float16_ ## name(a, b, fpst); \
99
@@ -XXX,XX +XXX,XX @@ ADVSIMD_HALFOP(mulx)
100
ADVSIMD_TWOHALFOP(mulx)
101
102
/* fused multiply-accumulate */
103
-float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp)
104
+uint32_t HELPER(advsimd_muladdh)(uint32_t a, uint32_t b, uint32_t c,
105
+ void *fpstp)
106
{
107
float_status *fpst = fpstp;
108
return float16_muladd(a, b, c, 0, fpst);
109
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_muladd2h)(uint32_t two_a, uint32_t two_b,
110
111
#define ADVSIMD_CMPRES(test) (test) ? 0xffff : 0
112
113
-uint32_t HELPER(advsimd_ceq_f16)(float16 a, float16 b, void *fpstp)
114
+uint32_t HELPER(advsimd_ceq_f16)(uint32_t a, uint32_t b, void *fpstp)
115
{
116
float_status *fpst = fpstp;
117
int compare = float16_compare_quiet(a, b, fpst);
118
return ADVSIMD_CMPRES(compare == float_relation_equal);
119
}
120
121
-uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp)
122
+uint32_t HELPER(advsimd_cge_f16)(uint32_t a, uint32_t b, void *fpstp)
123
{
124
float_status *fpst = fpstp;
125
int compare = float16_compare(a, b, fpst);
126
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp)
127
compare == float_relation_equal);
128
}
129
130
-uint32_t HELPER(advsimd_cgt_f16)(float16 a, float16 b, void *fpstp)
131
+uint32_t HELPER(advsimd_cgt_f16)(uint32_t a, uint32_t b, void *fpstp)
132
{
133
float_status *fpst = fpstp;
134
int compare = float16_compare(a, b, fpst);
135
return ADVSIMD_CMPRES(compare == float_relation_greater);
136
}
137
138
-uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp)
139
+uint32_t HELPER(advsimd_acge_f16)(uint32_t a, uint32_t b, void *fpstp)
140
{
141
float_status *fpst = fpstp;
142
float16 f0 = float16_abs(a);
143
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp)
144
compare == float_relation_equal);
145
}
146
147
-uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp)
148
+uint32_t HELPER(advsimd_acgt_f16)(uint32_t a, uint32_t b, void *fpstp)
149
{
150
float_status *fpst = fpstp;
151
float16 f0 = float16_abs(a);
152
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp)
153
}
154
155
/* round to integral */
156
-float16 HELPER(advsimd_rinth_exact)(float16 x, void *fp_status)
157
+uint32_t HELPER(advsimd_rinth_exact)(uint32_t x, void *fp_status)
158
{
159
return float16_round_to_int(x, fp_status);
160
}
161
162
-float16 HELPER(advsimd_rinth)(float16 x, void *fp_status)
163
+uint32_t HELPER(advsimd_rinth)(uint32_t x, void *fp_status)
164
{
165
int old_flags = get_float_exception_flags(fp_status), new_flags;
166
float16 ret;
167
@@ -XXX,XX +XXX,XX @@ float16 HELPER(advsimd_rinth)(float16 x, void *fp_status)
168
* setting the mode appropriately before calling the helper.
169
*/
170
171
-uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp)
172
+uint32_t HELPER(advsimd_f16tosinth)(uint32_t a, void *fpstp)
173
{
174
float_status *fpst = fpstp;
175
176
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp)
177
return float16_to_int16(a, fpst);
178
}
179
180
-uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp)
181
+uint32_t HELPER(advsimd_f16touinth)(uint32_t a, void *fpstp)
182
{
183
float_status *fpst = fpstp;
184
185
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp)
186
* Square Root and Reciprocal square root
187
*/
188
189
-float16 HELPER(sqrt_f16)(float16 a, void *fpstp)
190
+uint32_t HELPER(sqrt_f16)(uint32_t a, void *fpstp)
191
{
192
float_status *s = fpstp;
193
194
diff --git a/target/arm/helper.c b/target/arm/helper.c
195
index XXXXXXX..XXXXXXX 100644
196
--- a/target/arm/helper.c
197
+++ b/target/arm/helper.c
198
@@ -XXX,XX +XXX,XX @@ DO_VFP_cmp(d, float64)
199
200
/* Integer to float and float to integer conversions */
201
202
-#define CONV_ITOF(name, fsz, sign) \
203
- float##fsz HELPER(name)(uint32_t x, void *fpstp) \
204
-{ \
205
- float_status *fpst = fpstp; \
206
- return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \
207
+#define CONV_ITOF(name, ftype, fsz, sign) \
208
+ftype HELPER(name)(uint32_t x, void *fpstp) \
209
+{ \
210
+ float_status *fpst = fpstp; \
211
+ return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \
212
}
213
214
-#define CONV_FTOI(name, fsz, sign, round) \
215
-uint32_t HELPER(name)(float##fsz x, void *fpstp) \
216
-{ \
217
- float_status *fpst = fpstp; \
218
- if (float##fsz##_is_any_nan(x)) { \
219
- float_raise(float_flag_invalid, fpst); \
220
- return 0; \
221
- } \
222
- return float##fsz##_to_##sign##int32##round(x, fpst); \
223
+#define CONV_FTOI(name, ftype, fsz, sign, round) \
224
+uint32_t HELPER(name)(ftype x, void *fpstp) \
225
+{ \
226
+ float_status *fpst = fpstp; \
227
+ if (float##fsz##_is_any_nan(x)) { \
228
+ float_raise(float_flag_invalid, fpst); \
229
+ return 0; \
230
+ } \
231
+ return float##fsz##_to_##sign##int32##round(x, fpst); \
232
}
233
234
-#define FLOAT_CONVS(name, p, fsz, sign) \
235
-CONV_ITOF(vfp_##name##to##p, fsz, sign) \
236
-CONV_FTOI(vfp_to##name##p, fsz, sign, ) \
237
-CONV_FTOI(vfp_to##name##z##p, fsz, sign, _round_to_zero)
238
+#define FLOAT_CONVS(name, p, ftype, fsz, sign) \
239
+ CONV_ITOF(vfp_##name##to##p, ftype, fsz, sign) \
240
+ CONV_FTOI(vfp_to##name##p, ftype, fsz, sign, ) \
241
+ CONV_FTOI(vfp_to##name##z##p, ftype, fsz, sign, _round_to_zero)
242
243
-FLOAT_CONVS(si, h, 16, )
244
-FLOAT_CONVS(si, s, 32, )
245
-FLOAT_CONVS(si, d, 64, )
246
-FLOAT_CONVS(ui, h, 16, u)
247
-FLOAT_CONVS(ui, s, 32, u)
248
-FLOAT_CONVS(ui, d, 64, u)
249
+FLOAT_CONVS(si, h, uint32_t, 16, )
250
+FLOAT_CONVS(si, s, float32, 32, )
251
+FLOAT_CONVS(si, d, float64, 64, )
252
+FLOAT_CONVS(ui, h, uint32_t, 16, u)
253
+FLOAT_CONVS(ui, s, float32, 32, u)
254
+FLOAT_CONVS(ui, d, float64, 64, u)
255
256
#undef CONV_ITOF
257
#undef CONV_FTOI
258
@@ -XXX,XX +XXX,XX @@ static float16 do_postscale_fp16(float64 f, int shift, float_status *fpst)
259
return float64_to_float16(float64_scalbn(f, -shift, fpst), true, fpst);
260
}
261
262
-float16 HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst)
263
+uint32_t HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst)
264
{
265
return do_postscale_fp16(int32_to_float64(x, fpst), shift, fpst);
266
}
267
268
-float16 HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst)
269
+uint32_t HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst)
270
{
271
return do_postscale_fp16(uint32_to_float64(x, fpst), shift, fpst);
272
}
273
274
-float16 HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst)
275
+uint32_t HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst)
276
{
277
return do_postscale_fp16(int64_to_float64(x, fpst), shift, fpst);
278
}
279
280
-float16 HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst)
281
+uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst)
282
{
283
return do_postscale_fp16(uint64_to_float64(x, fpst), shift, fpst);
284
}
285
@@ -XXX,XX +XXX,XX @@ static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst)
286
}
75
}
287
}
76
}
288
77
289
-uint32_t HELPER(vfp_toshh)(float16 x, uint32_t shift, void *fpst)
78
-static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
290
+uint32_t HELPER(vfp_toshh)(uint32_t x, uint32_t shift, void *fpst)
79
+static void smmuv3_range_inval(SMMUState *s, Cmd *cmd)
291
{
80
{
292
return float64_to_int16(do_prescale_fp16(x, shift, fpst), fpst);
81
dma_addr_t end, addr = CMD_ADDR(cmd);
293
}
82
uint8_t type = CMD_TYPE(cmd);
294
83
@@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
295
-uint32_t HELPER(vfp_touhh)(float16 x, uint32_t shift, void *fpst)
84
}
296
+uint32_t HELPER(vfp_touhh)(uint32_t x, uint32_t shift, void *fpst)
85
297
{
86
if (!tg) {
298
return float64_to_uint16(do_prescale_fp16(x, shift, fpst), fpst);
87
- trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, 1, ttl, leaf);
299
}
88
+ trace_smmuv3_range_inval(vmid, asid, addr, tg, 1, ttl, leaf);
300
89
smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1);
301
-uint32_t HELPER(vfp_toslh)(float16 x, uint32_t shift, void *fpst)
90
smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl);
302
+uint32_t HELPER(vfp_toslh)(uint32_t x, uint32_t shift, void *fpst)
91
return;
303
{
92
@@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
304
return float64_to_int32(do_prescale_fp16(x, shift, fpst), fpst);
93
uint64_t mask = dma_aligned_pow2_mask(addr, end, 64);
305
}
94
306
95
num_pages = (mask + 1) >> granule;
307
-uint32_t HELPER(vfp_toulh)(float16 x, uint32_t shift, void *fpst)
96
- trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf);
308
+uint32_t HELPER(vfp_toulh)(uint32_t x, uint32_t shift, void *fpst)
97
+ trace_smmuv3_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf);
309
{
98
smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages);
310
return float64_to_uint32(do_prescale_fp16(x, shift, fpst), fpst);
99
smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl);
311
}
100
addr += mask + 1;
312
101
@@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
313
-uint64_t HELPER(vfp_tosqh)(float16 x, uint32_t shift, void *fpst)
102
{
314
+uint64_t HELPER(vfp_tosqh)(uint32_t x, uint32_t shift, void *fpst)
103
uint16_t asid = CMD_ASID(&cmd);
315
{
104
316
return float64_to_int64(do_prescale_fp16(x, shift, fpst), fpst);
105
+ if (!STAGE1_SUPPORTED(s)) {
317
}
106
+ cmd_error = SMMU_CERROR_ILL;
318
107
+ break;
319
-uint64_t HELPER(vfp_touqh)(float16 x, uint32_t shift, void *fpst)
108
+ }
320
+uint64_t HELPER(vfp_touqh)(uint32_t x, uint32_t shift, void *fpst)
109
+
321
{
110
trace_smmuv3_cmdq_tlbi_nh_asid(asid);
322
return float64_to_uint64(do_prescale_fp16(x, shift, fpst), fpst);
111
smmu_inv_notifiers_all(&s->smmu_state);
323
}
112
smmu_iotlb_inv_asid(bs, asid);
324
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(set_neon_rmode)(uint32_t rmode, CPUARMState *env)
113
break;
325
}
114
}
326
115
case SMMU_CMD_TLBI_NH_ALL:
327
/* Half precision conversions. */
116
+ if (!STAGE1_SUPPORTED(s)) {
328
-float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode)
117
+ cmd_error = SMMU_CERROR_ILL;
329
+float32 HELPER(vfp_fcvt_f16_to_f32)(uint32_t a, void *fpstp, uint32_t ahp_mode)
118
+ break;
330
{
119
+ }
331
/* Squash FZ16 to 0 for the duration of conversion. In this case,
120
+ QEMU_FALLTHROUGH;
332
* it would affect flushing input denormals.
121
case SMMU_CMD_TLBI_NSNH_ALL:
333
@@ -XXX,XX +XXX,XX @@ float32 HELPER(vfp_fcvt_f16_to_f32)(float16 a, void *fpstp, uint32_t ahp_mode)
122
trace_smmuv3_cmdq_tlbi_nh();
334
return r;
123
smmu_inv_notifiers_all(&s->smmu_state);
335
}
124
@@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
336
125
break;
337
-float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode)
126
case SMMU_CMD_TLBI_NH_VAA:
338
+uint32_t HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode)
127
case SMMU_CMD_TLBI_NH_VA:
339
{
128
- smmuv3_s1_range_inval(bs, &cmd);
340
/* Squash FZ16 to 0 for the duration of conversion. In this case,
129
+ if (!STAGE1_SUPPORTED(s)) {
341
* it would affect flushing output denormals.
130
+ cmd_error = SMMU_CERROR_ILL;
342
@@ -XXX,XX +XXX,XX @@ float16 HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode)
131
+ break;
343
return r;
132
+ }
344
}
133
+ smmuv3_range_inval(bs, &cmd);
345
134
+ break;
346
-float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode)
135
+ case SMMU_CMD_TLBI_S12_VMALL:
347
+float64 HELPER(vfp_fcvt_f16_to_f64)(uint32_t a, void *fpstp, uint32_t ahp_mode)
136
+ {
348
{
137
+ uint16_t vmid = CMD_VMID(&cmd);
349
/* Squash FZ16 to 0 for the duration of conversion. In this case,
138
+
350
* it would affect flushing input denormals.
139
+ if (!STAGE2_SUPPORTED(s)) {
351
@@ -XXX,XX +XXX,XX @@ float64 HELPER(vfp_fcvt_f16_to_f64)(float16 a, void *fpstp, uint32_t ahp_mode)
140
+ cmd_error = SMMU_CERROR_ILL;
352
return r;
141
+ break;
353
}
142
+ }
354
143
+
355
-float16 HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode)
144
+ trace_smmuv3_cmdq_tlbi_s12_vmid(vmid);
356
+uint32_t HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode)
145
+ smmu_inv_notifiers_all(&s->smmu_state);
357
{
146
+ smmu_iotlb_inv_vmid(bs, vmid);
358
/* Squash FZ16 to 0 for the duration of conversion. In this case,
147
+ break;
359
* it would affect flushing output denormals.
148
+ }
360
@@ -XXX,XX +XXX,XX @@ static bool round_to_inf(float_status *fpst, bool sign_bit)
149
+ case SMMU_CMD_TLBI_S2_IPA:
361
g_assert_not_reached();
150
+ if (!STAGE2_SUPPORTED(s)) {
362
}
151
+ cmd_error = SMMU_CERROR_ILL;
363
152
+ break;
364
-float16 HELPER(recpe_f16)(float16 input, void *fpstp)
153
+ }
365
+uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp)
154
+ /*
366
{
155
+ * As currently only either s1 or s2 are supported
367
float_status *fpst = fpstp;
156
+ * we can reuse same function for s2.
368
float16 f16 = float16_squash_input_denormal(input, fpst);
157
+ */
369
@@ -XXX,XX +XXX,XX @@ static uint64_t recip_sqrt_estimate(int *exp , int exp_off, uint64_t frac)
158
+ smmuv3_range_inval(bs, &cmd);
370
return extract64(estimate, 0, 8) << 44;
159
break;
371
}
160
case SMMU_CMD_TLBI_EL3_ALL:
372
161
case SMMU_CMD_TLBI_EL3_VA:
373
-float16 HELPER(rsqrte_f16)(float16 input, void *fpstp)
162
@@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
374
+uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp)
163
case SMMU_CMD_TLBI_EL2_ASID:
375
{
164
case SMMU_CMD_TLBI_EL2_VA:
376
float_status *s = fpstp;
165
case SMMU_CMD_TLBI_EL2_VAA:
377
float16 f16 = float16_squash_input_denormal(input, s);
166
- case SMMU_CMD_TLBI_S12_VMALL:
167
- case SMMU_CMD_TLBI_S2_IPA:
168
case SMMU_CMD_ATC_INV:
169
case SMMU_CMD_PRI_RESP:
170
case SMMU_CMD_RESUME:
171
@@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
172
break;
173
default:
174
cmd_error = SMMU_CERROR_ILL;
175
- qemu_log_mask(LOG_GUEST_ERROR,
176
- "Illegal command type: %d\n", CMD_TYPE(&cmd));
177
break;
178
}
179
qemu_mutex_unlock(&s->mutex);
180
if (cmd_error) {
181
+ if (cmd_error == SMMU_CERROR_ILL) {
182
+ qemu_log_mask(LOG_GUEST_ERROR,
183
+ "Illegal command type: %d\n", CMD_TYPE(&cmd));
184
+ }
185
break;
186
}
187
/*
188
diff --git a/hw/arm/trace-events b/hw/arm/trace-events
189
index XXXXXXX..XXXXXXX 100644
190
--- a/hw/arm/trace-events
191
+++ b/hw/arm/trace-events
192
@@ -XXX,XX +XXX,XX @@ smmu_ptw_block_pte(int stage, int level, uint64_t baseaddr, uint64_t pteaddr, ui
193
smmu_get_pte(uint64_t baseaddr, int index, uint64_t pteaddr, uint64_t pte) "baseaddr=0x%"PRIx64" index=0x%x, pteaddr=0x%"PRIx64", pte=0x%"PRIx64
194
smmu_iotlb_inv_all(void) "IOTLB invalidate all"
195
smmu_iotlb_inv_asid(uint16_t asid) "IOTLB invalidate asid=%d"
196
+smmu_iotlb_inv_vmid(uint16_t vmid) "IOTLB invalidate vmid=%d"
197
smmu_iotlb_inv_iova(uint16_t asid, uint64_t addr) "IOTLB invalidate asid=%d addr=0x%"PRIx64
198
smmu_inv_notifiers_mr(const char *name) "iommu mr=%s"
199
smmu_iotlb_lookup_hit(uint16_t asid, uint16_t vmid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache HIT asid=%d vmid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d"
200
@@ -XXX,XX +XXX,XX @@ smmuv3_cmdq_cfgi_ste_range(int start, int end) "start=0x%x - end=0x%x"
201
smmuv3_cmdq_cfgi_cd(uint32_t sid) "sid=0x%x"
202
smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid=0x%x (hits=%d, misses=%d, hit rate=%d)"
203
smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid=0x%x (hits=%d, misses=%d, hit rate=%d)"
204
-smmuv3_s1_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t num_pages, uint8_t ttl, bool leaf) "vmid=%d asid=%d addr=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" ttl=%d leaf=%d"
205
+smmuv3_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t num_pages, uint8_t ttl, bool leaf) "vmid=%d asid=%d addr=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" ttl=%d leaf=%d"
206
smmuv3_cmdq_tlbi_nh(void) ""
207
smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=%d"
208
+smmuv3_cmdq_tlbi_s12_vmid(uint16_t vmid) "vmid=%d"
209
smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x"
210
smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s"
211
smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s"
378
--
212
--
379
2.17.1
213
2.34.1
380
381
diff view generated by jsdifflib
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
1
From: Mostafa Saleh <smostafa@google.com>
2
add MemTxAttrs as an argument to address_space_access_valid().
3
Its callers either have an attrs value to hand, or don't care
4
and can use MEMTXATTRS_UNSPECIFIED.
5
2
3
In smmuv3_notify_iova, read the granule based on translation stage
4
and use VMID if valid value is sent.
5
6
Signed-off-by: Mostafa Saleh <smostafa@google.com>
7
Reviewed-by: Eric Auger <eric.auger@redhat.com>
8
Tested-by: Eric Auger <eric.auger@redhat.com>
9
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
10
Message-id: 20230516203327.2051088-10-smostafa@google.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180521140402.23318-6-peter.maydell@linaro.org
10
---
12
---
11
include/exec/memory.h | 4 +++-
13
hw/arm/smmuv3.c | 39 ++++++++++++++++++++++++++-------------
12
include/sysemu/dma.h | 3 ++-
14
hw/arm/trace-events | 2 +-
13
exec.c | 3 ++-
15
2 files changed, 27 insertions(+), 14 deletions(-)
14
target/s390x/diag.c | 6 ++++--
15
target/s390x/excp_helper.c | 3 ++-
16
target/s390x/mmu_helper.c | 3 ++-
17
target/s390x/sigp.c | 3 ++-
18
7 files changed, 17 insertions(+), 8 deletions(-)
19
16
20
diff --git a/include/exec/memory.h b/include/exec/memory.h
17
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
21
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
22
--- a/include/exec/memory.h
19
--- a/hw/arm/smmuv3.c
23
+++ b/include/exec/memory.h
20
+++ b/hw/arm/smmuv3.c
24
@@ -XXX,XX +XXX,XX @@ static inline MemoryRegion *address_space_translate(AddressSpace *as,
21
@@ -XXX,XX +XXX,XX @@ epilogue:
25
* @addr: address within that address space
22
* @mr: IOMMU mr region handle
26
* @len: length of the area to be checked
23
* @n: notifier to be called
27
* @is_write: indicates the transfer direction
24
* @asid: address space ID or negative value if we don't care
28
+ * @attrs: memory attributes
25
+ * @vmid: virtual machine ID or negative value if we don't care
26
* @iova: iova
27
* @tg: translation granule (if communicated through range invalidation)
28
* @num_pages: number of @granule sized pages (if tg != 0), otherwise 1
29
*/
29
*/
30
-bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_write);
30
static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
31
+bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len,
31
IOMMUNotifier *n,
32
+ bool is_write, MemTxAttrs attrs);
32
- int asid, dma_addr_t iova,
33
33
- uint8_t tg, uint64_t num_pages)
34
/* address_space_map: map a physical memory region into a host virtual address
34
+ int asid, int vmid,
35
*
35
+ dma_addr_t iova, uint8_t tg,
36
diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
36
+ uint64_t num_pages)
37
index XXXXXXX..XXXXXXX 100644
38
--- a/include/sysemu/dma.h
39
+++ b/include/sysemu/dma.h
40
@@ -XXX,XX +XXX,XX @@ static inline bool dma_memory_valid(AddressSpace *as,
41
DMADirection dir)
42
{
37
{
43
return address_space_access_valid(as, addr, len,
38
SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
44
- dir == DMA_DIRECTION_FROM_DEVICE);
39
IOMMUTLBEvent event;
45
+ dir == DMA_DIRECTION_FROM_DEVICE,
40
uint8_t granule;
46
+ MEMTXATTRS_UNSPECIFIED);
41
+ SMMUv3State *s = sdev->smmu;
47
}
42
48
43
if (!tg) {
49
static inline int dma_memory_rw_relaxed(AddressSpace *as, dma_addr_t addr,
44
SMMUEventInfo event = {.inval_ste_allowed = true};
50
diff --git a/exec.c b/exec.c
45
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
51
index XXXXXXX..XXXXXXX 100644
52
--- a/exec.c
53
+++ b/exec.c
54
@@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
55
}
56
57
bool address_space_access_valid(AddressSpace *as, hwaddr addr,
58
- int len, bool is_write)
59
+ int len, bool is_write,
60
+ MemTxAttrs attrs)
61
{
62
FlatView *fv;
63
bool result;
64
diff --git a/target/s390x/diag.c b/target/s390x/diag.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/target/s390x/diag.c
67
+++ b/target/s390x/diag.c
68
@@ -XXX,XX +XXX,XX @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3, uintptr_t ra)
69
return;
46
return;
70
}
47
}
71
if (!address_space_access_valid(&address_space_memory, addr,
48
72
- sizeof(IplParameterBlock), false)) {
49
- tt = select_tt(cfg, iova);
73
+ sizeof(IplParameterBlock), false,
50
- if (!tt) {
74
+ MEMTXATTRS_UNSPECIFIED)) {
51
+ if (vmid >= 0 && cfg->s2cfg.vmid != vmid) {
75
s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra);
76
return;
52
return;
77
}
53
}
78
@@ -XXX,XX +XXX,XX @@ out:
54
- granule = tt->granule_sz;
79
return;
55
+
56
+ if (STAGE1_SUPPORTED(s)) {
57
+ tt = select_tt(cfg, iova);
58
+ if (!tt) {
59
+ return;
60
+ }
61
+ granule = tt->granule_sz;
62
+ } else {
63
+ granule = cfg->s2cfg.granule_sz;
64
+ }
65
+
66
} else {
67
granule = tg * 2 + 10;
68
}
69
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
70
memory_region_notify_iommu_one(n, &event);
71
}
72
73
-/* invalidate an asid/iova range tuple in all mr's */
74
-static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova,
75
- uint8_t tg, uint64_t num_pages)
76
+/* invalidate an asid/vmid/iova range tuple in all mr's */
77
+static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, int vmid,
78
+ dma_addr_t iova, uint8_t tg,
79
+ uint64_t num_pages)
80
{
81
SMMUDevice *sdev;
82
83
@@ -XXX,XX +XXX,XX @@ static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova,
84
IOMMUMemoryRegion *mr = &sdev->iommu;
85
IOMMUNotifier *n;
86
87
- trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, iova,
88
- tg, num_pages);
89
+ trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, vmid,
90
+ iova, tg, num_pages);
91
92
IOMMU_NOTIFIER_FOREACH(n, mr) {
93
- smmuv3_notify_iova(mr, n, asid, iova, tg, num_pages);
94
+ smmuv3_notify_iova(mr, n, asid, vmid, iova, tg, num_pages);
80
}
95
}
81
if (!address_space_access_valid(&address_space_memory, addr,
96
}
82
- sizeof(IplParameterBlock), true)) {
97
}
83
+ sizeof(IplParameterBlock), true,
98
@@ -XXX,XX +XXX,XX @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd)
84
+ MEMTXATTRS_UNSPECIFIED)) {
99
85
s390_program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO, ra);
100
if (!tg) {
86
return;
101
trace_smmuv3_range_inval(vmid, asid, addr, tg, 1, ttl, leaf);
87
}
102
- smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1);
88
diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c
103
+ smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, 1);
89
index XXXXXXX..XXXXXXX 100644
104
smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl);
90
--- a/target/s390x/excp_helper.c
91
+++ b/target/s390x/excp_helper.c
92
@@ -XXX,XX +XXX,XX @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, int size,
93
94
/* check out of RAM access */
95
if (!address_space_access_valid(&address_space_memory, raddr,
96
- TARGET_PAGE_SIZE, rw)) {
97
+ TARGET_PAGE_SIZE, rw,
98
+ MEMTXATTRS_UNSPECIFIED)) {
99
DPRINTF("%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__,
100
(uint64_t)raddr, (uint64_t)ram_size);
101
trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);
102
diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
103
index XXXXXXX..XXXXXXX 100644
104
--- a/target/s390x/mmu_helper.c
105
+++ b/target/s390x/mmu_helper.c
106
@@ -XXX,XX +XXX,XX @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,
107
return ret;
108
}
109
if (!address_space_access_valid(&address_space_memory, pages[i],
110
- TARGET_PAGE_SIZE, is_write)) {
111
+ TARGET_PAGE_SIZE, is_write,
112
+ MEMTXATTRS_UNSPECIFIED)) {
113
trigger_access_exception(env, PGM_ADDRESSING, ILEN_AUTO, 0);
114
return -EFAULT;
115
}
116
diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c
117
index XXXXXXX..XXXXXXX 100644
118
--- a/target/s390x/sigp.c
119
+++ b/target/s390x/sigp.c
120
@@ -XXX,XX +XXX,XX @@ static void sigp_set_prefix(CPUState *cs, run_on_cpu_data arg)
121
cpu_synchronize_state(cs);
122
123
if (!address_space_access_valid(&address_space_memory, addr,
124
- sizeof(struct LowCore), false)) {
125
+ sizeof(struct LowCore), false,
126
+ MEMTXATTRS_UNSPECIFIED)) {
127
set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER);
128
return;
105
return;
129
}
106
}
107
@@ -XXX,XX +XXX,XX @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd)
108
109
num_pages = (mask + 1) >> granule;
110
trace_smmuv3_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf);
111
- smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages);
112
+ smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, num_pages);
113
smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl);
114
addr += mask + 1;
115
}
116
diff --git a/hw/arm/trace-events b/hw/arm/trace-events
117
index XXXXXXX..XXXXXXX 100644
118
--- a/hw/arm/trace-events
119
+++ b/hw/arm/trace-events
120
@@ -XXX,XX +XXX,XX @@ smmuv3_cmdq_tlbi_s12_vmid(uint16_t vmid) "vmid=%d"
121
smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x"
122
smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s"
123
smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s"
124
-smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64
125
+smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint16_t vmid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d vmid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64
126
130
--
127
--
131
2.17.1
128
2.34.1
132
133
diff view generated by jsdifflib
1
From: Igor Mammedov <imammedo@redhat.com>
1
From: Mostafa Saleh <smostafa@google.com>
2
2
3
When QEMU is started with following CLI
3
As everything is in place, we can use a new system property to
4
-machine virt,gic-version=3,accel=kvm -cpu host -bios AAVMF_CODE.fd
4
advertise which stage is supported and remove bad_ste from STE
5
it crashes with abort at
5
stage2 config.
6
accel/kvm/kvm-all.c:2164:
7
KVM_SET_DEVICE_ATTR failed: Group 6 attr 0x000000000000c665: Invalid argument
8
6
9
Which is caused by implicit dependency of kvm_arm_gicv3_reset() on
7
The property added arm-smmuv3.stage can have 3 values:
10
arm_gicv3_icc_reset() where the later is called by CPU reset
8
- "1": Stage-1 only is advertised.
11
reset callback.
9
- "2": Stage-2 only is advertised.
12
10
13
However commit:
11
If not passed or an unsupported value is passed, it will default to
14
3b77f6c arm/boot: split load_dtb() from arm_load_kernel()
12
stage-1.
15
broke CPU reset callback registration in case
16
13
17
arm_load_kernel()
14
Advertise VMID16.
18
...
19
if (!info->kernel_filename || info->firmware_loaded)
20
15
21
branch is taken, i.e. it's sufficient to provide a firmware
16
Don't try to decode CD, if stage-2 is configured.
22
or do not provide kernel on CLI to skip cpu reset callback
23
registration, where before offending commit the callback
24
has been registered unconditionally.
25
17
26
Fix it by registering the callback right at the beginning of
27
arm_load_kernel() unconditionally instead of doing it at the end.
28
29
NOTE:
30
we probably should eliminate that dependency anyways as well as
31
separate arch CPU reset parts from arm_load_kernel() into CPU
32
itself, but that refactoring that I probably would have to do
33
anyways later for CPU hotplug to work.
34
35
Reported-by: Auger Eric <eric.auger@redhat.com>
36
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
37
Reviewed-by: Eric Auger <eric.auger@redhat.com>
18
Reviewed-by: Eric Auger <eric.auger@redhat.com>
19
Signed-off-by: Mostafa Saleh <smostafa@google.com>
38
Tested-by: Eric Auger <eric.auger@redhat.com>
20
Tested-by: Eric Auger <eric.auger@redhat.com>
39
Message-id: 1527070950-208350-1-git-send-email-imammedo@redhat.com
21
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
40
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
22
Message-id: 20230516203327.2051088-11-smostafa@google.com
41
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
42
---
24
---
43
hw/arm/boot.c | 18 +++++++++---------
25
include/hw/arm/smmuv3.h | 1 +
44
1 file changed, 9 insertions(+), 9 deletions(-)
26
hw/arm/smmuv3.c | 32 ++++++++++++++++++++++----------
27
2 files changed, 23 insertions(+), 10 deletions(-)
45
28
46
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
29
diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h
47
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
48
--- a/hw/arm/boot.c
31
--- a/include/hw/arm/smmuv3.h
49
+++ b/hw/arm/boot.c
32
+++ b/include/hw/arm/smmuv3.h
50
@@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
33
@@ -XXX,XX +XXX,XX @@ struct SMMUv3State {
51
static const ARMInsnFixup *primary_loader;
34
52
AddressSpace *as = arm_boot_address_space(cpu, info);
35
qemu_irq irq[4];
53
36
QemuMutex mutex;
54
+ /* CPU objects (unlike devices) are not automatically reset on system
37
+ char *stage;
55
+ * reset, so we must always register a handler to do so. If we're
38
};
56
+ * actually loading a kernel, the handler is also responsible for
39
57
+ * arranging that we start it correctly.
40
typedef enum {
58
+ */
41
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
59
+ for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) {
42
index XXXXXXX..XXXXXXX 100644
60
+ qemu_register_reset(do_cpu_reset, ARM_CPU(cs));
43
--- a/hw/arm/smmuv3.c
44
+++ b/hw/arm/smmuv3.c
45
@@ -XXX,XX +XXX,XX @@
46
#include "hw/irq.h"
47
#include "hw/sysbus.h"
48
#include "migration/vmstate.h"
49
+#include "hw/qdev-properties.h"
50
#include "hw/qdev-core.h"
51
#include "hw/pci/pci.h"
52
#include "cpu.h"
53
@@ -XXX,XX +XXX,XX @@ void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *info)
54
55
static void smmuv3_init_regs(SMMUv3State *s)
56
{
57
- /**
58
- * IDR0: stage1 only, AArch64 only, coherent access, 16b ASID,
59
- * multi-level stream table
60
- */
61
- s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1); /* stage 1 supported */
62
+ /* Based on sys property, the stages supported in smmu will be advertised.*/
63
+ if (s->stage && !strcmp("2", s->stage)) {
64
+ s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S2P, 1);
65
+ } else {
66
+ s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1);
61
+ }
67
+ }
62
+
68
+
63
/* The board code is not supposed to set secure_board_setup unless
69
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, TTF, 2); /* AArch64 PTW only */
64
* running its code in secure mode is actually possible, and KVM
70
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, COHACC, 1); /* IO coherent */
65
* doesn't support secure.
71
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, ASID16, 1); /* 16-bit ASID */
66
@@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
72
+ s->idr[0] = FIELD_DP32(s->idr[0], IDR0, VMID16, 1); /* 16-bit VMID */
67
ARM_CPU(cs)->env.boot_info = info;
73
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, TTENDIAN, 2); /* little endian */
74
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, STALL_MODEL, 1); /* No stall */
75
/* terminated transaction will always be aborted/error returned */
76
@@ -XXX,XX +XXX,XX @@ static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *ste)
77
goto bad_ste;
68
}
78
}
69
79
70
- /* CPU objects (unlike devices) are not automatically reset on system
80
- /* This is still here as stage 2 has not been fully enabled yet. */
71
- * reset, so we must always register a handler to do so. If we're
81
- qemu_log_mask(LOG_UNIMP, "SMMUv3 does not support stage 2 yet\n");
72
- * actually loading a kernel, the handler is also responsible for
82
- goto bad_ste;
73
- * arranging that we start it correctly.
74
- */
75
- for (cs = first_cpu; cs; cs = CPU_NEXT(cs)) {
76
- qemu_register_reset(do_cpu_reset, ARM_CPU(cs));
77
- }
78
-
83
-
79
if (!info->skip_dtb_autoload && have_dtb(info)) {
84
return 0;
80
if (arm_load_dtb(info->dtb_start, info, info->dtb_limit, as) < 0) {
85
81
exit(1);
86
bad_ste:
87
@@ -XXX,XX +XXX,XX @@ static int smmuv3_decode_config(IOMMUMemoryRegion *mr, SMMUTransCfg *cfg,
88
return ret;
89
}
90
91
- if (cfg->aborted || cfg->bypassed) {
92
+ if (cfg->aborted || cfg->bypassed || (cfg->stage == 2)) {
93
return 0;
94
}
95
96
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3 = {
97
}
98
};
99
100
+static Property smmuv3_properties[] = {
101
+ /*
102
+ * Stages of translation advertised.
103
+ * "1": Stage 1
104
+ * "2": Stage 2
105
+ * Defaults to stage 1
106
+ */
107
+ DEFINE_PROP_STRING("stage", SMMUv3State, stage),
108
+ DEFINE_PROP_END_OF_LIST()
109
+};
110
+
111
static void smmuv3_instance_init(Object *obj)
112
{
113
/* Nothing much to do here as of now */
114
@@ -XXX,XX +XXX,XX @@ static void smmuv3_class_init(ObjectClass *klass, void *data)
115
&c->parent_phases);
116
c->parent_realize = dc->realize;
117
dc->realize = smmu_realize;
118
+ device_class_set_props(dc, smmuv3_properties);
119
}
120
121
static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
82
--
122
--
83
2.17.1
123
2.34.1
84
85
diff view generated by jsdifflib
1
From: Shannon Zhao <zhaoshenglong@huawei.com>
1
From: Tommy Wu <tommy.wu@sifive.com>
2
2
3
acpi_data_push uses g_array_set_size to resize the memory size. If there
3
When we receive a packet from the xilinx_axienet and then try to s2mem
4
is no enough contiguous memory, the address will be changed. So previous
4
through the xilinx_axidma, if the descriptor ring buffer is full in the
5
pointer could not be used any more. It must update the pointer and use
5
xilinx axidma driver, we’ll assert the DMASR.HALTED in the
6
the new one.
6
function : stream_process_s2mem and return 0. In the end, we’ll be stuck in
7
an infinite loop in axienet_eth_rx_notify.
7
8
8
Also, previous codes wrongly use le32 conversion of iort->node_offset
9
This patch checks the DMASR.HALTED state when we try to push data
9
for subsequent computations that will result incorrect value if host is
10
from xilinx axi-enet to xilinx axi-dma. When the DMASR.HALTED is asserted,
10
not litlle endian. So use the non-converted one instead.
11
we will not keep pushing the data and then prevent the infinte loop.
11
12
12
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
13
Signed-off-by: Tommy Wu <tommy.wu@sifive.com>
13
Reviewed-by: Eric Auger <eric.auger@redhat.com>
14
Reviewed-by: Edgar E. Iglesias <edgar@zeroasic.com>
14
Message-id: 1527663951-14552-1-git-send-email-zhaoshenglong@huawei.com
15
Reviewed-by: Frank Chang <frank.chang@sifive.com>
16
Message-id: 20230519062137.1251741-1-tommy.wu@sifive.com
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
18
---
17
hw/arm/virt-acpi-build.c | 20 +++++++++++++++-----
19
hw/dma/xilinx_axidma.c | 11 ++++++++---
18
1 file changed, 15 insertions(+), 5 deletions(-)
20
1 file changed, 8 insertions(+), 3 deletions(-)
19
21
20
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
22
diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
21
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/virt-acpi-build.c
24
--- a/hw/dma/xilinx_axidma.c
23
+++ b/hw/arm/virt-acpi-build.c
25
+++ b/hw/dma/xilinx_axidma.c
24
@@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
26
@@ -XXX,XX +XXX,XX @@ static inline int stream_idle(struct Stream *s)
25
AcpiIortItsGroup *its;
27
return !!(s->regs[R_DMASR] & DMASR_IDLE);
26
AcpiIortTable *iort;
28
}
27
AcpiIortSmmu3 *smmu;
29
28
- size_t node_size, iort_length, smmu_offset = 0;
30
+static inline int stream_halted(struct Stream *s)
29
+ size_t node_size, iort_node_offset, iort_length, smmu_offset = 0;
31
+{
30
AcpiIortRC *rc;
32
+ return !!(s->regs[R_DMASR] & DMASR_HALTED);
31
33
+}
32
iort = acpi_data_push(table_data, sizeof(*iort));
34
+
33
@@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
35
static void stream_reset(struct Stream *s)
34
36
{
35
iort_length = sizeof(*iort);
37
s->regs[R_DMASR] = DMASR_HALTED; /* starts up halted. */
36
iort->node_count = cpu_to_le32(nb_nodes);
38
@@ -XXX,XX +XXX,XX @@ static void stream_process_mem2s(struct Stream *s, StreamSink *tx_data_dev,
37
- iort->node_offset = cpu_to_le32(sizeof(*iort));
39
uint64_t addr;
38
+ /*
40
bool eop;
39
+ * Use a copy in case table_data->data moves during acpi_data_push
41
40
+ * operations.
42
- if (!stream_running(s) || stream_idle(s)) {
41
+ */
43
+ if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
42
+ iort_node_offset = sizeof(*iort);
44
return;
43
+ iort->node_offset = cpu_to_le32(iort_node_offset);
44
45
/* ITS group node */
46
node_size = sizeof(*its) + sizeof(uint32_t);
47
@@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
48
int irq = vms->irqmap[VIRT_SMMU];
49
50
/* SMMUv3 node */
51
- smmu_offset = iort->node_offset + node_size;
52
+ smmu_offset = iort_node_offset + node_size;
53
node_size = sizeof(*smmu) + sizeof(*idmap);
54
iort_length += node_size;
55
smmu = acpi_data_push(table_data, node_size);
56
@@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
57
idmap->id_count = cpu_to_le32(0xFFFF);
58
idmap->output_base = 0;
59
/* output IORT node is the ITS group node (the first node) */
60
- idmap->output_reference = cpu_to_le32(iort->node_offset);
61
+ idmap->output_reference = cpu_to_le32(iort_node_offset);
62
}
45
}
63
46
64
/* Root Complex Node */
47
@@ -XXX,XX +XXX,XX @@ static size_t stream_process_s2mem(struct Stream *s, unsigned char *buf,
65
@@ -XXX,XX +XXX,XX @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
48
unsigned int rxlen;
66
idmap->output_reference = cpu_to_le32(smmu_offset);
49
size_t pos = 0;
67
} else {
50
68
/* output IORT node is the ITS group node (the first node) */
51
- if (!stream_running(s) || stream_idle(s)) {
69
- idmap->output_reference = cpu_to_le32(iort->node_offset);
52
+ if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
70
+ idmap->output_reference = cpu_to_le32(iort_node_offset);
53
return 0;
71
}
54
}
72
55
73
+ /*
56
@@ -XXX,XX +XXX,XX @@ xilinx_axidma_data_stream_can_push(StreamSink *obj,
74
+ * Update the pointer address in case table_data->data moves during above
57
XilinxAXIDMAStreamSink *ds = XILINX_AXI_DMA_DATA_STREAM(obj);
75
+ * acpi_data_push operations.
58
struct Stream *s = &ds->dma->streams[1];
76
+ */
59
77
+ iort = (AcpiIortTable *)(table_data->data + iort_start);
60
- if (!stream_running(s) || stream_idle(s)) {
78
iort->length = cpu_to_le32(iort_length);
61
+ if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
79
62
ds->dma->notify = notify;
80
build_header(linker, table_data, (void *)(table_data->data + iort_start),
63
ds->dma->notify_opaque = notify_opaque;
64
return false;
81
--
65
--
82
2.17.1
66
2.34.1
83
67
84
68
diff view generated by jsdifflib
1
From: Shannon Zhao <zhaoshenglong@huawei.com>
1
From: Clément Chigot <chigot@adacore.com>
2
2
3
kvm_irqchip_create called by kvm_init will call kvm_init_irq_routing to
3
When passing --smp with a number lower than XLNX_ZYNQMP_NUM_APU_CPUS,
4
initialize global capability variables. If we call kvm_init_irq_routing in
4
the expression (ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS) will result
5
GIC realize function, previous allocated memory will leak.
5
in a positive number as ms->smp.cpus is a unsigned int.
6
This will raise the following error afterwards, as Qemu will try to
7
instantiate some additional RPUs.
8
| $ qemu-system-aarch64 --smp 1 -M xlnx-zcu102
9
| **
10
| ERROR:../src/tcg/tcg.c:777:tcg_register_thread:
11
| assertion failed: (n < tcg_max_ctxs)
6
12
7
Fix this by deleting the unnecessary call.
13
Signed-off-by: Clément Chigot <chigot@adacore.com>
8
14
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
9
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
15
Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com>
10
Reviewed-by: Eric Auger <eric.auger@redhat.com>
16
Message-id: 20230524143714.565792-1-chigot@adacore.com
11
Message-id: 1527750994-14360-1-git-send-email-zhaoshenglong@huawei.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
18
---
14
hw/intc/arm_gic_kvm.c | 1 -
19
hw/arm/xlnx-zynqmp.c | 2 +-
15
hw/intc/arm_gicv3_kvm.c | 1 -
20
1 file changed, 1 insertion(+), 1 deletion(-)
16
2 files changed, 2 deletions(-)
17
21
18
diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c
22
diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
19
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/intc/arm_gic_kvm.c
24
--- a/hw/arm/xlnx-zynqmp.c
21
+++ b/hw/intc/arm_gic_kvm.c
25
+++ b/hw/arm/xlnx-zynqmp.c
22
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp)
26
@@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,
23
27
const char *boot_cpu, Error **errp)
24
if (kvm_has_gsi_routing()) {
28
{
25
/* set up irq routing */
29
int i;
26
- kvm_init_irq_routing(kvm_state);
30
- int num_rpus = MIN(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS,
27
for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) {
31
+ int num_rpus = MIN((int)(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS),
28
kvm_irqchip_add_irq_route(kvm_state, i, 0, i);
32
XLNX_ZYNQMP_NUM_RPU_CPUS);
29
}
33
30
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
34
if (num_rpus <= 0) {
31
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/intc/arm_gicv3_kvm.c
33
+++ b/hw/intc/arm_gicv3_kvm.c
34
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
35
36
if (kvm_has_gsi_routing()) {
37
/* set up irq routing */
38
- kvm_init_irq_routing(kvm_state);
39
for (i = 0; i < s->num_irq - GIC_INTERNAL; ++i) {
40
kvm_irqchip_add_irq_route(kvm_state, i, 0, i);
41
}
42
--
35
--
43
2.17.1
36
2.34.1
44
37
45
38
diff view generated by jsdifflib
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
1
From: Thomas Huth <thuth@redhat.com>
2
add MemTxAttrs as an argument to address_space_get_iotlb_entry().
3
2
3
pflash-cfi02-test.c always uses the "musicpal" machine for testing,
4
test-arm-mptimer.c always uses the "vexpress-a9" machine, and
5
microbit-test.c requires the "microbit" machine, so we should only
6
run these tests if the machines have been enabled in the configuration.
7
8
Signed-off-by: Thomas Huth <thuth@redhat.com>
9
Reviewed-by: Fabiano Rosas <farosas@suse.de>
10
Message-id: 20230524080600.1618137-1-thuth@redhat.com
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180521140402.23318-12-peter.maydell@linaro.org
8
---
12
---
9
include/exec/memory.h | 2 +-
13
tests/qtest/meson.build | 7 ++++---
10
exec.c | 2 +-
14
1 file changed, 4 insertions(+), 3 deletions(-)
11
hw/virtio/vhost.c | 3 ++-
12
3 files changed, 4 insertions(+), 3 deletions(-)
13
15
14
diff --git a/include/exec/memory.h b/include/exec/memory.h
16
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/include/exec/memory.h
18
--- a/tests/qtest/meson.build
17
+++ b/include/exec/memory.h
19
+++ b/tests/qtest/meson.build
18
@@ -XXX,XX +XXX,XX @@ void address_space_cache_destroy(MemoryRegionCache *cache);
20
@@ -XXX,XX +XXX,XX @@ qtests_arm = \
19
* entry. Should be called from an RCU critical section.
21
(config_all_devices.has_key('CONFIG_CMSDK_APB_DUALTIMER') ? ['cmsdk-apb-dualtimer-test'] : []) + \
20
*/
22
(config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \
21
IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
23
(config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \
22
- bool is_write);
24
- (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \
23
+ bool is_write, MemTxAttrs attrs);
25
+ (config_all_devices.has_key('CONFIG_PFLASH_CFI02') and
24
26
+ config_all_devices.has_key('CONFIG_MUSICPAL') ? ['pflash-cfi02-test'] : []) + \
25
/* address_space_translate: translate an address range into an address space
27
(config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed : []) + \
26
* into a MemoryRegion and an address range into that section. Should be
28
(config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \
27
diff --git a/exec.c b/exec.c
29
(config_all_devices.has_key('CONFIG_GENERIC_LOADER') ? ['hexloader-test'] : []) + \
28
index XXXXXXX..XXXXXXX 100644
30
(config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \
29
--- a/exec.c
31
+ (config_all_devices.has_key('CONFIG_VEXPRESS') ? ['test-arm-mptimer'] : []) + \
30
+++ b/exec.c
32
+ (config_all_devices.has_key('CONFIG_MICROBIT') ? ['microbit-test'] : []) + \
31
@@ -XXX,XX +XXX,XX @@ static MemoryRegionSection flatview_do_translate(FlatView *fv,
33
['arm-cpu-features',
32
34
- 'microbit-test',
33
/* Called from RCU critical section */
35
- 'test-arm-mptimer',
34
IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
36
'boot-serial-test']
35
- bool is_write)
37
36
+ bool is_write, MemTxAttrs attrs)
38
# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
37
{
38
MemoryRegionSection section;
39
hwaddr xlat, page_mask;
40
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/virtio/vhost.c
43
+++ b/hw/virtio/vhost.c
44
@@ -XXX,XX +XXX,XX @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write)
45
trace_vhost_iotlb_miss(dev, 1);
46
47
iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as,
48
- iova, write);
49
+ iova, write,
50
+ MEMTXATTRS_UNSPECIFIED);
51
if (iotlb.target_as != NULL) {
52
ret = vhost_memory_region_lookup(dev, iotlb.translated_addr,
53
&uaddr, &len);
54
--
39
--
55
2.17.1
40
2.34.1
56
57
diff view generated by jsdifflib
1
Add more detail to the documentation for memory_region_init_iommu()
1
For M-profile, there is no guest-facing A-profile format FSR, but we
2
and other IOMMU-related functions and data structures.
2
still use the env->exception.fsr field to pass fault information from
3
the point where a fault is raised to the code in
4
arm_v7m_cpu_do_interrupt() which interprets it and sets the M-profile
5
specific fault status registers. So it doesn't matter whether we
6
fill in env->exception.fsr in the short format or the LPAE format, as
7
long as both sides agree. As it happens arm_v7m_cpu_do_interrupt()
8
assumes short-form.
3
9
10
In compute_fsr_fsc() we weren't explicitly choosing short-form for
11
M-profile, but instead relied on it falling out in the wash because
12
arm_s1_regime_using_lpae_format() would be false. This was broken in
13
commit 452c67a4 when we added v8R support, because we said "PMSAv8 is
14
always LPAE format" (as it is for v8R), forgetting that we were
15
implicitly using this code path on M-profile. At that point we would
16
hit a g_assert_not_reached():
17
ERROR:../../target/arm/internals.h:549:arm_fi_to_lfsc: code should not be reached
18
19
#7 0x0000555555e055f7 in arm_fi_to_lfsc (fi=0x7fffecff9a90) at ../../target/arm/internals.h:549
20
#8 0x0000555555e05a27 in compute_fsr_fsc (env=0x555557356670, fi=0x7fffecff9a90, target_el=1, mmu_idx=1, ret_fsc=0x7fffecff9a1c)
21
at ../../target/arm/tlb_helper.c:95
22
#9 0x0000555555e05b62 in arm_deliver_fault (cpu=0x555557354800, addr=268961344, access_type=MMU_INST_FETCH, mmu_idx=1, fi=0x7fffecff9a90)
23
at ../../target/arm/tlb_helper.c:132
24
#10 0x0000555555e06095 in arm_cpu_tlb_fill (cs=0x555557354800, address=268961344, size=1, access_type=MMU_INST_FETCH, mmu_idx=1, probe=false, retaddr=0)
25
at ../../target/arm/tlb_helper.c:260
26
27
The specific assertion changed when commit fcc7404eff24b4c added
28
"assert not M-profile" to arm_is_secure_below_el3(), because the
29
conditions being checked in compute_fsr_fsc() include
30
arm_el_is_aa64(), which will end up calling arm_is_secure_below_el3()
31
and asserting before we try to call arm_fi_to_lfsc():
32
33
#7 0x0000555555efaf43 in arm_is_secure_below_el3 (env=0x5555574665a0) at ../../target/arm/cpu.h:2396
34
#8 0x0000555555efb103 in arm_is_el2_enabled (env=0x5555574665a0) at ../../target/arm/cpu.h:2448
35
#9 0x0000555555efb204 in arm_el_is_aa64 (env=0x5555574665a0, el=1) at ../../target/arm/cpu.h:2509
36
#10 0x0000555555efbdfd in compute_fsr_fsc (env=0x5555574665a0, fi=0x7fffecff99e0, target_el=1, mmu_idx=1, ret_fsc=0x7fffecff996c)
37
38
Avoid the assertion and the incorrect FSR format selection by
39
explicitly making M-profile use the short-format in this function.
40
41
Fixes: 452c67a42704 ("target/arm: Enable TTBCR_EAE for ARMv8-R AArch32")a
42
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1658
43
Cc: qemu-stable@nongnu.org
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
44
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
45
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
46
Message-id: 20230523131726.866635-1-peter.maydell@linaro.org
7
Reviewed-by: Eric Auger <eric.auger@redhat.com>
8
Message-id: 20180521140402.23318-2-peter.maydell@linaro.org
9
---
47
---
10
include/exec/memory.h | 105 ++++++++++++++++++++++++++++++++++++++----
48
target/arm/tcg/tlb_helper.c | 13 +++++++++++--
11
1 file changed, 95 insertions(+), 10 deletions(-)
49
1 file changed, 11 insertions(+), 2 deletions(-)
12
50
13
diff --git a/include/exec/memory.h b/include/exec/memory.h
51
diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c
14
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
15
--- a/include/exec/memory.h
53
--- a/target/arm/tcg/tlb_helper.c
16
+++ b/include/exec/memory.h
54
+++ b/target/arm/tcg/tlb_helper.c
17
@@ -XXX,XX +XXX,XX @@ enum IOMMUMemoryRegionAttr {
55
@@ -XXX,XX +XXX,XX @@ static uint32_t compute_fsr_fsc(CPUARMState *env, ARMMMUFaultInfo *fi,
18
IOMMU_ATTR_SPAPR_TCE_FD
56
ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx);
19
};
57
uint32_t fsr, fsc;
20
58
21
+/**
59
- if (target_el == 2 || arm_el_is_aa64(env, target_el) ||
22
+ * IOMMUMemoryRegionClass:
60
- arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) {
23
+ *
61
+ /*
24
+ * All IOMMU implementations need to subclass TYPE_IOMMU_MEMORY_REGION
62
+ * For M-profile there is no guest-facing FSR. We compute a
25
+ * and provide an implementation of at least the @translate method here
63
+ * short-form value for env->exception.fsr which we will then
26
+ * to handle requests to the memory region. Other methods are optional.
64
+ * examine in arm_v7m_cpu_do_interrupt(). In theory we could
27
+ *
65
+ * use the LPAE format instead as long as both bits of code agree
28
+ * The IOMMU implementation must use the IOMMU notifier infrastructure
66
+ * (and arm_fi_to_lfsc() handled the M-profile specific
29
+ * to report whenever mappings are changed, by calling
67
+ * ARMFault_QEMU_NSCExec and ARMFault_QEMU_SFault cases).
30
+ * memory_region_notify_iommu() (or, if necessary, by calling
31
+ * memory_region_notify_one() for each registered notifier).
32
+ */
33
typedef struct IOMMUMemoryRegionClass {
34
/* private */
35
struct DeviceClass parent_class;
36
37
/*
38
- * Return a TLB entry that contains a given address. Flag should
39
- * be the access permission of this translation operation. We can
40
- * set flag to IOMMU_NONE to mean that we don't need any
41
- * read/write permission checks, like, when for region replay.
42
+ * Return a TLB entry that contains a given address.
43
+ *
44
+ * The IOMMUAccessFlags indicated via @flag are optional and may
45
+ * be specified as IOMMU_NONE to indicate that the caller needs
46
+ * the full translation information for both reads and writes. If
47
+ * the access flags are specified then the IOMMU implementation
48
+ * may use this as an optimization, to stop doing a page table
49
+ * walk as soon as it knows that the requested permissions are not
50
+ * allowed. If IOMMU_NONE is passed then the IOMMU must do the
51
+ * full page table walk and report the permissions in the returned
52
+ * IOMMUTLBEntry. (Note that this implies that an IOMMU may not
53
+ * return different mappings for reads and writes.)
54
+ *
55
+ * The returned information remains valid while the caller is
56
+ * holding the big QEMU lock or is inside an RCU critical section;
57
+ * if the caller wishes to cache the mapping beyond that it must
58
+ * register an IOMMU notifier so it can invalidate its cached
59
+ * information when the IOMMU mapping changes.
60
+ *
61
+ * @iommu: the IOMMUMemoryRegion
62
+ * @hwaddr: address to be translated within the memory region
63
+ * @flag: requested access permissions
64
*/
65
IOMMUTLBEntry (*translate)(IOMMUMemoryRegion *iommu, hwaddr addr,
66
IOMMUAccessFlags flag);
67
- /* Returns minimum supported page size */
68
+ /* Returns minimum supported page size in bytes.
69
+ * If this method is not provided then the minimum is assumed to
70
+ * be TARGET_PAGE_SIZE.
71
+ *
72
+ * @iommu: the IOMMUMemoryRegion
73
+ */
68
+ */
74
uint64_t (*get_min_page_size)(IOMMUMemoryRegion *iommu);
69
+ if (!arm_feature(env, ARM_FEATURE_M) &&
75
- /* Called when IOMMU Notifier flag changed */
70
+ (target_el == 2 || arm_el_is_aa64(env, target_el) ||
76
+ /* Called when IOMMU Notifier flag changes (ie when the set of
71
+ arm_s1_regime_using_lpae_format(env, arm_mmu_idx))) {
77
+ * events which IOMMU users are requesting notification for changes).
72
/*
78
+ * Optional method -- need not be provided if the IOMMU does not
73
* LPAE format fault status register : bottom 6 bits are
79
+ * need to know exactly which events must be notified.
74
* status code in the same form as needed for syndrome
80
+ *
81
+ * @iommu: the IOMMUMemoryRegion
82
+ * @old_flags: events which previously needed to be notified
83
+ * @new_flags: events which now need to be notified
84
+ */
85
void (*notify_flag_changed)(IOMMUMemoryRegion *iommu,
86
IOMMUNotifierFlag old_flags,
87
IOMMUNotifierFlag new_flags);
88
- /* Set this up to provide customized IOMMU replay function */
89
+ /* Called to handle memory_region_iommu_replay().
90
+ *
91
+ * The default implementation of memory_region_iommu_replay() is to
92
+ * call the IOMMU translate method for every page in the address space
93
+ * with flag == IOMMU_NONE and then call the notifier if translate
94
+ * returns a valid mapping. If this method is implemented then it
95
+ * overrides the default behaviour, and must provide the full semantics
96
+ * of memory_region_iommu_replay(), by calling @notifier for every
97
+ * translation present in the IOMMU.
98
+ *
99
+ * Optional method -- an IOMMU only needs to provide this method
100
+ * if the default is inefficient or produces undesirable side effects.
101
+ *
102
+ * Note: this is not related to record-and-replay functionality.
103
+ */
104
void (*replay)(IOMMUMemoryRegion *iommu, IOMMUNotifier *notifier);
105
106
- /* Get IOMMU misc attributes */
107
- int (*get_attr)(IOMMUMemoryRegion *iommu, enum IOMMUMemoryRegionAttr,
108
+ /* Get IOMMU misc attributes. This is an optional method that
109
+ * can be used to allow users of the IOMMU to get implementation-specific
110
+ * information. The IOMMU implements this method to handle calls
111
+ * by IOMMU users to memory_region_iommu_get_attr() by filling in
112
+ * the arbitrary data pointer for any IOMMUMemoryRegionAttr values that
113
+ * the IOMMU supports. If the method is unimplemented then
114
+ * memory_region_iommu_get_attr() will always return -EINVAL.
115
+ *
116
+ * @iommu: the IOMMUMemoryRegion
117
+ * @attr: attribute being queried
118
+ * @data: memory to fill in with the attribute data
119
+ *
120
+ * Returns 0 on success, or a negative errno; in particular
121
+ * returns -EINVAL for unrecognized or unimplemented attribute types.
122
+ */
123
+ int (*get_attr)(IOMMUMemoryRegion *iommu, enum IOMMUMemoryRegionAttr attr,
124
void *data);
125
} IOMMUMemoryRegionClass;
126
127
@@ -XXX,XX +XXX,XX @@ static inline void memory_region_init_reservation(MemoryRegion *mr,
128
* An IOMMU region translates addresses and forwards accesses to a target
129
* memory region.
130
*
131
+ * The IOMMU implementation must define a subclass of TYPE_IOMMU_MEMORY_REGION.
132
+ * @_iommu_mr should be a pointer to enough memory for an instance of
133
+ * that subclass, @instance_size is the size of that subclass, and
134
+ * @mrtypename is its name. This function will initialize @_iommu_mr as an
135
+ * instance of the subclass, and its methods will then be called to handle
136
+ * accesses to the memory region. See the documentation of
137
+ * #IOMMUMemoryRegionClass for further details.
138
+ *
139
* @_iommu_mr: the #IOMMUMemoryRegion to be initialized
140
* @instance_size: the IOMMUMemoryRegion subclass instance size
141
* @mrtypename: the type name of the #IOMMUMemoryRegion
142
@@ -XXX,XX +XXX,XX @@ void memory_region_register_iommu_notifier(MemoryRegion *mr,
143
* a notifier with the minimum page granularity returned by
144
* mr->iommu_ops->get_page_size().
145
*
146
+ * Note: this is not related to record-and-replay functionality.
147
+ *
148
* @iommu_mr: the memory region to observe
149
* @n: the notifier to which to replay iommu mappings
150
*/
151
@@ -XXX,XX +XXX,XX @@ void memory_region_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n);
152
* memory_region_iommu_replay_all: replay existing IOMMU translations
153
* to all the notifiers registered.
154
*
155
+ * Note: this is not related to record-and-replay functionality.
156
+ *
157
* @iommu_mr: the memory region to observe
158
*/
159
void memory_region_iommu_replay_all(IOMMUMemoryRegion *iommu_mr);
160
@@ -XXX,XX +XXX,XX @@ void memory_region_unregister_iommu_notifier(MemoryRegion *mr,
161
* memory_region_iommu_get_attr: return an IOMMU attr if get_attr() is
162
* defined on the IOMMU.
163
*
164
- * Returns 0 if succeded, error code otherwise.
165
+ * Returns 0 on success, or a negative errno otherwise. In particular,
166
+ * -EINVAL indicates that the IOMMU does not support the requested
167
+ * attribute.
168
*
169
* @iommu_mr: the memory region
170
* @attr: the requested attribute
171
--
75
--
172
2.17.1
76
2.34.1
173
174
diff view generated by jsdifflib
1
Provide a VMSTATE_BOOL_SUB_ARRAY to go with VMSTATE_UINT8_SUB_ARRAY
1
From: Fabiano Rosas <farosas@suse.de>
2
and friends.
3
2
3
We currently need to select ARM_V7M unconditionally when TCG is
4
present in the build because some translate.c helpers and the whole of
5
m_helpers.c are not yet under CONFIG_ARM_V7M.
6
7
Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Signed-off-by: Fabiano Rosas <farosas@suse.de>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Message-id: 20230523180525.29994-2-farosas@suse.de
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Message-id: 20180521140402.23318-23-peter.maydell@linaro.org
7
---
12
---
8
include/migration/vmstate.h | 3 +++
13
target/arm/Kconfig | 3 +++
9
1 file changed, 3 insertions(+)
14
1 file changed, 3 insertions(+)
10
15
11
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
16
diff --git a/target/arm/Kconfig b/target/arm/Kconfig
12
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
13
--- a/include/migration/vmstate.h
18
--- a/target/arm/Kconfig
14
+++ b/include/migration/vmstate.h
19
+++ b/target/arm/Kconfig
15
@@ -XXX,XX +XXX,XX @@ extern const VMStateInfo vmstate_info_qtailq;
20
@@ -XXX,XX +XXX,XX @@
16
#define VMSTATE_BOOL_ARRAY(_f, _s, _n) \
21
config ARM
17
VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0)
22
bool
18
23
select ARM_COMPATIBLE_SEMIHOSTING if TCG
19
+#define VMSTATE_BOOL_SUB_ARRAY(_f, _s, _start, _num) \
20
+ VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_bool, bool)
21
+
24
+
22
#define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \
25
+ # We need to select this until we move m_helper.c and the
23
VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t)
26
+ # translate.c v7m helpers under ARM_V7M.
24
27
select ARM_V7M if TCG
28
29
config AARCH64
25
--
30
--
26
2.17.1
31
2.34.1
27
32
28
33
diff view generated by jsdifflib
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
1
From: Fabiano Rosas <farosas@suse.de>
2
add MemTxAttrs as an argument to memory_region_access_valid().
3
Its callers either have an attrs value to hand, or don't care
4
and can use MEMTXATTRS_UNSPECIFIED.
5
2
6
The callsite in flatview_access_valid() is part of a recursive
3
When we moved the arm default CONFIGs into Kconfig and removed them
7
loop flatview_access_valid() -> memory_region_access_valid() ->
4
from default.mak, we made it harder to identify which CONFIGs are
8
subpage_accepts() -> flatview_access_valid(); we make it pass
5
selected by default in case users want to disable them.
9
MEMTXATTRS_UNSPECIFIED for now, until the next several commits
10
have plumbed an attrs parameter through the rest of the loop
11
and we can add an attrs parameter to flatview_access_valid().
12
6
7
Bring back the default entries into default.mak, but keep them
8
commented out. This way users can keep their workflows of editing
9
default.mak to remove build options without needing to search through
10
Kconfig.
11
12
Reported-by: Thomas Huth <thuth@redhat.com>
13
Signed-off-by: Fabiano Rosas <farosas@suse.de>
14
Reviewed-by: Thomas Huth <thuth@redhat.com>
15
Message-id: 20230523180525.29994-3-farosas@suse.de
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Message-id: 20180521140402.23318-8-peter.maydell@linaro.org
17
---
17
---
18
include/exec/memory-internal.h | 3 ++-
18
configs/devices/aarch64-softmmu/default.mak | 6 ++++
19
exec.c | 4 +++-
19
configs/devices/arm-softmmu/default.mak | 40 +++++++++++++++++++++
20
hw/s390x/s390-pci-inst.c | 3 ++-
20
2 files changed, 46 insertions(+)
21
memory.c | 7 ++++---
22
4 files changed, 11 insertions(+), 6 deletions(-)
23
21
24
diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h
22
diff --git a/configs/devices/aarch64-softmmu/default.mak b/configs/devices/aarch64-softmmu/default.mak
25
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
26
--- a/include/exec/memory-internal.h
24
--- a/configs/devices/aarch64-softmmu/default.mak
27
+++ b/include/exec/memory-internal.h
25
+++ b/configs/devices/aarch64-softmmu/default.mak
28
@@ -XXX,XX +XXX,XX @@ void flatview_unref(FlatView *view);
26
@@ -XXX,XX +XXX,XX @@
29
extern const MemoryRegionOps unassigned_mem_ops;
27
30
28
# We support all the 32 bit boards so need all their config
31
bool memory_region_access_valid(MemoryRegion *mr, hwaddr addr,
29
include ../arm-softmmu/default.mak
32
- unsigned size, bool is_write);
30
+
33
+ unsigned size, bool is_write,
31
+# These are selected by default when TCG is enabled, uncomment them to
34
+ MemTxAttrs attrs);
32
+# keep out of the build.
35
33
+# CONFIG_XLNX_ZYNQMP_ARM=n
36
void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section);
34
+# CONFIG_XLNX_VERSAL=n
37
AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv);
35
+# CONFIG_SBSA_REF=n
38
diff --git a/exec.c b/exec.c
36
diff --git a/configs/devices/arm-softmmu/default.mak b/configs/devices/arm-softmmu/default.mak
39
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
40
--- a/exec.c
38
--- a/configs/devices/arm-softmmu/default.mak
41
+++ b/exec.c
39
+++ b/configs/devices/arm-softmmu/default.mak
42
@@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
40
@@ -XXX,XX +XXX,XX @@
43
mr = flatview_translate(fv, addr, &xlat, &l, is_write);
41
# CONFIG_TEST_DEVICES=n
44
if (!memory_access_is_direct(mr, is_write)) {
42
45
l = memory_access_size(mr, l, addr);
43
CONFIG_ARM_VIRT=y
46
- if (!memory_region_access_valid(mr, xlat, l, is_write)) {
44
+
47
+ /* When our callers all have attrs we'll pass them through here */
45
+# These are selected by default when TCG is enabled, uncomment them to
48
+ if (!memory_region_access_valid(mr, xlat, l, is_write,
46
+# keep out of the build.
49
+ MEMTXATTRS_UNSPECIFIED)) {
47
+# CONFIG_CUBIEBOARD=n
50
return false;
48
+# CONFIG_EXYNOS4=n
51
}
49
+# CONFIG_HIGHBANK=n
52
}
50
+# CONFIG_INTEGRATOR=n
53
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
51
+# CONFIG_FSL_IMX31=n
54
index XXXXXXX..XXXXXXX 100644
52
+# CONFIG_MUSICPAL=n
55
--- a/hw/s390x/s390-pci-inst.c
53
+# CONFIG_MUSCA=n
56
+++ b/hw/s390x/s390-pci-inst.c
54
+# CONFIG_CHEETAH=n
57
@@ -XXX,XX +XXX,XX @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr,
55
+# CONFIG_SX1=n
58
mr = s390_get_subregion(mr, offset, len);
56
+# CONFIG_NSERIES=n
59
offset -= mr->addr;
57
+# CONFIG_STELLARIS=n
60
58
+# CONFIG_STM32VLDISCOVERY=n
61
- if (!memory_region_access_valid(mr, offset, len, true)) {
59
+# CONFIG_REALVIEW=n
62
+ if (!memory_region_access_valid(mr, offset, len, true,
60
+# CONFIG_VERSATILE=n
63
+ MEMTXATTRS_UNSPECIFIED)) {
61
+# CONFIG_VEXPRESS=n
64
s390_program_interrupt(env, PGM_OPERAND, 6, ra);
62
+# CONFIG_ZYNQ=n
65
return 0;
63
+# CONFIG_MAINSTONE=n
66
}
64
+# CONFIG_GUMSTIX=n
67
diff --git a/memory.c b/memory.c
65
+# CONFIG_SPITZ=n
68
index XXXXXXX..XXXXXXX 100644
66
+# CONFIG_TOSA=n
69
--- a/memory.c
67
+# CONFIG_Z2=n
70
+++ b/memory.c
68
+# CONFIG_NPCM7XX=n
71
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps ram_device_mem_ops = {
69
+# CONFIG_COLLIE=n
72
bool memory_region_access_valid(MemoryRegion *mr,
70
+# CONFIG_ASPEED_SOC=n
73
hwaddr addr,
71
+# CONFIG_NETDUINO2=n
74
unsigned size,
72
+# CONFIG_NETDUINOPLUS2=n
75
- bool is_write)
73
+# CONFIG_OLIMEX_STM32_H405=n
76
+ bool is_write,
74
+# CONFIG_MPS2=n
77
+ MemTxAttrs attrs)
75
+# CONFIG_RASPI=n
78
{
76
+# CONFIG_DIGIC=n
79
int access_size_min, access_size_max;
77
+# CONFIG_SABRELITE=n
80
int access_size, i;
78
+# CONFIG_EMCRAFT_SF2=n
81
@@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_read(MemoryRegion *mr,
79
+# CONFIG_MICROBIT=n
82
{
80
+# CONFIG_FSL_IMX25=n
83
MemTxResult r;
81
+# CONFIG_FSL_IMX7=n
84
82
+# CONFIG_FSL_IMX6UL=n
85
- if (!memory_region_access_valid(mr, addr, size, false)) {
83
+# CONFIG_ALLWINNER_H3=n
86
+ if (!memory_region_access_valid(mr, addr, size, false, attrs)) {
87
*pval = unassigned_mem_read(mr, addr, size);
88
return MEMTX_DECODE_ERROR;
89
}
90
@@ -XXX,XX +XXX,XX @@ MemTxResult memory_region_dispatch_write(MemoryRegion *mr,
91
unsigned size,
92
MemTxAttrs attrs)
93
{
94
- if (!memory_region_access_valid(mr, addr, size, true)) {
95
+ if (!memory_region_access_valid(mr, addr, size, true, attrs)) {
96
unassigned_mem_write(mr, addr, data, size);
97
return MEMTX_DECODE_ERROR;
98
}
99
--
84
--
100
2.17.1
85
2.34.1
101
102
diff view generated by jsdifflib
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
1
From: Fabiano Rosas <farosas@suse.de>
2
add MemTxAttrs as an argument to tb_invalidate_phys_addr().
2
3
Its callers either have an attrs value to hand, or don't care
3
Replace the 'default y if TCG' pattern with 'default y; depends on
4
and can use MEMTXATTRS_UNSPECIFIED.
4
TCG'.
5
5
6
That makes explict that there is a dependence on TCG and enabling
7
these CONFIGs via .mak files without TCG present will fail earlier.
8
9
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
10
Signed-off-by: Fabiano Rosas <farosas@suse.de>
11
Reviewed-by: Thomas Huth <thuth@redhat.com>
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
13
Message-id: 20230523180525.29994-4-farosas@suse.de
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
9
Message-id: 20180521140402.23318-3-peter.maydell@linaro.org
10
---
15
---
11
include/exec/exec-all.h | 5 +++--
16
hw/arm/Kconfig | 123 ++++++++++++++++++++++++++++++++-----------------
12
accel/tcg/translate-all.c | 2 +-
17
1 file changed, 82 insertions(+), 41 deletions(-)
13
exec.c | 2 +-
18
14
target/xtensa/op_helper.c | 3 ++-
19
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
15
4 files changed, 7 insertions(+), 5 deletions(-)
16
17
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
18
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
19
--- a/include/exec/exec-all.h
21
--- a/hw/arm/Kconfig
20
+++ b/include/exec/exec-all.h
22
+++ b/hw/arm/Kconfig
21
@@ -XXX,XX +XXX,XX @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr,
23
@@ -XXX,XX +XXX,XX @@ config ARM_VIRT
22
void tlb_set_page(CPUState *cpu, target_ulong vaddr,
24
23
hwaddr paddr, int prot,
25
config CHEETAH
24
int mmu_idx, target_ulong size);
26
bool
25
-void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr);
27
- default y if TCG && ARM
26
+void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs);
28
+ default y
27
void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx,
29
+ depends on TCG && ARM
28
uintptr_t retaddr);
30
select OMAP
29
#else
31
select TSC210X
30
@@ -XXX,XX +XXX,XX @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu,
32
31
uint16_t idxmap)
33
config CUBIEBOARD
32
{
34
bool
33
}
35
- default y if TCG && ARM
34
-static inline void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr)
36
+ default y
35
+static inline void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr,
37
+ depends on TCG && ARM
36
+ MemTxAttrs attrs)
38
select ALLWINNER_A10
37
{
39
38
}
40
config DIGIC
39
#endif
41
bool
40
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
42
- default y if TCG && ARM
41
index XXXXXXX..XXXXXXX 100644
43
+ default y
42
--- a/accel/tcg/translate-all.c
44
+ depends on TCG && ARM
43
+++ b/accel/tcg/translate-all.c
45
select PTIMER
44
@@ -XXX,XX +XXX,XX @@ static TranslationBlock *tb_find_pc(uintptr_t tc_ptr)
46
select PFLASH_CFI02
45
}
47
46
48
config EXYNOS4
47
#if !defined(CONFIG_USER_ONLY)
49
bool
48
-void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr)
50
- default y if TCG && ARM
49
+void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs)
51
+ default y
50
{
52
+ depends on TCG && ARM
51
ram_addr_t ram_addr;
53
imply I2C_DEVICES
52
MemoryRegion *mr;
54
select A9MPCORE
53
diff --git a/exec.c b/exec.c
55
select I2C
54
index XXXXXXX..XXXXXXX 100644
56
@@ -XXX,XX +XXX,XX @@ config EXYNOS4
55
--- a/exec.c
57
56
+++ b/exec.c
58
config HIGHBANK
57
@@ -XXX,XX +XXX,XX @@ static void breakpoint_invalidate(CPUState *cpu, target_ulong pc)
59
bool
58
if (phys != -1) {
60
- default y if TCG && ARM
59
/* Locks grabbed by tb_invalidate_phys_addr */
61
+ default y
60
tb_invalidate_phys_addr(cpu->cpu_ases[asidx].as,
62
+ depends on TCG && ARM
61
- phys | (pc & ~TARGET_PAGE_MASK));
63
select A9MPCORE
62
+ phys | (pc & ~TARGET_PAGE_MASK), attrs);
64
select A15MPCORE
63
}
65
select AHCI
64
}
66
@@ -XXX,XX +XXX,XX @@ config HIGHBANK
65
#endif
67
66
diff --git a/target/xtensa/op_helper.c b/target/xtensa/op_helper.c
68
config INTEGRATOR
67
index XXXXXXX..XXXXXXX 100644
69
bool
68
--- a/target/xtensa/op_helper.c
70
- default y if TCG && ARM
69
+++ b/target/xtensa/op_helper.c
71
+ default y
70
@@ -XXX,XX +XXX,XX @@ static void tb_invalidate_virtual_addr(CPUXtensaState *env, uint32_t vaddr)
72
+ depends on TCG && ARM
71
int ret = xtensa_get_physical_addr(env, false, vaddr, 2, 0,
73
select ARM_TIMER
72
&paddr, &page_size, &access);
74
select INTEGRATOR_DEBUG
73
if (ret == 0) {
75
select PL011 # UART
74
- tb_invalidate_phys_addr(&address_space_memory, paddr);
76
@@ -XXX,XX +XXX,XX @@ config INTEGRATOR
75
+ tb_invalidate_phys_addr(&address_space_memory, paddr,
77
76
+ MEMTXATTRS_UNSPECIFIED);
78
config MAINSTONE
77
}
79
bool
78
}
80
- default y if TCG && ARM
81
+ default y
82
+ depends on TCG && ARM
83
select PXA2XX
84
select PFLASH_CFI01
85
select SMC91C111
86
87
config MUSCA
88
bool
89
- default y if TCG && ARM
90
+ default y
91
+ depends on TCG && ARM
92
select ARMSSE
93
select PL011
94
select PL031
95
@@ -XXX,XX +XXX,XX @@ config MARVELL_88W8618
96
97
config MUSICPAL
98
bool
99
- default y if TCG && ARM
100
+ default y
101
+ depends on TCG && ARM
102
select OR_IRQ
103
select BITBANG_I2C
104
select MARVELL_88W8618
105
@@ -XXX,XX +XXX,XX @@ config MUSICPAL
106
107
config NETDUINO2
108
bool
109
- default y if TCG && ARM
110
+ default y
111
+ depends on TCG && ARM
112
select STM32F205_SOC
113
114
config NETDUINOPLUS2
115
bool
116
- default y if TCG && ARM
117
+ default y
118
+ depends on TCG && ARM
119
select STM32F405_SOC
120
121
config OLIMEX_STM32_H405
122
bool
123
- default y if TCG && ARM
124
+ default y
125
+ depends on TCG && ARM
126
select STM32F405_SOC
127
128
config NSERIES
129
bool
130
- default y if TCG && ARM
131
+ default y
132
+ depends on TCG && ARM
133
select OMAP
134
select TMP105 # temperature sensor
135
select BLIZZARD # LCD/TV controller
136
@@ -XXX,XX +XXX,XX @@ config PXA2XX
137
138
config GUMSTIX
139
bool
140
- default y if TCG && ARM
141
+ default y
142
+ depends on TCG && ARM
143
select PFLASH_CFI01
144
select SMC91C111
145
select PXA2XX
146
147
config TOSA
148
bool
149
- default y if TCG && ARM
150
+ default y
151
+ depends on TCG && ARM
152
select ZAURUS # scoop
153
select MICRODRIVE
154
select PXA2XX
155
@@ -XXX,XX +XXX,XX @@ config TOSA
156
157
config SPITZ
158
bool
159
- default y if TCG && ARM
160
+ default y
161
+ depends on TCG && ARM
162
select ADS7846 # touch-screen controller
163
select MAX111X # A/D converter
164
select WM8750 # audio codec
165
@@ -XXX,XX +XXX,XX @@ config SPITZ
166
167
config Z2
168
bool
169
- default y if TCG && ARM
170
+ default y
171
+ depends on TCG && ARM
172
select PFLASH_CFI01
173
select WM8750
174
select PL011 # UART
175
@@ -XXX,XX +XXX,XX @@ config Z2
176
177
config REALVIEW
178
bool
179
- default y if TCG && ARM
180
+ default y
181
+ depends on TCG && ARM
182
imply PCI_DEVICES
183
imply PCI_TESTDEV
184
imply I2C_DEVICES
185
@@ -XXX,XX +XXX,XX @@ config REALVIEW
186
187
config SBSA_REF
188
bool
189
- default y if TCG && AARCH64
190
+ default y
191
+ depends on TCG && AARCH64
192
imply PCI_DEVICES
193
select AHCI
194
select ARM_SMMUV3
195
@@ -XXX,XX +XXX,XX @@ config SBSA_REF
196
197
config SABRELITE
198
bool
199
- default y if TCG && ARM
200
+ default y
201
+ depends on TCG && ARM
202
select FSL_IMX6
203
select SSI_M25P80
204
205
config STELLARIS
206
bool
207
- default y if TCG && ARM
208
+ default y
209
+ depends on TCG && ARM
210
imply I2C_DEVICES
211
select ARM_V7M
212
select CMSDK_APB_WATCHDOG
213
@@ -XXX,XX +XXX,XX @@ config STELLARIS
214
215
config STM32VLDISCOVERY
216
bool
217
- default y if TCG && ARM
218
+ default y
219
+ depends on TCG && ARM
220
select STM32F100_SOC
221
222
config STRONGARM
223
@@ -XXX,XX +XXX,XX @@ config STRONGARM
224
225
config COLLIE
226
bool
227
- default y if TCG && ARM
228
+ default y
229
+ depends on TCG && ARM
230
select PFLASH_CFI01
231
select ZAURUS # scoop
232
select STRONGARM
233
234
config SX1
235
bool
236
- default y if TCG && ARM
237
+ default y
238
+ depends on TCG && ARM
239
select OMAP
240
241
config VERSATILE
242
bool
243
- default y if TCG && ARM
244
+ default y
245
+ depends on TCG && ARM
246
select ARM_TIMER # sp804
247
select PFLASH_CFI01
248
select LSI_SCSI_PCI
249
@@ -XXX,XX +XXX,XX @@ config VERSATILE
250
251
config VEXPRESS
252
bool
253
- default y if TCG && ARM
254
+ default y
255
+ depends on TCG && ARM
256
select A9MPCORE
257
select A15MPCORE
258
select ARM_MPTIMER
259
@@ -XXX,XX +XXX,XX @@ config VEXPRESS
260
261
config ZYNQ
262
bool
263
- default y if TCG && ARM
264
+ default y
265
+ depends on TCG && ARM
266
select A9MPCORE
267
select CADENCE # UART
268
select PFLASH_CFI02
269
@@ -XXX,XX +XXX,XX @@ config ZYNQ
270
config ARM_V7M
271
bool
272
# currently v7M must be included in a TCG build due to translate.c
273
- default y if TCG && ARM
274
+ default y
275
+ depends on TCG && ARM
276
select PTIMER
277
278
config ALLWINNER_A10
279
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10
280
281
config ALLWINNER_H3
282
bool
283
- default y if TCG && ARM
284
+ default y
285
+ depends on TCG && ARM
286
select ALLWINNER_A10_PIT
287
select ALLWINNER_SUN8I_EMAC
288
select ALLWINNER_I2C
289
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_H3
290
291
config RASPI
292
bool
293
- default y if TCG && ARM
294
+ default y
295
+ depends on TCG && ARM
296
select FRAMEBUFFER
297
select PL011 # UART
298
select SDHCI
299
@@ -XXX,XX +XXX,XX @@ config STM32F405_SOC
300
301
config XLNX_ZYNQMP_ARM
302
bool
303
- default y if TCG && AARCH64
304
+ default y
305
+ depends on TCG && AARCH64
306
select AHCI
307
select ARM_GIC
308
select CADENCE
309
@@ -XXX,XX +XXX,XX @@ config XLNX_ZYNQMP_ARM
310
311
config XLNX_VERSAL
312
bool
313
- default y if TCG && AARCH64
314
+ default y
315
+ depends on TCG && AARCH64
316
select ARM_GIC
317
select PL011
318
select CADENCE
319
@@ -XXX,XX +XXX,XX @@ config XLNX_VERSAL
320
321
config NPCM7XX
322
bool
323
- default y if TCG && ARM
324
+ default y
325
+ depends on TCG && ARM
326
select A9MPCORE
327
select ADM1272
328
select ARM_GIC
329
@@ -XXX,XX +XXX,XX @@ config NPCM7XX
330
331
config FSL_IMX25
332
bool
333
- default y if TCG && ARM
334
+ default y
335
+ depends on TCG && ARM
336
imply I2C_DEVICES
337
select IMX
338
select IMX_FEC
339
@@ -XXX,XX +XXX,XX @@ config FSL_IMX25
340
341
config FSL_IMX31
342
bool
343
- default y if TCG && ARM
344
+ default y
345
+ depends on TCG && ARM
346
imply I2C_DEVICES
347
select SERIAL
348
select IMX
349
@@ -XXX,XX +XXX,XX @@ config FSL_IMX6
350
351
config ASPEED_SOC
352
bool
353
- default y if TCG && ARM
354
+ default y
355
+ depends on TCG && ARM
356
select DS1338
357
select FTGMAC100
358
select I2C
359
@@ -XXX,XX +XXX,XX @@ config ASPEED_SOC
360
361
config MPS2
362
bool
363
- default y if TCG && ARM
364
+ default y
365
+ depends on TCG && ARM
366
imply I2C_DEVICES
367
select ARMSSE
368
select LAN9118
369
@@ -XXX,XX +XXX,XX @@ config MPS2
370
371
config FSL_IMX7
372
bool
373
- default y if TCG && ARM
374
+ default y
375
+ depends on TCG && ARM
376
imply PCI_DEVICES
377
imply TEST_DEVICES
378
imply I2C_DEVICES
379
@@ -XXX,XX +XXX,XX @@ config ARM_SMMUV3
380
381
config FSL_IMX6UL
382
bool
383
- default y if TCG && ARM
384
+ default y
385
+ depends on TCG && ARM
386
imply I2C_DEVICES
387
select A15MPCORE
388
select IMX
389
@@ -XXX,XX +XXX,XX @@ config FSL_IMX6UL
390
391
config MICROBIT
392
bool
393
- default y if TCG && ARM
394
+ default y
395
+ depends on TCG && ARM
396
select NRF51_SOC
397
398
config NRF51_SOC
399
@@ -XXX,XX +XXX,XX @@ config NRF51_SOC
400
401
config EMCRAFT_SF2
402
bool
403
- default y if TCG && ARM
404
+ default y
405
+ depends on TCG && ARM
406
select MSF2
407
select SSI_M25P80
79
408
80
--
409
--
81
2.17.1
410
2.34.1
82
411
83
412
diff view generated by jsdifflib
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
From: Enze Li <lienze@kylinos.cn>
2
2
3
cpregs_keys is an uint32_t* so the allocation should use uint32_t.
3
I noticed that in the latest version, the copyright string is still
4
g_new is even better because it is type-safe.
4
2022, even though 2023 is halfway through. This patch fixes that and
5
fixes the documentation along with it.
5
6
6
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7
Signed-off-by: Enze Li <lienze@kylinos.cn>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20230525064345.1152801-1-lienze@kylinos.cn
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
---
11
target/arm/gdbstub.c | 3 +--
12
docs/conf.py | 2 +-
12
1 file changed, 1 insertion(+), 2 deletions(-)
13
include/qemu/help-texts.h | 2 +-
14
2 files changed, 2 insertions(+), 2 deletions(-)
13
15
14
diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
16
diff --git a/docs/conf.py b/docs/conf.py
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/gdbstub.c
18
--- a/docs/conf.py
17
+++ b/target/arm/gdbstub.c
19
+++ b/docs/conf.py
18
@@ -XXX,XX +XXX,XX @@ int arm_gen_dynamic_xml(CPUState *cs)
20
@@ -XXX,XX +XXX,XX @@
19
RegisterSysregXmlParam param = {cs, s};
21
20
22
# General information about the project.
21
cpu->dyn_xml.num_cpregs = 0;
23
project = u'QEMU'
22
- cpu->dyn_xml.cpregs_keys = g_malloc(sizeof(uint32_t *) *
24
-copyright = u'2022, The QEMU Project Developers'
23
- g_hash_table_size(cpu->cp_regs));
25
+copyright = u'2023, The QEMU Project Developers'
24
+ cpu->dyn_xml.cpregs_keys = g_new(uint32_t, g_hash_table_size(cpu->cp_regs));
26
author = u'The QEMU Project Developers'
25
g_string_printf(s, "<?xml version=\"1.0\"?>");
27
26
g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">");
28
# The version info for the project you're documenting, acts as replacement for
27
g_string_append_printf(s, "<feature name=\"org.qemu.gdb.arm.sys.regs\">");
29
diff --git a/include/qemu/help-texts.h b/include/qemu/help-texts.h
30
index XXXXXXX..XXXXXXX 100644
31
--- a/include/qemu/help-texts.h
32
+++ b/include/qemu/help-texts.h
33
@@ -XXX,XX +XXX,XX @@
34
#define QEMU_HELP_TEXTS_H
35
36
/* Copyright string for -version arguments, About dialogs, etc */
37
-#define QEMU_COPYRIGHT "Copyright (c) 2003-2022 " \
38
+#define QEMU_COPYRIGHT "Copyright (c) 2003-2023 " \
39
"Fabrice Bellard and the QEMU Project developers"
40
41
/* Bug reporting information for --help arguments, About dialogs, etc */
28
--
42
--
29
2.17.1
43
2.34.1
30
31
diff view generated by jsdifflib
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
1
From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
2
add MemTxAttrs as an argument to flatview_access_valid().
3
Its callers now all have an attrs value to hand, so we can
4
correct our earlier temporary use of MEMTXATTRS_UNSPECIFIED.
5
2
3
Let add GIC information into DeviceTree as part of SBSA-REF versioning.
4
5
Trusted Firmware will read it and provide to next firmware level.
6
7
Bumps platform version to 0.1 one so we can check is node is present.
8
9
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180521140402.23318-10-peter.maydell@linaro.org
10
---
12
---
11
exec.c | 12 +++++-------
13
hw/arm/sbsa-ref.c | 19 ++++++++++++++++++-
12
1 file changed, 5 insertions(+), 7 deletions(-)
14
1 file changed, 18 insertions(+), 1 deletion(-)
13
15
14
diff --git a/exec.c b/exec.c
16
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/exec.c
18
--- a/hw/arm/sbsa-ref.c
17
+++ b/exec.c
19
+++ b/hw/arm/sbsa-ref.c
18
@@ -XXX,XX +XXX,XX @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr,
20
@@ -XXX,XX +XXX,XX @@
19
static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
21
#include "exec/hwaddr.h"
20
const uint8_t *buf, int len);
22
#include "kvm_arm.h"
21
static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
23
#include "hw/arm/boot.h"
22
- bool is_write);
24
+#include "hw/arm/fdt.h"
23
+ bool is_write, MemTxAttrs attrs);
25
#include "hw/arm/smmuv3.h"
24
26
#include "hw/block/flash.h"
25
static MemTxResult subpage_read(void *opaque, hwaddr addr, uint64_t *data,
27
#include "hw/boards.h"
26
unsigned len, MemTxAttrs attrs)
28
@@ -XXX,XX +XXX,XX @@ static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx)
27
@@ -XXX,XX +XXX,XX @@ static bool subpage_accepts(void *opaque, hwaddr addr,
29
return arm_cpu_mp_affinity(idx, clustersz);
28
#endif
29
30
return flatview_access_valid(subpage->fv, addr + subpage->base,
31
- len, is_write);
32
+ len, is_write, attrs);
33
}
30
}
34
31
35
static const MemoryRegionOps subpage_ops = {
32
+static void sbsa_fdt_add_gic_node(SBSAMachineState *sms)
36
@@ -XXX,XX +XXX,XX @@ static void cpu_notify_map_clients(void)
33
+{
34
+ char *nodename;
35
+
36
+ nodename = g_strdup_printf("/intc");
37
+ qemu_fdt_add_subnode(sms->fdt, nodename);
38
+ qemu_fdt_setprop_sized_cells(sms->fdt, nodename, "reg",
39
+ 2, sbsa_ref_memmap[SBSA_GIC_DIST].base,
40
+ 2, sbsa_ref_memmap[SBSA_GIC_DIST].size,
41
+ 2, sbsa_ref_memmap[SBSA_GIC_REDIST].base,
42
+ 2, sbsa_ref_memmap[SBSA_GIC_REDIST].size);
43
+
44
+ g_free(nodename);
45
+}
46
/*
47
* Firmware on this machine only uses ACPI table to load OS, these limited
48
* device tree nodes are just to let firmware know the info which varies from
49
@@ -XXX,XX +XXX,XX @@ static void create_fdt(SBSAMachineState *sms)
50
* fw compatibility.
51
*/
52
qemu_fdt_setprop_cell(fdt, "/", "machine-version-major", 0);
53
- qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 0);
54
+ qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 1);
55
56
if (ms->numa_state->have_numa_distance) {
57
int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t);
58
@@ -XXX,XX +XXX,XX @@ static void create_fdt(SBSAMachineState *sms)
59
60
g_free(nodename);
61
}
62
+
63
+ sbsa_fdt_add_gic_node(sms);
37
}
64
}
38
65
39
static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
66
#define SBSA_FLASH_SECTOR_SIZE (256 * KiB)
40
- bool is_write)
41
+ bool is_write, MemTxAttrs attrs)
42
{
43
MemoryRegion *mr;
44
hwaddr l, xlat;
45
@@ -XXX,XX +XXX,XX @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len,
46
mr = flatview_translate(fv, addr, &xlat, &l, is_write);
47
if (!memory_access_is_direct(mr, is_write)) {
48
l = memory_access_size(mr, l, addr);
49
- /* When our callers all have attrs we'll pass them through here */
50
- if (!memory_region_access_valid(mr, xlat, l, is_write,
51
- MEMTXATTRS_UNSPECIFIED)) {
52
+ if (!memory_region_access_valid(mr, xlat, l, is_write, attrs)) {
53
return false;
54
}
55
}
56
@@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr,
57
58
rcu_read_lock();
59
fv = address_space_to_flatview(as);
60
- result = flatview_access_valid(fv, addr, len, is_write);
61
+ result = flatview_access_valid(fv, addr, len, is_write, attrs);
62
rcu_read_unlock();
63
return result;
64
}
65
--
67
--
66
2.17.1
68
2.34.1
67
68
diff view generated by jsdifflib
1
From: Jan Kiszka <jan.kiszka@siemens.com>
1
From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
2
2
3
There was a nasty flip in identifying which register group an access is
3
We moved from VGA to Bochs to have PCIe card.
4
targeting. The issue caused spuriously raised priorities of the guest
5
when handing CPUs over in the Jailhouse hypervisor.
6
4
7
Cc: qemu-stable@nongnu.org
5
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
8
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
9
Message-id: 28b927d3-da58-bce4-cc13-bfec7f9b1cb9@siemens.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
8
---
13
hw/intc/arm_gicv3_cpuif.c | 12 ++++++------
9
docs/system/arm/sbsa.rst | 2 +-
14
1 file changed, 6 insertions(+), 6 deletions(-)
10
1 file changed, 1 insertion(+), 1 deletion(-)
15
11
16
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
12
diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst
17
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/intc/arm_gicv3_cpuif.c
14
--- a/docs/system/arm/sbsa.rst
19
+++ b/hw/intc/arm_gicv3_cpuif.c
15
+++ b/docs/system/arm/sbsa.rst
20
@@ -XXX,XX +XXX,XX @@ static uint64_t icv_ap_read(CPUARMState *env, const ARMCPRegInfo *ri)
16
@@ -XXX,XX +XXX,XX @@ The sbsa-ref board supports:
21
{
17
- System bus EHCI controller
22
GICv3CPUState *cs = icc_cs_from_env(env);
18
- CDROM and hard disc on AHCI bus
23
int regno = ri->opc2 & 3;
19
- E1000E ethernet card on PCIe bus
24
- int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS;
20
- - VGA display adaptor on PCIe bus
25
+ int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0;
21
+ - Bochs display adapter on PCIe bus
26
uint64_t value = cs->ich_apr[grp][regno];
22
- A generic SBSA watchdog device
27
28
trace_gicv3_icv_ap_read(ri->crm & 1, regno, gicv3_redist_affid(cs), value);
29
@@ -XXX,XX +XXX,XX @@ static void icv_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,
30
{
31
GICv3CPUState *cs = icc_cs_from_env(env);
32
int regno = ri->opc2 & 3;
33
- int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS;
34
+ int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0;
35
36
trace_gicv3_icv_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value);
37
38
@@ -XXX,XX +XXX,XX @@ static uint64_t icc_ap_read(CPUARMState *env, const ARMCPRegInfo *ri)
39
uint64_t value;
40
41
int regno = ri->opc2 & 3;
42
- int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1;
43
+ int grp = (ri->crm & 1) ? GICV3_G1 : GICV3_G0;
44
45
if (icv_access(env, grp == GICV3_G0 ? HCR_FMO : HCR_IMO)) {
46
return icv_ap_read(env, ri);
47
@@ -XXX,XX +XXX,XX @@ static void icc_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,
48
GICv3CPUState *cs = icc_cs_from_env(env);
49
50
int regno = ri->opc2 & 3;
51
- int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1;
52
+ int grp = (ri->crm & 1) ? GICV3_G1 : GICV3_G0;
53
54
if (icv_access(env, grp == GICV3_G0 ? HCR_FMO : HCR_IMO)) {
55
icv_ap_write(env, ri, value);
56
@@ -XXX,XX +XXX,XX @@ static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri)
57
{
58
GICv3CPUState *cs = icc_cs_from_env(env);
59
int regno = ri->opc2 & 3;
60
- int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS;
61
+ int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0;
62
uint64_t value;
63
64
value = cs->ich_apr[grp][regno];
65
@@ -XXX,XX +XXX,XX @@ static void ich_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,
66
{
67
GICv3CPUState *cs = icc_cs_from_env(env);
68
int regno = ri->opc2 & 3;
69
- int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS;
70
+ int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0;
71
72
trace_gicv3_ich_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value);
73
23
74
--
24
--
75
2.17.1
25
2.34.1
76
77
diff view generated by jsdifflib
Deleted patch
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
2
add MemTxAttrs as an argument to address_space_translate()
3
and address_space_translate_cached(). Callers either have an
4
attrs value to hand, or don't care and can use MEMTXATTRS_UNSPECIFIED.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180521140402.23318-4-peter.maydell@linaro.org
10
---
11
include/exec/memory.h | 4 +++-
12
accel/tcg/translate-all.c | 2 +-
13
exec.c | 14 +++++++++-----
14
hw/vfio/common.c | 3 ++-
15
memory_ldst.inc.c | 18 +++++++++---------
16
target/riscv/helper.c | 2 +-
17
6 files changed, 25 insertions(+), 18 deletions(-)
18
19
diff --git a/include/exec/memory.h b/include/exec/memory.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/include/exec/memory.h
22
+++ b/include/exec/memory.h
23
@@ -XXX,XX +XXX,XX @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
24
* #MemoryRegion.
25
* @len: pointer to length
26
* @is_write: indicates the transfer direction
27
+ * @attrs: memory attributes
28
*/
29
MemoryRegion *flatview_translate(FlatView *fv,
30
hwaddr addr, hwaddr *xlat,
31
@@ -XXX,XX +XXX,XX @@ MemoryRegion *flatview_translate(FlatView *fv,
32
33
static inline MemoryRegion *address_space_translate(AddressSpace *as,
34
hwaddr addr, hwaddr *xlat,
35
- hwaddr *len, bool is_write)
36
+ hwaddr *len, bool is_write,
37
+ MemTxAttrs attrs)
38
{
39
return flatview_translate(address_space_to_flatview(as),
40
addr, xlat, len, is_write);
41
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
42
index XXXXXXX..XXXXXXX 100644
43
--- a/accel/tcg/translate-all.c
44
+++ b/accel/tcg/translate-all.c
45
@@ -XXX,XX +XXX,XX @@ void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs)
46
hwaddr l = 1;
47
48
rcu_read_lock();
49
- mr = address_space_translate(as, addr, &addr, &l, false);
50
+ mr = address_space_translate(as, addr, &addr, &l, false, attrs);
51
if (!(memory_region_is_ram(mr)
52
|| memory_region_is_romd(mr))) {
53
rcu_read_unlock();
54
diff --git a/exec.c b/exec.c
55
index XXXXXXX..XXXXXXX 100644
56
--- a/exec.c
57
+++ b/exec.c
58
@@ -XXX,XX +XXX,XX @@ static inline void cpu_physical_memory_write_rom_internal(AddressSpace *as,
59
rcu_read_lock();
60
while (len > 0) {
61
l = len;
62
- mr = address_space_translate(as, addr, &addr1, &l, true);
63
+ mr = address_space_translate(as, addr, &addr1, &l, true,
64
+ MEMTXATTRS_UNSPECIFIED);
65
66
if (!(memory_region_is_ram(mr) ||
67
memory_region_is_romd(mr))) {
68
@@ -XXX,XX +XXX,XX @@ void address_space_cache_destroy(MemoryRegionCache *cache)
69
*/
70
static inline MemoryRegion *address_space_translate_cached(
71
MemoryRegionCache *cache, hwaddr addr, hwaddr *xlat,
72
- hwaddr *plen, bool is_write)
73
+ hwaddr *plen, bool is_write, MemTxAttrs attrs)
74
{
75
MemoryRegionSection section;
76
MemoryRegion *mr;
77
@@ -XXX,XX +XXX,XX @@ address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr,
78
MemoryRegion *mr;
79
80
l = len;
81
- mr = address_space_translate_cached(cache, addr, &addr1, &l, false);
82
+ mr = address_space_translate_cached(cache, addr, &addr1, &l, false,
83
+ MEMTXATTRS_UNSPECIFIED);
84
flatview_read_continue(cache->fv,
85
addr, MEMTXATTRS_UNSPECIFIED, buf, len,
86
addr1, l, mr);
87
@@ -XXX,XX +XXX,XX @@ address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr,
88
MemoryRegion *mr;
89
90
l = len;
91
- mr = address_space_translate_cached(cache, addr, &addr1, &l, true);
92
+ mr = address_space_translate_cached(cache, addr, &addr1, &l, true,
93
+ MEMTXATTRS_UNSPECIFIED);
94
flatview_write_continue(cache->fv,
95
addr, MEMTXATTRS_UNSPECIFIED, buf, len,
96
addr1, l, mr);
97
@@ -XXX,XX +XXX,XX @@ bool cpu_physical_memory_is_io(hwaddr phys_addr)
98
99
rcu_read_lock();
100
mr = address_space_translate(&address_space_memory,
101
- phys_addr, &phys_addr, &l, false);
102
+ phys_addr, &phys_addr, &l, false,
103
+ MEMTXATTRS_UNSPECIFIED);
104
105
res = !(memory_region_is_ram(mr) || memory_region_is_romd(mr));
106
rcu_read_unlock();
107
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
108
index XXXXXXX..XXXXXXX 100644
109
--- a/hw/vfio/common.c
110
+++ b/hw/vfio/common.c
111
@@ -XXX,XX +XXX,XX @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void **vaddr,
112
*/
113
mr = address_space_translate(&address_space_memory,
114
iotlb->translated_addr,
115
- &xlat, &len, writable);
116
+ &xlat, &len, writable,
117
+ MEMTXATTRS_UNSPECIFIED);
118
if (!memory_region_is_ram(mr)) {
119
error_report("iommu map to non memory area %"HWADDR_PRIx"",
120
xlat);
121
diff --git a/memory_ldst.inc.c b/memory_ldst.inc.c
122
index XXXXXXX..XXXXXXX 100644
123
--- a/memory_ldst.inc.c
124
+++ b/memory_ldst.inc.c
125
@@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_ldl_internal, SUFFIX)(ARG1_DECL,
126
bool release_lock = false;
127
128
RCU_READ_LOCK();
129
- mr = TRANSLATE(addr, &addr1, &l, false);
130
+ mr = TRANSLATE(addr, &addr1, &l, false, attrs);
131
if (l < 4 || !IS_DIRECT(mr, false)) {
132
release_lock |= prepare_mmio_access(mr);
133
134
@@ -XXX,XX +XXX,XX @@ static inline uint64_t glue(address_space_ldq_internal, SUFFIX)(ARG1_DECL,
135
bool release_lock = false;
136
137
RCU_READ_LOCK();
138
- mr = TRANSLATE(addr, &addr1, &l, false);
139
+ mr = TRANSLATE(addr, &addr1, &l, false, attrs);
140
if (l < 8 || !IS_DIRECT(mr, false)) {
141
release_lock |= prepare_mmio_access(mr);
142
143
@@ -XXX,XX +XXX,XX @@ uint32_t glue(address_space_ldub, SUFFIX)(ARG1_DECL,
144
bool release_lock = false;
145
146
RCU_READ_LOCK();
147
- mr = TRANSLATE(addr, &addr1, &l, false);
148
+ mr = TRANSLATE(addr, &addr1, &l, false, attrs);
149
if (!IS_DIRECT(mr, false)) {
150
release_lock |= prepare_mmio_access(mr);
151
152
@@ -XXX,XX +XXX,XX @@ static inline uint32_t glue(address_space_lduw_internal, SUFFIX)(ARG1_DECL,
153
bool release_lock = false;
154
155
RCU_READ_LOCK();
156
- mr = TRANSLATE(addr, &addr1, &l, false);
157
+ mr = TRANSLATE(addr, &addr1, &l, false, attrs);
158
if (l < 2 || !IS_DIRECT(mr, false)) {
159
release_lock |= prepare_mmio_access(mr);
160
161
@@ -XXX,XX +XXX,XX @@ void glue(address_space_stl_notdirty, SUFFIX)(ARG1_DECL,
162
bool release_lock = false;
163
164
RCU_READ_LOCK();
165
- mr = TRANSLATE(addr, &addr1, &l, true);
166
+ mr = TRANSLATE(addr, &addr1, &l, true, attrs);
167
if (l < 4 || !IS_DIRECT(mr, true)) {
168
release_lock |= prepare_mmio_access(mr);
169
170
@@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stl_internal, SUFFIX)(ARG1_DECL,
171
bool release_lock = false;
172
173
RCU_READ_LOCK();
174
- mr = TRANSLATE(addr, &addr1, &l, true);
175
+ mr = TRANSLATE(addr, &addr1, &l, true, attrs);
176
if (l < 4 || !IS_DIRECT(mr, true)) {
177
release_lock |= prepare_mmio_access(mr);
178
179
@@ -XXX,XX +XXX,XX @@ void glue(address_space_stb, SUFFIX)(ARG1_DECL,
180
bool release_lock = false;
181
182
RCU_READ_LOCK();
183
- mr = TRANSLATE(addr, &addr1, &l, true);
184
+ mr = TRANSLATE(addr, &addr1, &l, true, attrs);
185
if (!IS_DIRECT(mr, true)) {
186
release_lock |= prepare_mmio_access(mr);
187
r = memory_region_dispatch_write(mr, addr1, val, 1, attrs);
188
@@ -XXX,XX +XXX,XX @@ static inline void glue(address_space_stw_internal, SUFFIX)(ARG1_DECL,
189
bool release_lock = false;
190
191
RCU_READ_LOCK();
192
- mr = TRANSLATE(addr, &addr1, &l, true);
193
+ mr = TRANSLATE(addr, &addr1, &l, true, attrs);
194
if (l < 2 || !IS_DIRECT(mr, true)) {
195
release_lock |= prepare_mmio_access(mr);
196
197
@@ -XXX,XX +XXX,XX @@ static void glue(address_space_stq_internal, SUFFIX)(ARG1_DECL,
198
bool release_lock = false;
199
200
RCU_READ_LOCK();
201
- mr = TRANSLATE(addr, &addr1, &l, true);
202
+ mr = TRANSLATE(addr, &addr1, &l, true, attrs);
203
if (l < 8 || !IS_DIRECT(mr, true)) {
204
release_lock |= prepare_mmio_access(mr);
205
206
diff --git a/target/riscv/helper.c b/target/riscv/helper.c
207
index XXXXXXX..XXXXXXX 100644
208
--- a/target/riscv/helper.c
209
+++ b/target/riscv/helper.c
210
@@ -XXX,XX +XXX,XX @@ restart:
211
MemoryRegion *mr;
212
hwaddr l = sizeof(target_ulong), addr1;
213
mr = address_space_translate(cs->as, pte_addr,
214
- &addr1, &l, false);
215
+ &addr1, &l, false, MEMTXATTRS_UNSPECIFIED);
216
if (memory_access_is_direct(mr, true)) {
217
target_ulong *pte_pa =
218
qemu_map_ram_ptr(mr->ram_block, addr1);
219
--
220
2.17.1
221
222
diff view generated by jsdifflib
Deleted patch
1
As part of plumbing MemTxAttrs down to the IOMMU translate method,
2
add MemTxAttrs as an argument to flatview_extend_translation().
3
Its callers either have an attrs value to hand, or don't care
4
and can use MEMTXATTRS_UNSPECIFIED.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180521140402.23318-7-peter.maydell@linaro.org
10
---
11
exec.c | 15 ++++++++++-----
12
1 file changed, 10 insertions(+), 5 deletions(-)
13
14
diff --git a/exec.c b/exec.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/exec.c
17
+++ b/exec.c
18
@@ -XXX,XX +XXX,XX @@ bool address_space_access_valid(AddressSpace *as, hwaddr addr,
19
20
static hwaddr
21
flatview_extend_translation(FlatView *fv, hwaddr addr,
22
- hwaddr target_len,
23
- MemoryRegion *mr, hwaddr base, hwaddr len,
24
- bool is_write)
25
+ hwaddr target_len,
26
+ MemoryRegion *mr, hwaddr base, hwaddr len,
27
+ bool is_write, MemTxAttrs attrs)
28
{
29
hwaddr done = 0;
30
hwaddr xlat;
31
@@ -XXX,XX +XXX,XX @@ void *address_space_map(AddressSpace *as,
32
33
memory_region_ref(mr);
34
*plen = flatview_extend_translation(fv, addr, len, mr, xlat,
35
- l, is_write);
36
+ l, is_write, attrs);
37
ptr = qemu_ram_ptr_length(mr->ram_block, xlat, plen, true);
38
rcu_read_unlock();
39
40
@@ -XXX,XX +XXX,XX @@ int64_t address_space_cache_init(MemoryRegionCache *cache,
41
mr = cache->mrs.mr;
42
memory_region_ref(mr);
43
if (memory_access_is_direct(mr, is_write)) {
44
+ /* We don't care about the memory attributes here as we're only
45
+ * doing this if we found actual RAM, which behaves the same
46
+ * regardless of attributes; so UNSPECIFIED is fine.
47
+ */
48
l = flatview_extend_translation(cache->fv, addr, len, mr,
49
- cache->xlat, l, is_write);
50
+ cache->xlat, l, is_write,
51
+ MEMTXATTRS_UNSPECIFIED);
52
cache->ptr = qemu_ram_ptr_length(mr->ram_block, cache->xlat, &l, true);
53
} else {
54
cache->ptr = NULL;
55
--
56
2.17.1
57
58
diff view generated by jsdifflib