1
target-arm queue for rc1 -- these are all bug fixes.
1
Hi; here's the latest batch of arm changes. The big thing
2
in here is the SMMUv3 changes to add stage-2 translation support.
2
3
3
thanks
4
thanks
4
-- PMM
5
-- PMM
5
6
6
The following changes since commit b9404bf592e7ba74180e1a54ed7a266ec6ee67f2:
7
The following changes since commit aa9bbd865502ed517624ab6fe7d4b5d89ca95e43:
7
8
8
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-hmp-20190715' into staging (2019-07-15 12:22:07 +0100)
9
Merge tag 'pull-ppc-20230528' of https://gitlab.com/danielhb/qemu into staging (2023-05-29 14:31:52 -0700)
9
10
10
are available in the Git repository at:
11
are available in the Git repository at:
11
12
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190715
13
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230530
13
14
14
for you to fetch changes up to 51c9122e92b776a3f16af0b9282f1dc5012e2a19:
15
for you to fetch changes up to b03d0d4f531a8b867e0aac1fab0b876903015680:
15
16
16
target/arm: NS BusFault on vector table fetch escalates to NS HardFault (2019-07-15 14:17:04 +0100)
17
docs: sbsa: correct graphics card name (2023-05-30 13:32:46 +0100)
17
18
18
----------------------------------------------------------------
19
----------------------------------------------------------------
19
target-arm queue:
20
target-arm queue:
20
* report ARMv8-A FP support for AArch32 -cpu max
21
* fsl-imx6: Add SNVS support for i.MX6 boards
21
* hw/ssi/xilinx_spips: Avoid AXI writes to the LQSPI linear memory
22
* smmuv3: Add support for stage 2 translations
22
* hw/ssi/xilinx_spips: Avoid out-of-bound access to lqspi_buf[]
23
* hw/dma/xilinx_axidma: Check DMASR.HALTED to prevent infinite loop
23
* hw/ssi/mss-spi: Avoid crash when reading empty RX FIFO
24
* hw/arm/xlnx-zynqmp: fix unsigned error when checking the RPUs number
24
* hw/display/xlnx_dp: Avoid crash when reading empty RX FIFO
25
* cleanups for recent Kconfig changes
25
* hw/arm/virt: Fix non-secure flash mode
26
* target/arm: Explicitly select short-format FSR for M-profile
26
* pl031: Correctly migrate state when using -rtc clock=host
27
* tests/qtest: Run arm-specific tests only if the required machine is available
27
* fix regression that meant arm926 and arm1026 lost VFP
28
* hw/arm/sbsa-ref: add GIC node into DT
28
double-precision support
29
* docs: sbsa: correct graphics card name
29
* v8M: NS BusFault on vector table fetch escalates to NS HardFault
30
* Update copyright dates to 2023
30
31
31
----------------------------------------------------------------
32
----------------------------------------------------------------
32
Alex Bennée (1):
33
Clément Chigot (1):
33
target/arm: report ARMv8-A FP support for AArch32 -cpu max
34
hw/arm/xlnx-zynqmp: fix unsigned error when checking the RPUs number
34
35
35
David Engraf (1):
36
Enze Li (1):
36
hw/arm/virt: Fix non-secure flash mode
37
Update copyright dates to 2023
37
38
38
Peter Maydell (3):
39
Fabiano Rosas (3):
39
pl031: Correctly migrate state when using -rtc clock=host
40
target/arm: Explain why we need to select ARM_V7M
40
target/arm: Set VFP-related MVFR0 fields for arm926 and arm1026
41
arm/Kconfig: Keep Kconfig default entries in default.mak as documentation
41
target/arm: NS BusFault on vector table fetch escalates to NS HardFault
42
arm/Kconfig: Make TCG dependence explicit
42
43
43
Philippe Mathieu-Daudé (5):
44
Marcin Juszkiewicz (2):
44
hw/ssi/xilinx_spips: Convert lqspi_read() to read_with_attrs
45
hw/arm/sbsa-ref: add GIC node into DT
45
hw/ssi/xilinx_spips: Avoid AXI writes to the LQSPI linear memory
46
docs: sbsa: correct graphics card name
46
hw/ssi/xilinx_spips: Avoid out-of-bound access to lqspi_buf[]
47
hw/ssi/mss-spi: Avoid crash when reading empty RX FIFO
48
hw/display/xlnx_dp: Avoid crash when reading empty RX FIFO
49
47
50
include/hw/timer/pl031.h | 2 ++
48
Mostafa Saleh (10):
51
hw/arm/virt.c | 2 +-
49
hw/arm/smmuv3: Add missing fields for IDR0
52
hw/core/machine.c | 1 +
50
hw/arm/smmuv3: Update translation config to hold stage-2
53
hw/display/xlnx_dp.c | 15 +++++---
51
hw/arm/smmuv3: Refactor stage-1 PTW
54
hw/ssi/mss-spi.c | 8 ++++-
52
hw/arm/smmuv3: Add page table walk for stage-2
55
hw/ssi/xilinx_spips.c | 43 +++++++++++++++-------
53
hw/arm/smmuv3: Parse STE config for stage-2
56
hw/timer/pl031.c | 92 +++++++++++++++++++++++++++++++++++++++++++++---
54
hw/arm/smmuv3: Make TLB lookup work for stage-2
57
target/arm/cpu.c | 16 +++++++++
55
hw/arm/smmuv3: Add VMID to TLB tagging
58
target/arm/m_helper.c | 21 ++++++++---
56
hw/arm/smmuv3: Add CMDs related to stage-2
59
9 files changed, 174 insertions(+), 26 deletions(-)
57
hw/arm/smmuv3: Add stage-2 support in iova notifier
58
hw/arm/smmuv3: Add knob to choose translation stage and enable stage-2
60
59
60
Peter Maydell (1):
61
target/arm: Explicitly select short-format FSR for M-profile
62
63
Thomas Huth (1):
64
tests/qtest: Run arm-specific tests only if the required machine is available
65
66
Tommy Wu (1):
67
hw/dma/xilinx_axidma: Check DMASR.HALTED to prevent infinite loop.
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
New patch
1
From: Vitaly Cheptsov <cheptsov@ispras.ru>
1
2
3
SNVS is supported on both i.MX6 and i.MX6UL and is needed
4
to support shutdown on the board.
5
6
Cc: Peter Maydell <peter.maydell@linaro.org> (odd fixer:SABRELITE / i.MX6)
7
Cc: Jean-Christophe Dubois <jcd@tribudubois.net> (reviewer:SABRELITE / i.MX6)
8
Cc: qemu-arm@nongnu.org (open list:SABRELITE / i.MX6)
9
Cc: qemu-devel@nongnu.org (open list:All patches CC here)
10
Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru>
11
Message-id: 20230515095015.66860-1-cheptsov@ispras.ru
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
include/hw/arm/fsl-imx6.h | 2 ++
16
hw/arm/fsl-imx6.c | 8 ++++++++
17
2 files changed, 10 insertions(+)
18
19
diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/include/hw/arm/fsl-imx6.h
22
+++ b/include/hw/arm/fsl-imx6.h
23
@@ -XXX,XX +XXX,XX @@
24
#include "hw/cpu/a9mpcore.h"
25
#include "hw/misc/imx6_ccm.h"
26
#include "hw/misc/imx6_src.h"
27
+#include "hw/misc/imx7_snvs.h"
28
#include "hw/watchdog/wdt_imx2.h"
29
#include "hw/char/imx_serial.h"
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
*/
65
--
66
2.34.1
diff view generated by jsdifflib
New patch
1
From: Mostafa Saleh <smostafa@google.com>
1
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
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
21
hw/arm/smmuv3-internal.h | 2 ++
22
1 file changed, 2 insertions(+)
23
24
diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h
25
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/arm/smmuv3-internal.h
27
+++ b/hw/arm/smmuv3-internal.h
28
@@ -XXX,XX +XXX,XX @@ typedef enum SMMUTranslationStatus {
29
/* MMIO Registers */
30
31
REG32(IDR0, 0x0)
32
+ FIELD(IDR0, S2P, 0 , 1)
33
FIELD(IDR0, S1P, 1 , 1)
34
FIELD(IDR0, TTF, 2 , 2)
35
FIELD(IDR0, COHACC, 4 , 1)
36
FIELD(IDR0, ASID16, 12, 1)
37
+ FIELD(IDR0, VMID16, 18, 1)
38
FIELD(IDR0, TTENDIAN, 21, 2)
39
FIELD(IDR0, STALL_MODEL, 24, 2)
40
FIELD(IDR0, TERM_MODEL, 26, 1)
41
--
42
2.34.1
diff view generated by jsdifflib
New patch
1
From: Mostafa Saleh <smostafa@google.com>
1
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
35
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
36
---
37
include/hw/arm/smmu-common.h | 22 +++++++++++++++++++---
38
1 file changed, 19 insertions(+), 3 deletions(-)
39
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 SMMUTLBEntry {
45
uint8_t granule;
46
} SMMUTLBEntry;
47
48
+/* Stage-2 configuration. */
49
+typedef struct SMMUS2Cfg {
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
64
*/
65
typedef struct SMMUTransCfg {
66
+ /* Shared fields between stage-1 and stage-2. */
67
int stage; /* translation stage */
68
- bool aa64; /* arch64 or aarch32 translation table */
69
bool disabled; /* smmu is disabled */
70
bool bypassed; /* translation is bypassed */
71
bool aborted; /* translation is aborted */
72
+ uint32_t iotlb_hits; /* counts IOTLB hits */
73
+ uint32_t iotlb_misses; /* counts IOTLB misses*/
74
+ /* Used by stage-1 only. */
75
+ bool aa64; /* arch64 or aarch32 translation table */
76
bool record_faults; /* record fault events */
77
uint64_t ttb; /* TT base address */
78
uint8_t oas; /* output address width */
79
uint8_t tbi; /* Top Byte Ignore */
80
uint16_t asid;
81
SMMUTransTableInfo tt[2];
82
- uint32_t iotlb_hits; /* counts IOTLB hits for this asid */
83
- uint32_t iotlb_misses; /* counts IOTLB misses for this asid */
84
+ /* Used by stage-2 only. */
85
+ struct SMMUS2Cfg s2cfg;
86
} SMMUTransCfg;
87
88
typedef struct SMMUDevice {
89
--
90
2.34.1
diff view generated by jsdifflib
New patch
1
From: Mostafa Saleh <smostafa@google.com>
1
2
3
In preparation for adding stage-2 support, rename smmu_ptw_64 to
4
smmu_ptw_64_s1 and refactor some of the code so it can be reused in
5
stage-2 page table walk.
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
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
23
include/hw/arm/smmu-common.h | 16 +++++++++++++---
24
hw/arm/smmu-common.c | 27 ++++++++++-----------------
25
hw/arm/smmuv3.c | 2 ++
26
hw/arm/trace-events | 2 +-
27
4 files changed, 26 insertions(+), 21 deletions(-)
28
29
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
30
index XXXXXXX..XXXXXXX 100644
31
--- a/include/hw/arm/smmu-common.h
32
+++ b/include/hw/arm/smmu-common.h
33
@@ -XXX,XX +XXX,XX @@
34
#include "hw/pci/pci.h"
35
#include "qom/object.h"
36
37
-#define SMMU_PCI_BUS_MAX 256
38
-#define SMMU_PCI_DEVFN_MAX 256
39
-#define SMMU_PCI_DEVFN(sid) (sid & 0xFF)
40
+#define SMMU_PCI_BUS_MAX 256
41
+#define SMMU_PCI_DEVFN_MAX 256
42
+#define SMMU_PCI_DEVFN(sid) (sid & 0xFF)
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
64
index XXXXXXX..XXXXXXX 100644
65
--- a/hw/arm/smmu-common.c
66
+++ b/hw/arm/smmu-common.c
67
@@ -XXX,XX +XXX,XX @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova)
68
}
69
70
/**
71
- * smmu_ptw_64 - VMSAv8-64 Walk of the page tables for a given IOVA
72
+ * smmu_ptw_64_s1 - VMSAv8-64 Walk of the page tables for a given IOVA
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)
86
{
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;
123
}
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);
138
}
139
140
/**
141
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
142
index XXXXXXX..XXXXXXX 100644
143
--- a/hw/arm/smmuv3.c
144
+++ b/hw/arm/smmuv3.c
145
@@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr,
146
cached_entry = g_new0(SMMUTLBEntry, 1);
147
148
if (smmu_ptw(cfg, aligned_addr, flag, cached_entry, &ptw_info)) {
149
+ /* All faults from PTW has S2 field. */
150
+ event.u.f_walk_eabt.s2 = (ptw_info.stage == 2);
151
g_free(cached_entry);
152
switch (ptw_info.type) {
153
case SMMU_PTW_ERR_WALK_EABT:
154
diff --git a/hw/arm/trace-events b/hw/arm/trace-events
155
index XXXXXXX..XXXXXXX 100644
156
--- a/hw/arm/trace-events
157
+++ b/hw/arm/trace-events
158
@@ -XXX,XX +XXX,XX @@ virt_acpi_setup(void) "No fw cfg or ACPI disabled. Bailing out."
159
160
# smmu-common.c
161
smmu_add_mr(const char *name) "%s"
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
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
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
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
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"
167
--
168
2.34.1
diff view generated by jsdifflib
New patch
1
1
From: Mostafa Saleh <smostafa@google.com>
2
3
In preparation for adding stage-2 support, add Stage-2 PTW code.
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
42
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
43
---
44
hw/arm/smmu-internal.h | 35 ++++++++++
45
hw/arm/smmu-common.c | 142 ++++++++++++++++++++++++++++++++++++++++-
46
2 files changed, 176 insertions(+), 1 deletion(-)
47
48
diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h
49
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/arm/smmu-internal.h
51
+++ b/hw/arm/smmu-internal.h
52
@@ -XXX,XX +XXX,XX @@
53
#define PTE_APTABLE(pte) \
54
(extract64(pte, 61, 2))
55
56
+#define PTE_AF(pte) \
57
+ (extract64(pte, 10, 1))
58
/*
59
* TODO: At the moment all transactions are considered as privileged (EL1)
60
* as IOMMU translation callback does not pass user/priv attributes.
61
@@ -XXX,XX +XXX,XX @@
62
#define is_permission_fault(ap, perm) \
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)
243
{
244
- return smmu_ptw_64_s1(cfg, iova, perm, tlbe, info);
245
+ if (cfg->stage == 1) {
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();
265
}
266
267
/**
268
--
269
2.34.1
diff view generated by jsdifflib
New patch
1
1
From: Mostafa Saleh <smostafa@google.com>
2
3
Parse stage-2 configuration from STE and populate it in SMMUS2Cfg.
4
Validity of field values are checked when possible.
5
6
Only AA64 tables are supported and Small Translation Tables (STT) are
7
not supported.
8
9
According to SMMUv3 UM(IHI0070E) "5.2 Stream Table Entry": All fields
10
with an S2 prefix (with the exception of S2VMID) are IGNORED when
11
stage-2 bypasses translation (Config[1] == 0).
12
13
Which means that VMID can be used(for TLB tagging) even if stage-2 is
14
bypassed, so we parse it unconditionally when S2P exists. Otherwise
15
it is set to -1.(only S1P)
16
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
29
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
30
---
31
hw/arm/smmuv3-internal.h | 10 +-
32
include/hw/arm/smmu-common.h | 1 +
33
include/hw/arm/smmuv3.h | 3 +
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
38
index XXXXXXX..XXXXXXX 100644
39
--- a/hw/arm/smmuv3-internal.h
40
+++ b/hw/arm/smmuv3-internal.h
41
@@ -XXX,XX +XXX,XX @@ typedef struct CD {
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;
98
}
99
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)
110
+{
111
+ if (cfg->s2cfg.tsz > 39) {
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.
180
+ */
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;
227
+}
228
+
229
/* Returns < 0 in case of invalid STE, 0 otherwise */
230
static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg,
231
STE *ste, SMMUEventInfo *event)
232
{
233
uint32_t config;
234
+ int ret;
235
236
if (!STE_VALID(ste)) {
237
if (!event->inval_ste_allowed) {
238
@@ -XXX,XX +XXX,XX @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg,
239
return 0;
240
}
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;
327
--
328
2.34.1
diff view generated by jsdifflib
New patch
1
From: Mostafa Saleh <smostafa@google.com>
1
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
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
---
28
hw/arm/smmuv3.c | 44 +++++++++++++++++++++++++++++++++-----------
29
1 file changed, 33 insertions(+), 11 deletions(-)
30
31
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/arm/smmuv3.c
34
+++ b/hw/arm/smmuv3.c
35
@@ -XXX,XX +XXX,XX @@ static int smmuv3_decode_config(IOMMUMemoryRegion *mr, SMMUTransCfg *cfg,
36
STE ste;
37
CD cd;
38
39
+ /* ASID defaults to -1 (if s1 is not supported). */
40
+ cfg->asid = -1;
41
+
42
ret = smmu_find_ste(s, sid, &ste, event);
43
if (ret) {
44
return ret;
45
@@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr,
46
.addr_mask = ~(hwaddr)0,
47
.perm = IOMMU_NONE,
48
};
49
+ /*
50
+ * Combined attributes used for TLB lookup, as only one stage is supported,
51
+ * it will hold attributes based on the enabled stage.
52
+ */
53
+ SMMUTransTableInfo tt_combined;
54
55
qemu_mutex_lock(&s->mutex);
56
57
@@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr,
58
goto epilogue;
59
}
60
61
- tt = select_tt(cfg, addr);
62
- if (!tt) {
63
- if (cfg->record_faults) {
64
- event.type = SMMU_EVT_F_TRANSLATION;
65
- event.u.f_translation.addr = addr;
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;
104
--
105
2.34.1
diff view generated by jsdifflib
New patch
1
1
From: Mostafa Saleh <smostafa@google.com>
2
3
Allow TLB to be tagged with VMID.
4
5
If stage-1 is only supported, VMID is set to -1 and ignored from STE
6
and CMD_TLBI_NH* cmds.
7
8
Update smmu_iotlb_insert trace event to have vmid.
9
10
Signed-off-by: Mostafa Saleh <smostafa@google.com>
11
Reviewed-by: Eric Auger <eric.auger@redhat.com>
12
Tested-by: Eric Auger <eric.auger@redhat.com>
13
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
14
Message-id: 20230516203327.2051088-8-smostafa@google.com
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
17
hw/arm/smmu-internal.h | 2 ++
18
include/hw/arm/smmu-common.h | 5 +++--
19
hw/arm/smmu-common.c | 36 ++++++++++++++++++++++--------------
20
hw/arm/smmuv3.c | 12 +++++++++---
21
hw/arm/trace-events | 6 +++---
22
5 files changed, 39 insertions(+), 22 deletions(-)
23
24
diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h
25
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/arm/smmu-internal.h
27
+++ b/hw/arm/smmu-internal.h
28
@@ -XXX,XX +XXX,XX @@ static inline int pgd_concat_idx(int start_level, int granule_sz,
29
}
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)) {
149
return false;
150
}
151
+ if (info->vmid >= 0 && info->vmid != SMMU_IOTLB_VMID(iotlb_key)) {
152
+ return false;
153
+ }
154
return ((info->iova & ~entry->addr_mask) == entry->iova) ||
155
((entry->iova & ~info->mask) == info->iova);
156
}
157
158
-void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova,
159
+void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova,
160
uint8_t tg, uint64_t num_pages, uint8_t ttl)
161
{
162
/* if tg is not set we use 4KB range invalidation */
163
uint8_t granule = tg ? tg * 2 + 10 : 12;
164
165
if (ttl && (num_pages == 1) && (asid >= 0)) {
166
- SMMUIOTLBKey key = smmu_get_iotlb_key(asid, iova, tg, ttl);
167
+ SMMUIOTLBKey key = smmu_get_iotlb_key(asid, vmid, iova, tg, ttl);
168
169
if (g_hash_table_remove(s->iotlb, &key)) {
170
return;
171
@@ -XXX,XX +XXX,XX @@ void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova,
172
173
SMMUIOTLBPageInvInfo info = {
174
.asid = asid, .iova = iova,
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);
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)"
245
--
246
2.34.1
diff view generated by jsdifflib
New patch
1
1
From: Mostafa Saleh <smostafa@google.com>
2
3
CMD_TLBI_S2_IPA: As S1+S2 is not enabled, for now this can be the
4
same as CMD_TLBI_NH_VAA.
5
6
CMD_TLBI_S12_VMALL: Added new function to invalidate TLB by VMID.
7
8
For stage-1 only commands, add a check to throw CERROR_ILL if used
9
when stage-1 is not supported.
10
11
Reviewed-by: Eric Auger <eric.auger@redhat.com>
12
Signed-off-by: Mostafa Saleh <smostafa@google.com>
13
Tested-by: Eric Auger <eric.auger@redhat.com>
14
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
15
Message-id: 20230516203327.2051088-9-smostafa@google.com
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
18
include/hw/arm/smmu-common.h | 1 +
19
hw/arm/smmu-common.c | 16 +++++++++++
20
hw/arm/smmuv3.c | 55 ++++++++++++++++++++++++++++++------
21
hw/arm/trace-events | 4 ++-
22
4 files changed, 67 insertions(+), 9 deletions(-)
23
24
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
25
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/arm/smmu-common.h
27
+++ b/include/hw/arm/smmu-common.h
28
@@ -XXX,XX +XXX,XX @@ SMMUIOTLBKey smmu_get_iotlb_key(uint16_t asid, uint16_t vmid, uint64_t iova,
29
uint8_t tg, uint8_t level);
30
void smmu_iotlb_inv_all(SMMUState *s);
31
void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid);
32
+void smmu_iotlb_inv_vmid(SMMUState *s, uint16_t vmid);
33
void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova,
34
uint8_t tg, uint64_t num_pages, uint8_t ttl);
35
36
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/hw/arm/smmu-common.c
39
+++ b/hw/arm/smmu-common.c
40
@@ -XXX,XX +XXX,XX @@ static gboolean smmu_hash_remove_by_asid(gpointer key, gpointer value,
41
42
return SMMU_IOTLB_ASID(*iotlb_key) == asid;
43
}
44
+
45
+static gboolean smmu_hash_remove_by_vmid(gpointer key, gpointer value,
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)
56
{
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);
59
}
60
61
+inline void smmu_iotlb_inv_vmid(SMMUState *s, uint16_t vmid)
62
+{
63
+ trace_smmu_iotlb_inv_vmid(vmid);
64
+ g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_vmid, &vmid);
65
+}
66
+
67
/* VMSAv8-64 Translation */
68
69
/**
70
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
71
index XXXXXXX..XXXXXXX 100644
72
--- a/hw/arm/smmuv3.c
73
+++ b/hw/arm/smmuv3.c
74
@@ -XXX,XX +XXX,XX @@ static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova,
75
}
76
}
77
78
-static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
79
+static void smmuv3_range_inval(SMMUState *s, Cmd *cmd)
80
{
81
dma_addr_t end, addr = CMD_ADDR(cmd);
82
uint8_t type = CMD_TYPE(cmd);
83
@@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
84
}
85
86
if (!tg) {
87
- trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, 1, ttl, leaf);
88
+ trace_smmuv3_range_inval(vmid, asid, addr, tg, 1, ttl, leaf);
89
smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1);
90
smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl);
91
return;
92
@@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
93
uint64_t mask = dma_aligned_pow2_mask(addr, end, 64);
94
95
num_pages = (mask + 1) >> granule;
96
- trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf);
97
+ trace_smmuv3_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf);
98
smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages);
99
smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl);
100
addr += mask + 1;
101
@@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
102
{
103
uint16_t asid = CMD_ASID(&cmd);
104
105
+ if (!STAGE1_SUPPORTED(s)) {
106
+ cmd_error = SMMU_CERROR_ILL;
107
+ break;
108
+ }
109
+
110
trace_smmuv3_cmdq_tlbi_nh_asid(asid);
111
smmu_inv_notifiers_all(&s->smmu_state);
112
smmu_iotlb_inv_asid(bs, asid);
113
break;
114
}
115
case SMMU_CMD_TLBI_NH_ALL:
116
+ if (!STAGE1_SUPPORTED(s)) {
117
+ cmd_error = SMMU_CERROR_ILL;
118
+ break;
119
+ }
120
+ QEMU_FALLTHROUGH;
121
case SMMU_CMD_TLBI_NSNH_ALL:
122
trace_smmuv3_cmdq_tlbi_nh();
123
smmu_inv_notifiers_all(&s->smmu_state);
124
@@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
125
break;
126
case SMMU_CMD_TLBI_NH_VAA:
127
case SMMU_CMD_TLBI_NH_VA:
128
- smmuv3_s1_range_inval(bs, &cmd);
129
+ if (!STAGE1_SUPPORTED(s)) {
130
+ cmd_error = SMMU_CERROR_ILL;
131
+ break;
132
+ }
133
+ smmuv3_range_inval(bs, &cmd);
134
+ break;
135
+ case SMMU_CMD_TLBI_S12_VMALL:
136
+ {
137
+ uint16_t vmid = CMD_VMID(&cmd);
138
+
139
+ if (!STAGE2_SUPPORTED(s)) {
140
+ cmd_error = SMMU_CERROR_ILL;
141
+ break;
142
+ }
143
+
144
+ trace_smmuv3_cmdq_tlbi_s12_vmid(vmid);
145
+ smmu_inv_notifiers_all(&s->smmu_state);
146
+ smmu_iotlb_inv_vmid(bs, vmid);
147
+ break;
148
+ }
149
+ case SMMU_CMD_TLBI_S2_IPA:
150
+ if (!STAGE2_SUPPORTED(s)) {
151
+ cmd_error = SMMU_CERROR_ILL;
152
+ break;
153
+ }
154
+ /*
155
+ * As currently only either s1 or s2 are supported
156
+ * we can reuse same function for s2.
157
+ */
158
+ smmuv3_range_inval(bs, &cmd);
159
break;
160
case SMMU_CMD_TLBI_EL3_ALL:
161
case SMMU_CMD_TLBI_EL3_VA:
162
@@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
163
case SMMU_CMD_TLBI_EL2_ASID:
164
case SMMU_CMD_TLBI_EL2_VA:
165
case SMMU_CMD_TLBI_EL2_VAA:
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"
212
--
213
2.34.1
diff view generated by jsdifflib
1
In the M-profile architecture, when we do a vector table fetch and it
1
From: Mostafa Saleh <smostafa@google.com>
2
fails, we need to report a HardFault. Whether this is a Secure HF or
3
a NonSecure HF depends on several things. If AIRCR.BFHFNMINS is 0
4
then HF is always Secure, because there is no NonSecure HardFault.
5
Otherwise, the answer depends on whether the 'underlying exception'
6
(MemManage, BusFault, SecureFault) targets Secure or NonSecure. (In
7
the pseudocode, this is handled in the Vector() function: the final
8
exc.isSecure is calculated by looking at the exc.isSecure from the
9
exception returned from the memory access, not the isSecure input
10
argument.)
11
2
12
We weren't doing this correctly, because we were looking at
3
In smmuv3_notify_iova, read the granule based on translation stage
13
the target security domain of the exception we were trying to
4
and use VMID if valid value is sent.
14
load the vector table entry for. This produces errors of two kinds:
15
* a load from the NS vector table which hits the "NS access
16
to S memory" SecureFault should end up as a Secure HardFault,
17
but we were raising an NS HardFault
18
* a load from the S vector table which causes a BusFault
19
should raise an NS HardFault if BFHFNMINS == 1 (because
20
in that case all BusFaults are NonSecure), but we were raising
21
a Secure HardFault
22
5
23
Correct the logic.
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
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
hw/arm/smmuv3.c | 39 ++++++++++++++++++++++++++-------------
14
hw/arm/trace-events | 2 +-
15
2 files changed, 27 insertions(+), 14 deletions(-)
24
16
25
We also fix a comment error where we claimed that we might
17
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
26
be escalating MemManage to HardFault, and forgot about SecureFault.
27
(Vector loads can never hit MPU access faults, because they're
28
always aligned and always use the default address map.)
29
30
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
31
Message-id: 20190705094823.28905-1-peter.maydell@linaro.org
32
---
33
target/arm/m_helper.c | 21 +++++++++++++++++----
34
1 file changed, 17 insertions(+), 4 deletions(-)
35
36
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
37
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/m_helper.c
19
--- a/hw/arm/smmuv3.c
39
+++ b/target/arm/m_helper.c
20
+++ b/hw/arm/smmuv3.c
40
@@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure,
21
@@ -XXX,XX +XXX,XX @@ epilogue:
41
if (sattrs.ns) {
22
* @mr: IOMMU mr region handle
42
attrs.secure = false;
23
* @n: notifier to be called
43
} else if (!targets_secure) {
24
* @asid: address space ID or negative value if we don't care
44
- /* NS access to S memory */
25
+ * @vmid: virtual machine ID or negative value if we don't care
45
+ /*
26
* @iova: iova
46
+ * NS access to S memory: the underlying exception which we escalate
27
* @tg: translation granule (if communicated through range invalidation)
47
+ * to HardFault is SecureFault, which always targets Secure.
28
* @num_pages: number of @granule sized pages (if tg != 0), otherwise 1
48
+ */
29
*/
49
+ exc_secure = true;
30
static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
50
goto load_fail;
31
IOMMUNotifier *n,
32
- int asid, dma_addr_t iova,
33
- uint8_t tg, uint64_t num_pages)
34
+ int asid, int vmid,
35
+ dma_addr_t iova, uint8_t tg,
36
+ uint64_t num_pages)
37
{
38
SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
39
IOMMUTLBEvent event;
40
uint8_t granule;
41
+ SMMUv3State *s = sdev->smmu;
42
43
if (!tg) {
44
SMMUEventInfo event = {.inval_ste_allowed = true};
45
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
46
return;
47
}
48
49
- tt = select_tt(cfg, iova);
50
- if (!tt) {
51
+ if (vmid >= 0 && cfg->s2cfg.vmid != vmid) {
52
return;
53
}
54
- granule = tt->granule_sz;
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);
51
}
95
}
52
}
96
}
53
@@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure,
97
}
54
vector_entry = address_space_ldl(arm_addressspace(cs, attrs), addr,
98
@@ -XXX,XX +XXX,XX @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd)
55
attrs, &result);
99
56
if (result != MEMTX_OK) {
100
if (!tg) {
57
+ /*
101
trace_smmuv3_range_inval(vmid, asid, addr, tg, 1, ttl, leaf);
58
+ * Underlying exception is BusFault: its target security state
102
- smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1);
59
+ * depends on BFHFNMINS.
103
+ smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, 1);
60
+ */
104
smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl);
61
+ exc_secure = !(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK);
105
return;
62
goto load_fail;
63
}
106
}
64
*pvec = vector_entry;
107
@@ -XXX,XX +XXX,XX @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd)
65
@@ -XXX,XX +XXX,XX @@ load_fail:
108
66
/*
109
num_pages = (mask + 1) >> granule;
67
* All vector table fetch fails are reported as HardFault, with
110
trace_smmuv3_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf);
68
* HFSR.VECTTBL and .FORCED set. (FORCED is set because
111
- smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages);
69
- * technically the underlying exception is a MemManage or BusFault
112
+ smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, num_pages);
70
+ * technically the underlying exception is a SecureFault or BusFault
113
smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl);
71
* that is escalated to HardFault.) This is a terminal exception,
114
addr += mask + 1;
72
* so we will either take the HardFault immediately or else enter
115
}
73
* lockup (the latter case is handled in armv7m_nvic_set_pending_derived()).
116
diff --git a/hw/arm/trace-events b/hw/arm/trace-events
74
+ * The HardFault is Secure if BFHFNMINS is 0 (meaning that all HFs are
117
index XXXXXXX..XXXXXXX 100644
75
+ * secure); otherwise it targets the same security state as the
118
--- a/hw/arm/trace-events
76
+ * underlying exception.
119
+++ b/hw/arm/trace-events
77
*/
120
@@ -XXX,XX +XXX,XX @@ smmuv3_cmdq_tlbi_s12_vmid(uint16_t vmid) "vmid=%d"
78
- exc_secure = targets_secure ||
121
smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x"
79
- !(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK);
122
smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s"
80
+ if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
123
smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s"
81
+ exc_secure = true;
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
82
+ }
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
83
env->v7m.hfsr |= R_V7M_HFSR_VECTTBL_MASK | R_V7M_HFSR_FORCED_MASK;
126
84
armv7m_nvic_set_pending_derived(env->nvic, ARMV7M_EXCP_HARD, exc_secure);
85
return false;
86
--
127
--
87
2.20.1
128
2.34.1
88
89
diff view generated by jsdifflib
1
The PL031 RTC tracks the difference between the guest RTC
1
From: Mostafa Saleh <smostafa@google.com>
2
and the host RTC using a tick_offset field. For migration,
3
however, we currently always migrate the offset between
4
the guest and the vm_clock, even if the RTC clock is not
5
the same as the vm_clock; this was an attempt to retain
6
migration backwards compatibility.
7
2
8
Unfortunately this results in the RTC behaving oddly across
3
As everything is in place, we can use a new system property to
9
a VM state save and restore -- since the VM clock stands still
4
advertise which stage is supported and remove bad_ste from STE
10
across save-then-restore, regardless of how much real world
5
stage2 config.
11
time has elapsed, the guest RTC ends up out of sync with the
12
host RTC in the restored VM.
13
6
14
Fix this by migrating the raw tick_offset. To retain migration
7
The property added arm-smmuv3.stage can have 3 values:
15
compatibility as far as possible, we have a new property
8
- "1": Stage-1 only is advertised.
16
migrate-tick-offset; by default this is 'true' and we will
9
- "2": Stage-2 only is advertised.
17
migrate the true tick offset in a new subsection; if the
18
incoming data has no subsection we fall back to the old
19
vm_clock-based offset information, so old->new migration
20
compatibility is preserved. For complete new->old migration
21
compatibility, the property is set to 'false' for 4.0 and
22
earlier machine types (this will only affect 'virt-4.0'
23
and below, as none of the other pl031-using machines are
24
versioned).
25
10
26
Reported-by: Russell King <rmk@armlinux.org.uk>
11
If not passed or an unsupported value is passed, it will default to
12
stage-1.
13
14
Advertise VMID16.
15
16
Don't try to decode CD, if stage-2 is configured.
17
18
Reviewed-by: Eric Auger <eric.auger@redhat.com>
19
Signed-off-by: Mostafa Saleh <smostafa@google.com>
20
Tested-by: Eric Auger <eric.auger@redhat.com>
21
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
22
Message-id: 20230516203327.2051088-11-smostafa@google.com
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
29
Message-id: 20190709143912.28905-1-peter.maydell@linaro.org
30
---
24
---
31
include/hw/timer/pl031.h | 2 +
25
include/hw/arm/smmuv3.h | 1 +
32
hw/core/machine.c | 1 +
26
hw/arm/smmuv3.c | 32 ++++++++++++++++++++++----------
33
hw/timer/pl031.c | 92 ++++++++++++++++++++++++++++++++++++++--
27
2 files changed, 23 insertions(+), 10 deletions(-)
34
3 files changed, 91 insertions(+), 4 deletions(-)
35
28
36
diff --git a/include/hw/timer/pl031.h b/include/hw/timer/pl031.h
29
diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h
37
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
38
--- a/include/hw/timer/pl031.h
31
--- a/include/hw/arm/smmuv3.h
39
+++ b/include/hw/timer/pl031.h
32
+++ b/include/hw/arm/smmuv3.h
40
@@ -XXX,XX +XXX,XX @@ typedef struct PL031State {
33
@@ -XXX,XX +XXX,XX @@ struct SMMUv3State {
41
*/
34
42
uint32_t tick_offset_vmstate;
35
qemu_irq irq[4];
43
uint32_t tick_offset;
36
QemuMutex mutex;
44
+ bool tick_offset_migrated;
37
+ char *stage;
45
+ bool migrate_tick_offset;
38
};
46
39
47
uint32_t mr;
40
typedef enum {
48
uint32_t lr;
41
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
49
diff --git a/hw/core/machine.c b/hw/core/machine.c
50
index XXXXXXX..XXXXXXX 100644
42
index XXXXXXX..XXXXXXX 100644
51
--- a/hw/core/machine.c
43
--- a/hw/arm/smmuv3.c
52
+++ b/hw/core/machine.c
44
+++ b/hw/arm/smmuv3.c
53
@@ -XXX,XX +XXX,XX @@ GlobalProperty hw_compat_4_0[] = {
45
@@ -XXX,XX +XXX,XX @@
54
{ "virtio-gpu-pci", "edid", "false" },
46
#include "hw/irq.h"
55
{ "virtio-device", "use-started", "false" },
47
#include "hw/sysbus.h"
56
{ "virtio-balloon-device", "qemu-4-0-config-size", "true" },
48
#include "migration/vmstate.h"
57
+ { "pl031", "migrate-tick-offset", "false" },
49
+#include "hw/qdev-properties.h"
58
};
50
#include "hw/qdev-core.h"
59
const size_t hw_compat_4_0_len = G_N_ELEMENTS(hw_compat_4_0);
51
#include "hw/pci/pci.h"
60
52
#include "cpu.h"
61
diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c
53
@@ -XXX,XX +XXX,XX @@ void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *info)
62
index XXXXXXX..XXXXXXX 100644
54
63
--- a/hw/timer/pl031.c
55
static void smmuv3_init_regs(SMMUv3State *s)
64
+++ b/hw/timer/pl031.c
65
@@ -XXX,XX +XXX,XX @@ static int pl031_pre_save(void *opaque)
66
{
56
{
67
PL031State *s = opaque;
57
- /**
68
58
- * IDR0: stage1 only, AArch64 only, coherent access, 16b ASID,
69
- /* tick_offset is base_time - rtc_clock base time. Instead, we want to
59
- * multi-level stream table
70
- * store the base time relative to the QEMU_CLOCK_VIRTUAL for backwards-compatibility. */
60
- */
71
+ /*
61
- s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1); /* stage 1 supported */
72
+ * The PL031 device model code uses the tick_offset field, which is
62
+ /* Based on sys property, the stages supported in smmu will be advertised.*/
73
+ * the offset between what the guest RTC should read and what the
63
+ if (s->stage && !strcmp("2", s->stage)) {
74
+ * QEMU rtc_clock reads:
64
+ s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S2P, 1);
75
+ * guest_rtc = rtc_clock + tick_offset
65
+ } else {
76
+ * and so
66
+ s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1);
77
+ * tick_offset = guest_rtc - rtc_clock
67
+ }
78
+ *
68
+
79
+ * We want to migrate this offset, which sounds straightforward.
69
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, TTF, 2); /* AArch64 PTW only */
80
+ * Unfortunately older versions of QEMU migrated a conversion of this
70
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, COHACC, 1); /* IO coherent */
81
+ * offset into an offset from the vm_clock. (This was in turn an
71
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, ASID16, 1); /* 16-bit ASID */
82
+ * attempt to be compatible with even older QEMU versions, but it
72
+ s->idr[0] = FIELD_DP32(s->idr[0], IDR0, VMID16, 1); /* 16-bit VMID */
83
+ * has incorrect behaviour if the rtc_clock is not the same as the
73
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, TTENDIAN, 2); /* little endian */
84
+ * vm_clock.) So we put the actual tick_offset into a migration
74
s->idr[0] = FIELD_DP32(s->idr[0], IDR0, STALL_MODEL, 1); /* No stall */
85
+ * subsection, and the backwards-compatible time-relative-to-vm_clock
75
/* terminated transaction will always be aborted/error returned */
86
+ * in the main migration state.
76
@@ -XXX,XX +XXX,XX @@ static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *ste)
87
+ *
77
goto bad_ste;
88
+ * Calculate base time relative to QEMU_CLOCK_VIRTUAL:
78
}
89
+ */
79
90
int64_t delta = qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
80
- /* This is still here as stage 2 has not been fully enabled yet. */
91
s->tick_offset_vmstate = s->tick_offset + delta / NANOSECONDS_PER_SECOND;
81
- qemu_log_mask(LOG_UNIMP, "SMMUv3 does not support stage 2 yet\n");
92
82
- goto bad_ste;
83
-
93
return 0;
84
return 0;
94
}
85
95
86
bad_ste:
96
+static int pl031_pre_load(void *opaque)
87
@@ -XXX,XX +XXX,XX @@ static int smmuv3_decode_config(IOMMUMemoryRegion *mr, SMMUTransCfg *cfg,
97
+{
88
return ret;
98
+ PL031State *s = opaque;
89
}
99
+
90
100
+ s->tick_offset_migrated = false;
91
- if (cfg->aborted || cfg->bypassed) {
101
+ return 0;
92
+ if (cfg->aborted || cfg->bypassed || (cfg->stage == 2)) {
102
+}
93
return 0;
103
+
94
}
104
static int pl031_post_load(void *opaque, int version_id)
95
105
{
96
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3 = {
106
PL031State *s = opaque;
107
108
- int64_t delta = qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
109
- s->tick_offset = s->tick_offset_vmstate - delta / NANOSECONDS_PER_SECOND;
110
+ /*
111
+ * If we got the tick_offset subsection, then we can just use
112
+ * the value in that. Otherwise the source is an older QEMU and
113
+ * has given us the offset from the vm_clock; convert it back to
114
+ * an offset from the rtc_clock. This will cause time to incorrectly
115
+ * go backwards compared to the host RTC, but this is unavoidable.
116
+ */
117
+
118
+ if (!s->tick_offset_migrated) {
119
+ int64_t delta = qemu_clock_get_ns(rtc_clock) -
120
+ qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
121
+ s->tick_offset = s->tick_offset_vmstate -
122
+ delta / NANOSECONDS_PER_SECOND;
123
+ }
124
pl031_set_alarm(s);
125
return 0;
126
}
127
128
+static int pl031_tick_offset_post_load(void *opaque, int version_id)
129
+{
130
+ PL031State *s = opaque;
131
+
132
+ s->tick_offset_migrated = true;
133
+ return 0;
134
+}
135
+
136
+static bool pl031_tick_offset_needed(void *opaque)
137
+{
138
+ PL031State *s = opaque;
139
+
140
+ return s->migrate_tick_offset;
141
+}
142
+
143
+static const VMStateDescription vmstate_pl031_tick_offset = {
144
+ .name = "pl031/tick-offset",
145
+ .version_id = 1,
146
+ .minimum_version_id = 1,
147
+ .needed = pl031_tick_offset_needed,
148
+ .post_load = pl031_tick_offset_post_load,
149
+ .fields = (VMStateField[]) {
150
+ VMSTATE_UINT32(tick_offset, PL031State),
151
+ VMSTATE_END_OF_LIST()
152
+ }
153
+};
154
+
155
static const VMStateDescription vmstate_pl031 = {
156
.name = "pl031",
157
.version_id = 1,
158
.minimum_version_id = 1,
159
.pre_save = pl031_pre_save,
160
+ .pre_load = pl031_pre_load,
161
.post_load = pl031_post_load,
162
.fields = (VMStateField[]) {
163
VMSTATE_UINT32(tick_offset_vmstate, PL031State),
164
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pl031 = {
165
VMSTATE_UINT32(im, PL031State),
166
VMSTATE_UINT32(is, PL031State),
167
VMSTATE_END_OF_LIST()
168
+ },
169
+ .subsections = (const VMStateDescription*[]) {
170
+ &vmstate_pl031_tick_offset,
171
+ NULL
172
}
97
}
173
};
98
};
174
99
175
+static Property pl031_properties[] = {
100
+static Property smmuv3_properties[] = {
176
+ /*
101
+ /*
177
+ * True to correctly migrate the tick offset of the RTC. False to
102
+ * Stages of translation advertised.
178
+ * obtain backward migration compatibility with older QEMU versions,
103
+ * "1": Stage 1
179
+ * at the expense of the guest RTC going backwards compared with the
104
+ * "2": Stage 2
180
+ * host RTC when the VM is saved/restored if using -rtc host.
105
+ * Defaults to stage 1
181
+ * (Even if set to 'true' older QEMU can migrate forward to newer QEMU;
182
+ * 'false' also permits newer QEMU to migrate to older QEMU.)
183
+ */
106
+ */
184
+ DEFINE_PROP_BOOL("migrate-tick-offset",
107
+ DEFINE_PROP_STRING("stage", SMMUv3State, stage),
185
+ PL031State, migrate_tick_offset, true),
186
+ DEFINE_PROP_END_OF_LIST()
108
+ DEFINE_PROP_END_OF_LIST()
187
+};
109
+};
188
+
110
+
189
static void pl031_class_init(ObjectClass *klass, void *data)
111
static void smmuv3_instance_init(Object *obj)
190
{
112
{
191
DeviceClass *dc = DEVICE_CLASS(klass);
113
/* Nothing much to do here as of now */
192
114
@@ -XXX,XX +XXX,XX @@ static void smmuv3_class_init(ObjectClass *klass, void *data)
193
dc->vmsd = &vmstate_pl031;
115
&c->parent_phases);
194
+ dc->props = pl031_properties;
116
c->parent_realize = dc->realize;
117
dc->realize = smmu_realize;
118
+ device_class_set_props(dc, smmuv3_properties);
195
}
119
}
196
120
197
static const TypeInfo pl031_info = {
121
static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
198
--
122
--
199
2.20.1
123
2.34.1
200
201
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Tommy Wu <tommy.wu@sifive.com>
2
2
3
Lei Sun found while auditing the code that a CPU write would
3
When we receive a packet from the xilinx_axienet and then try to s2mem
4
trigger a NULL pointer dereference.
4
through the xilinx_axidma, if the descriptor ring buffer is full in the
5
xilinx axidma driver, we’ll assert the DMASR.HALTED in the
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.
5
8
6
>From UG1085 datasheet [*] AXI writes in this region are ignored
9
This patch checks the DMASR.HALTED state when we try to push data
7
and generates an AXI Slave Error (SLVERR).
10
from xilinx axi-enet to xilinx axi-dma. When the DMASR.HALTED is asserted,
11
we will not keep pushing the data and then prevent the infinte loop.
8
12
9
Fix by implementing the write_with_attrs() handler.
13
Signed-off-by: Tommy Wu <tommy.wu@sifive.com>
10
Return MEMTX_ERROR when the region is accessed (this error maps
14
Reviewed-by: Edgar E. Iglesias <edgar@zeroasic.com>
11
to an AXI slave error).
15
Reviewed-by: Frank Chang <frank.chang@sifive.com>
12
16
Message-id: 20230519062137.1251741-1-tommy.wu@sifive.com
13
[*] https://www.xilinx.com/support/documentation/user_guides/ug1085-zynq-ultrascale-trm.pdf
14
15
Reported-by: Lei Sun <slei.casper@gmail.com>
16
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
17
Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com>
18
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
18
---
21
hw/ssi/xilinx_spips.c | 16 ++++++++++++++++
19
hw/dma/xilinx_axidma.c | 11 ++++++++---
22
1 file changed, 16 insertions(+)
20
1 file changed, 8 insertions(+), 3 deletions(-)
23
21
24
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
22
diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
25
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/ssi/xilinx_spips.c
24
--- a/hw/dma/xilinx_axidma.c
27
+++ b/hw/ssi/xilinx_spips.c
25
+++ b/hw/dma/xilinx_axidma.c
28
@@ -XXX,XX +XXX,XX @@ static MemTxResult lqspi_read(void *opaque, hwaddr addr, uint64_t *value,
26
@@ -XXX,XX +XXX,XX @@ static inline int stream_idle(struct Stream *s)
29
return lqspi_read(opaque, addr, value, size, attrs);
27
return !!(s->regs[R_DMASR] & DMASR_IDLE);
30
}
28
}
31
29
32
+static MemTxResult lqspi_write(void *opaque, hwaddr offset, uint64_t value,
30
+static inline int stream_halted(struct Stream *s)
33
+ unsigned size, MemTxAttrs attrs)
34
+{
31
+{
35
+ /*
32
+ return !!(s->regs[R_DMASR] & DMASR_HALTED);
36
+ * From UG1085, Chapter 24 (Quad-SPI controllers):
37
+ * - Writes are ignored
38
+ * - AXI writes generate an external AXI slave error (SLVERR)
39
+ */
40
+ qemu_log_mask(LOG_GUEST_ERROR, "%s Unexpected %u-bit access to 0x%" PRIx64
41
+ " (value: 0x%" PRIx64 "\n",
42
+ __func__, size << 3, offset, value);
43
+
44
+ return MEMTX_ERROR;
45
+}
33
+}
46
+
34
+
47
static const MemoryRegionOps lqspi_ops = {
35
static void stream_reset(struct Stream *s)
48
.read_with_attrs = lqspi_read,
36
{
49
+ .write_with_attrs = lqspi_write,
37
s->regs[R_DMASR] = DMASR_HALTED; /* starts up halted. */
50
.endianness = DEVICE_NATIVE_ENDIAN,
38
@@ -XXX,XX +XXX,XX @@ static void stream_process_mem2s(struct Stream *s, StreamSink *tx_data_dev,
51
.valid = {
39
uint64_t addr;
52
.min_access_size = 1,
40
bool eop;
41
42
- if (!stream_running(s) || stream_idle(s)) {
43
+ if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
44
return;
45
}
46
47
@@ -XXX,XX +XXX,XX @@ static size_t stream_process_s2mem(struct Stream *s, unsigned char *buf,
48
unsigned int rxlen;
49
size_t pos = 0;
50
51
- if (!stream_running(s) || stream_idle(s)) {
52
+ if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
53
return 0;
54
}
55
56
@@ -XXX,XX +XXX,XX @@ xilinx_axidma_data_stream_can_push(StreamSink *obj,
57
XilinxAXIDMAStreamSink *ds = XILINX_AXI_DMA_DATA_STREAM(obj);
58
struct Stream *s = &ds->dma->streams[1];
59
60
- if (!stream_running(s) || stream_idle(s)) {
61
+ if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
62
ds->dma->notify = notify;
63
ds->dma->notify_opaque = notify_opaque;
64
return false;
53
--
65
--
54
2.20.1
66
2.34.1
55
67
56
68
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Clément Chigot <chigot@adacore.com>
2
2
3
Both lqspi_read() and lqspi_load_cache() expect a 32-bit
3
When passing --smp with a number lower than XLNX_ZYNQMP_NUM_APU_CPUS,
4
aligned address.
4
the expression (ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS) will result
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)
5
12
6
>From UG1085 datasheet [*] chapter on 'Quad-SPI Controller':
13
Signed-off-by: Clément Chigot <chigot@adacore.com>
7
8
Transfer Size Limitations
9
10
Because of the 32-bit wide TX, RX, and generic FIFO, all
11
APB/AXI transfers must be an integer multiple of 4-bytes.
12
Shorter transfers are not possible.
13
14
Set MemoryRegionOps.impl values to force 32-bit accesses,
15
this way we are sure we do not access the lqspi_buf[] array
16
out of bound.
17
18
[*] https://www.xilinx.com/support/documentation/user_guides/ug1085-zynq-ultrascale-trm.pdf
19
20
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
14
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
21
Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com>
15
Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com>
22
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
16
Message-id: 20230524143714.565792-1-chigot@adacore.com
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
---
18
---
25
hw/ssi/xilinx_spips.c | 4 ++++
19
hw/arm/xlnx-zynqmp.c | 2 +-
26
1 file changed, 4 insertions(+)
20
1 file changed, 1 insertion(+), 1 deletion(-)
27
21
28
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
22
diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
29
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/ssi/xilinx_spips.c
24
--- a/hw/arm/xlnx-zynqmp.c
31
+++ b/hw/ssi/xilinx_spips.c
25
+++ b/hw/arm/xlnx-zynqmp.c
32
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps lqspi_ops = {
26
@@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,
33
.read_with_attrs = lqspi_read,
27
const char *boot_cpu, Error **errp)
34
.write_with_attrs = lqspi_write,
28
{
35
.endianness = DEVICE_NATIVE_ENDIAN,
29
int i;
36
+ .impl = {
30
- int num_rpus = MIN(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS,
37
+ .min_access_size = 4,
31
+ int num_rpus = MIN((int)(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS),
38
+ .max_access_size = 4,
32
XLNX_ZYNQMP_NUM_RPU_CPUS);
39
+ },
33
40
.valid = {
34
if (num_rpus <= 0) {
41
.min_access_size = 1,
42
.max_access_size = 4
43
--
35
--
44
2.20.1
36
2.34.1
45
37
46
38
diff view generated by jsdifflib
New patch
1
From: Thomas Huth <thuth@redhat.com>
1
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
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
tests/qtest/meson.build | 7 ++++---
14
1 file changed, 4 insertions(+), 3 deletions(-)
15
16
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
17
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qtest/meson.build
19
+++ b/tests/qtest/meson.build
20
@@ -XXX,XX +XXX,XX @@ qtests_arm = \
21
(config_all_devices.has_key('CONFIG_CMSDK_APB_DUALTIMER') ? ['cmsdk-apb-dualtimer-test'] : []) + \
22
(config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \
23
(config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \
24
- (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \
25
+ (config_all_devices.has_key('CONFIG_PFLASH_CFI02') and
26
+ config_all_devices.has_key('CONFIG_MUSICPAL') ? ['pflash-cfi02-test'] : []) + \
27
(config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed : []) + \
28
(config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \
29
(config_all_devices.has_key('CONFIG_GENERIC_LOADER') ? ['hexloader-test'] : []) + \
30
(config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \
31
+ (config_all_devices.has_key('CONFIG_VEXPRESS') ? ['test-arm-mptimer'] : []) + \
32
+ (config_all_devices.has_key('CONFIG_MICROBIT') ? ['microbit-test'] : []) + \
33
['arm-cpu-features',
34
- 'microbit-test',
35
- 'test-arm-mptimer',
36
'boot-serial-test']
37
38
# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
39
--
40
2.34.1
diff view generated by jsdifflib
1
The ARMv5 architecture didn't specify detailed per-feature ID
1
For M-profile, there is no guest-facing A-profile format FSR, but we
2
registers. Now that we're using the MVFR0 register fields to
2
still use the env->exception.fsr field to pass fault information from
3
gate the existence of VFP instructions, we need to set up
3
the point where a fault is raised to the code in
4
the correct values in the cpu->isar structure so that we still
4
arm_v7m_cpu_do_interrupt() which interprets it and sets the M-profile
5
provide an FPU to the guest.
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.
6
9
7
This fixes a regression in the arm926 and arm1026 CPUs, which
10
In compute_fsr_fsc() we weren't explicitly choosing short-form for
8
are the only ones that both have VFP and are ARMv5 or earlier.
11
M-profile, but instead relied on it falling out in the wash because
9
This regression was introduced by the VFP refactoring, and more
12
arm_s1_regime_using_lpae_format() would be false. This was broken in
10
specifically by commits 1120827fa182f0e76 and 266bd25c485597c,
13
commit 452c67a4 when we added v8R support, because we said "PMSAv8 is
11
which accidentally disabled VFP short-vector support and
14
always LPAE format" (as it is for v8R), forgetting that we were
12
double-precision support on these CPUs.
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
13
18
14
Fixes: 1120827fa182f0e
19
#7 0x0000555555e055f7 in arm_fi_to_lfsc (fi=0x7fffecff9a90) at ../../target/arm/internals.h:549
15
Fixes: 266bd25c485597c
20
#8 0x0000555555e05a27 in compute_fsr_fsc (env=0x555557356670, fi=0x7fffecff9a90, target_el=1, mmu_idx=1, ret_fsc=0x7fffecff9a1c)
16
Fixes: https://bugs.launchpad.net/qemu/+bug/1836192
21
at ../../target/arm/tlb_helper.c:95
17
Reported-by: Christophe Lyon <christophe.lyon@linaro.org>
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
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
44
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
45
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
46
Message-id: 20230523131726.866635-1-peter.maydell@linaro.org
21
Tested-by: Christophe Lyon <christophe.lyon@linaro.org>
22
Message-id: 20190711131241.22231-1-peter.maydell@linaro.org
23
---
47
---
24
target/arm/cpu.c | 12 ++++++++++++
48
target/arm/tcg/tlb_helper.c | 13 +++++++++++--
25
1 file changed, 12 insertions(+)
49
1 file changed, 11 insertions(+), 2 deletions(-)
26
50
27
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
51
diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c
28
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/cpu.c
53
--- a/target/arm/tcg/tlb_helper.c
30
+++ b/target/arm/cpu.c
54
+++ b/target/arm/tcg/tlb_helper.c
31
@@ -XXX,XX +XXX,XX @@ static void arm926_initfn(Object *obj)
55
@@ -XXX,XX +XXX,XX @@ static uint32_t compute_fsr_fsc(CPUARMState *env, ARMMMUFaultInfo *fi,
32
* set the field to indicate Jazelle support within QEMU.
56
ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx);
33
*/
57
uint32_t fsr, fsc;
34
cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1);
58
59
- if (target_el == 2 || arm_el_is_aa64(env, target_el) ||
60
- arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) {
35
+ /*
61
+ /*
36
+ * Similarly, we need to set MVFR0 fields to enable double precision
62
+ * For M-profile there is no guest-facing FSR. We compute a
37
+ * and short vector support even though ARMv5 doesn't have this register.
63
+ * short-form value for env->exception.fsr which we will then
64
+ * examine in arm_v7m_cpu_do_interrupt(). In theory we could
65
+ * use the LPAE format instead as long as both bits of code agree
66
+ * (and arm_fi_to_lfsc() handled the M-profile specific
67
+ * ARMFault_QEMU_NSCExec and ARMFault_QEMU_SFault cases).
38
+ */
68
+ */
39
+ cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
69
+ if (!arm_feature(env, ARM_FEATURE_M) &&
40
+ cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1);
70
+ (target_el == 2 || arm_el_is_aa64(env, target_el) ||
41
}
71
+ arm_s1_regime_using_lpae_format(env, arm_mmu_idx))) {
42
72
/*
43
static void arm946_initfn(Object *obj)
73
* LPAE format fault status register : bottom 6 bits are
44
@@ -XXX,XX +XXX,XX @@ static void arm1026_initfn(Object *obj)
74
* status code in the same form as needed for syndrome
45
* set the field to indicate Jazelle support within QEMU.
46
*/
47
cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1);
48
+ /*
49
+ * Similarly, we need to set MVFR0 fields to enable double precision
50
+ * and short vector support even though ARMv5 doesn't have this register.
51
+ */
52
+ cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
53
+ cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1);
54
55
{
56
/* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */
57
--
75
--
58
2.20.1
76
2.34.1
59
60
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
Reading the RX_DATA register when the RX_FIFO is empty triggers
3
We currently need to select ARM_V7M unconditionally when TCG is
4
an abort. This can be easily reproduced:
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.
5
6
6
$ qemu-system-arm -M emcraft-sf2 -monitor stdio -S
7
Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
QEMU 4.0.50 monitor - type 'help' for more information
8
Signed-off-by: Fabiano Rosas <farosas@suse.de>
8
(qemu) x 0x40001010
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Aborted (core dumped)
10
Message-id: 20230523180525.29994-2-farosas@suse.de
10
11
(gdb) bt
12
#1 0x00007f035874f895 in abort () at /lib64/libc.so.6
13
#2 0x00005628686591ff in fifo8_pop (fifo=0x56286a9a4c68) at util/fifo8.c:66
14
#3 0x00005628683e0b8e in fifo32_pop (fifo=0x56286a9a4c68) at include/qemu/fifo32.h:137
15
#4 0x00005628683e0efb in spi_read (opaque=0x56286a9a4850, addr=4, size=4) at hw/ssi/mss-spi.c:168
16
#5 0x0000562867f96801 in memory_region_read_accessor (mr=0x56286a9a4b60, addr=16, value=0x7ffeecb0c5c8, size=4, shift=0, mask=4294967295, attrs=...) at memory.c:439
17
#6 0x0000562867f96cdb in access_with_adjusted_size (addr=16, value=0x7ffeecb0c5c8, size=4, access_size_min=1, access_size_max=4, access_fn=0x562867f967c3 <memory_region_read_accessor>, mr=0x56286a9a4b60, attrs=...) at memory.c:569
18
#7 0x0000562867f99940 in memory_region_dispatch_read1 (mr=0x56286a9a4b60, addr=16, pval=0x7ffeecb0c5c8, size=4, attrs=...) at memory.c:1420
19
#8 0x0000562867f99a08 in memory_region_dispatch_read (mr=0x56286a9a4b60, addr=16, pval=0x7ffeecb0c5c8, size=4, attrs=...) at memory.c:1447
20
#9 0x0000562867f38721 in flatview_read_continue (fv=0x56286aec6360, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4, addr1=16, l=4, mr=0x56286a9a4b60) at exec.c:3385
21
#10 0x0000562867f38874 in flatview_read (fv=0x56286aec6360, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4) at exec.c:3423
22
#11 0x0000562867f388ea in address_space_read_full (as=0x56286aa3e890, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4) at exec.c:3436
23
#12 0x0000562867f389c5 in address_space_rw (as=0x56286aa3e890, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4, is_write=false) at exec.c:3466
24
#13 0x0000562867f3bdd7 in cpu_memory_rw_debug (cpu=0x56286aa19d00, addr=1073745936, buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4, is_write=0) at exec.c:3976
25
#14 0x000056286811ed51 in memory_dump (mon=0x56286a8c32d0, count=1, format=120, wsize=4, addr=1073745936, is_physical=0) at monitor/misc.c:730
26
#15 0x000056286811eff1 in hmp_memory_dump (mon=0x56286a8c32d0, qdict=0x56286b15c400) at monitor/misc.c:785
27
#16 0x00005628684740ee in handle_hmp_command (mon=0x56286a8c32d0, cmdline=0x56286a8caeb2 "0x40001010") at monitor/hmp.c:1082
28
29
From the datasheet "Actel SmartFusion Microcontroller Subsystem
30
User's Guide" Rev.1, Table 13-3 "SPI Register Summary", this
31
register has a reset value of 0.
32
33
Check the FIFO is not empty before accessing it, else log an
34
error message.
35
36
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
37
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
38
Message-id: 20190709113715.7761-3-philmd@redhat.com
39
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
40
---
12
---
41
hw/ssi/mss-spi.c | 8 +++++++-
13
target/arm/Kconfig | 3 +++
42
1 file changed, 7 insertions(+), 1 deletion(-)
14
1 file changed, 3 insertions(+)
43
15
44
diff --git a/hw/ssi/mss-spi.c b/hw/ssi/mss-spi.c
16
diff --git a/target/arm/Kconfig b/target/arm/Kconfig
45
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
46
--- a/hw/ssi/mss-spi.c
18
--- a/target/arm/Kconfig
47
+++ b/hw/ssi/mss-spi.c
19
+++ b/target/arm/Kconfig
48
@@ -XXX,XX +XXX,XX @@ spi_read(void *opaque, hwaddr addr, unsigned int size)
20
@@ -XXX,XX +XXX,XX @@
49
case R_SPI_RX:
21
config ARM
50
s->regs[R_SPI_STATUS] &= ~S_RXFIFOFUL;
22
bool
51
s->regs[R_SPI_STATUS] &= ~S_RXCHOVRF;
23
select ARM_COMPATIBLE_SEMIHOSTING if TCG
52
- ret = fifo32_pop(&s->rx_fifo);
24
+
53
+ if (fifo32_is_empty(&s->rx_fifo)) {
25
+ # We need to select this until we move m_helper.c and the
54
+ qemu_log_mask(LOG_GUEST_ERROR,
26
+ # translate.c v7m helpers under ARM_V7M.
55
+ "%s: Reading empty RX_FIFO\n",
27
select ARM_V7M if TCG
56
+ __func__);
28
57
+ } else {
29
config AARCH64
58
+ ret = fifo32_pop(&s->rx_fifo);
59
+ }
60
if (fifo32_is_empty(&s->rx_fifo)) {
61
s->regs[R_SPI_STATUS] |= S_RXFIFOEMP;
62
}
63
--
30
--
64
2.20.1
31
2.34.1
65
32
66
33
diff view generated by jsdifflib
New patch
1
From: Fabiano Rosas <farosas@suse.de>
1
2
3
When we moved the arm default CONFIGs into Kconfig and removed them
4
from default.mak, we made it harder to identify which CONFIGs are
5
selected by default in case users want to disable them.
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
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
18
configs/devices/aarch64-softmmu/default.mak | 6 ++++
19
configs/devices/arm-softmmu/default.mak | 40 +++++++++++++++++++++
20
2 files changed, 46 insertions(+)
21
22
diff --git a/configs/devices/aarch64-softmmu/default.mak b/configs/devices/aarch64-softmmu/default.mak
23
index XXXXXXX..XXXXXXX 100644
24
--- a/configs/devices/aarch64-softmmu/default.mak
25
+++ b/configs/devices/aarch64-softmmu/default.mak
26
@@ -XXX,XX +XXX,XX @@
27
28
# We support all the 32 bit boards so need all their config
29
include ../arm-softmmu/default.mak
30
+
31
+# These are selected by default when TCG is enabled, uncomment them to
32
+# keep out of the build.
33
+# CONFIG_XLNX_ZYNQMP_ARM=n
34
+# CONFIG_XLNX_VERSAL=n
35
+# CONFIG_SBSA_REF=n
36
diff --git a/configs/devices/arm-softmmu/default.mak b/configs/devices/arm-softmmu/default.mak
37
index XXXXXXX..XXXXXXX 100644
38
--- a/configs/devices/arm-softmmu/default.mak
39
+++ b/configs/devices/arm-softmmu/default.mak
40
@@ -XXX,XX +XXX,XX @@
41
# CONFIG_TEST_DEVICES=n
42
43
CONFIG_ARM_VIRT=y
44
+
45
+# These are selected by default when TCG is enabled, uncomment them to
46
+# keep out of the build.
47
+# CONFIG_CUBIEBOARD=n
48
+# CONFIG_EXYNOS4=n
49
+# CONFIG_HIGHBANK=n
50
+# CONFIG_INTEGRATOR=n
51
+# CONFIG_FSL_IMX31=n
52
+# CONFIG_MUSICPAL=n
53
+# CONFIG_MUSCA=n
54
+# CONFIG_CHEETAH=n
55
+# CONFIG_SX1=n
56
+# CONFIG_NSERIES=n
57
+# CONFIG_STELLARIS=n
58
+# CONFIG_STM32VLDISCOVERY=n
59
+# CONFIG_REALVIEW=n
60
+# CONFIG_VERSATILE=n
61
+# CONFIG_VEXPRESS=n
62
+# CONFIG_ZYNQ=n
63
+# CONFIG_MAINSTONE=n
64
+# CONFIG_GUMSTIX=n
65
+# CONFIG_SPITZ=n
66
+# CONFIG_TOSA=n
67
+# CONFIG_Z2=n
68
+# CONFIG_NPCM7XX=n
69
+# CONFIG_COLLIE=n
70
+# CONFIG_ASPEED_SOC=n
71
+# CONFIG_NETDUINO2=n
72
+# CONFIG_NETDUINOPLUS2=n
73
+# CONFIG_OLIMEX_STM32_H405=n
74
+# CONFIG_MPS2=n
75
+# CONFIG_RASPI=n
76
+# CONFIG_DIGIC=n
77
+# CONFIG_SABRELITE=n
78
+# CONFIG_EMCRAFT_SF2=n
79
+# CONFIG_MICROBIT=n
80
+# CONFIG_FSL_IMX25=n
81
+# CONFIG_FSL_IMX7=n
82
+# CONFIG_FSL_IMX6UL=n
83
+# CONFIG_ALLWINNER_H3=n
84
--
85
2.34.1
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
In the previous commit we fixed a crash when the guest read a
3
Replace the 'default y if TCG' pattern with 'default y; depends on
4
register that pop from an empty FIFO.
4
TCG'.
5
By auditing the repository, we found another similar use with
5
6
an easy way to reproduce:
6
That makes explict that there is a dependence on TCG and enabling
7
7
these CONFIGs via .mak files without TCG present will fail earlier.
8
$ qemu-system-aarch64 -M xlnx-zcu102 -monitor stdio -S
8
9
QEMU 4.0.50 monitor - type 'help' for more information
9
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
10
(qemu) xp/b 0xfd4a0134
10
Signed-off-by: Fabiano Rosas <farosas@suse.de>
11
Aborted (core dumped)
11
Reviewed-by: Thomas Huth <thuth@redhat.com>
12
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
13
(gdb) bt
13
Message-id: 20230523180525.29994-4-farosas@suse.de
14
#0 0x00007f6936dea57f in raise () at /lib64/libc.so.6
15
#1 0x00007f6936dd4895 in abort () at /lib64/libc.so.6
16
#2 0x0000561ad32975ec in xlnx_dp_aux_pop_rx_fifo (s=0x7f692babee70) at hw/display/xlnx_dp.c:431
17
#3 0x0000561ad3297dc0 in xlnx_dp_read (opaque=0x7f692babee70, offset=77, size=4) at hw/display/xlnx_dp.c:667
18
#4 0x0000561ad321b896 in memory_region_read_accessor (mr=0x7f692babf620, addr=308, value=0x7ffe05c1db88, size=4, shift=0, mask=4294967295, attrs=...) at memory.c:439
19
#5 0x0000561ad321bd70 in access_with_adjusted_size (addr=308, value=0x7ffe05c1db88, size=1, access_size_min=4, access_size_max=4, access_fn=0x561ad321b858 <memory_region_read_accessor>, mr=0x7f692babf620, attrs=...) at memory.c:569
20
#6 0x0000561ad321e9d5 in memory_region_dispatch_read1 (mr=0x7f692babf620, addr=308, pval=0x7ffe05c1db88, size=1, attrs=...) at memory.c:1420
21
#7 0x0000561ad321ea9d in memory_region_dispatch_read (mr=0x7f692babf620, addr=308, pval=0x7ffe05c1db88, size=1, attrs=...) at memory.c:1447
22
#8 0x0000561ad31bd742 in flatview_read_continue (fv=0x561ad69c04f0, addr=4249485620, attrs=..., buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", len=1, addr1=308, l=1, mr=0x7f692babf620) at exec.c:3385
23
#9 0x0000561ad31bd895 in flatview_read (fv=0x561ad69c04f0, addr=4249485620, attrs=..., buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", len=1) at exec.c:3423
24
#10 0x0000561ad31bd90b in address_space_read_full (as=0x561ad5bb3020, addr=4249485620, attrs=..., buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", len=1) at exec.c:3436
25
#11 0x0000561ad33b1c42 in address_space_read (len=1, buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", attrs=..., addr=4249485620, as=0x561ad5bb3020) at include/exec/memory.h:2131
26
#12 0x0000561ad33b1c42 in memory_dump (mon=0x561ad59c4530, count=1, format=120, wsize=1, addr=4249485620, is_physical=1) at monitor/misc.c:723
27
#13 0x0000561ad33b1fc1 in hmp_physical_memory_dump (mon=0x561ad59c4530, qdict=0x561ad6c6fd00) at monitor/misc.c:795
28
#14 0x0000561ad37b4a9f in handle_hmp_command (mon=0x561ad59c4530, cmdline=0x561ad59d0f22 "/b 0x00000000fd4a0134") at monitor/hmp.c:1082
29
30
Fix by checking the FIFO is not empty before popping from it.
31
32
The datasheet is not clear about the reset value of this register,
33
we choose to return '0'.
34
35
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
36
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
37
Message-id: 20190709113715.7761-4-philmd@redhat.com
38
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
39
---
15
---
40
hw/display/xlnx_dp.c | 15 +++++++++++----
16
hw/arm/Kconfig | 123 ++++++++++++++++++++++++++++++++-----------------
41
1 file changed, 11 insertions(+), 4 deletions(-)
17
1 file changed, 82 insertions(+), 41 deletions(-)
42
18
43
diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c
19
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
44
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/display/xlnx_dp.c
21
--- a/hw/arm/Kconfig
46
+++ b/hw/display/xlnx_dp.c
22
+++ b/hw/arm/Kconfig
47
@@ -XXX,XX +XXX,XX @@ static uint8_t xlnx_dp_aux_pop_rx_fifo(XlnxDPState *s)
23
@@ -XXX,XX +XXX,XX @@ config ARM_VIRT
48
uint8_t ret;
24
49
25
config CHEETAH
50
if (fifo8_is_empty(&s->rx_fifo)) {
26
bool
51
- DPRINTF("rx_fifo underflow..\n");
27
- default y if TCG && ARM
52
- abort();
28
+ default y
53
+ qemu_log_mask(LOG_GUEST_ERROR,
29
+ depends on TCG && ARM
54
+ "%s: Reading empty RX_FIFO\n",
30
select OMAP
55
+ __func__);
31
select TSC210X
56
+ /*
32
57
+ * The datasheet is not clear about the reset value, it seems
33
config CUBIEBOARD
58
+ * to be unspecified. We choose to return '0'.
34
bool
59
+ */
35
- default y if TCG && ARM
60
+ ret = 0;
36
+ default y
61
+ } else {
37
+ depends on TCG && ARM
62
+ ret = fifo8_pop(&s->rx_fifo);
38
select ALLWINNER_A10
63
+ DPRINTF("pop 0x%" PRIX8 " from rx_fifo.\n", ret);
39
64
}
40
config DIGIC
65
- ret = fifo8_pop(&s->rx_fifo);
41
bool
66
- DPRINTF("pop 0x%" PRIX8 " from rx_fifo.\n", ret);
42
- default y if TCG && ARM
67
return ret;
43
+ default y
68
}
44
+ depends on TCG && ARM
45
select PTIMER
46
select PFLASH_CFI02
47
48
config EXYNOS4
49
bool
50
- default y if TCG && ARM
51
+ default y
52
+ depends on TCG && ARM
53
imply I2C_DEVICES
54
select A9MPCORE
55
select I2C
56
@@ -XXX,XX +XXX,XX @@ config EXYNOS4
57
58
config HIGHBANK
59
bool
60
- default y if TCG && ARM
61
+ default y
62
+ depends on TCG && ARM
63
select A9MPCORE
64
select A15MPCORE
65
select AHCI
66
@@ -XXX,XX +XXX,XX @@ config HIGHBANK
67
68
config INTEGRATOR
69
bool
70
- default y if TCG && ARM
71
+ default y
72
+ depends on TCG && ARM
73
select ARM_TIMER
74
select INTEGRATOR_DEBUG
75
select PL011 # UART
76
@@ -XXX,XX +XXX,XX @@ config INTEGRATOR
77
78
config MAINSTONE
79
bool
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
69
408
70
--
409
--
71
2.20.1
410
2.34.1
72
411
73
412
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Enze Li <lienze@kylinos.cn>
2
2
3
When we converted to using feature bits in 602f6e42cfbf we missed out
3
I noticed that in the latest version, the copyright string is still
4
the fact (dp && arm_dc_feature(s, ARM_FEATURE_V8)) was supported for
4
2022, even though 2023 is halfway through. This patch fixes that and
5
-cpu max configurations. This caused a regression in the GCC test
5
fixes the documentation along with it.
6
suite. Fix this by setting the appropriate bits in mvfr1.FPHP to
7
report ARMv8-A with FP support (but not ARMv8.2-FP16).
8
6
9
Fixes: https://bugs.launchpad.net/qemu/+bug/1836078
7
Signed-off-by: Enze Li <lienze@kylinos.cn>
10
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230525064345.1152801-1-lienze@kylinos.cn
12
Message-id: 20190711103737.10017-1-alex.bennee@linaro.org
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
11
---
15
target/arm/cpu.c | 4 ++++
12
docs/conf.py | 2 +-
16
1 file changed, 4 insertions(+)
13
include/qemu/help-texts.h | 2 +-
14
2 files changed, 2 insertions(+), 2 deletions(-)
17
15
18
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
16
diff --git a/docs/conf.py b/docs/conf.py
19
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/cpu.c
18
--- a/docs/conf.py
21
+++ b/target/arm/cpu.c
19
+++ b/docs/conf.py
22
@@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj)
20
@@ -XXX,XX +XXX,XX @@
23
t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1);
21
24
cpu->isar.id_isar6 = t;
22
# General information about the project.
25
23
project = u'QEMU'
26
+ t = cpu->isar.mvfr1;
24
-copyright = u'2022, The QEMU Project Developers'
27
+ t = FIELD_DP32(t, MVFR1, FPHP, 2); /* v8.0 FP support */
25
+copyright = u'2023, The QEMU Project Developers'
28
+ cpu->isar.mvfr1 = t;
26
author = u'The QEMU Project Developers'
29
+
27
30
t = cpu->isar.mvfr2;
28
# The version info for the project you're documenting, acts as replacement for
31
t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */
29
diff --git a/include/qemu/help-texts.h b/include/qemu/help-texts.h
32
t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */
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 */
33
--
42
--
34
2.20.1
43
2.34.1
35
36
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
2
2
3
In the next commit we will implement the write_with_attrs()
3
Let add GIC information into DeviceTree as part of SBSA-REF versioning.
4
handler. To avoid using different APIs, convert the read()
5
handler first.
6
4
7
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
5
Trusted Firmware will read it and provide to next firmware level.
8
Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com>
6
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
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>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
---
12
hw/ssi/xilinx_spips.c | 23 +++++++++++------------
13
hw/arm/sbsa-ref.c | 19 ++++++++++++++++++-
13
1 file changed, 11 insertions(+), 12 deletions(-)
14
1 file changed, 18 insertions(+), 1 deletion(-)
14
15
15
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
16
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
16
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/ssi/xilinx_spips.c
18
--- a/hw/arm/sbsa-ref.c
18
+++ b/hw/ssi/xilinx_spips.c
19
+++ b/hw/arm/sbsa-ref.c
19
@@ -XXX,XX +XXX,XX @@ static void lqspi_load_cache(void *opaque, hwaddr addr)
20
@@ -XXX,XX +XXX,XX @@
20
}
21
#include "exec/hwaddr.h"
22
#include "kvm_arm.h"
23
#include "hw/arm/boot.h"
24
+#include "hw/arm/fdt.h"
25
#include "hw/arm/smmuv3.h"
26
#include "hw/block/flash.h"
27
#include "hw/boards.h"
28
@@ -XXX,XX +XXX,XX @@ static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx)
29
return arm_cpu_mp_affinity(idx, clustersz);
21
}
30
}
22
31
23
-static uint64_t
32
+static void sbsa_fdt_add_gic_node(SBSAMachineState *sms)
24
-lqspi_read(void *opaque, hwaddr addr, unsigned int size)
33
+{
25
+static MemTxResult lqspi_read(void *opaque, hwaddr addr, uint64_t *value,
34
+ char *nodename;
26
+ unsigned size, MemTxAttrs attrs)
35
+
27
{
36
+ nodename = g_strdup_printf("/intc");
28
- XilinxQSPIPS *q = opaque;
37
+ qemu_fdt_add_subnode(sms->fdt, nodename);
29
- uint32_t ret;
38
+ qemu_fdt_setprop_sized_cells(sms->fdt, nodename, "reg",
30
+ XilinxQSPIPS *q = XILINX_QSPIPS(opaque);
39
+ 2, sbsa_ref_memmap[SBSA_GIC_DIST].base,
31
40
+ 2, sbsa_ref_memmap[SBSA_GIC_DIST].size,
32
if (addr >= q->lqspi_cached_addr &&
41
+ 2, sbsa_ref_memmap[SBSA_GIC_REDIST].base,
33
addr <= q->lqspi_cached_addr + LQSPI_CACHE_SIZE - 4) {
42
+ 2, sbsa_ref_memmap[SBSA_GIC_REDIST].size);
34
uint8_t *retp = &q->lqspi_buf[addr - q->lqspi_cached_addr];
43
+
35
- ret = cpu_to_le32(*(uint32_t *)retp);
44
+ g_free(nodename);
36
- DB_PRINT_L(1, "addr: %08x, data: %08x\n", (unsigned)addr,
45
+}
37
- (unsigned)ret);
46
/*
38
- return ret;
47
* Firmware on this machine only uses ACPI table to load OS, these limited
39
- } else {
48
* device tree nodes are just to let firmware know the info which varies from
40
- lqspi_load_cache(opaque, addr);
49
@@ -XXX,XX +XXX,XX @@ static void create_fdt(SBSAMachineState *sms)
41
- return lqspi_read(opaque, addr, size);
50
* fw compatibility.
42
+ *value = cpu_to_le32(*(uint32_t *)retp);
51
*/
43
+ DB_PRINT_L(1, "addr: %08" HWADDR_PRIx ", data: %08" PRIx64 "\n",
52
qemu_fdt_setprop_cell(fdt, "/", "machine-version-major", 0);
44
+ addr, *value);
53
- qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 0);
45
+ return MEMTX_OK;
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);
46
}
61
}
47
+
62
+
48
+ lqspi_load_cache(opaque, addr);
63
+ sbsa_fdt_add_gic_node(sms);
49
+ return lqspi_read(opaque, addr, value, size, attrs);
50
}
64
}
51
65
52
static const MemoryRegionOps lqspi_ops = {
66
#define SBSA_FLASH_SECTOR_SIZE (256 * KiB)
53
- .read = lqspi_read,
54
+ .read_with_attrs = lqspi_read,
55
.endianness = DEVICE_NATIVE_ENDIAN,
56
.valid = {
57
.min_access_size = 1,
58
--
67
--
59
2.20.1
68
2.34.1
60
61
diff view generated by jsdifflib
1
From: David Engraf <david.engraf@sysgo.com>
1
From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
2
2
3
Using the whole 128 MiB flash in non-secure mode is not working because
3
We moved from VGA to Bochs to have PCIe card.
4
virt_flash_fdt() expects the same address for secure_sysmem and sysmem.
5
This is not correctly handled by caller because it forwards NULL for
6
secure_sysmem in non-secure flash mode.
7
4
8
Fixed by using sysmem when secure_sysmem is NULL.
5
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
9
10
Signed-off-by: David Engraf <david.engraf@sysgo.com>
11
Message-id: 20190712075002.14326-1-david.engraf@sysgo.com
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
8
---
15
hw/arm/virt.c | 2 +-
9
docs/system/arm/sbsa.rst | 2 +-
16
1 file changed, 1 insertion(+), 1 deletion(-)
10
1 file changed, 1 insertion(+), 1 deletion(-)
17
11
18
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
12
diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst
19
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/virt.c
14
--- a/docs/system/arm/sbsa.rst
21
+++ b/hw/arm/virt.c
15
+++ b/docs/system/arm/sbsa.rst
22
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
16
@@ -XXX,XX +XXX,XX @@ The sbsa-ref board supports:
23
&machine->device_memory->mr);
17
- System bus EHCI controller
24
}
18
- CDROM and hard disc on AHCI bus
25
19
- E1000E ethernet card on PCIe bus
26
- virt_flash_fdt(vms, sysmem, secure_sysmem);
20
- - VGA display adaptor on PCIe bus
27
+ virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
21
+ - Bochs display adapter on PCIe bus
28
22
- A generic SBSA watchdog device
29
create_gic(vms, pic);
30
23
31
--
24
--
32
2.20.1
25
2.34.1
33
34
diff view generated by jsdifflib