1
target-arm queue for softfreeze: this is quite big as I
1
Hi; here's the latest round of arm patches. I have included also
2
was on holiday last week, so this is all just sneaking in
2
my patchset for the RTC devices to avoid keeping time_t and
3
under the wire. I particularly wanted to get Philippe's
3
time_t diffs in 32-bit variables.
4
patches in before freeze as that sort of code-movement
5
patchset is painful to have to rebase.
6
4
7
thanks
5
thanks
8
-- PMM
6
-- PMM
9
7
10
The following changes since commit ae9108f8f0746ce64d02afb1a216153a50926132:
8
The following changes since commit 156618d9ea67f2f2e31d9dedd97f2dcccbe6808c:
11
9
12
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-4.1-pull-request' into staging (2019-07-01 15:55:40 +0100)
10
Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging (2023-08-30 09:20:27 -0400)
13
11
14
are available in the Git repository at:
12
are available in the Git repository at:
15
13
16
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190701
14
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230831
17
15
18
for you to fetch changes up to 787a7e76c2e93a48c47b324fea592c9910a70483:
16
for you to fetch changes up to e73b8bb8a3e9a162f70e9ffbf922d4fafc96bbfb:
19
17
20
target/arm: Declare some M-profile functions publicly (2019-07-01 17:29:01 +0100)
18
hw/arm: Set number of MPU regions correctly for an505, an521, an524 (2023-08-31 11:07:02 +0100)
21
19
22
----------------------------------------------------------------
20
----------------------------------------------------------------
23
target-arm queue:
21
target-arm queue:
24
* hw/arm/boot: fix direct kernel boot with initrd
22
* Some of the preliminary patches for Cortex-A710 support
25
* hw/arm/msf2-som: Exit when the cpu is not the expected one
23
* i.MX7 and i.MX6UL refactoring
26
* i.mx7: fix bugs in PCI controller needed to boot recent kernels
24
* Implement SRC device for i.MX7
27
* aspeed: add RTC device
25
* Catch illegal-exception-return from EL3 with bad NSE/NS
28
* aspeed: fix some timer device bugs
26
* Use 64-bit offsets for holding time_t differences in RTC devices
29
* aspeed: add swift-bmc board
27
* Model correct number of MPU regions for an505, an521, an524 boards
30
* aspeed: vic: Add support for legacy register interface
31
* aspeed: add aspeed-xdma device
32
* Add new sbsa-ref board for aarch64
33
* target/arm: code refactoring in preparation for support of
34
compilation with TCG disabled
35
28
36
----------------------------------------------------------------
29
----------------------------------------------------------------
37
Adriana Kobylak (1):
30
Alex Bennée (1):
38
aspeed: Add support for the swift-bmc board
31
target/arm: properly document FEAT_CRC32
39
32
40
Andrew Jeffery (3):
33
Jean-Christophe Dubois (6):
41
aspeed/timer: Status register contains reload for stopped timer
34
Remove i.MX7 IOMUX GPR device from i.MX6UL
42
aspeed/timer: Fix match calculations
35
Refactor i.MX6UL processor code
43
aspeed: vic: Add support for legacy register interface
36
Add i.MX6UL missing devices.
37
Refactor i.MX7 processor code
38
Add i.MX7 missing TZ devices and memory regions
39
Add i.MX7 SRC device implementation
44
40
45
Andrew Jones (1):
41
Peter Maydell (8):
46
hw/arm/boot: fix direct kernel boot with initrd
42
target/arm: Catch illegal-exception-return from EL3 with bad NSE/NS
43
hw/rtc/m48t59: Use 64-bit arithmetic in set_alarm()
44
hw/rtc/twl92230: Use int64_t for sec_offset and alm_sec
45
hw/rtc/aspeed_rtc: Use 64-bit offset for holding time_t difference
46
rtc: Use time_t for passing and returning time offsets
47
target/arm: Do all "ARM_FEATURE_X implies Y" checks in post_init
48
hw/arm/armv7m: Add mpu-ns-regions and mpu-s-regions properties
49
hw/arm: Set number of MPU regions correctly for an505, an521, an524
47
50
48
Andrey Smirnov (5):
51
Richard Henderson (9):
49
i.mx7d: Add no-op/unimplemented APBH DMA module
52
target/arm: Reduce dcz_blocksize to uint8_t
50
i.mx7d: Add no-op/unimplemented PCIE PHY IP block
53
target/arm: Allow cpu to configure GM blocksize
51
pci: designware: Update MSI mapping unconditionally
54
target/arm: Support more GM blocksizes
52
pci: designware: Update MSI mapping when MSI address changes
55
target/arm: When tag memory is not present, set MTE=1
53
i.mx7d: pci: Update PCI IRQ mapping to match HW
56
target/arm: Introduce make_ccsidr64
57
target/arm: Apply access checks to neoverse-n1 special registers
58
target/arm: Apply access checks to neoverse-v1 special registers
59
target/arm: Suppress FEAT_TRBE (Trace Buffer Extension)
60
target/arm: Implement FEAT_HPDS2 as a no-op
54
61
55
Christian Svensson (1):
62
docs/system/arm/emulation.rst | 2 +
56
aspeed/timer: Ensure positive muldiv delta
63
include/hw/arm/armsse.h | 5 +
64
include/hw/arm/armv7m.h | 8 +
65
include/hw/arm/fsl-imx6ul.h | 158 ++++++++++++++++---
66
include/hw/arm/fsl-imx7.h | 338 ++++++++++++++++++++++++++++++-----------
67
include/hw/misc/imx7_src.h | 66 ++++++++
68
include/hw/rtc/aspeed_rtc.h | 2 +-
69
include/sysemu/rtc.h | 4 +-
70
target/arm/cpregs.h | 2 +
71
target/arm/cpu.h | 5 +-
72
target/arm/internals.h | 6 -
73
target/arm/tcg/translate.h | 2 +
74
hw/arm/armsse.c | 16 ++
75
hw/arm/armv7m.c | 21 +++
76
hw/arm/fsl-imx6ul.c | 174 +++++++++++++--------
77
hw/arm/fsl-imx7.c | 201 +++++++++++++++++++-----
78
hw/arm/mps2-tz.c | 29 ++++
79
hw/misc/imx7_src.c | 276 +++++++++++++++++++++++++++++++++
80
hw/rtc/aspeed_rtc.c | 5 +-
81
hw/rtc/m48t59.c | 2 +-
82
hw/rtc/twl92230.c | 4 +-
83
softmmu/rtc.c | 4 +-
84
target/arm/cpu.c | 207 ++++++++++++++-----------
85
target/arm/helper.c | 15 +-
86
target/arm/tcg/cpu32.c | 2 +-
87
target/arm/tcg/cpu64.c | 102 +++++++++----
88
target/arm/tcg/helper-a64.c | 9 ++
89
target/arm/tcg/mte_helper.c | 90 ++++++++---
90
target/arm/tcg/translate-a64.c | 5 +-
91
hw/misc/meson.build | 1 +
92
hw/misc/trace-events | 4 +
93
31 files changed, 1393 insertions(+), 372 deletions(-)
94
create mode 100644 include/hw/misc/imx7_src.h
95
create mode 100644 hw/misc/imx7_src.c
57
96
58
Cédric Le Goater (7):
59
aspeed: add a per SoC mapping for the interrupt space
60
aspeed: add a per SoC mapping for the memory space
61
aspeed: introduce a configurable number of CPU per machine
62
aspeed: add support for multiple NICs
63
aspeed: remove the "ram" link
64
aspeed: add a RAM memory region container
65
aspeed/smc: add a 'sdram_base' property
66
67
Eddie James (1):
68
hw/misc/aspeed_xdma: New device
69
70
Hongbo Zhang (2):
71
hw/arm: Add arm SBSA reference machine, skeleton part
72
hw/arm: Add arm SBSA reference machine, devices part
73
74
Jan Kiszka (1):
75
hw/arm/virt: Add support for Cortex-A7
76
77
Joel Stanley (4):
78
hw: timer: Add ASPEED RTC device
79
hw/arm/aspeed: Add RTC to SoC
80
aspeed/timer: Fix behaviour running Linux
81
aspeed: Link SCU to the watchdog
82
83
Philippe Mathieu-Daudé (19):
84
hw/arm/msf2-som: Exit when the cpu is not the expected one
85
target/arm: Makefile cleanup (Aarch64)
86
target/arm: Makefile cleanup (ARM)
87
target/arm: Makefile cleanup (KVM)
88
target/arm: Makefile cleanup (softmmu)
89
target/arm: Add copyright boilerplate
90
target/arm/helper: Remove unused include
91
target/arm: Fix multiline comment syntax
92
target/arm: Fix coding style issues
93
target/arm: Move CPU state dumping routines to cpu.c
94
target/arm: Declare get_phys_addr() function publicly
95
target/arm: Move TLB related routines to tlb_helper.c
96
target/arm/vfp_helper: Move code around
97
target/arm/vfp_helper: Extract vfp_set_fpscr_to_host()
98
target/arm/vfp_helper: Extract vfp_set_fpscr_from_host()
99
target/arm/vfp_helper: Restrict the SoftFloat use to TCG
100
target/arm: Restrict PSCI to TCG
101
target/arm: Declare arm_log_exception() function publicly
102
target/arm: Declare some M-profile functions publicly
103
104
Samuel Ortiz (1):
105
target/arm: Move the DC ZVA helper into op_helper
106
107
hw/arm/Makefile.objs | 1 +
108
hw/misc/Makefile.objs | 1 +
109
hw/timer/Makefile.objs | 2 +-
110
target/arm/Makefile.objs | 24 +-
111
include/hw/arm/aspeed_soc.h | 53 ++-
112
include/hw/arm/fsl-imx7.h | 14 +-
113
include/hw/misc/aspeed_xdma.h | 30 ++
114
include/hw/ssi/aspeed_smc.h | 3 +
115
include/hw/timer/aspeed_rtc.h | 31 ++
116
include/hw/watchdog/wdt_aspeed.h | 1 +
117
target/arm/cpu.h | 2 -
118
target/arm/internals.h | 69 ++-
119
target/arm/translate.h | 5 -
120
hw/arm/aspeed.c | 76 +++-
121
hw/arm/aspeed_soc.c | 262 +++++++++---
122
hw/arm/boot.c | 3 +-
123
hw/arm/fsl-imx7.c | 11 +
124
hw/arm/msf2-som.c | 1 +
125
hw/arm/sbsa-ref.c | 806 ++++++++++++++++++++++++++++++++++++
126
hw/arm/virt.c | 1 +
127
hw/intc/aspeed_vic.c | 105 +++--
128
hw/misc/aspeed_xdma.c | 165 ++++++++
129
hw/pci-host/designware.c | 18 +-
130
hw/ssi/aspeed_smc.c | 1 +
131
hw/timer/aspeed_rtc.c | 180 ++++++++
132
hw/timer/aspeed_timer.c | 76 ++--
133
hw/watchdog/wdt_aspeed.c | 20 +
134
target/arm/cpu.c | 232 ++++++++++-
135
target/arm/helper.c | 498 +++++++++-------------
136
target/arm/op_helper.c | 262 ++++++------
137
target/arm/tlb_helper.c | 200 +++++++++
138
target/arm/translate-a64.c | 128 ------
139
target/arm/translate.c | 91 +---
140
target/arm/vfp_helper.c | 199 +++++----
141
MAINTAINERS | 8 +
142
default-configs/aarch64-softmmu.mak | 1 +
143
hw/arm/Kconfig | 14 +
144
hw/misc/trace-events | 3 +
145
hw/timer/trace-events | 4 +
146
39 files changed, 2675 insertions(+), 926 deletions(-)
147
create mode 100644 include/hw/misc/aspeed_xdma.h
148
create mode 100644 include/hw/timer/aspeed_rtc.h
149
create mode 100644 hw/arm/sbsa-ref.c
150
create mode 100644 hw/misc/aspeed_xdma.c
151
create mode 100644 hw/timer/aspeed_rtc.c
152
create mode 100644 target/arm/tlb_helper.c
153
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
In the next commit we will split the M-profile functions from this
3
This value is only 4 bits wide.
4
file. Some function will be called out of helper.c. Declare them in
5
the "internals.h" header.
6
4
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190701132516.26392-22-philmd@redhat.com
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Message-id: 20230811214031.171020-2-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
target/arm/internals.h | 42 ++++++++++++++++++++++++++++++++++++++++++
11
target/arm/cpu.h | 3 ++-
13
target/arm/helper.c | 38 ++------------------------------------
12
1 file changed, 2 insertions(+), 1 deletion(-)
14
2 files changed, 44 insertions(+), 36 deletions(-)
15
13
16
diff --git a/target/arm/internals.h b/target/arm/internals.h
14
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/internals.h
16
--- a/target/arm/cpu.h
19
+++ b/target/arm/internals.h
17
+++ b/target/arm/cpu.h
20
@@ -XXX,XX +XXX,XX @@ static inline uint32_t v7m_sp_limit(CPUARMState *env)
18
@@ -XXX,XX +XXX,XX @@ struct ArchCPU {
21
}
19
bool prop_lpa2;
22
}
20
23
21
/* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */
24
+/**
22
- uint32_t dcz_blocksize;
25
+ * v7m_cpacr_pass:
23
+ uint8_t dcz_blocksize;
26
+ * Return true if the v7M CPACR permits access to the FPU for the specified
27
+ * security state and privilege level.
28
+ */
29
+static inline bool v7m_cpacr_pass(CPUARMState *env,
30
+ bool is_secure, bool is_priv)
31
+{
32
+ switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) {
33
+ case 0:
34
+ case 2: /* UNPREDICTABLE: we treat like 0 */
35
+ return false;
36
+ case 1:
37
+ return is_priv;
38
+ case 3:
39
+ return true;
40
+ default:
41
+ g_assert_not_reached();
42
+ }
43
+}
44
+
24
+
45
/**
25
uint64_t rvbar_prop; /* Property/input signals. */
46
* aarch32_mode_name(): Return name of the AArch32 CPU mode
26
47
* @psr: Program Status Register indicating CPU mode
27
/* Configurable aspects of GIC cpu interface (which is part of the CPU) */
48
@@ -XXX,XX +XXX,XX @@ static inline int exception_target_el(CPUARMState *env)
49
50
#ifndef CONFIG_USER_ONLY
51
52
+/* Security attributes for an address, as returned by v8m_security_lookup. */
53
+typedef struct V8M_SAttributes {
54
+ bool subpage; /* true if these attrs don't cover the whole TARGET_PAGE */
55
+ bool ns;
56
+ bool nsc;
57
+ uint8_t sregion;
58
+ bool srvalid;
59
+ uint8_t iregion;
60
+ bool irvalid;
61
+} V8M_SAttributes;
62
+
63
+void v8m_security_lookup(CPUARMState *env, uint32_t address,
64
+ MMUAccessType access_type, ARMMMUIdx mmu_idx,
65
+ V8M_SAttributes *sattrs);
66
+
67
+bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
68
+ MMUAccessType access_type, ARMMMUIdx mmu_idx,
69
+ hwaddr *phys_ptr, MemTxAttrs *txattrs,
70
+ int *prot, bool *is_subpage,
71
+ ARMMMUFaultInfo *fi, uint32_t *mregion);
72
+
73
/* Cacheability and shareability attributes for a memory access */
74
typedef struct ARMCacheAttrs {
75
unsigned int attrs:8; /* as in the MAIR register encoding */
76
diff --git a/target/arm/helper.c b/target/arm/helper.c
77
index XXXXXXX..XXXXXXX 100644
78
--- a/target/arm/helper.c
79
+++ b/target/arm/helper.c
80
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
81
hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot,
82
target_ulong *page_size_ptr,
83
ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs);
84
-
85
-/* Security attributes for an address, as returned by v8m_security_lookup. */
86
-typedef struct V8M_SAttributes {
87
- bool subpage; /* true if these attrs don't cover the whole TARGET_PAGE */
88
- bool ns;
89
- bool nsc;
90
- uint8_t sregion;
91
- bool srvalid;
92
- uint8_t iregion;
93
- bool irvalid;
94
-} V8M_SAttributes;
95
-
96
-static void v8m_security_lookup(CPUARMState *env, uint32_t address,
97
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
98
- V8M_SAttributes *sattrs);
99
#endif
100
101
static void switch_mode(CPUARMState *env, int mode);
102
@@ -XXX,XX +XXX,XX @@ void arm_log_exception(int idx)
103
}
104
}
105
106
-/*
107
- * Return true if the v7M CPACR permits access to the FPU for the specified
108
- * security state and privilege level.
109
- */
110
-static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv)
111
-{
112
- switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) {
113
- case 0:
114
- case 2: /* UNPREDICTABLE: we treat like 0 */
115
- return false;
116
- case 1:
117
- return is_priv;
118
- case 3:
119
- return true;
120
- default:
121
- g_assert_not_reached();
122
- }
123
-}
124
-
125
/*
126
* What kind of stack write are we doing? This affects how exceptions
127
* generated during the stacking are treated.
128
@@ -XXX,XX +XXX,XX @@ static bool v8m_is_sau_exempt(CPUARMState *env,
129
(address >= 0xe00ff000 && address <= 0xe00fffff);
130
}
131
132
-static void v8m_security_lookup(CPUARMState *env, uint32_t address,
133
+void v8m_security_lookup(CPUARMState *env, uint32_t address,
134
MMUAccessType access_type, ARMMMUIdx mmu_idx,
135
V8M_SAttributes *sattrs)
136
{
137
@@ -XXX,XX +XXX,XX @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address,
138
}
139
}
140
141
-static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
142
+bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
143
MMUAccessType access_type, ARMMMUIdx mmu_idx,
144
hwaddr *phys_ptr, MemTxAttrs *txattrs,
145
int *prot, bool *is_subpage,
146
--
28
--
147
2.20.1
29
2.34.1
148
30
149
31
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
In few commits we will split the M-profile functions from this
3
Previously we hard-coded the blocksize with GMID_EL1_BS.
4
file, and this function will also be called in the new file.
4
But the value we choose for -cpu max does not match the
5
Declare it in the "internals.h" header.
5
value that cortex-a710 uses.
6
Since it is in the middle of a block of M profile functions,
6
7
move it previous to this block to ease the later refactor.
7
Mirror the way we handle dcz_blocksize.
8
8
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Message-id: 20190701132516.26392-21-philmd@redhat.com
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20230811214031.171020-3-richard.henderson@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
13
---
14
target/arm/internals.h | 2 ++
14
target/arm/cpu.h | 2 ++
15
target/arm/helper.c | 76 +++++++++++++++++++++---------------------
15
target/arm/internals.h | 6 -----
16
2 files changed, 40 insertions(+), 38 deletions(-)
16
target/arm/tcg/translate.h | 2 ++
17
17
target/arm/helper.c | 11 +++++---
18
target/arm/tcg/cpu64.c | 1 +
19
target/arm/tcg/mte_helper.c | 46 ++++++++++++++++++++++------------
20
target/arm/tcg/translate-a64.c | 5 ++--
21
7 files changed, 45 insertions(+), 28 deletions(-)
22
23
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
24
index XXXXXXX..XXXXXXX 100644
25
--- a/target/arm/cpu.h
26
+++ b/target/arm/cpu.h
27
@@ -XXX,XX +XXX,XX @@ struct ArchCPU {
28
29
/* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */
30
uint8_t dcz_blocksize;
31
+ /* GM blocksize, in log_2(words), ie low 4 bits of GMID_EL0 */
32
+ uint8_t gm_blocksize;
33
34
uint64_t rvbar_prop; /* Property/input signals. */
35
18
diff --git a/target/arm/internals.h b/target/arm/internals.h
36
diff --git a/target/arm/internals.h b/target/arm/internals.h
19
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/internals.h
38
--- a/target/arm/internals.h
21
+++ b/target/arm/internals.h
39
+++ b/target/arm/internals.h
22
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
40
@@ -XXX,XX +XXX,XX @@ void arm_log_exception(CPUState *cs);
23
target_ulong *page_size,
41
24
ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs);
25
26
+void arm_log_exception(int idx);
27
+
28
#endif /* !CONFIG_USER_ONLY */
42
#endif /* !CONFIG_USER_ONLY */
29
43
30
#endif
44
-/*
45
- * The log2 of the words in the tag block, for GMID_EL1.BS.
46
- * The is the maximum, 256 bytes, which manipulates 64-bits of tags.
47
- */
48
-#define GMID_EL1_BS 6
49
-
50
/*
51
* SVE predicates are 1/8 the size of SVE vectors, and cannot use
52
* the same simd_desc() encoding due to restrictions on size.
53
diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h
54
index XXXXXXX..XXXXXXX 100644
55
--- a/target/arm/tcg/translate.h
56
+++ b/target/arm/tcg/translate.h
57
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
58
int8_t btype;
59
/* A copy of cpu->dcz_blocksize. */
60
uint8_t dcz_blocksize;
61
+ /* A copy of cpu->gm_blocksize. */
62
+ uint8_t gm_blocksize;
63
/* True if this page is guarded. */
64
bool guarded_page;
65
/* Bottom two bits of XScale c15_cpar coprocessor access control reg */
31
diff --git a/target/arm/helper.c b/target/arm/helper.c
66
diff --git a/target/arm/helper.c b/target/arm/helper.c
32
index XXXXXXX..XXXXXXX 100644
67
index XXXXXXX..XXXXXXX 100644
33
--- a/target/arm/helper.c
68
--- a/target/arm/helper.c
34
+++ b/target/arm/helper.c
69
+++ b/target/arm/helper.c
35
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
70
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_reginfo[] = {
36
return target_el;
71
.opc0 = 3, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 6,
72
.access = PL1_RW, .accessfn = access_mte,
73
.fieldoffset = offsetof(CPUARMState, cp15.gcr_el1) },
74
- { .name = "GMID_EL1", .state = ARM_CP_STATE_AA64,
75
- .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 4,
76
- .access = PL1_R, .accessfn = access_aa64_tid5,
77
- .type = ARM_CP_CONST, .resetvalue = GMID_EL1_BS },
78
{ .name = "TCO", .state = ARM_CP_STATE_AA64,
79
.opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 7,
80
.type = ARM_CP_NO_RAW,
81
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
82
* then define only a RAZ/WI version of PSTATE.TCO.
83
*/
84
if (cpu_isar_feature(aa64_mte, cpu)) {
85
+ ARMCPRegInfo gmid_reginfo = {
86
+ .name = "GMID_EL1", .state = ARM_CP_STATE_AA64,
87
+ .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 4,
88
+ .access = PL1_R, .accessfn = access_aa64_tid5,
89
+ .type = ARM_CP_CONST, .resetvalue = cpu->gm_blocksize,
90
+ };
91
+ define_one_arm_cp_reg(cpu, &gmid_reginfo);
92
define_arm_cp_regs(cpu, mte_reginfo);
93
define_arm_cp_regs(cpu, mte_el0_cacheop_reginfo);
94
} else if (cpu_isar_feature(aa64_mte_insn_reg, cpu)) {
95
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
96
index XXXXXXX..XXXXXXX 100644
97
--- a/target/arm/tcg/cpu64.c
98
+++ b/target/arm/tcg/cpu64.c
99
@@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj)
100
cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */
101
cpu->dcz_blocksize = 7; /* 512 bytes */
102
#endif
103
+ cpu->gm_blocksize = 6; /* 256 bytes */
104
105
cpu->sve_vq.supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ);
106
cpu->sme_vq.supported = SVE_VQ_POW2_MAP;
107
diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c
108
index XXXXXXX..XXXXXXX 100644
109
--- a/target/arm/tcg/mte_helper.c
110
+++ b/target/arm/tcg/mte_helper.c
111
@@ -XXX,XX +XXX,XX @@ void HELPER(st2g_stub)(CPUARMState *env, uint64_t ptr)
112
}
37
}
113
}
38
114
39
+void arm_log_exception(int idx)
115
-#define LDGM_STGM_SIZE (4 << GMID_EL1_BS)
40
+{
116
-
41
+ if (qemu_loglevel_mask(CPU_LOG_INT)) {
117
uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr)
42
+ const char *exc = NULL;
118
{
43
+ static const char * const excnames[] = {
119
int mmu_idx = cpu_mmu_index(env, false);
44
+ [EXCP_UDEF] = "Undefined Instruction",
120
uintptr_t ra = GETPC();
45
+ [EXCP_SWI] = "SVC",
121
+ int gm_bs = env_archcpu(env)->gm_blocksize;
46
+ [EXCP_PREFETCH_ABORT] = "Prefetch Abort",
122
+ int gm_bs_bytes = 4 << gm_bs;
47
+ [EXCP_DATA_ABORT] = "Data Abort",
123
void *tag_mem;
48
+ [EXCP_IRQ] = "IRQ",
124
49
+ [EXCP_FIQ] = "FIQ",
125
- ptr = QEMU_ALIGN_DOWN(ptr, LDGM_STGM_SIZE);
50
+ [EXCP_BKPT] = "Breakpoint",
126
+ ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes);
51
+ [EXCP_EXCEPTION_EXIT] = "QEMU v7M exception exit",
127
52
+ [EXCP_KERNEL_TRAP] = "QEMU intercept of kernel commpage",
128
/* Trap if accessing an invalid page. */
53
+ [EXCP_HVC] = "Hypervisor Call",
129
tag_mem = allocation_tag_mem(env, mmu_idx, ptr, MMU_DATA_LOAD,
54
+ [EXCP_HYP_TRAP] = "Hypervisor Trap",
130
- LDGM_STGM_SIZE, MMU_DATA_LOAD,
55
+ [EXCP_SMC] = "Secure Monitor Call",
131
- LDGM_STGM_SIZE / (2 * TAG_GRANULE), ra);
56
+ [EXCP_VIRQ] = "Virtual IRQ",
132
+ gm_bs_bytes, MMU_DATA_LOAD,
57
+ [EXCP_VFIQ] = "Virtual FIQ",
133
+ gm_bs_bytes / (2 * TAG_GRANULE), ra);
58
+ [EXCP_SEMIHOST] = "Semihosting call",
134
59
+ [EXCP_NOCP] = "v7M NOCP UsageFault",
135
/* The tag is squashed to zero if the page does not support tags. */
60
+ [EXCP_INVSTATE] = "v7M INVSTATE UsageFault",
136
if (!tag_mem) {
61
+ [EXCP_STKOF] = "v8M STKOF UsageFault",
137
return 0;
62
+ [EXCP_LAZYFP] = "v7M exception during lazy FP stacking",
138
}
63
+ [EXCP_LSERR] = "v8M LSERR UsageFault",
139
64
+ [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault",
140
- QEMU_BUILD_BUG_ON(GMID_EL1_BS != 6);
65
+ };
141
/*
66
+
142
- * We are loading 64-bits worth of tags. The ordering of elements
67
+ if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
143
- * within the word corresponds to a 64-bit little-endian operation.
68
+ exc = excnames[idx];
144
+ * The ordering of elements within the word corresponds to
69
+ }
145
+ * a little-endian operation.
70
+ if (!exc) {
146
*/
71
+ exc = "unknown";
147
- return ldq_le_p(tag_mem);
72
+ }
148
+ switch (gm_bs) {
73
+ qemu_log_mask(CPU_LOG_INT, "Taking exception %d [%s]\n", idx, exc);
149
+ case 6:
150
+ /* 256 bytes -> 16 tags -> 64 result bits */
151
+ return ldq_le_p(tag_mem);
152
+ default:
153
+ /* cpu configured with unsupported gm blocksize. */
154
+ g_assert_not_reached();
74
+ }
155
+ }
75
+}
76
+
77
/*
78
* Return true if the v7M CPACR permits access to the FPU for the specified
79
* security state and privilege level.
80
@@ -XXX,XX +XXX,XX @@ static bool do_v7m_function_return(ARMCPU *cpu)
81
return true;
82
}
156
}
83
157
84
-static void arm_log_exception(int idx)
158
void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val)
85
-{
86
- if (qemu_loglevel_mask(CPU_LOG_INT)) {
87
- const char *exc = NULL;
88
- static const char * const excnames[] = {
89
- [EXCP_UDEF] = "Undefined Instruction",
90
- [EXCP_SWI] = "SVC",
91
- [EXCP_PREFETCH_ABORT] = "Prefetch Abort",
92
- [EXCP_DATA_ABORT] = "Data Abort",
93
- [EXCP_IRQ] = "IRQ",
94
- [EXCP_FIQ] = "FIQ",
95
- [EXCP_BKPT] = "Breakpoint",
96
- [EXCP_EXCEPTION_EXIT] = "QEMU v7M exception exit",
97
- [EXCP_KERNEL_TRAP] = "QEMU intercept of kernel commpage",
98
- [EXCP_HVC] = "Hypervisor Call",
99
- [EXCP_HYP_TRAP] = "Hypervisor Trap",
100
- [EXCP_SMC] = "Secure Monitor Call",
101
- [EXCP_VIRQ] = "Virtual IRQ",
102
- [EXCP_VFIQ] = "Virtual FIQ",
103
- [EXCP_SEMIHOST] = "Semihosting call",
104
- [EXCP_NOCP] = "v7M NOCP UsageFault",
105
- [EXCP_INVSTATE] = "v7M INVSTATE UsageFault",
106
- [EXCP_STKOF] = "v8M STKOF UsageFault",
107
- [EXCP_LAZYFP] = "v7M exception during lazy FP stacking",
108
- [EXCP_LSERR] = "v8M LSERR UsageFault",
109
- [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault",
110
- };
111
-
112
- if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
113
- exc = excnames[idx];
114
- }
115
- if (!exc) {
116
- exc = "unknown";
117
- }
118
- qemu_log_mask(CPU_LOG_INT, "Taking exception %d [%s]\n", idx, exc);
119
- }
120
-}
121
-
122
static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx,
123
uint32_t addr, uint16_t *insn)
124
{
159
{
160
int mmu_idx = cpu_mmu_index(env, false);
161
uintptr_t ra = GETPC();
162
+ int gm_bs = env_archcpu(env)->gm_blocksize;
163
+ int gm_bs_bytes = 4 << gm_bs;
164
void *tag_mem;
165
166
- ptr = QEMU_ALIGN_DOWN(ptr, LDGM_STGM_SIZE);
167
+ ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes);
168
169
/* Trap if accessing an invalid page. */
170
tag_mem = allocation_tag_mem(env, mmu_idx, ptr, MMU_DATA_STORE,
171
- LDGM_STGM_SIZE, MMU_DATA_LOAD,
172
- LDGM_STGM_SIZE / (2 * TAG_GRANULE), ra);
173
+ gm_bs_bytes, MMU_DATA_LOAD,
174
+ gm_bs_bytes / (2 * TAG_GRANULE), ra);
175
176
/*
177
* Tag store only happens if the page support tags,
178
@@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val)
179
return;
180
}
181
182
- QEMU_BUILD_BUG_ON(GMID_EL1_BS != 6);
183
/*
184
- * We are storing 64-bits worth of tags. The ordering of elements
185
- * within the word corresponds to a 64-bit little-endian operation.
186
+ * The ordering of elements within the word corresponds to
187
+ * a little-endian operation.
188
*/
189
- stq_le_p(tag_mem, val);
190
+ switch (gm_bs) {
191
+ case 6:
192
+ stq_le_p(tag_mem, val);
193
+ break;
194
+ default:
195
+ /* cpu configured with unsupported gm blocksize. */
196
+ g_assert_not_reached();
197
+ }
198
}
199
200
void HELPER(stzgm_tags)(CPUARMState *env, uint64_t ptr, uint64_t val)
201
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
202
index XXXXXXX..XXXXXXX 100644
203
--- a/target/arm/tcg/translate-a64.c
204
+++ b/target/arm/tcg/translate-a64.c
205
@@ -XXX,XX +XXX,XX @@ static bool trans_STGM(DisasContext *s, arg_ldst_tag *a)
206
gen_helper_stgm(cpu_env, addr, tcg_rt);
207
} else {
208
MMUAccessType acc = MMU_DATA_STORE;
209
- int size = 4 << GMID_EL1_BS;
210
+ int size = 4 << s->gm_blocksize;
211
212
clean_addr = clean_data_tbi(s, addr);
213
tcg_gen_andi_i64(clean_addr, clean_addr, -size);
214
@@ -XXX,XX +XXX,XX @@ static bool trans_LDGM(DisasContext *s, arg_ldst_tag *a)
215
gen_helper_ldgm(tcg_rt, cpu_env, addr);
216
} else {
217
MMUAccessType acc = MMU_DATA_LOAD;
218
- int size = 4 << GMID_EL1_BS;
219
+ int size = 4 << s->gm_blocksize;
220
221
clean_addr = clean_data_tbi(s, addr);
222
tcg_gen_andi_i64(clean_addr, clean_addr, -size);
223
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase,
224
dc->cp_regs = arm_cpu->cp_regs;
225
dc->features = env->features;
226
dc->dcz_blocksize = arm_cpu->dcz_blocksize;
227
+ dc->gm_blocksize = arm_cpu->gm_blocksize;
228
229
#ifdef CONFIG_USER_ONLY
230
/* In sve_probe_page, we assume TBI is enabled. */
125
--
231
--
126
2.20.1
232
2.34.1
127
128
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Since we'll move this code around, fix its style first.
3
Support all of the easy GM block sizes.
4
Use direct memory operations, since the pointers are aligned.
4
5
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
While BS=2 (16 bytes, 1 tag) is a legal setting, that requires
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
an atomic store of one nibble. This is not difficult, but there
7
Message-id: 20190701132516.26392-9-philmd@redhat.com
8
is also no point in supporting it until required.
9
10
Note that cortex-a710 sets GM blocksize to match its cacheline
11
size of 64 bytes. I expect many implementations will also
12
match the cacheline, which makes 16 bytes very unlikely.
13
14
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Message-id: 20230811214031.171020-4-richard.henderson@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
18
---
10
target/arm/translate.c | 11 ++++++-----
19
target/arm/cpu.c | 18 +++++++++---
11
target/arm/vfp_helper.c | 36 ++++++++++++++++++++++++------------
20
target/arm/tcg/mte_helper.c | 56 +++++++++++++++++++++++++++++++------
12
2 files changed, 30 insertions(+), 17 deletions(-)
21
2 files changed, 62 insertions(+), 12 deletions(-)
13
22
14
diff --git a/target/arm/translate.c b/target/arm/translate.c
23
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
15
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate.c
25
--- a/target/arm/cpu.c
17
+++ b/target/arm/translate.c
26
+++ b/target/arm/cpu.c
18
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
27
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
19
loaded_base = 0;
28
ID_PFR1, VIRTUALIZATION, 0);
20
loaded_var = NULL;
29
}
21
n = 0;
30
22
- for(i=0;i<16;i++) {
31
+ if (cpu_isar_feature(aa64_mte, cpu)) {
23
+ for (i = 0; i < 16; i++) {
32
+ /*
24
if (insn & (1 << i))
33
+ * The architectural range of GM blocksize is 2-6, however qemu
25
n++;
34
+ * doesn't support blocksize of 2 (see HELPER(ldgm)).
26
}
35
+ */
27
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
36
+ if (tcg_enabled()) {
28
}
37
+ assert(cpu->gm_blocksize >= 3 && cpu->gm_blocksize <= 6);
29
}
38
+ }
30
j = 0;
39
+
31
- for(i=0;i<16;i++) {
40
#ifndef CONFIG_USER_ONLY
32
+ for (i = 0; i < 16; i++) {
41
- if (cpu->tag_memory == NULL && cpu_isar_feature(aa64_mte, cpu)) {
33
if (insn & (1 << i)) {
42
/*
34
if (is_load) {
43
* Disable the MTE feature bits if we do not have tag-memory
35
/* load */
44
* provided by the machine.
36
@@ -XXX,XX +XXX,XX @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags)
45
*/
46
- cpu->isar.id_aa64pfr1 =
47
- FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0);
48
- }
49
+ if (cpu->tag_memory == NULL) {
50
+ cpu->isar.id_aa64pfr1 =
51
+ FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0);
52
+ }
53
#endif
54
+ }
55
56
if (tcg_enabled()) {
57
/*
58
diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c
59
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/tcg/mte_helper.c
61
+++ b/target/arm/tcg/mte_helper.c
62
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr)
63
int gm_bs = env_archcpu(env)->gm_blocksize;
64
int gm_bs_bytes = 4 << gm_bs;
65
void *tag_mem;
66
+ uint64_t ret;
67
+ int shift;
68
69
ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes);
70
71
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr)
72
73
/*
74
* The ordering of elements within the word corresponds to
75
- * a little-endian operation.
76
+ * a little-endian operation. Computation of shift comes from
77
+ *
78
+ * index = address<LOG2_TAG_GRANULE+3:LOG2_TAG_GRANULE>
79
+ * data<index*4+3:index*4> = tag
80
+ *
81
+ * Because of the alignment of ptr above, BS=6 has shift=0.
82
+ * All memory operations are aligned. Defer support for BS=2,
83
+ * requiring insertion or extraction of a nibble, until we
84
+ * support a cpu that requires it.
85
*/
86
switch (gm_bs) {
87
+ case 3:
88
+ /* 32 bytes -> 2 tags -> 8 result bits */
89
+ ret = *(uint8_t *)tag_mem;
90
+ break;
91
+ case 4:
92
+ /* 64 bytes -> 4 tags -> 16 result bits */
93
+ ret = cpu_to_le16(*(uint16_t *)tag_mem);
94
+ break;
95
+ case 5:
96
+ /* 128 bytes -> 8 tags -> 32 result bits */
97
+ ret = cpu_to_le32(*(uint32_t *)tag_mem);
98
+ break;
99
case 6:
100
/* 256 bytes -> 16 tags -> 64 result bits */
101
- return ldq_le_p(tag_mem);
102
+ return cpu_to_le64(*(uint64_t *)tag_mem);
103
default:
104
- /* cpu configured with unsupported gm blocksize. */
105
+ /*
106
+ * CPU configured with unsupported/invalid gm blocksize.
107
+ * This is detected early in arm_cpu_realizefn.
108
+ */
109
g_assert_not_reached();
110
}
111
+ shift = extract64(ptr, LOG2_TAG_GRANULE, 4) * 4;
112
+ return ret << shift;
113
}
114
115
void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val)
116
@@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val)
117
int gm_bs = env_archcpu(env)->gm_blocksize;
118
int gm_bs_bytes = 4 << gm_bs;
119
void *tag_mem;
120
+ int shift;
121
122
ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes);
123
124
@@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val)
37
return;
125
return;
38
}
126
}
39
127
40
- for(i=0;i<16;i++) {
128
- /*
41
+ for (i = 0; i < 16; i++) {
129
- * The ordering of elements within the word corresponds to
42
qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]);
130
- * a little-endian operation.
43
- if ((i % 4) == 3)
131
- */
44
+ if ((i % 4) == 3) {
132
+ /* See LDGM for comments on BS and on shift. */
45
qemu_fprintf(f, "\n");
133
+ shift = extract64(ptr, LOG2_TAG_GRANULE, 4) * 4;
46
- else
134
+ val >>= shift;
47
+ } else {
135
switch (gm_bs) {
48
qemu_fprintf(f, " ");
136
+ case 3:
49
+ }
137
+ /* 32 bytes -> 2 tags -> 8 result bits */
50
}
138
+ *(uint8_t *)tag_mem = val;
51
139
+ break;
52
if (arm_feature(env, ARM_FEATURE_M)) {
140
+ case 4:
53
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
141
+ /* 64 bytes -> 4 tags -> 16 result bits */
54
index XXXXXXX..XXXXXXX 100644
142
+ *(uint16_t *)tag_mem = cpu_to_le16(val);
55
--- a/target/arm/vfp_helper.c
143
+ break;
56
+++ b/target/arm/vfp_helper.c
144
+ case 5:
57
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_from_host(int host_bits)
145
+ /* 128 bytes -> 8 tags -> 32 result bits */
58
{
146
+ *(uint32_t *)tag_mem = cpu_to_le32(val);
59
int target_bits = 0;
147
+ break;
60
148
case 6:
61
- if (host_bits & float_flag_invalid)
149
- stq_le_p(tag_mem, val);
62
+ if (host_bits & float_flag_invalid) {
150
+ /* 256 bytes -> 16 tags -> 64 result bits */
63
target_bits |= 1;
151
+ *(uint64_t *)tag_mem = cpu_to_le64(val);
64
- if (host_bits & float_flag_divbyzero)
152
break;
65
+ }
153
default:
66
+ if (host_bits & float_flag_divbyzero) {
154
/* cpu configured with unsupported gm blocksize. */
67
target_bits |= 2;
68
- if (host_bits & float_flag_overflow)
69
+ }
70
+ if (host_bits & float_flag_overflow) {
71
target_bits |= 4;
72
- if (host_bits & (float_flag_underflow | float_flag_output_denormal))
73
+ }
74
+ if (host_bits & (float_flag_underflow | float_flag_output_denormal)) {
75
target_bits |= 8;
76
- if (host_bits & float_flag_inexact)
77
+ }
78
+ if (host_bits & float_flag_inexact) {
79
target_bits |= 0x10;
80
- if (host_bits & float_flag_input_denormal)
81
+ }
82
+ if (host_bits & float_flag_input_denormal) {
83
target_bits |= 0x80;
84
+ }
85
return target_bits;
86
}
87
88
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits)
89
{
90
int host_bits = 0;
91
92
- if (target_bits & 1)
93
+ if (target_bits & 1) {
94
host_bits |= float_flag_invalid;
95
- if (target_bits & 2)
96
+ }
97
+ if (target_bits & 2) {
98
host_bits |= float_flag_divbyzero;
99
- if (target_bits & 4)
100
+ }
101
+ if (target_bits & 4) {
102
host_bits |= float_flag_overflow;
103
- if (target_bits & 8)
104
+ }
105
+ if (target_bits & 8) {
106
host_bits |= float_flag_underflow;
107
- if (target_bits & 0x10)
108
+ }
109
+ if (target_bits & 0x10) {
110
host_bits |= float_flag_inexact;
111
- if (target_bits & 0x80)
112
+ }
113
+ if (target_bits & 0x80) {
114
host_bits |= float_flag_input_denormal;
115
+ }
116
return host_bits;
117
}
118
119
--
155
--
120
2.20.1
156
2.34.1
121
122
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Under KVM, the kernel gets the HVC call and handle the PSCI requests.
3
When the cpu support MTE, but the system does not, reduce cpu
4
support to user instructions at EL0 instead of completely
5
disabling MTE. If we encounter a cpu implementation which does
6
something else, we can revisit this setting.
4
7
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20190701132516.26392-20-philmd@redhat.com
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20230811214031.171020-5-richard.henderson@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
12
---
10
target/arm/internals.h | 6 +++++-
13
target/arm/cpu.c | 7 ++++---
11
1 file changed, 5 insertions(+), 1 deletion(-)
14
1 file changed, 4 insertions(+), 3 deletions(-)
12
15
13
diff --git a/target/arm/internals.h b/target/arm/internals.h
16
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
14
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/internals.h
18
--- a/target/arm/cpu.c
16
+++ b/target/arm/internals.h
19
+++ b/target/arm/cpu.c
17
@@ -XXX,XX +XXX,XX @@ vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len);
20
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
18
/* Callback function for when a watchpoint or breakpoint triggers. */
21
19
void arm_debug_excp_handler(CPUState *cs);
22
#ifndef CONFIG_USER_ONLY
20
23
/*
21
-#ifdef CONFIG_USER_ONLY
24
- * Disable the MTE feature bits if we do not have tag-memory
22
+#if defined(CONFIG_USER_ONLY) || !defined(CONFIG_TCG)
25
- * provided by the machine.
23
static inline bool arm_is_psci_call(ARMCPU *cpu, int excp_type)
26
+ * If we do not have tag-memory provided by the machine,
24
{
27
+ * reduce MTE support to instructions enabled at EL0.
25
return false;
28
+ * This matches Cortex-A710 BROADCASTMTE input being LOW.
26
}
29
*/
27
+static inline void arm_handle_psci_call(ARMCPU *cpu)
30
if (cpu->tag_memory == NULL) {
28
+{
31
cpu->isar.id_aa64pfr1 =
29
+ g_assert_not_reached();
32
- FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0);
30
+}
33
+ FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 1);
31
#else
34
}
32
/* Return true if the r0/x0 value indicates that this SMC/HVC is a PSCI call. */
35
#endif
33
bool arm_is_psci_call(ARMCPU *cpu, int excp_type);
36
}
34
--
37
--
35
2.20.1
38
2.34.1
36
37
diff view generated by jsdifflib
1
From: Hongbo Zhang <hongbo.zhang@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
For AArch64, the existing "virt" machine is primarily meant to
3
Do not hard-code the constants for Neoverse V1.
4
run on KVM and execute virtualization workloads, but we need an
5
environment as faithful as possible to physical hardware, for supporting
6
firmware and OS development for physical Aarch64 machines.
7
4
8
This patch introduces new machine type 'sbsa-ref' with main features:
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
- Based on 'virt' machine type.
10
- A new memory map.
11
- CPU type cortex-a57.
12
- EL2 and EL3 are enabled.
13
- GIC version 3.
14
- System bus AHCI controller.
15
- System bus EHCI controller.
16
- CDROM and hard disc on AHCI bus.
17
- E1000E ethernet card on PCIE bus.
18
- VGA display adaptor on PCIE bus.
19
- No virtio devices.
20
- No fw_cfg device.
21
- No ACPI table supplied.
22
- Only minimal device tree nodes.
23
24
Arm Trusted Firmware and UEFI porting to this are done accordingly,
25
and the firmware should supply ACPI tables to the guest OS. The
26
minimal device tree nodes supplied by QEMU for this platform are only
27
to pass the dynamic info reflecting command line input to firmware,
28
not for loading the guest OS.
29
30
To make the review easier, this task is split into two patches, the
31
fundamental skeleton part and the peripheral devices part; this patch is
32
the first part.
33
34
Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
35
Message-id: 1561890034-15921-2-git-send-email-hongbo.zhang@linaro.org
36
[PMM: commit message tweaks; moved some bits between patch 1 and 2
37
to ensure patch 1 builds cleanly; removed unneeded lines from
38
Kconfig stanza; only provide board for qemu-system-aarch64, not
39
qemu-system-arm; added MAINTAINERS entry]
40
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20230811214031.171020-6-richard.henderson@linaro.org
41
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
42
---
9
---
43
hw/arm/Makefile.objs | 1 +
10
target/arm/tcg/cpu64.c | 48 ++++++++++++++++++++++++++++--------------
44
hw/arm/sbsa-ref.c | 271 ++++++++++++++++++++++++++++
11
1 file changed, 32 insertions(+), 16 deletions(-)
45
MAINTAINERS | 8 +
46
default-configs/aarch64-softmmu.mak | 1 +
47
hw/arm/Kconfig | 14 ++
48
5 files changed, 295 insertions(+)
49
create mode 100644 hw/arm/sbsa-ref.c
50
12
51
diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
13
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
52
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
53
--- a/hw/arm/Makefile.objs
15
--- a/target/arm/tcg/cpu64.c
54
+++ b/hw/arm/Makefile.objs
16
+++ b/target/arm/tcg/cpu64.c
55
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_SPITZ) += spitz.o
56
obj-$(CONFIG_TOSA) += tosa.o
57
obj-$(CONFIG_Z2) += z2.o
58
obj-$(CONFIG_REALVIEW) += realview.o
59
+obj-$(CONFIG_SBSA_REF) += sbsa-ref.o
60
obj-$(CONFIG_STELLARIS) += stellaris.o
61
obj-$(CONFIG_COLLIE) += collie.o
62
obj-$(CONFIG_VERSATILE) += versatilepb.o
63
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
64
new file mode 100644
65
index XXXXXXX..XXXXXXX
66
--- /dev/null
67
+++ b/hw/arm/sbsa-ref.c
68
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@
69
+/*
18
#include "qemu/module.h"
70
+ * ARM SBSA Reference Platform emulation
19
#include "qapi/visitor.h"
71
+ *
20
#include "hw/qdev-properties.h"
72
+ * Copyright (c) 2018 Linaro Limited
73
+ * Written by Hongbo Zhang <hongbo.zhang@linaro.org>
74
+ *
75
+ * This program is free software; you can redistribute it and/or modify it
76
+ * under the terms and conditions of the GNU General Public License,
77
+ * version 2 or later, as published by the Free Software Foundation.
78
+ *
79
+ * This program is distributed in the hope it will be useful, but WITHOUT
80
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
81
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
82
+ * more details.
83
+ *
84
+ * You should have received a copy of the GNU General Public License along with
85
+ * this program. If not, see <http://www.gnu.org/licenses/>.
86
+ */
87
+
88
+#include "qemu/osdep.h"
89
+#include "qapi/error.h"
90
+#include "qemu/error-report.h"
91
+#include "qemu/units.h"
21
+#include "qemu/units.h"
92
+#include "sysemu/numa.h"
22
#include "internals.h"
93
+#include "sysemu/sysemu.h"
23
#include "cpregs.h"
94
+#include "exec/address-spaces.h"
24
95
+#include "exec/hwaddr.h"
25
+static uint64_t make_ccsidr64(unsigned assoc, unsigned linesize,
96
+#include "kvm_arm.h"
26
+ unsigned cachesize)
97
+#include "hw/arm/boot.h"
98
+#include "hw/boards.h"
99
+#include "hw/intc/arm_gicv3_common.h"
100
+
101
+#define RAMLIMIT_GB 8192
102
+#define RAMLIMIT_BYTES (RAMLIMIT_GB * GiB)
103
+
104
+enum {
105
+ SBSA_FLASH,
106
+ SBSA_MEM,
107
+ SBSA_CPUPERIPHS,
108
+ SBSA_GIC_DIST,
109
+ SBSA_GIC_REDIST,
110
+ SBSA_SMMU,
111
+ SBSA_UART,
112
+ SBSA_RTC,
113
+ SBSA_PCIE,
114
+ SBSA_PCIE_MMIO,
115
+ SBSA_PCIE_MMIO_HIGH,
116
+ SBSA_PCIE_PIO,
117
+ SBSA_PCIE_ECAM,
118
+ SBSA_GPIO,
119
+ SBSA_SECURE_UART,
120
+ SBSA_SECURE_UART_MM,
121
+ SBSA_SECURE_MEM,
122
+ SBSA_AHCI,
123
+ SBSA_EHCI,
124
+};
125
+
126
+typedef struct MemMapEntry {
127
+ hwaddr base;
128
+ hwaddr size;
129
+} MemMapEntry;
130
+
131
+typedef struct {
132
+ MachineState parent;
133
+ struct arm_boot_info bootinfo;
134
+ int smp_cpus;
135
+ void *fdt;
136
+ int fdt_size;
137
+ int psci_conduit;
138
+} SBSAMachineState;
139
+
140
+#define TYPE_SBSA_MACHINE MACHINE_TYPE_NAME("sbsa-ref")
141
+#define SBSA_MACHINE(obj) \
142
+ OBJECT_CHECK(SBSAMachineState, (obj), TYPE_SBSA_MACHINE)
143
+
144
+static const MemMapEntry sbsa_ref_memmap[] = {
145
+ /* 512M boot ROM */
146
+ [SBSA_FLASH] = { 0, 0x20000000 },
147
+ /* 512M secure memory */
148
+ [SBSA_SECURE_MEM] = { 0x20000000, 0x20000000 },
149
+ /* Space reserved for CPU peripheral devices */
150
+ [SBSA_CPUPERIPHS] = { 0x40000000, 0x00040000 },
151
+ [SBSA_GIC_DIST] = { 0x40060000, 0x00010000 },
152
+ [SBSA_GIC_REDIST] = { 0x40080000, 0x04000000 },
153
+ [SBSA_UART] = { 0x60000000, 0x00001000 },
154
+ [SBSA_RTC] = { 0x60010000, 0x00001000 },
155
+ [SBSA_GPIO] = { 0x60020000, 0x00001000 },
156
+ [SBSA_SECURE_UART] = { 0x60030000, 0x00001000 },
157
+ [SBSA_SECURE_UART_MM] = { 0x60040000, 0x00001000 },
158
+ [SBSA_SMMU] = { 0x60050000, 0x00020000 },
159
+ /* Space here reserved for more SMMUs */
160
+ [SBSA_AHCI] = { 0x60100000, 0x00010000 },
161
+ [SBSA_EHCI] = { 0x60110000, 0x00010000 },
162
+ /* Space here reserved for other devices */
163
+ [SBSA_PCIE_PIO] = { 0x7fff0000, 0x00010000 },
164
+ /* 32-bit address PCIE MMIO space */
165
+ [SBSA_PCIE_MMIO] = { 0x80000000, 0x70000000 },
166
+ /* 256M PCIE ECAM space */
167
+ [SBSA_PCIE_ECAM] = { 0xf0000000, 0x10000000 },
168
+ /* ~1TB PCIE MMIO space (4GB to 1024GB boundary) */
169
+ [SBSA_PCIE_MMIO_HIGH] = { 0x100000000ULL, 0xFF00000000ULL },
170
+ [SBSA_MEM] = { 0x10000000000ULL, RAMLIMIT_BYTES },
171
+};
172
+
173
+static void sbsa_ref_init(MachineState *machine)
174
+{
27
+{
175
+ SBSAMachineState *sms = SBSA_MACHINE(machine);
28
+ unsigned lg_linesize = ctz32(linesize);
176
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
29
+ unsigned sets;
177
+ MemoryRegion *sysmem = get_system_memory();
178
+ MemoryRegion *secure_sysmem = NULL;
179
+ MemoryRegion *ram = g_new(MemoryRegion, 1);
180
+ const CPUArchIdList *possible_cpus;
181
+ int n, sbsa_max_cpus;
182
+
183
+ if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a57"))) {
184
+ error_report("sbsa-ref: CPU type other than the built-in "
185
+ "cortex-a57 not supported");
186
+ exit(1);
187
+ }
188
+
189
+ if (kvm_enabled()) {
190
+ error_report("sbsa-ref: KVM is not supported for this machine");
191
+ exit(1);
192
+ }
193
+
30
+
194
+ /*
31
+ /*
195
+ * This machine has EL3 enabled, external firmware should supply PSCI
32
+ * The 64-bit CCSIDR_EL1 format is:
196
+ * implementation, so the QEMU's internal PSCI is disabled.
33
+ * [55:32] number of sets - 1
34
+ * [23:3] associativity - 1
35
+ * [2:0] log2(linesize) - 4
36
+ * so 0 == 16 bytes, 1 == 32 bytes, 2 == 64 bytes, etc
197
+ */
37
+ */
198
+ sms->psci_conduit = QEMU_PSCI_CONDUIT_DISABLED;
38
+ assert(assoc != 0);
39
+ assert(is_power_of_2(linesize));
40
+ assert(lg_linesize >= 4 && lg_linesize <= 7 + 4);
199
+
41
+
200
+ sbsa_max_cpus = sbsa_ref_memmap[SBSA_GIC_REDIST].size / GICV3_REDIST_SIZE;
42
+ /* sets * associativity * linesize == cachesize. */
43
+ sets = cachesize / (assoc * linesize);
44
+ assert(cachesize % (assoc * linesize) == 0);
201
+
45
+
202
+ if (max_cpus > sbsa_max_cpus) {
46
+ return ((uint64_t)(sets - 1) << 32)
203
+ error_report("Number of SMP CPUs requested (%d) exceeds max CPUs "
47
+ | ((assoc - 1) << 3)
204
+ "supported by machine 'sbsa-ref' (%d)",
48
+ | (lg_linesize - 4);
205
+ max_cpus, sbsa_max_cpus);
206
+ exit(1);
207
+ }
208
+
209
+ sms->smp_cpus = smp_cpus;
210
+
211
+ if (machine->ram_size > sbsa_ref_memmap[SBSA_MEM].size) {
212
+ error_report("sbsa-ref: cannot model more than %dGB RAM", RAMLIMIT_GB);
213
+ exit(1);
214
+ }
215
+
216
+ possible_cpus = mc->possible_cpu_arch_ids(machine);
217
+ for (n = 0; n < possible_cpus->len; n++) {
218
+ Object *cpuobj;
219
+ CPUState *cs;
220
+
221
+ if (n >= smp_cpus) {
222
+ break;
223
+ }
224
+
225
+ cpuobj = object_new(possible_cpus->cpus[n].type);
226
+ object_property_set_int(cpuobj, possible_cpus->cpus[n].arch_id,
227
+ "mp-affinity", NULL);
228
+
229
+ cs = CPU(cpuobj);
230
+ cs->cpu_index = n;
231
+
232
+ numa_cpu_pre_plug(&possible_cpus->cpus[cs->cpu_index], DEVICE(cpuobj),
233
+ &error_fatal);
234
+
235
+ if (object_property_find(cpuobj, "reset-cbar", NULL)) {
236
+ object_property_set_int(cpuobj,
237
+ sbsa_ref_memmap[SBSA_CPUPERIPHS].base,
238
+ "reset-cbar", &error_abort);
239
+ }
240
+
241
+ object_property_set_link(cpuobj, OBJECT(sysmem), "memory",
242
+ &error_abort);
243
+
244
+ object_property_set_link(cpuobj, OBJECT(secure_sysmem),
245
+ "secure-memory", &error_abort);
246
+
247
+ object_property_set_bool(cpuobj, true, "realized", &error_fatal);
248
+ object_unref(cpuobj);
249
+ }
250
+
251
+ memory_region_allocate_system_memory(ram, NULL, "sbsa-ref.ram",
252
+ machine->ram_size);
253
+ memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ram);
254
+
255
+ sms->bootinfo.ram_size = machine->ram_size;
256
+ sms->bootinfo.kernel_filename = machine->kernel_filename;
257
+ sms->bootinfo.nb_cpus = smp_cpus;
258
+ sms->bootinfo.board_id = -1;
259
+ sms->bootinfo.loader_start = sbsa_ref_memmap[SBSA_MEM].base;
260
+ arm_load_kernel(ARM_CPU(first_cpu), &sms->bootinfo);
261
+}
49
+}
262
+
50
+
263
+static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx)
51
static void aarch64_a35_initfn(Object *obj)
264
+{
52
{
265
+ uint8_t clustersz = ARM_DEFAULT_CPUS_PER_CLUSTER;
53
ARMCPU *cpu = ARM_CPU(obj);
266
+ return arm_cpu_mp_affinity(idx, clustersz);
54
@@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_v1_initfn(Object *obj)
267
+}
55
* The Neoverse-V1 r1p2 TRM lists 32-bit format CCSIDR_EL1 values,
268
+
56
* but also says it implements CCIDX, which means they should be
269
+static const CPUArchIdList *sbsa_ref_possible_cpu_arch_ids(MachineState *ms)
57
* 64-bit format. So we here use values which are based on the textual
270
+{
58
- * information in chapter 2 of the TRM (and on the fact that
271
+ SBSAMachineState *sms = SBSA_MACHINE(ms);
59
- * sets * associativity * linesize == cachesize).
272
+ int n;
60
- *
273
+
61
- * The 64-bit CCSIDR_EL1 format is:
274
+ if (ms->possible_cpus) {
62
- * [55:32] number of sets - 1
275
+ assert(ms->possible_cpus->len == max_cpus);
63
- * [23:3] associativity - 1
276
+ return ms->possible_cpus;
64
- * [2:0] log2(linesize) - 4
277
+ }
65
- * so 0 == 16 bytes, 1 == 32 bytes, 2 == 64 bytes, etc
278
+
66
- *
279
+ ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) +
67
- * L1: 4-way set associative 64-byte line size, total size 64K,
280
+ sizeof(CPUArchId) * max_cpus);
68
- * so sets is 256.
281
+ ms->possible_cpus->len = max_cpus;
69
+ * information in chapter 2 of the TRM:
282
+ for (n = 0; n < ms->possible_cpus->len; n++) {
70
*
283
+ ms->possible_cpus->cpus[n].type = ms->cpu_type;
71
+ * L1: 4-way set associative 64-byte line size, total size 64K.
284
+ ms->possible_cpus->cpus[n].arch_id =
72
* L2: 8-way set associative, 64 byte line size, either 512K or 1MB.
285
+ sbsa_ref_cpu_mp_affinity(sms, n);
73
- * We pick 1MB, so this has 2048 sets.
286
+ ms->possible_cpus->cpus[n].props.has_thread_id = true;
74
- *
287
+ ms->possible_cpus->cpus[n].props.thread_id = n;
75
* L3: No L3 (this matches the CLIDR_EL1 value).
288
+ }
76
*/
289
+ return ms->possible_cpus;
77
- cpu->ccsidr[0] = 0x000000ff0000001aull; /* 64KB L1 dcache */
290
+}
78
- cpu->ccsidr[1] = 0x000000ff0000001aull; /* 64KB L1 icache */
291
+
79
- cpu->ccsidr[2] = 0x000007ff0000003aull; /* 1MB L2 cache */
292
+static CpuInstanceProperties
80
+ cpu->ccsidr[0] = make_ccsidr64(4, 64, 64 * KiB); /* L1 dcache */
293
+sbsa_ref_cpu_index_to_props(MachineState *ms, unsigned cpu_index)
81
+ cpu->ccsidr[1] = cpu->ccsidr[0]; /* L1 icache */
294
+{
82
+ cpu->ccsidr[2] = make_ccsidr64(8, 64, 1 * MiB); /* L2 cache */
295
+ MachineClass *mc = MACHINE_GET_CLASS(ms);
83
296
+ const CPUArchIdList *possible_cpus = mc->possible_cpu_arch_ids(ms);
84
/* From 3.2.115 SCTLR_EL3 */
297
+
85
cpu->reset_sctlr = 0x30c50838;
298
+ assert(cpu_index < possible_cpus->len);
299
+ return possible_cpus->cpus[cpu_index].props;
300
+}
301
+
302
+static int64_t
303
+sbsa_ref_get_default_cpu_node_id(const MachineState *ms, int idx)
304
+{
305
+ return idx % nb_numa_nodes;
306
+}
307
+
308
+static void sbsa_ref_class_init(ObjectClass *oc, void *data)
309
+{
310
+ MachineClass *mc = MACHINE_CLASS(oc);
311
+
312
+ mc->init = sbsa_ref_init;
313
+ mc->desc = "QEMU 'SBSA Reference' ARM Virtual Machine";
314
+ mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a57");
315
+ mc->max_cpus = 512;
316
+ mc->pci_allow_0_address = true;
317
+ mc->minimum_page_bits = 12;
318
+ mc->block_default_type = IF_IDE;
319
+ mc->no_cdrom = 1;
320
+ mc->default_ram_size = 1 * GiB;
321
+ mc->default_cpus = 4;
322
+ mc->possible_cpu_arch_ids = sbsa_ref_possible_cpu_arch_ids;
323
+ mc->cpu_index_to_instance_props = sbsa_ref_cpu_index_to_props;
324
+ mc->get_default_cpu_node_id = sbsa_ref_get_default_cpu_node_id;
325
+}
326
+
327
+static const TypeInfo sbsa_ref_info = {
328
+ .name = TYPE_SBSA_MACHINE,
329
+ .parent = TYPE_MACHINE,
330
+ .class_init = sbsa_ref_class_init,
331
+ .instance_size = sizeof(SBSAMachineState),
332
+};
333
+
334
+static void sbsa_ref_machine_init(void)
335
+{
336
+ type_register_static(&sbsa_ref_info);
337
+}
338
+
339
+type_init(sbsa_ref_machine_init);
340
diff --git a/MAINTAINERS b/MAINTAINERS
341
index XXXXXXX..XXXXXXX 100644
342
--- a/MAINTAINERS
343
+++ b/MAINTAINERS
344
@@ -XXX,XX +XXX,XX @@ F: include/hw/arm/fsl-imx6.h
345
F: include/hw/misc/imx6_*.h
346
F: include/hw/ssi/imx_spi.h
347
348
+SBSA-REF
349
+M: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
350
+M: Peter Maydell <peter.maydell@linaro.org>
351
+R: Leif Lindholm <leif.lindholm@linaro.org>
352
+L: qemu-arm@nongnu.org
353
+S: Maintained
354
+F: hw/arm/sbsa-ref.c
355
+
356
Sharp SL-5500 (Collie) PDA
357
M: Peter Maydell <peter.maydell@linaro.org>
358
L: qemu-arm@nongnu.org
359
diff --git a/default-configs/aarch64-softmmu.mak b/default-configs/aarch64-softmmu.mak
360
index XXXXXXX..XXXXXXX 100644
361
--- a/default-configs/aarch64-softmmu.mak
362
+++ b/default-configs/aarch64-softmmu.mak
363
@@ -XXX,XX +XXX,XX @@ include arm-softmmu.mak
364
365
CONFIG_XLNX_ZYNQMP_ARM=y
366
CONFIG_XLNX_VERSAL=y
367
+CONFIG_SBSA_REF=y
368
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
369
index XXXXXXX..XXXXXXX 100644
370
--- a/hw/arm/Kconfig
371
+++ b/hw/arm/Kconfig
372
@@ -XXX,XX +XXX,XX @@ config REALVIEW
373
select DS1338 # I2C RTC+NVRAM
374
select USB_OHCI
375
376
+config SBSA_REF
377
+ bool
378
+ imply PCI_DEVICES
379
+ select AHCI
380
+ select ARM_SMMUV3
381
+ select GPIO_KEY
382
+ select PCI_EXPRESS
383
+ select PCI_EXPRESS_GENERIC_BRIDGE
384
+ select PFLASH_CFI01
385
+ select PL011 # UART
386
+ select PL031 # RTC
387
+ select PL061 # GPIO
388
+ select USB_EHCI_SYSBUS
389
+
390
config SABRELITE
391
bool
392
select FSL_IMX6
393
--
86
--
394
2.20.1
87
2.34.1
395
396
diff view generated by jsdifflib
1
From: Samuel Ortiz <sameo@linux.intel.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Those helpers are a software implementation of the ARM v8 memory zeroing
3
Access to many of the special registers is enabled or disabled
4
op code. They should be moved to the op helper file, which is going to
4
by ACTLR_EL[23], which we implement as constant 0, which means
5
eventually be built only when TCG is enabled.
5
that all writes outside EL3 should trap.
6
6
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Robert Bradford <robert.bradford@intel.com>
9
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Message-id: 20190701132516.26392-10-philmd@redhat.com
13
[PMD: Rebased]
14
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20230811214031.171020-7-richard.henderson@linaro.org
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
11
---
18
target/arm/helper.c | 92 -----------------------------------------
12
target/arm/cpregs.h | 2 ++
19
target/arm/op_helper.c | 93 ++++++++++++++++++++++++++++++++++++++++++
13
target/arm/helper.c | 4 ++--
20
2 files changed, 93 insertions(+), 92 deletions(-)
14
target/arm/tcg/cpu64.c | 46 +++++++++++++++++++++++++++++++++---------
15
3 files changed, 41 insertions(+), 11 deletions(-)
21
16
17
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpregs.h
20
+++ b/target/arm/cpregs.h
21
@@ -XXX,XX +XXX,XX @@ static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { }
22
void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu);
23
#endif
24
25
+CPAccessResult access_tvm_trvm(CPUARMState *, const ARMCPRegInfo *, bool);
26
+
27
#endif /* TARGET_ARM_CPREGS_H */
22
diff --git a/target/arm/helper.c b/target/arm/helper.c
28
diff --git a/target/arm/helper.c b/target/arm/helper.c
23
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/helper.c
30
--- a/target/arm/helper.c
25
+++ b/target/arm/helper.c
31
+++ b/target/arm/helper.c
26
@@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
32
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tpm(CPUARMState *env, const ARMCPRegInfo *ri,
27
#endif
28
}
33
}
29
34
30
-void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)
35
/* Check for traps from EL1 due to HCR_EL2.TVM and HCR_EL2.TRVM. */
31
-{
36
-static CPAccessResult access_tvm_trvm(CPUARMState *env, const ARMCPRegInfo *ri,
32
- /*
37
- bool isread)
33
- * Implement DC ZVA, which zeroes a fixed-length block of memory.
38
+CPAccessResult access_tvm_trvm(CPUARMState *env, const ARMCPRegInfo *ri,
34
- * Note that we do not implement the (architecturally mandated)
39
+ bool isread)
35
- * alignment fault for attempts to use this on Device memory
40
{
36
- * (which matches the usual QEMU behaviour of not implementing either
41
if (arm_current_el(env) == 1) {
37
- * alignment faults or any memory attribute handling).
42
uint64_t trap = isread ? HCR_TRVM : HCR_TVM;
38
- */
43
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
39
-
40
- ARMCPU *cpu = env_archcpu(env);
41
- uint64_t blocklen = 4 << cpu->dcz_blocksize;
42
- uint64_t vaddr = vaddr_in & ~(blocklen - 1);
43
-
44
-#ifndef CONFIG_USER_ONLY
45
- {
46
- /*
47
- * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than
48
- * the block size so we might have to do more than one TLB lookup.
49
- * We know that in fact for any v8 CPU the page size is at least 4K
50
- * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only
51
- * 1K as an artefact of legacy v5 subpage support being present in the
52
- * same QEMU executable. So in practice the hostaddr[] array has
53
- * two entries, given the current setting of TARGET_PAGE_BITS_MIN.
54
- */
55
- int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE);
56
- void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)];
57
- int try, i;
58
- unsigned mmu_idx = cpu_mmu_index(env, false);
59
- TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx);
60
-
61
- assert(maxidx <= ARRAY_SIZE(hostaddr));
62
-
63
- for (try = 0; try < 2; try++) {
64
-
65
- for (i = 0; i < maxidx; i++) {
66
- hostaddr[i] = tlb_vaddr_to_host(env,
67
- vaddr + TARGET_PAGE_SIZE * i,
68
- 1, mmu_idx);
69
- if (!hostaddr[i]) {
70
- break;
71
- }
72
- }
73
- if (i == maxidx) {
74
- /*
75
- * If it's all in the TLB it's fair game for just writing to;
76
- * we know we don't need to update dirty status, etc.
77
- */
78
- for (i = 0; i < maxidx - 1; i++) {
79
- memset(hostaddr[i], 0, TARGET_PAGE_SIZE);
80
- }
81
- memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE));
82
- return;
83
- }
84
- /*
85
- * OK, try a store and see if we can populate the tlb. This
86
- * might cause an exception if the memory isn't writable,
87
- * in which case we will longjmp out of here. We must for
88
- * this purpose use the actual register value passed to us
89
- * so that we get the fault address right.
90
- */
91
- helper_ret_stb_mmu(env, vaddr_in, 0, oi, GETPC());
92
- /* Now we can populate the other TLB entries, if any */
93
- for (i = 0; i < maxidx; i++) {
94
- uint64_t va = vaddr + TARGET_PAGE_SIZE * i;
95
- if (va != (vaddr_in & TARGET_PAGE_MASK)) {
96
- helper_ret_stb_mmu(env, va, 0, oi, GETPC());
97
- }
98
- }
99
- }
100
-
101
- /*
102
- * Slow path (probably attempt to do this to an I/O device or
103
- * similar, or clearing of a block of code we have translations
104
- * cached for). Just do a series of byte writes as the architecture
105
- * demands. It's not worth trying to use a cpu_physical_memory_map(),
106
- * memset(), unmap() sequence here because:
107
- * + we'd need to account for the blocksize being larger than a page
108
- * + the direct-RAM access case is almost always going to be dealt
109
- * with in the fastpath code above, so there's no speed benefit
110
- * + we would have to deal with the map returning NULL because the
111
- * bounce buffer was in use
112
- */
113
- for (i = 0; i < blocklen; i++) {
114
- helper_ret_stb_mmu(env, vaddr + i, 0, oi, GETPC());
115
- }
116
- }
117
-#else
118
- memset(g2h(vaddr), 0, blocklen);
119
-#endif
120
-}
121
-
122
/* Note that signed overflow is undefined in C. The following routines are
123
careful to use unsigned types where modulo arithmetic is required.
124
Failure to do so _will_ break on newer gcc. */
125
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
126
index XXXXXXX..XXXXXXX 100644
44
index XXXXXXX..XXXXXXX 100644
127
--- a/target/arm/op_helper.c
45
--- a/target/arm/tcg/cpu64.c
128
+++ b/target/arm/op_helper.c
46
+++ b/target/arm/tcg/cpu64.c
129
@@ -XXX,XX +XXX,XX @@
47
@@ -XXX,XX +XXX,XX @@ static void aarch64_a64fx_initfn(Object *obj)
130
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
48
/* TODO: Add A64FX specific HPC extension registers */
131
*/
132
#include "qemu/osdep.h"
133
+#include "qemu/units.h"
134
#include "qemu/log.h"
135
#include "qemu/main-loop.h"
136
#include "cpu.h"
137
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(ror_cc)(CPUARMState *env, uint32_t x, uint32_t i)
138
return ((uint32_t)x >> shift) | (x << (32 - shift));
139
}
140
}
49
}
50
51
+static CPAccessResult access_actlr_w(CPUARMState *env, const ARMCPRegInfo *r,
52
+ bool read)
53
+{
54
+ if (!read) {
55
+ int el = arm_current_el(env);
141
+
56
+
142
+void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)
57
+ /* Because ACTLR_EL2 is constant 0, writes below EL2 trap to EL2. */
143
+{
58
+ if (el < 2 && arm_is_el2_enabled(env)) {
144
+ /*
59
+ return CP_ACCESS_TRAP_EL2;
145
+ * Implement DC ZVA, which zeroes a fixed-length block of memory.
146
+ * Note that we do not implement the (architecturally mandated)
147
+ * alignment fault for attempts to use this on Device memory
148
+ * (which matches the usual QEMU behaviour of not implementing either
149
+ * alignment faults or any memory attribute handling).
150
+ */
151
+
152
+ ARMCPU *cpu = env_archcpu(env);
153
+ uint64_t blocklen = 4 << cpu->dcz_blocksize;
154
+ uint64_t vaddr = vaddr_in & ~(blocklen - 1);
155
+
156
+#ifndef CONFIG_USER_ONLY
157
+ {
158
+ /*
159
+ * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than
160
+ * the block size so we might have to do more than one TLB lookup.
161
+ * We know that in fact for any v8 CPU the page size is at least 4K
162
+ * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only
163
+ * 1K as an artefact of legacy v5 subpage support being present in the
164
+ * same QEMU executable. So in practice the hostaddr[] array has
165
+ * two entries, given the current setting of TARGET_PAGE_BITS_MIN.
166
+ */
167
+ int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE);
168
+ void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)];
169
+ int try, i;
170
+ unsigned mmu_idx = cpu_mmu_index(env, false);
171
+ TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx);
172
+
173
+ assert(maxidx <= ARRAY_SIZE(hostaddr));
174
+
175
+ for (try = 0; try < 2; try++) {
176
+
177
+ for (i = 0; i < maxidx; i++) {
178
+ hostaddr[i] = tlb_vaddr_to_host(env,
179
+ vaddr + TARGET_PAGE_SIZE * i,
180
+ 1, mmu_idx);
181
+ if (!hostaddr[i]) {
182
+ break;
183
+ }
184
+ }
185
+ if (i == maxidx) {
186
+ /*
187
+ * If it's all in the TLB it's fair game for just writing to;
188
+ * we know we don't need to update dirty status, etc.
189
+ */
190
+ for (i = 0; i < maxidx - 1; i++) {
191
+ memset(hostaddr[i], 0, TARGET_PAGE_SIZE);
192
+ }
193
+ memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE));
194
+ return;
195
+ }
196
+ /*
197
+ * OK, try a store and see if we can populate the tlb. This
198
+ * might cause an exception if the memory isn't writable,
199
+ * in which case we will longjmp out of here. We must for
200
+ * this purpose use the actual register value passed to us
201
+ * so that we get the fault address right.
202
+ */
203
+ helper_ret_stb_mmu(env, vaddr_in, 0, oi, GETPC());
204
+ /* Now we can populate the other TLB entries, if any */
205
+ for (i = 0; i < maxidx; i++) {
206
+ uint64_t va = vaddr + TARGET_PAGE_SIZE * i;
207
+ if (va != (vaddr_in & TARGET_PAGE_MASK)) {
208
+ helper_ret_stb_mmu(env, va, 0, oi, GETPC());
209
+ }
210
+ }
211
+ }
60
+ }
212
+
61
+ /* Because ACTLR_EL3 is constant 0, writes below EL3 trap to EL3. */
213
+ /*
62
+ if (el < 3 && arm_feature(env, ARM_FEATURE_EL3)) {
214
+ * Slow path (probably attempt to do this to an I/O device or
63
+ return CP_ACCESS_TRAP_EL3;
215
+ * similar, or clearing of a block of code we have translations
216
+ * cached for). Just do a series of byte writes as the architecture
217
+ * demands. It's not worth trying to use a cpu_physical_memory_map(),
218
+ * memset(), unmap() sequence here because:
219
+ * + we'd need to account for the blocksize being larger than a page
220
+ * + the direct-RAM access case is almost always going to be dealt
221
+ * with in the fastpath code above, so there's no speed benefit
222
+ * + we would have to deal with the map returning NULL because the
223
+ * bounce buffer was in use
224
+ */
225
+ for (i = 0; i < blocklen; i++) {
226
+ helper_ret_stb_mmu(env, vaddr + i, 0, oi, GETPC());
227
+ }
64
+ }
228
+ }
65
+ }
229
+#else
66
+ return CP_ACCESS_OK;
230
+ memset(g2h(vaddr), 0, blocklen);
231
+#endif
232
+}
67
+}
68
+
69
static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = {
70
{ .name = "ATCR_EL1", .state = ARM_CP_STATE_AA64,
71
.opc0 = 3, .opc1 = 0, .crn = 15, .crm = 7, .opc2 = 0,
72
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
73
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0,
74
+ /* Traps and enables are the same as for TCR_EL1. */
75
+ .accessfn = access_tvm_trvm, .fgt = FGT_TCR_EL1, },
76
{ .name = "ATCR_EL2", .state = ARM_CP_STATE_AA64,
77
.opc0 = 3, .opc1 = 4, .crn = 15, .crm = 7, .opc2 = 0,
78
.access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
79
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = {
80
.access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
81
{ .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64,
82
.opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 0,
83
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
84
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0,
85
+ .accessfn = access_actlr_w },
86
{ .name = "CPUACTLR2_EL1", .state = ARM_CP_STATE_AA64,
87
.opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 1,
88
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
89
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0,
90
+ .accessfn = access_actlr_w },
91
{ .name = "CPUACTLR3_EL1", .state = ARM_CP_STATE_AA64,
92
.opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 2,
93
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
94
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0,
95
+ .accessfn = access_actlr_w },
96
/*
97
* Report CPUCFR_EL1.SCU as 1, as we do not implement the DSU
98
* (and in particular its system registers).
99
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = {
100
.access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 4 },
101
{ .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64,
102
.opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 4,
103
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0x961563010 },
104
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0x961563010,
105
+ .accessfn = access_actlr_w },
106
{ .name = "CPUPCR_EL3", .state = ARM_CP_STATE_AA64,
107
.opc0 = 3, .opc1 = 6, .crn = 15, .crm = 8, .opc2 = 1,
108
.access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
109
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = {
110
.access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
111
{ .name = "CPUPWRCTLR_EL1", .state = ARM_CP_STATE_AA64,
112
.opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 7,
113
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
114
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0,
115
+ .accessfn = access_actlr_w },
116
{ .name = "ERXPFGCDN_EL1", .state = ARM_CP_STATE_AA64,
117
.opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 2,
118
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
119
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0,
120
+ .accessfn = access_actlr_w },
121
{ .name = "ERXPFGCTL_EL1", .state = ARM_CP_STATE_AA64,
122
.opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 1,
123
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
124
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0,
125
+ .accessfn = access_actlr_w },
126
{ .name = "ERXPFGF_EL1", .state = ARM_CP_STATE_AA64,
127
.opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 0,
128
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
129
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0,
130
+ .accessfn = access_actlr_w },
131
};
132
133
static void define_neoverse_n1_cp_reginfo(ARMCPU *cpu)
233
--
134
--
234
2.20.1
135
2.34.1
235
236
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Fix the condition used to check whether the initrd fits
3
There is only one additional EL1 register modeled, which
4
into RAM; in some cases if an initrd was also passed on
4
also needs to use access_actlr_w.
5
the command line we would get an error stating that it
6
was too big to fit into RAM after the kernel. Despite the
7
error the loader continued anyway, though, so also add an
8
exit(1) when the initrd is actually too big.
9
5
10
Fixes: 852dc64d665f ("hw/arm/boot: Diagnose layouts that put initrd or
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
DTB off the end of RAM")
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Andrew Jones <drjones@redhat.com>
8
Message-id: 20230811214031.171020-8-richard.henderson@linaro.org
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
Message-id: 20190618125844.4863-1-drjones@redhat.com
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
10
---
17
hw/arm/boot.c | 3 ++-
11
target/arm/tcg/cpu64.c | 3 ++-
18
1 file changed, 2 insertions(+), 1 deletion(-)
12
1 file changed, 2 insertions(+), 1 deletion(-)
19
13
20
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
14
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
21
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/boot.c
16
--- a/target/arm/tcg/cpu64.c
23
+++ b/hw/arm/boot.c
17
+++ b/target/arm/tcg/cpu64.c
24
@@ -XXX,XX +XXX,XX @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
18
@@ -XXX,XX +XXX,XX @@ static void define_neoverse_n1_cp_reginfo(ARMCPU *cpu)
25
info->initrd_filename);
19
static const ARMCPRegInfo neoverse_v1_cp_reginfo[] = {
26
exit(1);
20
{ .name = "CPUECTLR2_EL1", .state = ARM_CP_STATE_AA64,
27
}
21
.opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 5,
28
- if (info->initrd_start + initrd_size > info->ram_size) {
22
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
29
+ if (info->initrd_start + initrd_size > ram_end) {
23
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0,
30
error_report("could not load initrd '%s': "
24
+ .accessfn = access_actlr_w },
31
"too big to fit into RAM after the kernel",
25
{ .name = "CPUPPMCR_EL3", .state = ARM_CP_STATE_AA64,
32
info->initrd_filename);
26
.opc0 = 3, .opc1 = 6, .crn = 15, .crm = 2, .opc2 = 0,
33
+ exit(1);
27
.access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
34
}
35
} else {
36
initrd_size = 0;
37
--
28
--
38
2.20.1
29
2.34.1
39
40
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
This machine correctly defines its default_cpu_type to cortex-m3
4
and report an error if the user requested another cpu_type,
5
however it does not exit, and this can confuse users trying
6
to use another core:
7
8
$ qemu-system-arm -M emcraft-sf2 -cpu cortex-m4 -kernel test-m4.elf
9
qemu-system-arm: This board can only be used with CPU cortex-m3-arm-cpu
10
[output related to M3 core ...]
11
12
The CPU is indeed a M3 core:
13
14
(qemu) info qom-tree
15
/machine (emcraft-sf2-machine)
16
/unattached (container)
17
/device[0] (msf2-soc)
18
/armv7m (armv7m)
19
/cpu (cortex-m3-arm-cpu)
20
21
Add the missing exit() call to return to the shell.
22
23
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
24
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
25
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
26
Message-id: 20190617160136.29930-1-philmd@redhat.com
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
29
hw/arm/msf2-som.c | 1 +
30
1 file changed, 1 insertion(+)
31
32
diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/arm/msf2-som.c
35
+++ b/hw/arm/msf2-som.c
36
@@ -XXX,XX +XXX,XX @@ static void emcraft_sf2_s2s010_init(MachineState *machine)
37
if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) {
38
error_report("This board can only be used with CPU %s",
39
mc->default_cpu_type);
40
+ exit(1);
41
}
42
43
memory_region_init_ram(ddr, NULL, "ddr-ram", DDR_SIZE,
44
--
45
2.20.1
46
47
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
These routines are TCG specific.
3
Like FEAT_TRF (Self-hosted Trace Extension), suppress tracing
4
The arm_deliver_fault() function is only used within the new
4
external to the cpu, which is out of scope for QEMU.
5
helper. Make it static.
6
5
7
Suggested-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Message-id: 20190701132516.26392-13-philmd@redhat.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20230811214031.171020-10-richard.henderson@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
10
---
13
target/arm/Makefile.objs | 1 +
11
target/arm/cpu.c | 3 +++
14
target/arm/internals.h | 3 -
12
1 file changed, 3 insertions(+)
15
target/arm/cpu.c | 6 +-
16
target/arm/helper.c | 53 -----------
17
target/arm/op_helper.c | 135 --------------------------
18
target/arm/tlb_helper.c | 200 +++++++++++++++++++++++++++++++++++++++
19
6 files changed, 205 insertions(+), 193 deletions(-)
20
create mode 100644 target/arm/tlb_helper.c
21
13
22
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
23
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/Makefile.objs
25
+++ b/target/arm/Makefile.objs
26
@@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c
27
target/arm/translate.o: target/arm/decode-vfp.inc.c
28
target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c
29
30
+obj-y += tlb_helper.o
31
obj-y += translate.o op_helper.o
32
obj-y += crypto_helper.o
33
obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o
34
diff --git a/target/arm/internals.h b/target/arm/internals.h
35
index XXXXXXX..XXXXXXX 100644
36
--- a/target/arm/internals.h
37
+++ b/target/arm/internals.h
38
@@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
39
MMUAccessType access_type, int mmu_idx,
40
bool probe, uintptr_t retaddr);
41
42
-void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type,
43
- int mmu_idx, ARMMMUFaultInfo *fi) QEMU_NORETURN;
44
-
45
/* Return true if the stage 1 translation regime is using LPAE format page
46
* tables */
47
bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx);
48
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
14
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
49
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
50
--- a/target/arm/cpu.c
16
--- a/target/arm/cpu.c
51
+++ b/target/arm/cpu.c
17
+++ b/target/arm/cpu.c
52
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
18
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
53
cc->gdb_write_register = arm_cpu_gdb_write_register;
19
/* FEAT_SPE (Statistical Profiling Extension) */
54
#ifndef CONFIG_USER_ONLY
20
cpu->isar.id_aa64dfr0 =
55
cc->do_interrupt = arm_cpu_do_interrupt;
21
FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, PMSVER, 0);
56
- cc->do_unaligned_access = arm_cpu_do_unaligned_access;
22
+ /* FEAT_TRBE (Trace Buffer Extension) */
57
- cc->do_transaction_failed = arm_cpu_do_transaction_failed;
23
+ cpu->isar.id_aa64dfr0 =
58
cc->get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug;
24
+ FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, TRACEBUFFER, 0);
59
cc->asidx_from_attrs = arm_asidx_from_attrs;
25
/* FEAT_TRF (Self-hosted Trace Extension) */
60
cc->vmsd = &vmstate_arm_cpu;
26
cpu->isar.id_aa64dfr0 =
61
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
27
FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, TRACEFILT, 0);
62
#ifdef CONFIG_TCG
63
cc->tcg_initialize = arm_translate_init;
64
cc->tlb_fill = arm_cpu_tlb_fill;
65
+#if !defined(CONFIG_USER_ONLY)
66
+ cc->do_unaligned_access = arm_cpu_do_unaligned_access;
67
+ cc->do_transaction_failed = arm_cpu_do_transaction_failed;
68
+#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
69
#endif
70
}
71
72
diff --git a/target/arm/helper.c b/target/arm/helper.c
73
index XXXXXXX..XXXXXXX 100644
74
--- a/target/arm/helper.c
75
+++ b/target/arm/helper.c
76
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
77
78
#endif
79
80
-bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
81
- MMUAccessType access_type, int mmu_idx,
82
- bool probe, uintptr_t retaddr)
83
-{
84
- ARMCPU *cpu = ARM_CPU(cs);
85
-
86
-#ifdef CONFIG_USER_ONLY
87
- cpu->env.exception.vaddress = address;
88
- if (access_type == MMU_INST_FETCH) {
89
- cs->exception_index = EXCP_PREFETCH_ABORT;
90
- } else {
91
- cs->exception_index = EXCP_DATA_ABORT;
92
- }
93
- cpu_loop_exit_restore(cs, retaddr);
94
-#else
95
- hwaddr phys_addr;
96
- target_ulong page_size;
97
- int prot, ret;
98
- MemTxAttrs attrs = {};
99
- ARMMMUFaultInfo fi = {};
100
-
101
- /*
102
- * Walk the page table and (if the mapping exists) add the page
103
- * to the TLB. On success, return true. Otherwise, if probing,
104
- * return false. Otherwise populate fsr with ARM DFSR/IFSR fault
105
- * register format, and signal the fault.
106
- */
107
- ret = get_phys_addr(&cpu->env, address, access_type,
108
- core_to_arm_mmu_idx(&cpu->env, mmu_idx),
109
- &phys_addr, &attrs, &prot, &page_size, &fi, NULL);
110
- if (likely(!ret)) {
111
- /*
112
- * Map a single [sub]page. Regions smaller than our declared
113
- * target page size are handled specially, so for those we
114
- * pass in the exact addresses.
115
- */
116
- if (page_size >= TARGET_PAGE_SIZE) {
117
- phys_addr &= TARGET_PAGE_MASK;
118
- address &= TARGET_PAGE_MASK;
119
- }
120
- tlb_set_page_with_attrs(cs, address, phys_addr, attrs,
121
- prot, mmu_idx, page_size);
122
- return true;
123
- } else if (probe) {
124
- return false;
125
- } else {
126
- /* now we have a real cpu fault */
127
- cpu_restore_state(cs, retaddr, true);
128
- arm_deliver_fault(cpu, address, access_type, mmu_idx, &fi);
129
- }
130
-#endif
131
-}
132
-
133
/* Note that signed overflow is undefined in C. The following routines are
134
careful to use unsigned types where modulo arithmetic is required.
135
Failure to do so _will_ break on newer gcc. */
136
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
137
index XXXXXXX..XXXXXXX 100644
138
--- a/target/arm/op_helper.c
139
+++ b/target/arm/op_helper.c
140
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_tbl)(uint32_t ireg, uint32_t def, void *vn,
141
return val;
142
}
143
144
-#if !defined(CONFIG_USER_ONLY)
145
-
146
-static inline uint32_t merge_syn_data_abort(uint32_t template_syn,
147
- unsigned int target_el,
148
- bool same_el, bool ea,
149
- bool s1ptw, bool is_write,
150
- int fsc)
151
-{
152
- uint32_t syn;
153
-
154
- /*
155
- * ISV is only set for data aborts routed to EL2 and
156
- * never for stage-1 page table walks faulting on stage 2.
157
- *
158
- * Furthermore, ISV is only set for certain kinds of load/stores.
159
- * If the template syndrome does not have ISV set, we should leave
160
- * it cleared.
161
- *
162
- * See ARMv8 specs, D7-1974:
163
- * ISS encoding for an exception from a Data Abort, the
164
- * ISV field.
165
- */
166
- if (!(template_syn & ARM_EL_ISV) || target_el != 2 || s1ptw) {
167
- syn = syn_data_abort_no_iss(same_el,
168
- ea, 0, s1ptw, is_write, fsc);
169
- } else {
170
- /*
171
- * Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template
172
- * syndrome created at translation time.
173
- * Now we create the runtime syndrome with the remaining fields.
174
- */
175
- syn = syn_data_abort_with_iss(same_el,
176
- 0, 0, 0, 0, 0,
177
- ea, 0, s1ptw, is_write, fsc,
178
- false);
179
- /* Merge the runtime syndrome with the template syndrome. */
180
- syn |= template_syn;
181
- }
182
- return syn;
183
-}
184
-
185
-void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type,
186
- int mmu_idx, ARMMMUFaultInfo *fi)
187
-{
188
- CPUARMState *env = &cpu->env;
189
- int target_el;
190
- bool same_el;
191
- uint32_t syn, exc, fsr, fsc;
192
- ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx);
193
-
194
- target_el = exception_target_el(env);
195
- if (fi->stage2) {
196
- target_el = 2;
197
- env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4;
198
- }
199
- same_el = (arm_current_el(env) == target_el);
200
-
201
- if (target_el == 2 || arm_el_is_aa64(env, target_el) ||
202
- arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) {
203
- /*
204
- * LPAE format fault status register : bottom 6 bits are
205
- * status code in the same form as needed for syndrome
206
- */
207
- fsr = arm_fi_to_lfsc(fi);
208
- fsc = extract32(fsr, 0, 6);
209
- } else {
210
- fsr = arm_fi_to_sfsc(fi);
211
- /*
212
- * Short format FSR : this fault will never actually be reported
213
- * to an EL that uses a syndrome register. Use a (currently)
214
- * reserved FSR code in case the constructed syndrome does leak
215
- * into the guest somehow.
216
- */
217
- fsc = 0x3f;
218
- }
219
-
220
- if (access_type == MMU_INST_FETCH) {
221
- syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc);
222
- exc = EXCP_PREFETCH_ABORT;
223
- } else {
224
- syn = merge_syn_data_abort(env->exception.syndrome, target_el,
225
- same_el, fi->ea, fi->s1ptw,
226
- access_type == MMU_DATA_STORE,
227
- fsc);
228
- if (access_type == MMU_DATA_STORE
229
- && arm_feature(env, ARM_FEATURE_V6)) {
230
- fsr |= (1 << 11);
231
- }
232
- exc = EXCP_DATA_ABORT;
233
- }
234
-
235
- env->exception.vaddress = addr;
236
- env->exception.fsr = fsr;
237
- raise_exception(env, exc, syn, target_el);
238
-}
239
-
240
-/* Raise a data fault alignment exception for the specified virtual address */
241
-void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
242
- MMUAccessType access_type,
243
- int mmu_idx, uintptr_t retaddr)
244
-{
245
- ARMCPU *cpu = ARM_CPU(cs);
246
- ARMMMUFaultInfo fi = {};
247
-
248
- /* now we have a real cpu fault */
249
- cpu_restore_state(cs, retaddr, true);
250
-
251
- fi.type = ARMFault_Alignment;
252
- arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi);
253
-}
254
-
255
-/*
256
- * arm_cpu_do_transaction_failed: handle a memory system error response
257
- * (eg "no device/memory present at address") by raising an external abort
258
- * exception
259
- */
260
-void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
261
- vaddr addr, unsigned size,
262
- MMUAccessType access_type,
263
- int mmu_idx, MemTxAttrs attrs,
264
- MemTxResult response, uintptr_t retaddr)
265
-{
266
- ARMCPU *cpu = ARM_CPU(cs);
267
- ARMMMUFaultInfo fi = {};
268
-
269
- /* now we have a real cpu fault */
270
- cpu_restore_state(cs, retaddr, true);
271
-
272
- fi.ea = arm_extabort_type(response);
273
- fi.type = ARMFault_SyncExternal;
274
- arm_deliver_fault(cpu, addr, access_type, mmu_idx, &fi);
275
-}
276
-
277
-#endif /* !defined(CONFIG_USER_ONLY) */
278
-
279
void HELPER(v8m_stackcheck)(CPUARMState *env, uint32_t newvalue)
280
{
281
/*
282
diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c
283
new file mode 100644
284
index XXXXXXX..XXXXXXX
285
--- /dev/null
286
+++ b/target/arm/tlb_helper.c
287
@@ -XXX,XX +XXX,XX @@
288
+/*
289
+ * ARM TLB (Translation lookaside buffer) helpers.
290
+ *
291
+ * This code is licensed under the GNU GPL v2 or later.
292
+ *
293
+ * SPDX-License-Identifier: GPL-2.0-or-later
294
+ */
295
+#include "qemu/osdep.h"
296
+#include "cpu.h"
297
+#include "internals.h"
298
+#include "exec/exec-all.h"
299
+
300
+#if !defined(CONFIG_USER_ONLY)
301
+
302
+static inline uint32_t merge_syn_data_abort(uint32_t template_syn,
303
+ unsigned int target_el,
304
+ bool same_el, bool ea,
305
+ bool s1ptw, bool is_write,
306
+ int fsc)
307
+{
308
+ uint32_t syn;
309
+
310
+ /*
311
+ * ISV is only set for data aborts routed to EL2 and
312
+ * never for stage-1 page table walks faulting on stage 2.
313
+ *
314
+ * Furthermore, ISV is only set for certain kinds of load/stores.
315
+ * If the template syndrome does not have ISV set, we should leave
316
+ * it cleared.
317
+ *
318
+ * See ARMv8 specs, D7-1974:
319
+ * ISS encoding for an exception from a Data Abort, the
320
+ * ISV field.
321
+ */
322
+ if (!(template_syn & ARM_EL_ISV) || target_el != 2 || s1ptw) {
323
+ syn = syn_data_abort_no_iss(same_el,
324
+ ea, 0, s1ptw, is_write, fsc);
325
+ } else {
326
+ /*
327
+ * Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template
328
+ * syndrome created at translation time.
329
+ * Now we create the runtime syndrome with the remaining fields.
330
+ */
331
+ syn = syn_data_abort_with_iss(same_el,
332
+ 0, 0, 0, 0, 0,
333
+ ea, 0, s1ptw, is_write, fsc,
334
+ false);
335
+ /* Merge the runtime syndrome with the template syndrome. */
336
+ syn |= template_syn;
337
+ }
338
+ return syn;
339
+}
340
+
341
+static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr,
342
+ MMUAccessType access_type,
343
+ int mmu_idx, ARMMMUFaultInfo *fi)
344
+{
345
+ CPUARMState *env = &cpu->env;
346
+ int target_el;
347
+ bool same_el;
348
+ uint32_t syn, exc, fsr, fsc;
349
+ ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx);
350
+
351
+ target_el = exception_target_el(env);
352
+ if (fi->stage2) {
353
+ target_el = 2;
354
+ env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4;
355
+ }
356
+ same_el = (arm_current_el(env) == target_el);
357
+
358
+ if (target_el == 2 || arm_el_is_aa64(env, target_el) ||
359
+ arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) {
360
+ /*
361
+ * LPAE format fault status register : bottom 6 bits are
362
+ * status code in the same form as needed for syndrome
363
+ */
364
+ fsr = arm_fi_to_lfsc(fi);
365
+ fsc = extract32(fsr, 0, 6);
366
+ } else {
367
+ fsr = arm_fi_to_sfsc(fi);
368
+ /*
369
+ * Short format FSR : this fault will never actually be reported
370
+ * to an EL that uses a syndrome register. Use a (currently)
371
+ * reserved FSR code in case the constructed syndrome does leak
372
+ * into the guest somehow.
373
+ */
374
+ fsc = 0x3f;
375
+ }
376
+
377
+ if (access_type == MMU_INST_FETCH) {
378
+ syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc);
379
+ exc = EXCP_PREFETCH_ABORT;
380
+ } else {
381
+ syn = merge_syn_data_abort(env->exception.syndrome, target_el,
382
+ same_el, fi->ea, fi->s1ptw,
383
+ access_type == MMU_DATA_STORE,
384
+ fsc);
385
+ if (access_type == MMU_DATA_STORE
386
+ && arm_feature(env, ARM_FEATURE_V6)) {
387
+ fsr |= (1 << 11);
388
+ }
389
+ exc = EXCP_DATA_ABORT;
390
+ }
391
+
392
+ env->exception.vaddress = addr;
393
+ env->exception.fsr = fsr;
394
+ raise_exception(env, exc, syn, target_el);
395
+}
396
+
397
+/* Raise a data fault alignment exception for the specified virtual address */
398
+void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
399
+ MMUAccessType access_type,
400
+ int mmu_idx, uintptr_t retaddr)
401
+{
402
+ ARMCPU *cpu = ARM_CPU(cs);
403
+ ARMMMUFaultInfo fi = {};
404
+
405
+ /* now we have a real cpu fault */
406
+ cpu_restore_state(cs, retaddr, true);
407
+
408
+ fi.type = ARMFault_Alignment;
409
+ arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi);
410
+}
411
+
412
+/*
413
+ * arm_cpu_do_transaction_failed: handle a memory system error response
414
+ * (eg "no device/memory present at address") by raising an external abort
415
+ * exception
416
+ */
417
+void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
418
+ vaddr addr, unsigned size,
419
+ MMUAccessType access_type,
420
+ int mmu_idx, MemTxAttrs attrs,
421
+ MemTxResult response, uintptr_t retaddr)
422
+{
423
+ ARMCPU *cpu = ARM_CPU(cs);
424
+ ARMMMUFaultInfo fi = {};
425
+
426
+ /* now we have a real cpu fault */
427
+ cpu_restore_state(cs, retaddr, true);
428
+
429
+ fi.ea = arm_extabort_type(response);
430
+ fi.type = ARMFault_SyncExternal;
431
+ arm_deliver_fault(cpu, addr, access_type, mmu_idx, &fi);
432
+}
433
+
434
+#endif /* !defined(CONFIG_USER_ONLY) */
435
+
436
+bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
437
+ MMUAccessType access_type, int mmu_idx,
438
+ bool probe, uintptr_t retaddr)
439
+{
440
+ ARMCPU *cpu = ARM_CPU(cs);
441
+
442
+#ifdef CONFIG_USER_ONLY
443
+ cpu->env.exception.vaddress = address;
444
+ if (access_type == MMU_INST_FETCH) {
445
+ cs->exception_index = EXCP_PREFETCH_ABORT;
446
+ } else {
447
+ cs->exception_index = EXCP_DATA_ABORT;
448
+ }
449
+ cpu_loop_exit_restore(cs, retaddr);
450
+#else
451
+ hwaddr phys_addr;
452
+ target_ulong page_size;
453
+ int prot, ret;
454
+ MemTxAttrs attrs = {};
455
+ ARMMMUFaultInfo fi = {};
456
+
457
+ /*
458
+ * Walk the page table and (if the mapping exists) add the page
459
+ * to the TLB. On success, return true. Otherwise, if probing,
460
+ * return false. Otherwise populate fsr with ARM DFSR/IFSR fault
461
+ * register format, and signal the fault.
462
+ */
463
+ ret = get_phys_addr(&cpu->env, address, access_type,
464
+ core_to_arm_mmu_idx(&cpu->env, mmu_idx),
465
+ &phys_addr, &attrs, &prot, &page_size, &fi, NULL);
466
+ if (likely(!ret)) {
467
+ /*
468
+ * Map a single [sub]page. Regions smaller than our declared
469
+ * target page size are handled specially, so for those we
470
+ * pass in the exact addresses.
471
+ */
472
+ if (page_size >= TARGET_PAGE_SIZE) {
473
+ phys_addr &= TARGET_PAGE_MASK;
474
+ address &= TARGET_PAGE_MASK;
475
+ }
476
+ tlb_set_page_with_attrs(cs, address, phys_addr, attrs,
477
+ prot, mmu_idx, page_size);
478
+ return true;
479
+ } else if (probe) {
480
+ return false;
481
+ } else {
482
+ /* now we have a real cpu fault */
483
+ cpu_restore_state(cs, retaddr, true);
484
+ arm_deliver_fault(cpu, address, access_type, mmu_idx, &fi);
485
+ }
486
+#endif
487
+}
488
--
28
--
489
2.20.1
29
2.34.1
490
491
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This code is specific to the SoftFloat floating-point
3
This feature allows the operating system to set TCR_ELx.HWU*
4
implementation, which is only used by TCG.
4
to allow the implementation to use the PBHA bits from the
5
block and page descriptors for for IMPLEMENTATION DEFINED
6
purposes. Since QEMU has no need to use these bits, we may
7
simply ignore them.
5
8
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20190701132516.26392-18-philmd@redhat.com
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20230811214031.171020-11-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
13
---
11
target/arm/vfp_helper.c | 26 +++++++++++++++++++++++---
14
docs/system/arm/emulation.rst | 1 +
12
1 file changed, 23 insertions(+), 3 deletions(-)
15
target/arm/tcg/cpu32.c | 2 +-
16
target/arm/tcg/cpu64.c | 2 +-
17
3 files changed, 3 insertions(+), 2 deletions(-)
13
18
14
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
19
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
15
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/vfp_helper.c
21
--- a/docs/system/arm/emulation.rst
17
+++ b/target/arm/vfp_helper.c
22
+++ b/docs/system/arm/emulation.rst
18
@@ -XXX,XX +XXX,XX @@
23
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
19
*/
24
- FEAT_HAFDBS (Hardware management of the access flag and dirty bit state)
20
25
- FEAT_HCX (Support for the HCRX_EL2 register)
21
#include "qemu/osdep.h"
26
- FEAT_HPDS (Hierarchical permission disables)
22
-#include "qemu/log.h"
27
+- FEAT_HPDS2 (Translation table page-based hardware attributes)
23
#include "cpu.h"
28
- FEAT_I8MM (AArch64 Int8 matrix multiplication instructions)
24
#include "exec/helper-proto.h"
29
- FEAT_IDST (ID space trap handling)
25
-#include "fpu/softfloat.h"
30
- FEAT_IESB (Implicit error synchronization event)
26
#include "internals.h"
31
diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c
27
-
32
index XXXXXXX..XXXXXXX 100644
28
+#ifdef CONFIG_TCG
33
--- a/target/arm/tcg/cpu32.c
29
+#include "qemu/log.h"
34
+++ b/target/arm/tcg/cpu32.c
30
+#include "fpu/softfloat.h"
35
@@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu)
31
+#endif
36
cpu->isar.id_mmfr3 = t;
32
37
33
/* VFP support. We follow the convention used for VFP instructions:
38
t = cpu->isar.id_mmfr4;
34
Single precision routines have a "s" suffix, double precision a
39
- t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* FEAT_AA32HPD */
35
"d" suffix. */
40
+ t = FIELD_DP32(t, ID_MMFR4, HPDS, 2); /* FEAT_HPDS2 */
36
41
t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
37
+#ifdef CONFIG_TCG
42
t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* FEAT_TTCNP */
38
+
43
t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* FEAT_XNX */
39
/* Convert host exception flags to vfp form. */
44
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
40
static inline int vfp_exceptbits_from_host(int host_bits)
45
index XXXXXXX..XXXXXXX 100644
41
{
46
--- a/target/arm/tcg/cpu64.c
42
@@ -XXX,XX +XXX,XX @@ static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val)
47
+++ b/target/arm/tcg/cpu64.c
43
set_float_exception_flags(0, &env->vfp.standard_fp_status);
48
@@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj)
44
}
49
t = FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 2); /* FEAT_HAFDBS */
45
50
t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */
46
+#else
51
t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */
47
+
52
- t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */
48
+static uint32_t vfp_get_fpscr_from_host(CPUARMState *env)
53
+ t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 2); /* FEAT_HPDS2 */
49
+{
54
t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); /* FEAT_LOR */
50
+ return 0;
55
t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 3); /* FEAT_PAN3 */
51
+}
56
t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */
52
+
53
+static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val)
54
+{
55
+}
56
+
57
+#endif
58
+
59
uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
60
{
61
uint32_t i, fpscr;
62
@@ -XXX,XX +XXX,XX @@ void vfp_set_fpscr(CPUARMState *env, uint32_t val)
63
HELPER(vfp_set_fpscr)(env, val);
64
}
65
66
+#ifdef CONFIG_TCG
67
+
68
#define VFP_HELPER(name, p) HELPER(glue(glue(vfp_,name),p))
69
70
#define VFP_BINOP(name) \
71
@@ -XXX,XX +XXX,XX @@ float64 HELPER(frint64_d)(float64 f, void *fpst)
72
{
73
return frint_d(f, fpst, 64);
74
}
75
+
76
+#endif
77
--
57
--
78
2.20.1
58
2.34.1
79
80
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Alex Bennée <alex.bennee@linaro.org>
2
2
3
The vfp_set_fpscr() helper contains code specific to the host
3
This is a mandatory feature for Armv8.1 architectures but we don't
4
floating point implementation (here the SoftFloat library).
4
state the feature clearly in our emulation list. Also include
5
Extract this code to vfp_set_fpscr_from_host().
5
FEAT_CRC32 comment in aarch64_max_tcg_initfn for ease of grepping.
6
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Message-id: 20190701132516.26392-17-philmd@redhat.com
8
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20230824075406.1515566-1-alex.bennee@linaro.org
10
Cc: qemu-stable@nongnu.org
11
Message-Id: <20230222110104.3996971-1-alex.bennee@linaro.org>
12
[PMM: pluralize 'instructions' in docs]
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
14
---
12
target/arm/vfp_helper.c | 19 +++++++++++++------
15
docs/system/arm/emulation.rst | 1 +
13
1 file changed, 13 insertions(+), 6 deletions(-)
16
target/arm/tcg/cpu64.c | 2 +-
17
2 files changed, 2 insertions(+), 1 deletion(-)
14
18
15
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
19
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
16
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/vfp_helper.c
21
--- a/docs/system/arm/emulation.rst
18
+++ b/target/arm/vfp_helper.c
22
+++ b/docs/system/arm/emulation.rst
19
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits)
23
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
20
return host_bits;
24
- FEAT_BBM at level 2 (Translation table break-before-make levels)
21
}
25
- FEAT_BF16 (AArch64 BFloat16 instructions)
22
26
- FEAT_BTI (Branch Target Identification)
23
+static uint32_t vfp_get_fpscr_from_host(CPUARMState *env)
27
+- FEAT_CRC32 (CRC32 instructions)
24
+{
28
- FEAT_CSV2 (Cache speculation variant 2)
25
+ uint32_t i;
29
- FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1)
26
+
30
- FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2)
27
+ i = get_float_exception_flags(&env->vfp.fp_status);
31
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
28
+ i |= get_float_exception_flags(&env->vfp.standard_fp_status);
32
index XXXXXXX..XXXXXXX 100644
29
+ /* FZ16 does not generate an input denormal exception. */
33
--- a/target/arm/tcg/cpu64.c
30
+ i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
34
+++ b/target/arm/tcg/cpu64.c
31
+ & ~float_flag_input_denormal);
35
@@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj)
32
+ return vfp_exceptbits_from_host(i);
36
t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* FEAT_PMULL */
33
+}
37
t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); /* FEAT_SHA1 */
34
+
38
t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* FEAT_SHA512 */
35
static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val)
39
- t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);
36
{
40
+ t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); /* FEAT_CRC32 */
37
int i;
41
t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); /* FEAT_LSE */
38
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
42
t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); /* FEAT_RDM */
39
| (env->vfp.vec_len << 16)
43
t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); /* FEAT_SHA3 */
40
| (env->vfp.vec_stride << 20);
41
42
- i = get_float_exception_flags(&env->vfp.fp_status);
43
- i |= get_float_exception_flags(&env->vfp.standard_fp_status);
44
- /* FZ16 does not generate an input denormal exception. */
45
- i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
46
- & ~float_flag_input_denormal);
47
- fpscr |= vfp_exceptbits_from_host(i);
48
+ fpscr |= vfp_get_fpscr_from_host(env);
49
50
i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3];
51
fpscr |= i ? FPCR_QC : 0;
52
--
44
--
53
2.20.1
45
2.34.1
54
46
55
47
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Jean-Christophe Dubois <jcd@tribudubois.net>
2
2
3
The vfp_set_fpscr() helper contains code specific to the host
3
i.MX7 IOMUX GPR device is not equivalent to i.MX6UL IOMUXC GPR device.
4
floating point implementation (here the SoftFloat library).
4
In particular, register 22 is not present on i.MX6UL and this is actualy
5
Extract this code to vfp_set_fpscr_to_host().
5
The only register that is really emulated in the i.MX7 IOMUX GPR device.
6
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Note: The i.MX6UL code is actually also implementing the IOMUX GPR device
8
Message-id: 20190701132516.26392-16-philmd@redhat.com
8
as an unimplemented device at the same bus adress and the 2 instantiations
9
were actualy colliding. So we go back to the unimplemented device for now.
10
11
Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
12
Message-id: 48681bf51ee97646479bb261bee19abebbc8074e.1692964892.git.jcd@tribudubois.net
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
15
---
12
target/arm/vfp_helper.c | 127 +++++++++++++++++++++-------------------
16
include/hw/arm/fsl-imx6ul.h | 2 --
13
1 file changed, 66 insertions(+), 61 deletions(-)
17
hw/arm/fsl-imx6ul.c | 11 -----------
18
2 files changed, 13 deletions(-)
14
19
15
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
20
diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h
16
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/vfp_helper.c
22
--- a/include/hw/arm/fsl-imx6ul.h
18
+++ b/target/arm/vfp_helper.c
23
+++ b/include/hw/arm/fsl-imx6ul.h
19
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits)
24
@@ -XXX,XX +XXX,XX @@
20
return host_bits;
25
#include "hw/misc/imx6ul_ccm.h"
21
}
26
#include "hw/misc/imx6_src.h"
22
27
#include "hw/misc/imx7_snvs.h"
23
-uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
28
-#include "hw/misc/imx7_gpr.h"
24
-{
29
#include "hw/intc/imx_gpcv2.h"
25
- uint32_t i, fpscr;
30
#include "hw/watchdog/wdt_imx2.h"
31
#include "hw/gpio/imx_gpio.h"
32
@@ -XXX,XX +XXX,XX @@ struct FslIMX6ULState {
33
IMX6SRCState src;
34
IMX7SNVSState snvs;
35
IMXGPCv2State gpcv2;
36
- IMX7GPRState gpr;
37
IMXSPIState spi[FSL_IMX6UL_NUM_ECSPIS];
38
IMXI2CState i2c[FSL_IMX6UL_NUM_I2CS];
39
IMXSerialState uart[FSL_IMX6UL_NUM_UARTS];
40
diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/arm/fsl-imx6ul.c
43
+++ b/hw/arm/fsl-imx6ul.c
44
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj)
45
*/
46
object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS);
47
48
- /*
49
- * GPR
50
- */
51
- object_initialize_child(obj, "gpr", &s->gpr, TYPE_IMX7_GPR);
26
-
52
-
27
- fpscr = env->vfp.xregs[ARM_VFP_FPSCR]
53
/*
28
- | (env->vfp.vec_len << 16)
54
* GPIOs 1 to 5
29
- | (env->vfp.vec_stride << 20);
55
*/
56
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
57
FSL_IMX6UL_WDOGn_IRQ[i]));
58
}
59
60
- /*
61
- * GPR
62
- */
63
- sysbus_realize(SYS_BUS_DEVICE(&s->gpr), &error_abort);
64
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX6UL_IOMUXC_GPR_ADDR);
30
-
65
-
31
- i = get_float_exception_flags(&env->vfp.fp_status);
66
/*
32
- i |= get_float_exception_flags(&env->vfp.standard_fp_status);
67
* SDMA
33
- /* FZ16 does not generate an input denormal exception. */
68
*/
34
- i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
35
- & ~float_flag_input_denormal);
36
- fpscr |= vfp_exceptbits_from_host(i);
37
-
38
- i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3];
39
- fpscr |= i ? FPCR_QC : 0;
40
-
41
- return fpscr;
42
-}
43
-
44
-uint32_t vfp_get_fpscr(CPUARMState *env)
45
-{
46
- return HELPER(vfp_get_fpscr)(env);
47
-}
48
-
49
-void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
50
+static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val)
51
{
52
int i;
53
uint32_t changed = env->vfp.xregs[ARM_VFP_FPSCR];
54
55
- /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */
56
- if (!cpu_isar_feature(aa64_fp16, env_archcpu(env))) {
57
- val &= ~FPCR_FZ16;
58
- }
59
-
60
- if (arm_feature(env, ARM_FEATURE_M)) {
61
- /*
62
- * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits
63
- * and also for the trapped-exception-handling bits IxE.
64
- */
65
- val &= 0xf7c0009f;
66
- }
67
-
68
- /*
69
- * We don't implement trapped exception handling, so the
70
- * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!)
71
- *
72
- * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC
73
- * (which are stored in fp_status), and the other RES0 bits
74
- * in between, then we clear all of the low 16 bits.
75
- */
76
- env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000;
77
- env->vfp.vec_len = (val >> 16) & 7;
78
- env->vfp.vec_stride = (val >> 20) & 3;
79
-
80
- /*
81
- * The bit we set within fpscr_q is arbitrary; the register as a
82
- * whole being zero/non-zero is what counts.
83
- */
84
- env->vfp.qc[0] = val & FPCR_QC;
85
- env->vfp.qc[1] = 0;
86
- env->vfp.qc[2] = 0;
87
- env->vfp.qc[3] = 0;
88
-
89
changed ^= val;
90
if (changed & (3 << 22)) {
91
i = (val >> 22) & 3;
92
@@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
93
set_float_exception_flags(0, &env->vfp.standard_fp_status);
94
}
95
96
+uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
97
+{
98
+ uint32_t i, fpscr;
99
+
100
+ fpscr = env->vfp.xregs[ARM_VFP_FPSCR]
101
+ | (env->vfp.vec_len << 16)
102
+ | (env->vfp.vec_stride << 20);
103
+
104
+ i = get_float_exception_flags(&env->vfp.fp_status);
105
+ i |= get_float_exception_flags(&env->vfp.standard_fp_status);
106
+ /* FZ16 does not generate an input denormal exception. */
107
+ i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
108
+ & ~float_flag_input_denormal);
109
+ fpscr |= vfp_exceptbits_from_host(i);
110
+
111
+ i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3];
112
+ fpscr |= i ? FPCR_QC : 0;
113
+
114
+ return fpscr;
115
+}
116
+
117
+uint32_t vfp_get_fpscr(CPUARMState *env)
118
+{
119
+ return HELPER(vfp_get_fpscr)(env);
120
+}
121
+
122
+void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
123
+{
124
+ /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */
125
+ if (!cpu_isar_feature(aa64_fp16, env_archcpu(env))) {
126
+ val &= ~FPCR_FZ16;
127
+ }
128
+
129
+ if (arm_feature(env, ARM_FEATURE_M)) {
130
+ /*
131
+ * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits
132
+ * and also for the trapped-exception-handling bits IxE.
133
+ */
134
+ val &= 0xf7c0009f;
135
+ }
136
+
137
+ /*
138
+ * We don't implement trapped exception handling, so the
139
+ * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!)
140
+ *
141
+ * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC
142
+ * (which are stored in fp_status), and the other RES0 bits
143
+ * in between, then we clear all of the low 16 bits.
144
+ */
145
+ env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000;
146
+ env->vfp.vec_len = (val >> 16) & 7;
147
+ env->vfp.vec_stride = (val >> 20) & 3;
148
+
149
+ /*
150
+ * The bit we set within fpscr_q is arbitrary; the register as a
151
+ * whole being zero/non-zero is what counts.
152
+ */
153
+ env->vfp.qc[0] = val & FPCR_QC;
154
+ env->vfp.qc[1] = 0;
155
+ env->vfp.qc[2] = 0;
156
+ env->vfp.qc[3] = 0;
157
+
158
+ vfp_set_fpscr_to_host(env, val);
159
+}
160
+
161
void vfp_set_fpscr(CPUARMState *env, uint32_t val)
162
{
163
HELPER(vfp_set_fpscr)(env, val);
164
--
69
--
165
2.20.1
70
2.34.1
166
167
diff view generated by jsdifflib
1
From: Jan Kiszka <jan.kiszka@siemens.com>
1
From: Jean-Christophe Dubois <jcd@tribudubois.net>
2
2
3
Allow cortex-a7 to be used with the virt board; it supports
3
* Add Addr and size definition for most i.MX6UL devices in i.MX6UL header file.
4
the v7VE features and there is no reason to deny this type.
4
* Use those newly defined named constants whenever possible.
5
* Standardize the way we init a familly of unimplemented devices
6
- SAI
7
- PWM
8
- CAN
9
* Add/rework few comments
5
10
6
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
11
Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Message-id: d579043fbd4e4b490370783fda43fc02c8e9be75.1692964892.git.jcd@tribudubois.net
8
Message-id: fc5404f7-4d1d-c28f-6e48-d8799c82acc0@web.de
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
15
---
12
hw/arm/virt.c | 1 +
16
include/hw/arm/fsl-imx6ul.h | 156 +++++++++++++++++++++++++++++++-----
13
1 file changed, 1 insertion(+)
17
hw/arm/fsl-imx6ul.c | 147 ++++++++++++++++++++++-----------
18
2 files changed, 232 insertions(+), 71 deletions(-)
14
19
15
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
20
diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h
16
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/virt.c
22
--- a/include/hw/arm/fsl-imx6ul.h
18
+++ b/hw/arm/virt.c
23
+++ b/include/hw/arm/fsl-imx6ul.h
19
@@ -XXX,XX +XXX,XX @@ static const int a15irqmap[] = {
24
@@ -XXX,XX +XXX,XX @@
25
#include "exec/memory.h"
26
#include "cpu.h"
27
#include "qom/object.h"
28
+#include "qemu/units.h"
29
30
#define TYPE_FSL_IMX6UL "fsl-imx6ul"
31
OBJECT_DECLARE_SIMPLE_TYPE(FslIMX6ULState, FSL_IMX6UL)
32
@@ -XXX,XX +XXX,XX @@ enum FslIMX6ULConfiguration {
33
FSL_IMX6UL_NUM_ADCS = 2,
34
FSL_IMX6UL_NUM_USB_PHYS = 2,
35
FSL_IMX6UL_NUM_USBS = 2,
36
+ FSL_IMX6UL_NUM_SAIS = 3,
37
+ FSL_IMX6UL_NUM_CANS = 2,
38
+ FSL_IMX6UL_NUM_PWMS = 4,
20
};
39
};
21
40
22
static const char *valid_cpus[] = {
41
struct FslIMX6ULState {
23
+ ARM_CPU_TYPE_NAME("cortex-a7"),
42
@@ -XXX,XX +XXX,XX @@ struct FslIMX6ULState {
24
ARM_CPU_TYPE_NAME("cortex-a15"),
43
25
ARM_CPU_TYPE_NAME("cortex-a53"),
44
enum FslIMX6ULMemoryMap {
26
ARM_CPU_TYPE_NAME("cortex-a57"),
45
FSL_IMX6UL_MMDC_ADDR = 0x80000000,
46
- FSL_IMX6UL_MMDC_SIZE = 2 * 1024 * 1024 * 1024UL,
47
+ FSL_IMX6UL_MMDC_SIZE = (2 * GiB),
48
49
FSL_IMX6UL_QSPI1_MEM_ADDR = 0x60000000,
50
- FSL_IMX6UL_EIM_ALIAS_ADDR = 0x58000000,
51
- FSL_IMX6UL_EIM_CS_ADDR = 0x50000000,
52
- FSL_IMX6UL_AES_ENCRYPT_ADDR = 0x10000000,
53
- FSL_IMX6UL_QSPI1_RX_ADDR = 0x0C000000,
54
+ FSL_IMX6UL_QSPI1_MEM_SIZE = (256 * MiB),
55
56
- /* AIPS-2 */
57
+ FSL_IMX6UL_EIM_ALIAS_ADDR = 0x58000000,
58
+ FSL_IMX6UL_EIM_ALIAS_SIZE = (128 * MiB),
59
+
60
+ FSL_IMX6UL_EIM_CS_ADDR = 0x50000000,
61
+ FSL_IMX6UL_EIM_CS_SIZE = (128 * MiB),
62
+
63
+ FSL_IMX6UL_AES_ENCRYPT_ADDR = 0x10000000,
64
+ FSL_IMX6UL_AES_ENCRYPT_SIZE = (1 * MiB),
65
+
66
+ FSL_IMX6UL_QSPI1_RX_ADDR = 0x0C000000,
67
+ FSL_IMX6UL_QSPI1_RX_SIZE = (32 * MiB),
68
+
69
+ /* AIPS-2 Begin */
70
FSL_IMX6UL_UART6_ADDR = 0x021FC000,
71
+
72
FSL_IMX6UL_I2C4_ADDR = 0x021F8000,
73
+
74
FSL_IMX6UL_UART5_ADDR = 0x021F4000,
75
FSL_IMX6UL_UART4_ADDR = 0x021F0000,
76
FSL_IMX6UL_UART3_ADDR = 0x021EC000,
77
FSL_IMX6UL_UART2_ADDR = 0x021E8000,
78
+
79
FSL_IMX6UL_WDOG3_ADDR = 0x021E4000,
80
+
81
FSL_IMX6UL_QSPI_ADDR = 0x021E0000,
82
+ FSL_IMX6UL_QSPI_SIZE = 0x500,
83
+
84
FSL_IMX6UL_SYS_CNT_CTRL_ADDR = 0x021DC000,
85
+ FSL_IMX6UL_SYS_CNT_CTRL_SIZE = (16 * KiB),
86
+
87
FSL_IMX6UL_SYS_CNT_CMP_ADDR = 0x021D8000,
88
+ FSL_IMX6UL_SYS_CNT_CMP_SIZE = (16 * KiB),
89
+
90
FSL_IMX6UL_SYS_CNT_RD_ADDR = 0x021D4000,
91
+ FSL_IMX6UL_SYS_CNT_RD_SIZE = (16 * KiB),
92
+
93
FSL_IMX6UL_TZASC_ADDR = 0x021D0000,
94
+ FSL_IMX6UL_TZASC_SIZE = (16 * KiB),
95
+
96
FSL_IMX6UL_PXP_ADDR = 0x021CC000,
97
+ FSL_IMX6UL_PXP_SIZE = (16 * KiB),
98
+
99
FSL_IMX6UL_LCDIF_ADDR = 0x021C8000,
100
+ FSL_IMX6UL_LCDIF_SIZE = 0x100,
101
+
102
FSL_IMX6UL_CSI_ADDR = 0x021C4000,
103
+ FSL_IMX6UL_CSI_SIZE = 0x100,
104
+
105
FSL_IMX6UL_CSU_ADDR = 0x021C0000,
106
+ FSL_IMX6UL_CSU_SIZE = (16 * KiB),
107
+
108
FSL_IMX6UL_OCOTP_CTRL_ADDR = 0x021BC000,
109
+ FSL_IMX6UL_OCOTP_CTRL_SIZE = (4 * KiB),
110
+
111
FSL_IMX6UL_EIM_ADDR = 0x021B8000,
112
+ FSL_IMX6UL_EIM_SIZE = 0x100,
113
+
114
FSL_IMX6UL_SIM2_ADDR = 0x021B4000,
115
+
116
FSL_IMX6UL_MMDC_CFG_ADDR = 0x021B0000,
117
+ FSL_IMX6UL_MMDC_CFG_SIZE = (4 * KiB),
118
+
119
FSL_IMX6UL_ROMCP_ADDR = 0x021AC000,
120
+ FSL_IMX6UL_ROMCP_SIZE = 0x300,
121
+
122
FSL_IMX6UL_I2C3_ADDR = 0x021A8000,
123
FSL_IMX6UL_I2C2_ADDR = 0x021A4000,
124
FSL_IMX6UL_I2C1_ADDR = 0x021A0000,
125
+
126
FSL_IMX6UL_ADC2_ADDR = 0x0219C000,
127
FSL_IMX6UL_ADC1_ADDR = 0x02198000,
128
+ FSL_IMX6UL_ADCn_SIZE = 0x100,
129
+
130
FSL_IMX6UL_USDHC2_ADDR = 0x02194000,
131
FSL_IMX6UL_USDHC1_ADDR = 0x02190000,
132
- FSL_IMX6UL_SIM1_ADDR = 0x0218C000,
133
- FSL_IMX6UL_ENET1_ADDR = 0x02188000,
134
- FSL_IMX6UL_USBO2_USBMISC_ADDR = 0x02184800,
135
- FSL_IMX6UL_USBO2_USB_ADDR = 0x02184000,
136
- FSL_IMX6UL_USBO2_PL301_ADDR = 0x02180000,
137
- FSL_IMX6UL_AIPS2_CFG_ADDR = 0x0217C000,
138
- FSL_IMX6UL_CAAM_ADDR = 0x02140000,
139
- FSL_IMX6UL_A7MPCORE_DAP_ADDR = 0x02100000,
140
141
- /* AIPS-1 */
142
+ FSL_IMX6UL_SIM1_ADDR = 0x0218C000,
143
+ FSL_IMX6UL_SIMn_SIZE = (16 * KiB),
144
+
145
+ FSL_IMX6UL_ENET1_ADDR = 0x02188000,
146
+
147
+ FSL_IMX6UL_USBO2_USBMISC_ADDR = 0x02184800,
148
+ FSL_IMX6UL_USBO2_USB1_ADDR = 0x02184000,
149
+ FSL_IMX6UL_USBO2_USB2_ADDR = 0x02184200,
150
+
151
+ FSL_IMX6UL_USBO2_PL301_ADDR = 0x02180000,
152
+ FSL_IMX6UL_USBO2_PL301_SIZE = (16 * KiB),
153
+
154
+ FSL_IMX6UL_AIPS2_CFG_ADDR = 0x0217C000,
155
+ FSL_IMX6UL_AIPS2_CFG_SIZE = 0x100,
156
+
157
+ FSL_IMX6UL_CAAM_ADDR = 0x02140000,
158
+ FSL_IMX6UL_CAAM_SIZE = (16 * KiB),
159
+
160
+ FSL_IMX6UL_A7MPCORE_DAP_ADDR = 0x02100000,
161
+ FSL_IMX6UL_A7MPCORE_DAP_SIZE = (4 * KiB),
162
+ /* AIPS-2 End */
163
+
164
+ /* AIPS-1 Begin */
165
FSL_IMX6UL_PWM8_ADDR = 0x020FC000,
166
FSL_IMX6UL_PWM7_ADDR = 0x020F8000,
167
FSL_IMX6UL_PWM6_ADDR = 0x020F4000,
168
FSL_IMX6UL_PWM5_ADDR = 0x020F0000,
169
+
170
FSL_IMX6UL_SDMA_ADDR = 0x020EC000,
171
+ FSL_IMX6UL_SDMA_SIZE = 0x300,
172
+
173
FSL_IMX6UL_GPT2_ADDR = 0x020E8000,
174
+
175
FSL_IMX6UL_IOMUXC_GPR_ADDR = 0x020E4000,
176
+ FSL_IMX6UL_IOMUXC_GPR_SIZE = 0x40,
177
+
178
FSL_IMX6UL_IOMUXC_ADDR = 0x020E0000,
179
+ FSL_IMX6UL_IOMUXC_SIZE = 0x700,
180
+
181
FSL_IMX6UL_GPC_ADDR = 0x020DC000,
182
+
183
FSL_IMX6UL_SRC_ADDR = 0x020D8000,
184
+
185
FSL_IMX6UL_EPIT2_ADDR = 0x020D4000,
186
FSL_IMX6UL_EPIT1_ADDR = 0x020D0000,
187
+
188
FSL_IMX6UL_SNVS_HP_ADDR = 0x020CC000,
189
+
190
FSL_IMX6UL_USBPHY2_ADDR = 0x020CA000,
191
- FSL_IMX6UL_USBPHY2_SIZE = (4 * 1024),
192
FSL_IMX6UL_USBPHY1_ADDR = 0x020C9000,
193
- FSL_IMX6UL_USBPHY1_SIZE = (4 * 1024),
194
+
195
FSL_IMX6UL_ANALOG_ADDR = 0x020C8000,
196
+ FSL_IMX6UL_ANALOG_SIZE = 0x300,
197
+
198
FSL_IMX6UL_CCM_ADDR = 0x020C4000,
199
+
200
FSL_IMX6UL_WDOG2_ADDR = 0x020C0000,
201
FSL_IMX6UL_WDOG1_ADDR = 0x020BC000,
202
+
203
FSL_IMX6UL_KPP_ADDR = 0x020B8000,
204
+ FSL_IMX6UL_KPP_SIZE = 0x10,
205
+
206
FSL_IMX6UL_ENET2_ADDR = 0x020B4000,
207
+
208
FSL_IMX6UL_SNVS_LP_ADDR = 0x020B0000,
209
+ FSL_IMX6UL_SNVS_LP_SIZE = (16 * KiB),
210
+
211
FSL_IMX6UL_GPIO5_ADDR = 0x020AC000,
212
FSL_IMX6UL_GPIO4_ADDR = 0x020A8000,
213
FSL_IMX6UL_GPIO3_ADDR = 0x020A4000,
214
FSL_IMX6UL_GPIO2_ADDR = 0x020A0000,
215
FSL_IMX6UL_GPIO1_ADDR = 0x0209C000,
216
+
217
FSL_IMX6UL_GPT1_ADDR = 0x02098000,
218
+
219
FSL_IMX6UL_CAN2_ADDR = 0x02094000,
220
FSL_IMX6UL_CAN1_ADDR = 0x02090000,
221
+ FSL_IMX6UL_CANn_SIZE = (4 * KiB),
222
+
223
FSL_IMX6UL_PWM4_ADDR = 0x0208C000,
224
FSL_IMX6UL_PWM3_ADDR = 0x02088000,
225
FSL_IMX6UL_PWM2_ADDR = 0x02084000,
226
FSL_IMX6UL_PWM1_ADDR = 0x02080000,
227
+ FSL_IMX6UL_PWMn_SIZE = 0x20,
228
+
229
FSL_IMX6UL_AIPS1_CFG_ADDR = 0x0207C000,
230
+ FSL_IMX6UL_AIPS1_CFG_SIZE = (16 * KiB),
231
+
232
FSL_IMX6UL_BEE_ADDR = 0x02044000,
233
+ FSL_IMX6UL_BEE_SIZE = (16 * KiB),
234
+
235
FSL_IMX6UL_TOUCH_CTRL_ADDR = 0x02040000,
236
+ FSL_IMX6UL_TOUCH_CTRL_SIZE = 0x100,
237
+
238
FSL_IMX6UL_SPBA_ADDR = 0x0203C000,
239
+ FSL_IMX6UL_SPBA_SIZE = 0x100,
240
+
241
FSL_IMX6UL_ASRC_ADDR = 0x02034000,
242
+ FSL_IMX6UL_ASRC_SIZE = 0x100,
243
+
244
FSL_IMX6UL_SAI3_ADDR = 0x02030000,
245
FSL_IMX6UL_SAI2_ADDR = 0x0202C000,
246
FSL_IMX6UL_SAI1_ADDR = 0x02028000,
247
+ FSL_IMX6UL_SAIn_SIZE = 0x200,
248
+
249
FSL_IMX6UL_UART8_ADDR = 0x02024000,
250
FSL_IMX6UL_UART1_ADDR = 0x02020000,
251
FSL_IMX6UL_UART7_ADDR = 0x02018000,
252
+
253
FSL_IMX6UL_ECSPI4_ADDR = 0x02014000,
254
FSL_IMX6UL_ECSPI3_ADDR = 0x02010000,
255
FSL_IMX6UL_ECSPI2_ADDR = 0x0200C000,
256
FSL_IMX6UL_ECSPI1_ADDR = 0x02008000,
257
+
258
FSL_IMX6UL_SPDIF_ADDR = 0x02004000,
259
+ FSL_IMX6UL_SPDIF_SIZE = 0x100,
260
+ /* AIPS-1 End */
261
+
262
+ FSL_IMX6UL_BCH_ADDR = 0x01808000,
263
+ FSL_IMX6UL_BCH_SIZE = 0x200,
264
+
265
+ FSL_IMX6UL_GPMI_ADDR = 0x01806000,
266
+ FSL_IMX6UL_GPMI_SIZE = 0x200,
267
268
FSL_IMX6UL_APBH_DMA_ADDR = 0x01804000,
269
- FSL_IMX6UL_APBH_DMA_SIZE = (32 * 1024),
270
+ FSL_IMX6UL_APBH_DMA_SIZE = (4 * KiB),
271
272
FSL_IMX6UL_A7MPCORE_ADDR = 0x00A00000,
273
274
FSL_IMX6UL_OCRAM_ALIAS_ADDR = 0x00920000,
275
- FSL_IMX6UL_OCRAM_ALIAS_SIZE = 0x00060000,
276
+ FSL_IMX6UL_OCRAM_ALIAS_SIZE = (384 * KiB),
277
+
278
FSL_IMX6UL_OCRAM_MEM_ADDR = 0x00900000,
279
- FSL_IMX6UL_OCRAM_MEM_SIZE = 0x00020000,
280
+ FSL_IMX6UL_OCRAM_MEM_SIZE = (128 * KiB),
281
+
282
FSL_IMX6UL_CAAM_MEM_ADDR = 0x00100000,
283
- FSL_IMX6UL_CAAM_MEM_SIZE = 0x00008000,
284
+ FSL_IMX6UL_CAAM_MEM_SIZE = (32 * KiB),
285
+
286
FSL_IMX6UL_ROM_ADDR = 0x00000000,
287
- FSL_IMX6UL_ROM_SIZE = 0x00018000,
288
+ FSL_IMX6UL_ROM_SIZE = (96 * KiB),
289
};
290
291
enum FslIMX6ULIRQs {
292
diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c
293
index XXXXXXX..XXXXXXX 100644
294
--- a/hw/arm/fsl-imx6ul.c
295
+++ b/hw/arm/fsl-imx6ul.c
296
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj)
297
object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS);
298
299
/*
300
- * GPIOs 1 to 5
301
+ * GPIOs
302
*/
303
for (i = 0; i < FSL_IMX6UL_NUM_GPIOS; i++) {
304
snprintf(name, NAME_SIZE, "gpio%d", i);
305
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj)
306
}
307
308
/*
309
- * GPT 1, 2
310
+ * GPTs
311
*/
312
for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) {
313
snprintf(name, NAME_SIZE, "gpt%d", i);
314
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj)
315
}
316
317
/*
318
- * EPIT 1, 2
319
+ * EPITs
320
*/
321
for (i = 0; i < FSL_IMX6UL_NUM_EPITS; i++) {
322
snprintf(name, NAME_SIZE, "epit%d", i + 1);
323
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj)
324
}
325
326
/*
327
- * eCSPI
328
+ * eCSPIs
329
*/
330
for (i = 0; i < FSL_IMX6UL_NUM_ECSPIS; i++) {
331
snprintf(name, NAME_SIZE, "spi%d", i + 1);
332
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj)
333
}
334
335
/*
336
- * I2C
337
+ * I2Cs
338
*/
339
for (i = 0; i < FSL_IMX6UL_NUM_I2CS; i++) {
340
snprintf(name, NAME_SIZE, "i2c%d", i + 1);
341
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj)
342
}
343
344
/*
345
- * UART
346
+ * UARTs
347
*/
348
for (i = 0; i < FSL_IMX6UL_NUM_UARTS; i++) {
349
snprintf(name, NAME_SIZE, "uart%d", i);
350
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj)
351
}
352
353
/*
354
- * Ethernet
355
+ * Ethernets
356
*/
357
for (i = 0; i < FSL_IMX6UL_NUM_ETHS; i++) {
358
snprintf(name, NAME_SIZE, "eth%d", i);
359
object_initialize_child(obj, name, &s->eth[i], TYPE_IMX_ENET);
360
}
361
362
- /* USB */
363
+ /*
364
+ * USB PHYs
365
+ */
366
for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) {
367
snprintf(name, NAME_SIZE, "usbphy%d", i);
368
object_initialize_child(obj, name, &s->usbphy[i], TYPE_IMX_USBPHY);
369
}
370
+
371
+ /*
372
+ * USBs
373
+ */
374
for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) {
375
snprintf(name, NAME_SIZE, "usb%d", i);
376
object_initialize_child(obj, name, &s->usb[i], TYPE_CHIPIDEA);
377
}
378
379
/*
380
- * SDHCI
381
+ * SDHCIs
382
*/
383
for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) {
384
snprintf(name, NAME_SIZE, "usdhc%d", i);
385
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj)
386
}
387
388
/*
389
- * Watchdog
390
+ * Watchdogs
391
*/
392
for (i = 0; i < FSL_IMX6UL_NUM_WDTS; i++) {
393
snprintf(name, NAME_SIZE, "wdt%d", i);
394
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
395
* A7MPCORE DAP
396
*/
397
create_unimplemented_device("a7mpcore-dap", FSL_IMX6UL_A7MPCORE_DAP_ADDR,
398
- 0x100000);
399
+ FSL_IMX6UL_A7MPCORE_DAP_SIZE);
400
401
/*
402
- * GPT 1, 2
403
+ * GPTs
404
*/
405
for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) {
406
static const hwaddr FSL_IMX6UL_GPTn_ADDR[FSL_IMX6UL_NUM_GPTS] = {
407
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
408
}
409
410
/*
411
- * EPIT 1, 2
412
+ * EPITs
413
*/
414
for (i = 0; i < FSL_IMX6UL_NUM_EPITS; i++) {
415
static const hwaddr FSL_IMX6UL_EPITn_ADDR[FSL_IMX6UL_NUM_EPITS] = {
416
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
417
}
418
419
/*
420
- * GPIO
421
+ * GPIOs
422
*/
423
for (i = 0; i < FSL_IMX6UL_NUM_GPIOS; i++) {
424
static const hwaddr FSL_IMX6UL_GPIOn_ADDR[FSL_IMX6UL_NUM_GPIOS] = {
425
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
426
}
427
428
/*
429
- * IOMUXC and IOMUXC_GPR
430
+ * IOMUXC
431
*/
432
- for (i = 0; i < 1; i++) {
433
- static const hwaddr FSL_IMX6UL_IOMUXCn_ADDR[FSL_IMX6UL_NUM_IOMUXCS] = {
434
- FSL_IMX6UL_IOMUXC_ADDR,
435
- FSL_IMX6UL_IOMUXC_GPR_ADDR,
436
- };
437
-
438
- snprintf(name, NAME_SIZE, "iomuxc%d", i);
439
- create_unimplemented_device(name, FSL_IMX6UL_IOMUXCn_ADDR[i], 0x4000);
440
- }
441
+ create_unimplemented_device("iomuxc", FSL_IMX6UL_IOMUXC_ADDR,
442
+ FSL_IMX6UL_IOMUXC_SIZE);
443
+ create_unimplemented_device("iomuxc_gpr", FSL_IMX6UL_IOMUXC_GPR_ADDR,
444
+ FSL_IMX6UL_IOMUXC_GPR_SIZE);
445
446
/*
447
* CCM
448
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
449
sysbus_realize(SYS_BUS_DEVICE(&s->gpcv2), &error_abort);
450
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpcv2), 0, FSL_IMX6UL_GPC_ADDR);
451
452
- /* Initialize all ECSPI */
453
+ /*
454
+ * ECSPIs
455
+ */
456
for (i = 0; i < FSL_IMX6UL_NUM_ECSPIS; i++) {
457
static const hwaddr FSL_IMX6UL_SPIn_ADDR[FSL_IMX6UL_NUM_ECSPIS] = {
458
FSL_IMX6UL_ECSPI1_ADDR,
459
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
460
}
461
462
/*
463
- * I2C
464
+ * I2Cs
465
*/
466
for (i = 0; i < FSL_IMX6UL_NUM_I2CS; i++) {
467
static const hwaddr FSL_IMX6UL_I2Cn_ADDR[FSL_IMX6UL_NUM_I2CS] = {
468
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
469
}
470
471
/*
472
- * UART
473
+ * UARTs
474
*/
475
for (i = 0; i < FSL_IMX6UL_NUM_UARTS; i++) {
476
static const hwaddr FSL_IMX6UL_UARTn_ADDR[FSL_IMX6UL_NUM_UARTS] = {
477
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
478
}
479
480
/*
481
- * Ethernet
482
+ * Ethernets
483
*
484
* We must use two loops since phy_connected affects the other interface
485
* and we have to set all properties before calling sysbus_realize().
486
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
487
FSL_IMX6UL_ENETn_TIMER_IRQ[i]));
488
}
489
490
- /* USB */
491
+ /*
492
+ * USB PHYs
493
+ */
494
for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) {
495
+ static const hwaddr
496
+ FSL_IMX6UL_USB_PHYn_ADDR[FSL_IMX6UL_NUM_USB_PHYS] = {
497
+ FSL_IMX6UL_USBPHY1_ADDR,
498
+ FSL_IMX6UL_USBPHY2_ADDR,
499
+ };
500
+
501
sysbus_realize(SYS_BUS_DEVICE(&s->usbphy[i]), &error_abort);
502
sysbus_mmio_map(SYS_BUS_DEVICE(&s->usbphy[i]), 0,
503
- FSL_IMX6UL_USBPHY1_ADDR + i * 0x1000);
504
+ FSL_IMX6UL_USB_PHYn_ADDR[i]);
505
}
506
507
+ /*
508
+ * USBs
509
+ */
510
for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) {
511
+ static const hwaddr FSL_IMX6UL_USB02_USBn_ADDR[FSL_IMX6UL_NUM_USBS] = {
512
+ FSL_IMX6UL_USBO2_USB1_ADDR,
513
+ FSL_IMX6UL_USBO2_USB2_ADDR,
514
+ };
515
+
516
static const int FSL_IMX6UL_USBn_IRQ[] = {
517
FSL_IMX6UL_USB1_IRQ,
518
FSL_IMX6UL_USB2_IRQ,
519
};
520
+
521
sysbus_realize(SYS_BUS_DEVICE(&s->usb[i]), &error_abort);
522
sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0,
523
- FSL_IMX6UL_USBO2_USB_ADDR + i * 0x200);
524
+ FSL_IMX6UL_USB02_USBn_ADDR[i]);
525
sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0,
526
qdev_get_gpio_in(DEVICE(&s->a7mpcore),
527
FSL_IMX6UL_USBn_IRQ[i]));
528
}
529
530
/*
531
- * USDHC
532
+ * USDHCs
533
*/
534
for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) {
535
static const hwaddr FSL_IMX6UL_USDHCn_ADDR[FSL_IMX6UL_NUM_USDHCS] = {
536
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
537
sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX6UL_SNVS_HP_ADDR);
538
539
/*
540
- * Watchdog
541
+ * Watchdogs
542
*/
543
for (i = 0; i < FSL_IMX6UL_NUM_WDTS; i++) {
544
static const hwaddr FSL_IMX6UL_WDOGn_ADDR[FSL_IMX6UL_NUM_WDTS] = {
545
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
546
FSL_IMX6UL_WDOG2_ADDR,
547
FSL_IMX6UL_WDOG3_ADDR,
548
};
549
+
550
static const int FSL_IMX6UL_WDOGn_IRQ[FSL_IMX6UL_NUM_WDTS] = {
551
FSL_IMX6UL_WDOG1_IRQ,
552
FSL_IMX6UL_WDOG2_IRQ,
553
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
554
/*
555
* SDMA
556
*/
557
- create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, 0x4000);
558
+ create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR,
559
+ FSL_IMX6UL_SDMA_SIZE);
560
561
/*
562
- * SAI (Audio SSI (Synchronous Serial Interface))
563
+ * SAIs (Audio SSI (Synchronous Serial Interface))
564
*/
565
- create_unimplemented_device("sai1", FSL_IMX6UL_SAI1_ADDR, 0x4000);
566
- create_unimplemented_device("sai2", FSL_IMX6UL_SAI2_ADDR, 0x4000);
567
- create_unimplemented_device("sai3", FSL_IMX6UL_SAI3_ADDR, 0x4000);
568
+ for (i = 0; i < FSL_IMX6UL_NUM_SAIS; i++) {
569
+ static const hwaddr FSL_IMX6UL_SAIn_ADDR[FSL_IMX6UL_NUM_SAIS] = {
570
+ FSL_IMX6UL_SAI1_ADDR,
571
+ FSL_IMX6UL_SAI2_ADDR,
572
+ FSL_IMX6UL_SAI3_ADDR,
573
+ };
574
+
575
+ snprintf(name, NAME_SIZE, "sai%d", i);
576
+ create_unimplemented_device(name, FSL_IMX6UL_SAIn_ADDR[i],
577
+ FSL_IMX6UL_SAIn_SIZE);
578
+ }
579
580
/*
581
- * PWM
582
+ * PWMs
583
*/
584
- create_unimplemented_device("pwm1", FSL_IMX6UL_PWM1_ADDR, 0x4000);
585
- create_unimplemented_device("pwm2", FSL_IMX6UL_PWM2_ADDR, 0x4000);
586
- create_unimplemented_device("pwm3", FSL_IMX6UL_PWM3_ADDR, 0x4000);
587
- create_unimplemented_device("pwm4", FSL_IMX6UL_PWM4_ADDR, 0x4000);
588
+ for (i = 0; i < FSL_IMX6UL_NUM_PWMS; i++) {
589
+ static const hwaddr FSL_IMX6UL_PWMn_ADDR[FSL_IMX6UL_NUM_PWMS] = {
590
+ FSL_IMX6UL_PWM1_ADDR,
591
+ FSL_IMX6UL_PWM2_ADDR,
592
+ FSL_IMX6UL_PWM3_ADDR,
593
+ FSL_IMX6UL_PWM4_ADDR,
594
+ };
595
+
596
+ snprintf(name, NAME_SIZE, "pwm%d", i);
597
+ create_unimplemented_device(name, FSL_IMX6UL_PWMn_ADDR[i],
598
+ FSL_IMX6UL_PWMn_SIZE);
599
+ }
600
601
/*
602
* Audio ASRC (asynchronous sample rate converter)
603
*/
604
- create_unimplemented_device("asrc", FSL_IMX6UL_ASRC_ADDR, 0x4000);
605
+ create_unimplemented_device("asrc", FSL_IMX6UL_ASRC_ADDR,
606
+ FSL_IMX6UL_ASRC_SIZE);
607
608
/*
609
- * CAN
610
+ * CANs
611
*/
612
- create_unimplemented_device("can1", FSL_IMX6UL_CAN1_ADDR, 0x4000);
613
- create_unimplemented_device("can2", FSL_IMX6UL_CAN2_ADDR, 0x4000);
614
+ for (i = 0; i < FSL_IMX6UL_NUM_CANS; i++) {
615
+ static const hwaddr FSL_IMX6UL_CANn_ADDR[FSL_IMX6UL_NUM_CANS] = {
616
+ FSL_IMX6UL_CAN1_ADDR,
617
+ FSL_IMX6UL_CAN2_ADDR,
618
+ };
619
+
620
+ snprintf(name, NAME_SIZE, "can%d", i);
621
+ create_unimplemented_device(name, FSL_IMX6UL_CANn_ADDR[i],
622
+ FSL_IMX6UL_CANn_SIZE);
623
+ }
624
625
/*
626
* APHB_DMA
627
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
628
};
629
630
snprintf(name, NAME_SIZE, "adc%d", i);
631
- create_unimplemented_device(name, FSL_IMX6UL_ADCn_ADDR[i], 0x4000);
632
+ create_unimplemented_device(name, FSL_IMX6UL_ADCn_ADDR[i],
633
+ FSL_IMX6UL_ADCn_SIZE);
634
}
635
636
/*
637
* LCD
638
*/
639
- create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR, 0x4000);
640
+ create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR,
641
+ FSL_IMX6UL_LCDIF_SIZE);
642
643
/*
644
* ROM memory
27
--
645
--
28
2.20.1
646
2.34.1
29
30
diff view generated by jsdifflib
1
From: Hongbo Zhang <hongbo.zhang@linaro.org>
1
From: Jean-Christophe Dubois <jcd@tribudubois.net>
2
2
3
Following the previous patch, this patch adds peripheral devices to the
3
* Add TZASC as unimplemented device.
4
newly introduced SBSA-ref machine.
4
- Allow bare metal application to access this (unimplemented) device
5
* Add CSU as unimplemented device.
6
- Allow bare metal application to access this (unimplemented) device
7
* Add 4 missing PWM devices
5
8
6
Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
9
Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
7
Message-id: 1561890034-15921-3-git-send-email-hongbo.zhang@linaro.org
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 59e4dc56e14eccfefd379275ec19048dff9c10b3.1692964892.git.jcd@tribudubois.net
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
13
---
11
hw/arm/sbsa-ref.c | 535 ++++++++++++++++++++++++++++++++++++++++++++++
14
include/hw/arm/fsl-imx6ul.h | 2 +-
12
1 file changed, 535 insertions(+)
15
hw/arm/fsl-imx6ul.c | 16 ++++++++++++++++
16
2 files changed, 17 insertions(+), 1 deletion(-)
13
17
14
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
18
diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h
15
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/sbsa-ref.c
20
--- a/include/hw/arm/fsl-imx6ul.h
17
+++ b/hw/arm/sbsa-ref.c
21
+++ b/include/hw/arm/fsl-imx6ul.h
18
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@ enum FslIMX6ULConfiguration {
19
*/
23
FSL_IMX6UL_NUM_USBS = 2,
20
24
FSL_IMX6UL_NUM_SAIS = 3,
21
#include "qemu/osdep.h"
25
FSL_IMX6UL_NUM_CANS = 2,
22
+#include "qemu-common.h"
26
- FSL_IMX6UL_NUM_PWMS = 4,
23
#include "qapi/error.h"
27
+ FSL_IMX6UL_NUM_PWMS = 8,
24
#include "qemu/error-report.h"
25
#include "qemu/units.h"
26
+#include "sysemu/device_tree.h"
27
#include "sysemu/numa.h"
28
#include "sysemu/sysemu.h"
29
#include "exec/address-spaces.h"
30
#include "exec/hwaddr.h"
31
#include "kvm_arm.h"
32
#include "hw/arm/boot.h"
33
+#include "hw/block/flash.h"
34
#include "hw/boards.h"
35
+#include "hw/ide/internal.h"
36
+#include "hw/ide/ahci_internal.h"
37
#include "hw/intc/arm_gicv3_common.h"
38
+#include "hw/loader.h"
39
+#include "hw/pci-host/gpex.h"
40
+#include "hw/usb.h"
41
+#include "net/net.h"
42
43
#define RAMLIMIT_GB 8192
44
#define RAMLIMIT_BYTES (RAMLIMIT_GB * GiB)
45
46
+#define NUM_IRQS 256
47
+#define NUM_SMMU_IRQS 4
48
+#define NUM_SATA_PORTS 6
49
+
50
+#define VIRTUAL_PMU_IRQ 7
51
+#define ARCH_GIC_MAINT_IRQ 9
52
+#define ARCH_TIMER_VIRT_IRQ 11
53
+#define ARCH_TIMER_S_EL1_IRQ 13
54
+#define ARCH_TIMER_NS_EL1_IRQ 14
55
+#define ARCH_TIMER_NS_EL2_IRQ 10
56
+
57
enum {
58
SBSA_FLASH,
59
SBSA_MEM,
60
@@ -XXX,XX +XXX,XX @@ typedef struct {
61
void *fdt;
62
int fdt_size;
63
int psci_conduit;
64
+ PFlashCFI01 *flash[2];
65
} SBSAMachineState;
66
67
#define TYPE_SBSA_MACHINE MACHINE_TYPE_NAME("sbsa-ref")
68
@@ -XXX,XX +XXX,XX @@ static const MemMapEntry sbsa_ref_memmap[] = {
69
[SBSA_MEM] = { 0x10000000000ULL, RAMLIMIT_BYTES },
70
};
28
};
71
29
72
+static const int sbsa_ref_irqmap[] = {
30
struct FslIMX6ULState {
73
+ [SBSA_UART] = 1,
31
diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c
74
+ [SBSA_RTC] = 2,
32
index XXXXXXX..XXXXXXX 100644
75
+ [SBSA_PCIE] = 3, /* ... to 6 */
33
--- a/hw/arm/fsl-imx6ul.c
76
+ [SBSA_GPIO] = 7,
34
+++ b/hw/arm/fsl-imx6ul.c
77
+ [SBSA_SECURE_UART] = 8,
35
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
78
+ [SBSA_SECURE_UART_MM] = 9,
36
FSL_IMX6UL_PWM2_ADDR,
79
+ [SBSA_AHCI] = 10,
37
FSL_IMX6UL_PWM3_ADDR,
80
+ [SBSA_EHCI] = 11,
38
FSL_IMX6UL_PWM4_ADDR,
81
+};
39
+ FSL_IMX6UL_PWM5_ADDR,
82
+
40
+ FSL_IMX6UL_PWM6_ADDR,
83
+/*
41
+ FSL_IMX6UL_PWM7_ADDR,
84
+ * Firmware on this machine only uses ACPI table to load OS, these limited
42
+ FSL_IMX6UL_PWM8_ADDR,
85
+ * device tree nodes are just to let firmware know the info which varies from
43
};
86
+ * command line parameters, so it is not necessary to be fully compatible
44
87
+ * with the kernel CPU and NUMA binding rules.
45
snprintf(name, NAME_SIZE, "pwm%d", i);
88
+ */
46
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
89
+static void create_fdt(SBSAMachineState *sms)
47
create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR,
90
+{
48
FSL_IMX6UL_LCDIF_SIZE);
91
+ void *fdt = create_device_tree(&sms->fdt_size);
49
92
+ const MachineState *ms = MACHINE(sms);
93
+ int cpu;
94
+
95
+ if (!fdt) {
96
+ error_report("create_device_tree() failed");
97
+ exit(1);
98
+ }
99
+
100
+ sms->fdt = fdt;
101
+
102
+ qemu_fdt_setprop_string(fdt, "/", "compatible", "linux,sbsa-ref");
103
+ qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2);
104
+ qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 0x2);
105
+
106
+ if (have_numa_distance) {
107
+ int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t);
108
+ uint32_t *matrix = g_malloc0(size);
109
+ int idx, i, j;
110
+
111
+ for (i = 0; i < nb_numa_nodes; i++) {
112
+ for (j = 0; j < nb_numa_nodes; j++) {
113
+ idx = (i * nb_numa_nodes + j) * 3;
114
+ matrix[idx + 0] = cpu_to_be32(i);
115
+ matrix[idx + 1] = cpu_to_be32(j);
116
+ matrix[idx + 2] = cpu_to_be32(numa_info[i].distance[j]);
117
+ }
118
+ }
119
+
120
+ qemu_fdt_add_subnode(fdt, "/distance-map");
121
+ qemu_fdt_setprop(fdt, "/distance-map", "distance-matrix",
122
+ matrix, size);
123
+ g_free(matrix);
124
+ }
125
+
126
+ qemu_fdt_add_subnode(sms->fdt, "/cpus");
127
+
128
+ for (cpu = sms->smp_cpus - 1; cpu >= 0; cpu--) {
129
+ char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu);
130
+ ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu));
131
+ CPUState *cs = CPU(armcpu);
132
+
133
+ qemu_fdt_add_subnode(sms->fdt, nodename);
134
+
135
+ if (ms->possible_cpus->cpus[cs->cpu_index].props.has_node_id) {
136
+ qemu_fdt_setprop_cell(sms->fdt, nodename, "numa-node-id",
137
+ ms->possible_cpus->cpus[cs->cpu_index].props.node_id);
138
+ }
139
+
140
+ g_free(nodename);
141
+ }
142
+}
143
+
144
+#define SBSA_FLASH_SECTOR_SIZE (256 * KiB)
145
+
146
+static PFlashCFI01 *sbsa_flash_create1(SBSAMachineState *sms,
147
+ const char *name,
148
+ const char *alias_prop_name)
149
+{
150
+ /*
50
+ /*
151
+ * Create a single flash device. We use the same parameters as
51
+ * CSU
152
+ * the flash devices on the Versatile Express board.
153
+ */
52
+ */
154
+ DeviceState *dev = qdev_create(NULL, TYPE_PFLASH_CFI01);
53
+ create_unimplemented_device("csu", FSL_IMX6UL_CSU_ADDR,
155
+
54
+ FSL_IMX6UL_CSU_SIZE);
156
+ qdev_prop_set_uint64(dev, "sector-length", SBSA_FLASH_SECTOR_SIZE);
157
+ qdev_prop_set_uint8(dev, "width", 4);
158
+ qdev_prop_set_uint8(dev, "device-width", 2);
159
+ qdev_prop_set_bit(dev, "big-endian", false);
160
+ qdev_prop_set_uint16(dev, "id0", 0x89);
161
+ qdev_prop_set_uint16(dev, "id1", 0x18);
162
+ qdev_prop_set_uint16(dev, "id2", 0x00);
163
+ qdev_prop_set_uint16(dev, "id3", 0x00);
164
+ qdev_prop_set_string(dev, "name", name);
165
+ object_property_add_child(OBJECT(sms), name, OBJECT(dev),
166
+ &error_abort);
167
+ object_property_add_alias(OBJECT(sms), alias_prop_name,
168
+ OBJECT(dev), "drive", &error_abort);
169
+ return PFLASH_CFI01(dev);
170
+}
171
+
172
+static void sbsa_flash_create(SBSAMachineState *sms)
173
+{
174
+ sms->flash[0] = sbsa_flash_create1(sms, "sbsa.flash0", "pflash0");
175
+ sms->flash[1] = sbsa_flash_create1(sms, "sbsa.flash1", "pflash1");
176
+}
177
+
178
+static void sbsa_flash_map1(PFlashCFI01 *flash,
179
+ hwaddr base, hwaddr size,
180
+ MemoryRegion *sysmem)
181
+{
182
+ DeviceState *dev = DEVICE(flash);
183
+
184
+ assert(size % SBSA_FLASH_SECTOR_SIZE == 0);
185
+ assert(size / SBSA_FLASH_SECTOR_SIZE <= UINT32_MAX);
186
+ qdev_prop_set_uint32(dev, "num-blocks", size / SBSA_FLASH_SECTOR_SIZE);
187
+ qdev_init_nofail(dev);
188
+
189
+ memory_region_add_subregion(sysmem, base,
190
+ sysbus_mmio_get_region(SYS_BUS_DEVICE(dev),
191
+ 0));
192
+}
193
+
194
+static void sbsa_flash_map(SBSAMachineState *sms,
195
+ MemoryRegion *sysmem,
196
+ MemoryRegion *secure_sysmem)
197
+{
198
+ /*
199
+ * Map two flash devices to fill the SBSA_FLASH space in the memmap.
200
+ * sysmem is the system memory space. secure_sysmem is the secure view
201
+ * of the system, and the first flash device should be made visible only
202
+ * there. The second flash device is visible to both secure and nonsecure.
203
+ * If sysmem == secure_sysmem this means there is no separate Secure
204
+ * address space and both flash devices are generally visible.
205
+ */
206
+ hwaddr flashsize = sbsa_ref_memmap[SBSA_FLASH].size / 2;
207
+ hwaddr flashbase = sbsa_ref_memmap[SBSA_FLASH].base;
208
+
209
+ sbsa_flash_map1(sms->flash[0], flashbase, flashsize,
210
+ secure_sysmem);
211
+ sbsa_flash_map1(sms->flash[1], flashbase + flashsize, flashsize,
212
+ sysmem);
213
+}
214
+
215
+static bool sbsa_firmware_init(SBSAMachineState *sms,
216
+ MemoryRegion *sysmem,
217
+ MemoryRegion *secure_sysmem)
218
+{
219
+ int i;
220
+ BlockBackend *pflash_blk0;
221
+
222
+ /* Map legacy -drive if=pflash to machine properties */
223
+ for (i = 0; i < ARRAY_SIZE(sms->flash); i++) {
224
+ pflash_cfi01_legacy_drive(sms->flash[i],
225
+ drive_get(IF_PFLASH, 0, i));
226
+ }
227
+
228
+ sbsa_flash_map(sms, sysmem, secure_sysmem);
229
+
230
+ pflash_blk0 = pflash_cfi01_get_blk(sms->flash[0]);
231
+
232
+ if (bios_name) {
233
+ char *fname;
234
+ MemoryRegion *mr;
235
+ int image_size;
236
+
237
+ if (pflash_blk0) {
238
+ error_report("The contents of the first flash device may be "
239
+ "specified with -bios or with -drive if=pflash... "
240
+ "but you cannot use both options at once");
241
+ exit(1);
242
+ }
243
+
244
+ /* Fall back to -bios */
245
+
246
+ fname = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
247
+ if (!fname) {
248
+ error_report("Could not find ROM image '%s'", bios_name);
249
+ exit(1);
250
+ }
251
+ mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(sms->flash[0]), 0);
252
+ image_size = load_image_mr(fname, mr);
253
+ g_free(fname);
254
+ if (image_size < 0) {
255
+ error_report("Could not load ROM image '%s'", bios_name);
256
+ exit(1);
257
+ }
258
+ }
259
+
260
+ return pflash_blk0 || bios_name;
261
+}
262
+
263
+static void create_secure_ram(SBSAMachineState *sms,
264
+ MemoryRegion *secure_sysmem)
265
+{
266
+ MemoryRegion *secram = g_new(MemoryRegion, 1);
267
+ hwaddr base = sbsa_ref_memmap[SBSA_SECURE_MEM].base;
268
+ hwaddr size = sbsa_ref_memmap[SBSA_SECURE_MEM].size;
269
+
270
+ memory_region_init_ram(secram, NULL, "sbsa-ref.secure-ram", size,
271
+ &error_fatal);
272
+ memory_region_add_subregion(secure_sysmem, base, secram);
273
+}
274
+
275
+static void create_gic(SBSAMachineState *sms, qemu_irq *pic)
276
+{
277
+ DeviceState *gicdev;
278
+ SysBusDevice *gicbusdev;
279
+ const char *gictype;
280
+ uint32_t redist0_capacity, redist0_count;
281
+ int i;
282
+
283
+ gictype = gicv3_class_name();
284
+
285
+ gicdev = qdev_create(NULL, gictype);
286
+ qdev_prop_set_uint32(gicdev, "revision", 3);
287
+ qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus);
288
+ /*
289
+ * Note that the num-irq property counts both internal and external
290
+ * interrupts; there are always 32 of the former (mandated by GIC spec).
291
+ */
292
+ qdev_prop_set_uint32(gicdev, "num-irq", NUM_IRQS + 32);
293
+ qdev_prop_set_bit(gicdev, "has-security-extensions", true);
294
+
295
+ redist0_capacity =
296
+ sbsa_ref_memmap[SBSA_GIC_REDIST].size / GICV3_REDIST_SIZE;
297
+ redist0_count = MIN(smp_cpus, redist0_capacity);
298
+
299
+ qdev_prop_set_uint32(gicdev, "len-redist-region-count", 1);
300
+ qdev_prop_set_uint32(gicdev, "redist-region-count[0]", redist0_count);
301
+
302
+ qdev_init_nofail(gicdev);
303
+ gicbusdev = SYS_BUS_DEVICE(gicdev);
304
+ sysbus_mmio_map(gicbusdev, 0, sbsa_ref_memmap[SBSA_GIC_DIST].base);
305
+ sysbus_mmio_map(gicbusdev, 1, sbsa_ref_memmap[SBSA_GIC_REDIST].base);
306
+
55
+
307
+ /*
56
+ /*
308
+ * Wire the outputs from each CPU's generic timer and the GICv3
57
+ * TZASC
309
+ * maintenance interrupt signal to the appropriate GIC PPI inputs,
310
+ * and the GIC's IRQ/FIQ/VIRQ/VFIQ interrupt outputs to the CPU's inputs.
311
+ */
58
+ */
312
+ for (i = 0; i < smp_cpus; i++) {
59
+ create_unimplemented_device("tzasc", FSL_IMX6UL_TZASC_ADDR,
313
+ DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
60
+ FSL_IMX6UL_TZASC_SIZE);
314
+ int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS;
315
+ int irq;
316
+ /*
317
+ * Mapping from the output timer irq lines from the CPU to the
318
+ * GIC PPI inputs used for this board.
319
+ */
320
+ const int timer_irq[] = {
321
+ [GTIMER_PHYS] = ARCH_TIMER_NS_EL1_IRQ,
322
+ [GTIMER_VIRT] = ARCH_TIMER_VIRT_IRQ,
323
+ [GTIMER_HYP] = ARCH_TIMER_NS_EL2_IRQ,
324
+ [GTIMER_SEC] = ARCH_TIMER_S_EL1_IRQ,
325
+ };
326
+
327
+ for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
328
+ qdev_connect_gpio_out(cpudev, irq,
329
+ qdev_get_gpio_in(gicdev,
330
+ ppibase + timer_irq[irq]));
331
+ }
332
+
333
+ qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", 0,
334
+ qdev_get_gpio_in(gicdev, ppibase
335
+ + ARCH_GIC_MAINT_IRQ));
336
+ qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0,
337
+ qdev_get_gpio_in(gicdev, ppibase
338
+ + VIRTUAL_PMU_IRQ));
339
+
340
+ sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
341
+ sysbus_connect_irq(gicbusdev, i + smp_cpus,
342
+ qdev_get_gpio_in(cpudev, ARM_CPU_FIQ));
343
+ sysbus_connect_irq(gicbusdev, i + 2 * smp_cpus,
344
+ qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ));
345
+ sysbus_connect_irq(gicbusdev, i + 3 * smp_cpus,
346
+ qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ));
347
+ }
348
+
349
+ for (i = 0; i < NUM_IRQS; i++) {
350
+ pic[i] = qdev_get_gpio_in(gicdev, i);
351
+ }
352
+}
353
+
354
+static void create_uart(const SBSAMachineState *sms, qemu_irq *pic, int uart,
355
+ MemoryRegion *mem, Chardev *chr)
356
+{
357
+ hwaddr base = sbsa_ref_memmap[uart].base;
358
+ int irq = sbsa_ref_irqmap[uart];
359
+ DeviceState *dev = qdev_create(NULL, "pl011");
360
+ SysBusDevice *s = SYS_BUS_DEVICE(dev);
361
+
362
+ qdev_prop_set_chr(dev, "chardev", chr);
363
+ qdev_init_nofail(dev);
364
+ memory_region_add_subregion(mem, base,
365
+ sysbus_mmio_get_region(s, 0));
366
+ sysbus_connect_irq(s, 0, pic[irq]);
367
+}
368
+
369
+static void create_rtc(const SBSAMachineState *sms, qemu_irq *pic)
370
+{
371
+ hwaddr base = sbsa_ref_memmap[SBSA_RTC].base;
372
+ int irq = sbsa_ref_irqmap[SBSA_RTC];
373
+
374
+ sysbus_create_simple("pl031", base, pic[irq]);
375
+}
376
+
377
+static DeviceState *gpio_key_dev;
378
+static void sbsa_ref_powerdown_req(Notifier *n, void *opaque)
379
+{
380
+ /* use gpio Pin 3 for power button event */
381
+ qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1);
382
+}
383
+
384
+static Notifier sbsa_ref_powerdown_notifier = {
385
+ .notify = sbsa_ref_powerdown_req
386
+};
387
+
388
+static void create_gpio(const SBSAMachineState *sms, qemu_irq *pic)
389
+{
390
+ DeviceState *pl061_dev;
391
+ hwaddr base = sbsa_ref_memmap[SBSA_GPIO].base;
392
+ int irq = sbsa_ref_irqmap[SBSA_GPIO];
393
+
394
+ pl061_dev = sysbus_create_simple("pl061", base, pic[irq]);
395
+
396
+ gpio_key_dev = sysbus_create_simple("gpio-key", -1,
397
+ qdev_get_gpio_in(pl061_dev, 3));
398
+
399
+ /* connect powerdown request */
400
+ qemu_register_powerdown_notifier(&sbsa_ref_powerdown_notifier);
401
+}
402
+
403
+static void create_ahci(const SBSAMachineState *sms, qemu_irq *pic)
404
+{
405
+ hwaddr base = sbsa_ref_memmap[SBSA_AHCI].base;
406
+ int irq = sbsa_ref_irqmap[SBSA_AHCI];
407
+ DeviceState *dev;
408
+ DriveInfo *hd[NUM_SATA_PORTS];
409
+ SysbusAHCIState *sysahci;
410
+ AHCIState *ahci;
411
+ int i;
412
+
413
+ dev = qdev_create(NULL, "sysbus-ahci");
414
+ qdev_prop_set_uint32(dev, "num-ports", NUM_SATA_PORTS);
415
+ qdev_init_nofail(dev);
416
+ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
417
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]);
418
+
419
+ sysahci = SYSBUS_AHCI(dev);
420
+ ahci = &sysahci->ahci;
421
+ ide_drive_get(hd, ARRAY_SIZE(hd));
422
+ for (i = 0; i < ahci->ports; i++) {
423
+ if (hd[i] == NULL) {
424
+ continue;
425
+ }
426
+ ide_create_drive(&ahci->dev[i].port, 0, hd[i]);
427
+ }
428
+}
429
+
430
+static void create_ehci(const SBSAMachineState *sms, qemu_irq *pic)
431
+{
432
+ hwaddr base = sbsa_ref_memmap[SBSA_EHCI].base;
433
+ int irq = sbsa_ref_irqmap[SBSA_EHCI];
434
+
435
+ sysbus_create_simple("platform-ehci-usb", base, pic[irq]);
436
+}
437
+
438
+static void create_smmu(const SBSAMachineState *sms, qemu_irq *pic,
439
+ PCIBus *bus)
440
+{
441
+ hwaddr base = sbsa_ref_memmap[SBSA_SMMU].base;
442
+ int irq = sbsa_ref_irqmap[SBSA_SMMU];
443
+ DeviceState *dev;
444
+ int i;
445
+
446
+ dev = qdev_create(NULL, "arm-smmuv3");
447
+
448
+ object_property_set_link(OBJECT(dev), OBJECT(bus), "primary-bus",
449
+ &error_abort);
450
+ qdev_init_nofail(dev);
451
+ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
452
+ for (i = 0; i < NUM_SMMU_IRQS; i++) {
453
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]);
454
+ }
455
+}
456
+
457
+static void create_pcie(SBSAMachineState *sms, qemu_irq *pic)
458
+{
459
+ hwaddr base_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].base;
460
+ hwaddr size_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].size;
461
+ hwaddr base_mmio = sbsa_ref_memmap[SBSA_PCIE_MMIO].base;
462
+ hwaddr size_mmio = sbsa_ref_memmap[SBSA_PCIE_MMIO].size;
463
+ hwaddr base_mmio_high = sbsa_ref_memmap[SBSA_PCIE_MMIO_HIGH].base;
464
+ hwaddr size_mmio_high = sbsa_ref_memmap[SBSA_PCIE_MMIO_HIGH].size;
465
+ hwaddr base_pio = sbsa_ref_memmap[SBSA_PCIE_PIO].base;
466
+ int irq = sbsa_ref_irqmap[SBSA_PCIE];
467
+ MemoryRegion *mmio_alias, *mmio_alias_high, *mmio_reg;
468
+ MemoryRegion *ecam_alias, *ecam_reg;
469
+ DeviceState *dev;
470
+ PCIHostState *pci;
471
+ int i;
472
+
473
+ dev = qdev_create(NULL, TYPE_GPEX_HOST);
474
+ qdev_init_nofail(dev);
475
+
476
+ /* Map ECAM space */
477
+ ecam_alias = g_new0(MemoryRegion, 1);
478
+ ecam_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
479
+ memory_region_init_alias(ecam_alias, OBJECT(dev), "pcie-ecam",
480
+ ecam_reg, 0, size_ecam);
481
+ memory_region_add_subregion(get_system_memory(), base_ecam, ecam_alias);
482
+
483
+ /* Map the MMIO space */
484
+ mmio_alias = g_new0(MemoryRegion, 1);
485
+ mmio_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1);
486
+ memory_region_init_alias(mmio_alias, OBJECT(dev), "pcie-mmio",
487
+ mmio_reg, base_mmio, size_mmio);
488
+ memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias);
489
+
490
+ /* Map the MMIO_HIGH space */
491
+ mmio_alias_high = g_new0(MemoryRegion, 1);
492
+ memory_region_init_alias(mmio_alias_high, OBJECT(dev), "pcie-mmio-high",
493
+ mmio_reg, base_mmio_high, size_mmio_high);
494
+ memory_region_add_subregion(get_system_memory(), base_mmio_high,
495
+ mmio_alias_high);
496
+
497
+ /* Map IO port space */
498
+ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_pio);
499
+
500
+ for (i = 0; i < GPEX_NUM_IRQS; i++) {
501
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]);
502
+ gpex_set_irq_num(GPEX_HOST(dev), i, irq + i);
503
+ }
504
+
505
+ pci = PCI_HOST_BRIDGE(dev);
506
+ if (pci->bus) {
507
+ for (i = 0; i < nb_nics; i++) {
508
+ NICInfo *nd = &nd_table[i];
509
+
510
+ if (!nd->model) {
511
+ nd->model = g_strdup("e1000e");
512
+ }
513
+
514
+ pci_nic_init_nofail(nd, pci->bus, nd->model, NULL);
515
+ }
516
+ }
517
+
518
+ pci_create_simple(pci->bus, -1, "VGA");
519
+
520
+ create_smmu(sms, pic, pci->bus);
521
+}
522
+
523
+static void *sbsa_ref_dtb(const struct arm_boot_info *binfo, int *fdt_size)
524
+{
525
+ const SBSAMachineState *board = container_of(binfo, SBSAMachineState,
526
+ bootinfo);
527
+
528
+ *fdt_size = board->fdt_size;
529
+ return board->fdt;
530
+}
531
+
532
static void sbsa_ref_init(MachineState *machine)
533
{
534
SBSAMachineState *sms = SBSA_MACHINE(machine);
535
@@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine)
536
MemoryRegion *sysmem = get_system_memory();
537
MemoryRegion *secure_sysmem = NULL;
538
MemoryRegion *ram = g_new(MemoryRegion, 1);
539
+ bool firmware_loaded;
540
const CPUArchIdList *possible_cpus;
541
int n, sbsa_max_cpus;
542
+ qemu_irq pic[NUM_IRQS];
543
544
if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a57"))) {
545
error_report("sbsa-ref: CPU type other than the built-in "
546
@@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine)
547
exit(1);
548
}
549
550
+ /*
551
+ * The Secure view of the world is the same as the NonSecure,
552
+ * but with a few extra devices. Create it as a container region
553
+ * containing the system memory at low priority; any secure-only
554
+ * devices go in at higher priority and take precedence.
555
+ */
556
+ secure_sysmem = g_new(MemoryRegion, 1);
557
+ memory_region_init(secure_sysmem, OBJECT(machine), "secure-memory",
558
+ UINT64_MAX);
559
+ memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1);
560
+
561
+ firmware_loaded = sbsa_firmware_init(sms, sysmem,
562
+ secure_sysmem ?: sysmem);
563
+
564
+ if (machine->kernel_filename && firmware_loaded) {
565
+ error_report("sbsa-ref: No fw_cfg device on this machine, "
566
+ "so -kernel option is not supported when firmware loaded, "
567
+ "please load OS from hard disk instead");
568
+ exit(1);
569
+ }
570
+
61
+
571
/*
62
/*
572
* This machine has EL3 enabled, external firmware should supply PSCI
63
* ROM memory
573
* implementation, so the QEMU's internal PSCI is disabled.
64
*/
574
@@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine)
575
machine->ram_size);
576
memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ram);
577
578
+ create_fdt(sms);
579
+
580
+ create_secure_ram(sms, secure_sysmem);
581
+
582
+ create_gic(sms, pic);
583
+
584
+ create_uart(sms, pic, SBSA_UART, sysmem, serial_hd(0));
585
+ create_uart(sms, pic, SBSA_SECURE_UART, secure_sysmem, serial_hd(1));
586
+ /* Second secure UART for RAS and MM from EL0 */
587
+ create_uart(sms, pic, SBSA_SECURE_UART_MM, secure_sysmem, serial_hd(2));
588
+
589
+ create_rtc(sms, pic);
590
+
591
+ create_gpio(sms, pic);
592
+
593
+ create_ahci(sms, pic);
594
+
595
+ create_ehci(sms, pic);
596
+
597
+ create_pcie(sms, pic);
598
+
599
sms->bootinfo.ram_size = machine->ram_size;
600
sms->bootinfo.kernel_filename = machine->kernel_filename;
601
sms->bootinfo.nb_cpus = smp_cpus;
602
sms->bootinfo.board_id = -1;
603
sms->bootinfo.loader_start = sbsa_ref_memmap[SBSA_MEM].base;
604
+ sms->bootinfo.get_dtb = sbsa_ref_dtb;
605
+ sms->bootinfo.firmware_loaded = firmware_loaded;
606
arm_load_kernel(ARM_CPU(first_cpu), &sms->bootinfo);
607
}
608
609
@@ -XXX,XX +XXX,XX @@ sbsa_ref_get_default_cpu_node_id(const MachineState *ms, int idx)
610
return idx % nb_numa_nodes;
611
}
612
613
+static void sbsa_ref_instance_init(Object *obj)
614
+{
615
+ SBSAMachineState *sms = SBSA_MACHINE(obj);
616
+
617
+ sbsa_flash_create(sms);
618
+}
619
+
620
static void sbsa_ref_class_init(ObjectClass *oc, void *data)
621
{
622
MachineClass *mc = MACHINE_CLASS(oc);
623
@@ -XXX,XX +XXX,XX @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data)
624
static const TypeInfo sbsa_ref_info = {
625
.name = TYPE_SBSA_MACHINE,
626
.parent = TYPE_MACHINE,
627
+ .instance_init = sbsa_ref_instance_init,
628
.class_init = sbsa_ref_class_init,
629
.instance_size = sizeof(SBSAMachineState),
630
};
631
--
65
--
632
2.20.1
66
2.34.1
633
67
634
68
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: Jean-Christophe Dubois <jcd@tribudubois.net>
2
2
3
Instantiate no-op APBH DMA module. Needed to boot latest Linux kernel.
3
* Add Addr and size definition for all i.MX7 devices in i.MX7 header file.
4
* Use those newly defined named constants whenever possible.
5
* Standardize the way we init a familly of unimplemented devices
6
- SAI
7
- PWM
8
- CAN
9
* Add/rework few comments
4
10
5
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
11
Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
6
Cc: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 59e195d33e4d486a8d131392acd46633c8c10ed7.1692964892.git.jcd@tribudubois.net
7
Cc: Michael S. Tsirkin <mst@redhat.com>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Cc: qemu-devel@nongnu.org
9
Cc: qemu-arm@nongnu.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
---
15
---
13
include/hw/arm/fsl-imx7.h | 3 +++
16
include/hw/arm/fsl-imx7.h | 330 ++++++++++++++++++++++++++++----------
14
hw/arm/fsl-imx7.c | 6 ++++++
17
hw/arm/fsl-imx7.c | 130 ++++++++++-----
15
2 files changed, 9 insertions(+)
18
2 files changed, 335 insertions(+), 125 deletions(-)
16
19
17
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
20
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
18
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/arm/fsl-imx7.h
22
--- a/include/hw/arm/fsl-imx7.h
20
+++ b/include/hw/arm/fsl-imx7.h
23
+++ b/include/hw/arm/fsl-imx7.h
24
@@ -XXX,XX +XXX,XX @@
25
#include "hw/misc/imx7_ccm.h"
26
#include "hw/misc/imx7_snvs.h"
27
#include "hw/misc/imx7_gpr.h"
28
-#include "hw/misc/imx6_src.h"
29
#include "hw/watchdog/wdt_imx2.h"
30
#include "hw/gpio/imx_gpio.h"
31
#include "hw/char/imx_serial.h"
32
@@ -XXX,XX +XXX,XX @@
33
#include "hw/usb/chipidea.h"
34
#include "cpu.h"
35
#include "qom/object.h"
36
+#include "qemu/units.h"
37
38
#define TYPE_FSL_IMX7 "fsl-imx7"
39
OBJECT_DECLARE_SIMPLE_TYPE(FslIMX7State, FSL_IMX7)
40
@@ -XXX,XX +XXX,XX @@ enum FslIMX7Configuration {
41
FSL_IMX7_NUM_ECSPIS = 4,
42
FSL_IMX7_NUM_USBS = 3,
43
FSL_IMX7_NUM_ADCS = 2,
44
+ FSL_IMX7_NUM_SAIS = 3,
45
+ FSL_IMX7_NUM_CANS = 2,
46
+ FSL_IMX7_NUM_PWMS = 4,
47
};
48
49
struct FslIMX7State {
50
@@ -XXX,XX +XXX,XX @@ struct FslIMX7State {
51
52
enum FslIMX7MemoryMap {
53
FSL_IMX7_MMDC_ADDR = 0x80000000,
54
- FSL_IMX7_MMDC_SIZE = 2 * 1024 * 1024 * 1024UL,
55
+ FSL_IMX7_MMDC_SIZE = (2 * GiB),
56
57
- FSL_IMX7_GPIO1_ADDR = 0x30200000,
58
- FSL_IMX7_GPIO2_ADDR = 0x30210000,
59
- FSL_IMX7_GPIO3_ADDR = 0x30220000,
60
- FSL_IMX7_GPIO4_ADDR = 0x30230000,
61
- FSL_IMX7_GPIO5_ADDR = 0x30240000,
62
- FSL_IMX7_GPIO6_ADDR = 0x30250000,
63
- FSL_IMX7_GPIO7_ADDR = 0x30260000,
64
+ FSL_IMX7_QSPI1_MEM_ADDR = 0x60000000,
65
+ FSL_IMX7_QSPI1_MEM_SIZE = (256 * MiB),
66
67
- FSL_IMX7_IOMUXC_LPSR_GPR_ADDR = 0x30270000,
68
+ FSL_IMX7_PCIE1_MEM_ADDR = 0x40000000,
69
+ FSL_IMX7_PCIE1_MEM_SIZE = (256 * MiB),
70
71
- FSL_IMX7_WDOG1_ADDR = 0x30280000,
72
- FSL_IMX7_WDOG2_ADDR = 0x30290000,
73
- FSL_IMX7_WDOG3_ADDR = 0x302A0000,
74
- FSL_IMX7_WDOG4_ADDR = 0x302B0000,
75
+ FSL_IMX7_QSPI1_RX_BUF_ADDR = 0x34000000,
76
+ FSL_IMX7_QSPI1_RX_BUF_SIZE = (32 * MiB),
77
78
- FSL_IMX7_IOMUXC_LPSR_ADDR = 0x302C0000,
79
+ /* PCIe Peripherals */
80
+ FSL_IMX7_PCIE_REG_ADDR = 0x33800000,
81
82
- FSL_IMX7_GPT1_ADDR = 0x302D0000,
83
- FSL_IMX7_GPT2_ADDR = 0x302E0000,
84
- FSL_IMX7_GPT3_ADDR = 0x302F0000,
85
- FSL_IMX7_GPT4_ADDR = 0x30300000,
86
+ /* MMAP Peripherals */
87
+ FSL_IMX7_DMA_APBH_ADDR = 0x33000000,
88
+ FSL_IMX7_DMA_APBH_SIZE = 0x8000,
89
90
- FSL_IMX7_IOMUXC_ADDR = 0x30330000,
91
- FSL_IMX7_IOMUXC_GPR_ADDR = 0x30340000,
92
- FSL_IMX7_IOMUXCn_SIZE = 0x1000,
93
+ /* GPV configuration */
94
+ FSL_IMX7_GPV6_ADDR = 0x32600000,
95
+ FSL_IMX7_GPV5_ADDR = 0x32500000,
96
+ FSL_IMX7_GPV4_ADDR = 0x32400000,
97
+ FSL_IMX7_GPV3_ADDR = 0x32300000,
98
+ FSL_IMX7_GPV2_ADDR = 0x32200000,
99
+ FSL_IMX7_GPV1_ADDR = 0x32100000,
100
+ FSL_IMX7_GPV0_ADDR = 0x32000000,
101
+ FSL_IMX7_GPVn_SIZE = (1 * MiB),
102
103
- FSL_IMX7_OCOTP_ADDR = 0x30350000,
104
- FSL_IMX7_OCOTP_SIZE = 0x10000,
105
+ /* Arm Peripherals */
106
+ FSL_IMX7_A7MPCORE_ADDR = 0x31000000,
107
108
- FSL_IMX7_ANALOG_ADDR = 0x30360000,
109
- FSL_IMX7_SNVS_ADDR = 0x30370000,
110
- FSL_IMX7_CCM_ADDR = 0x30380000,
111
+ /* AIPS-3 Begin */
112
113
- FSL_IMX7_SRC_ADDR = 0x30390000,
114
- FSL_IMX7_SRC_SIZE = 0x1000,
115
+ FSL_IMX7_ENET2_ADDR = 0x30BF0000,
116
+ FSL_IMX7_ENET1_ADDR = 0x30BE0000,
117
118
- FSL_IMX7_ADC1_ADDR = 0x30610000,
119
- FSL_IMX7_ADC2_ADDR = 0x30620000,
120
- FSL_IMX7_ADCn_SIZE = 0x1000,
121
+ FSL_IMX7_SDMA_ADDR = 0x30BD0000,
122
+ FSL_IMX7_SDMA_SIZE = (4 * KiB),
123
124
- FSL_IMX7_PWM1_ADDR = 0x30660000,
125
- FSL_IMX7_PWM2_ADDR = 0x30670000,
126
- FSL_IMX7_PWM3_ADDR = 0x30680000,
127
- FSL_IMX7_PWM4_ADDR = 0x30690000,
128
- FSL_IMX7_PWMn_SIZE = 0x10000,
129
+ FSL_IMX7_EIM_ADDR = 0x30BC0000,
130
+ FSL_IMX7_EIM_SIZE = (4 * KiB),
131
132
- FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000,
133
- FSL_IMX7_PCIE_PHY_SIZE = 0x10000,
134
+ FSL_IMX7_QSPI_ADDR = 0x30BB0000,
135
+ FSL_IMX7_QSPI_SIZE = 0x8000,
136
137
- FSL_IMX7_GPC_ADDR = 0x303A0000,
138
+ FSL_IMX7_SIM2_ADDR = 0x30BA0000,
139
+ FSL_IMX7_SIM1_ADDR = 0x30B90000,
140
+ FSL_IMX7_SIMn_SIZE = (4 * KiB),
141
+
142
+ FSL_IMX7_USDHC3_ADDR = 0x30B60000,
143
+ FSL_IMX7_USDHC2_ADDR = 0x30B50000,
144
+ FSL_IMX7_USDHC1_ADDR = 0x30B40000,
145
+
146
+ FSL_IMX7_USB3_ADDR = 0x30B30000,
147
+ FSL_IMX7_USBMISC3_ADDR = 0x30B30200,
148
+ FSL_IMX7_USB2_ADDR = 0x30B20000,
149
+ FSL_IMX7_USBMISC2_ADDR = 0x30B20200,
150
+ FSL_IMX7_USB1_ADDR = 0x30B10000,
151
+ FSL_IMX7_USBMISC1_ADDR = 0x30B10200,
152
+ FSL_IMX7_USBMISCn_SIZE = 0x200,
153
+
154
+ FSL_IMX7_USB_PL301_ADDR = 0x30AD0000,
155
+ FSL_IMX7_USB_PL301_SIZE = (64 * KiB),
156
+
157
+ FSL_IMX7_SEMAPHORE_HS_ADDR = 0x30AC0000,
158
+ FSL_IMX7_SEMAPHORE_HS_SIZE = (64 * KiB),
159
+
160
+ FSL_IMX7_MUB_ADDR = 0x30AB0000,
161
+ FSL_IMX7_MUA_ADDR = 0x30AA0000,
162
+ FSL_IMX7_MUn_SIZE = (KiB),
163
+
164
+ FSL_IMX7_UART7_ADDR = 0x30A90000,
165
+ FSL_IMX7_UART6_ADDR = 0x30A80000,
166
+ FSL_IMX7_UART5_ADDR = 0x30A70000,
167
+ FSL_IMX7_UART4_ADDR = 0x30A60000,
168
+
169
+ FSL_IMX7_I2C4_ADDR = 0x30A50000,
170
+ FSL_IMX7_I2C3_ADDR = 0x30A40000,
171
+ FSL_IMX7_I2C2_ADDR = 0x30A30000,
172
+ FSL_IMX7_I2C1_ADDR = 0x30A20000,
173
+
174
+ FSL_IMX7_CAN2_ADDR = 0x30A10000,
175
+ FSL_IMX7_CAN1_ADDR = 0x30A00000,
176
+ FSL_IMX7_CANn_SIZE = (4 * KiB),
177
+
178
+ FSL_IMX7_AIPS3_CONF_ADDR = 0x309F0000,
179
+ FSL_IMX7_AIPS3_CONF_SIZE = (64 * KiB),
180
181
FSL_IMX7_CAAM_ADDR = 0x30900000,
182
- FSL_IMX7_CAAM_SIZE = 0x40000,
183
+ FSL_IMX7_CAAM_SIZE = (256 * KiB),
184
185
- FSL_IMX7_CAN1_ADDR = 0x30A00000,
186
- FSL_IMX7_CAN2_ADDR = 0x30A10000,
187
- FSL_IMX7_CANn_SIZE = 0x10000,
188
+ FSL_IMX7_SPBA_ADDR = 0x308F0000,
189
+ FSL_IMX7_SPBA_SIZE = (4 * KiB),
190
191
- FSL_IMX7_I2C1_ADDR = 0x30A20000,
192
- FSL_IMX7_I2C2_ADDR = 0x30A30000,
193
- FSL_IMX7_I2C3_ADDR = 0x30A40000,
194
- FSL_IMX7_I2C4_ADDR = 0x30A50000,
195
+ FSL_IMX7_SAI3_ADDR = 0x308C0000,
196
+ FSL_IMX7_SAI2_ADDR = 0x308B0000,
197
+ FSL_IMX7_SAI1_ADDR = 0x308A0000,
198
+ FSL_IMX7_SAIn_SIZE = (4 * KiB),
199
200
- FSL_IMX7_ECSPI1_ADDR = 0x30820000,
201
- FSL_IMX7_ECSPI2_ADDR = 0x30830000,
202
- FSL_IMX7_ECSPI3_ADDR = 0x30840000,
203
- FSL_IMX7_ECSPI4_ADDR = 0x30630000,
204
-
205
- FSL_IMX7_LCDIF_ADDR = 0x30730000,
206
- FSL_IMX7_LCDIF_SIZE = 0x1000,
207
-
208
- FSL_IMX7_UART1_ADDR = 0x30860000,
209
+ FSL_IMX7_UART3_ADDR = 0x30880000,
210
/*
211
* Some versions of the reference manual claim that UART2 is @
212
* 0x30870000, but experiments with HW + DT files in upstream
21
@@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap {
213
@@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap {
22
FSL_IMX7_PCIE_REG_SIZE = 16 * 1024,
214
* actually located @ 0x30890000
23
215
*/
24
FSL_IMX7_GPR_ADDR = 0x30340000,
216
FSL_IMX7_UART2_ADDR = 0x30890000,
25
+
217
- FSL_IMX7_UART3_ADDR = 0x30880000,
26
+ FSL_IMX7_DMA_APBH_ADDR = 0x33000000,
218
- FSL_IMX7_UART4_ADDR = 0x30A60000,
27
+ FSL_IMX7_DMA_APBH_SIZE = 0x2000,
219
- FSL_IMX7_UART5_ADDR = 0x30A70000,
220
- FSL_IMX7_UART6_ADDR = 0x30A80000,
221
- FSL_IMX7_UART7_ADDR = 0x30A90000,
222
+ FSL_IMX7_UART1_ADDR = 0x30860000,
223
224
- FSL_IMX7_SAI1_ADDR = 0x308A0000,
225
- FSL_IMX7_SAI2_ADDR = 0x308B0000,
226
- FSL_IMX7_SAI3_ADDR = 0x308C0000,
227
- FSL_IMX7_SAIn_SIZE = 0x10000,
228
+ FSL_IMX7_ECSPI3_ADDR = 0x30840000,
229
+ FSL_IMX7_ECSPI2_ADDR = 0x30830000,
230
+ FSL_IMX7_ECSPI1_ADDR = 0x30820000,
231
+ FSL_IMX7_ECSPIn_SIZE = (4 * KiB),
232
233
- FSL_IMX7_ENET1_ADDR = 0x30BE0000,
234
- FSL_IMX7_ENET2_ADDR = 0x30BF0000,
235
+ /* AIPS-3 End */
236
237
- FSL_IMX7_USB1_ADDR = 0x30B10000,
238
- FSL_IMX7_USBMISC1_ADDR = 0x30B10200,
239
- FSL_IMX7_USB2_ADDR = 0x30B20000,
240
- FSL_IMX7_USBMISC2_ADDR = 0x30B20200,
241
- FSL_IMX7_USB3_ADDR = 0x30B30000,
242
- FSL_IMX7_USBMISC3_ADDR = 0x30B30200,
243
- FSL_IMX7_USBMISCn_SIZE = 0x200,
244
+ /* AIPS-2 Begin */
245
246
- FSL_IMX7_USDHC1_ADDR = 0x30B40000,
247
- FSL_IMX7_USDHC2_ADDR = 0x30B50000,
248
- FSL_IMX7_USDHC3_ADDR = 0x30B60000,
249
+ FSL_IMX7_AXI_DEBUG_MON_ADDR = 0x307E0000,
250
+ FSL_IMX7_AXI_DEBUG_MON_SIZE = (64 * KiB),
251
252
- FSL_IMX7_SDMA_ADDR = 0x30BD0000,
253
- FSL_IMX7_SDMA_SIZE = 0x1000,
254
+ FSL_IMX7_PERFMON2_ADDR = 0x307D0000,
255
+ FSL_IMX7_PERFMON1_ADDR = 0x307C0000,
256
+ FSL_IMX7_PERFMONn_SIZE = (64 * KiB),
257
+
258
+ FSL_IMX7_DDRC_ADDR = 0x307A0000,
259
+ FSL_IMX7_DDRC_SIZE = (4 * KiB),
260
+
261
+ FSL_IMX7_DDRC_PHY_ADDR = 0x30790000,
262
+ FSL_IMX7_DDRC_PHY_SIZE = (4 * KiB),
263
+
264
+ FSL_IMX7_TZASC_ADDR = 0x30780000,
265
+ FSL_IMX7_TZASC_SIZE = (64 * KiB),
266
+
267
+ FSL_IMX7_MIPI_DSI_ADDR = 0x30760000,
268
+ FSL_IMX7_MIPI_DSI_SIZE = (4 * KiB),
269
+
270
+ FSL_IMX7_MIPI_CSI_ADDR = 0x30750000,
271
+ FSL_IMX7_MIPI_CSI_SIZE = 0x4000,
272
+
273
+ FSL_IMX7_LCDIF_ADDR = 0x30730000,
274
+ FSL_IMX7_LCDIF_SIZE = 0x8000,
275
+
276
+ FSL_IMX7_CSI_ADDR = 0x30710000,
277
+ FSL_IMX7_CSI_SIZE = (4 * KiB),
278
+
279
+ FSL_IMX7_PXP_ADDR = 0x30700000,
280
+ FSL_IMX7_PXP_SIZE = 0x4000,
281
+
282
+ FSL_IMX7_EPDC_ADDR = 0x306F0000,
283
+ FSL_IMX7_EPDC_SIZE = (4 * KiB),
284
+
285
+ FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000,
286
+ FSL_IMX7_PCIE_PHY_SIZE = (4 * KiB),
287
+
288
+ FSL_IMX7_SYSCNT_CTRL_ADDR = 0x306C0000,
289
+ FSL_IMX7_SYSCNT_CMP_ADDR = 0x306B0000,
290
+ FSL_IMX7_SYSCNT_RD_ADDR = 0x306A0000,
291
+
292
+ FSL_IMX7_PWM4_ADDR = 0x30690000,
293
+ FSL_IMX7_PWM3_ADDR = 0x30680000,
294
+ FSL_IMX7_PWM2_ADDR = 0x30670000,
295
+ FSL_IMX7_PWM1_ADDR = 0x30660000,
296
+ FSL_IMX7_PWMn_SIZE = (4 * KiB),
297
+
298
+ FSL_IMX7_FlEXTIMER2_ADDR = 0x30650000,
299
+ FSL_IMX7_FlEXTIMER1_ADDR = 0x30640000,
300
+ FSL_IMX7_FLEXTIMERn_SIZE = (4 * KiB),
301
+
302
+ FSL_IMX7_ECSPI4_ADDR = 0x30630000,
303
+
304
+ FSL_IMX7_ADC2_ADDR = 0x30620000,
305
+ FSL_IMX7_ADC1_ADDR = 0x30610000,
306
+ FSL_IMX7_ADCn_SIZE = (4 * KiB),
307
+
308
+ FSL_IMX7_AIPS2_CONF_ADDR = 0x305F0000,
309
+ FSL_IMX7_AIPS2_CONF_SIZE = (64 * KiB),
310
+
311
+ /* AIPS-2 End */
312
+
313
+ /* AIPS-1 Begin */
314
+
315
+ FSL_IMX7_CSU_ADDR = 0x303E0000,
316
+ FSL_IMX7_CSU_SIZE = (64 * KiB),
317
+
318
+ FSL_IMX7_RDC_ADDR = 0x303D0000,
319
+ FSL_IMX7_RDC_SIZE = (4 * KiB),
320
+
321
+ FSL_IMX7_SEMAPHORE2_ADDR = 0x303C0000,
322
+ FSL_IMX7_SEMAPHORE1_ADDR = 0x303B0000,
323
+ FSL_IMX7_SEMAPHOREn_SIZE = (4 * KiB),
324
+
325
+ FSL_IMX7_GPC_ADDR = 0x303A0000,
326
+
327
+ FSL_IMX7_SRC_ADDR = 0x30390000,
328
+ FSL_IMX7_SRC_SIZE = (4 * KiB),
329
+
330
+ FSL_IMX7_CCM_ADDR = 0x30380000,
331
+
332
+ FSL_IMX7_SNVS_HP_ADDR = 0x30370000,
333
+
334
+ FSL_IMX7_ANALOG_ADDR = 0x30360000,
335
+
336
+ FSL_IMX7_OCOTP_ADDR = 0x30350000,
337
+ FSL_IMX7_OCOTP_SIZE = 0x10000,
338
+
339
+ FSL_IMX7_IOMUXC_GPR_ADDR = 0x30340000,
340
+ FSL_IMX7_IOMUXC_GPR_SIZE = (4 * KiB),
341
+
342
+ FSL_IMX7_IOMUXC_ADDR = 0x30330000,
343
+ FSL_IMX7_IOMUXC_SIZE = (4 * KiB),
344
+
345
+ FSL_IMX7_KPP_ADDR = 0x30320000,
346
+ FSL_IMX7_KPP_SIZE = (4 * KiB),
347
+
348
+ FSL_IMX7_ROMCP_ADDR = 0x30310000,
349
+ FSL_IMX7_ROMCP_SIZE = (4 * KiB),
350
+
351
+ FSL_IMX7_GPT4_ADDR = 0x30300000,
352
+ FSL_IMX7_GPT3_ADDR = 0x302F0000,
353
+ FSL_IMX7_GPT2_ADDR = 0x302E0000,
354
+ FSL_IMX7_GPT1_ADDR = 0x302D0000,
355
+
356
+ FSL_IMX7_IOMUXC_LPSR_ADDR = 0x302C0000,
357
+ FSL_IMX7_IOMUXC_LPSR_SIZE = (4 * KiB),
358
+
359
+ FSL_IMX7_WDOG4_ADDR = 0x302B0000,
360
+ FSL_IMX7_WDOG3_ADDR = 0x302A0000,
361
+ FSL_IMX7_WDOG2_ADDR = 0x30290000,
362
+ FSL_IMX7_WDOG1_ADDR = 0x30280000,
363
+
364
+ FSL_IMX7_IOMUXC_LPSR_GPR_ADDR = 0x30270000,
365
+
366
+ FSL_IMX7_GPIO7_ADDR = 0x30260000,
367
+ FSL_IMX7_GPIO6_ADDR = 0x30250000,
368
+ FSL_IMX7_GPIO5_ADDR = 0x30240000,
369
+ FSL_IMX7_GPIO4_ADDR = 0x30230000,
370
+ FSL_IMX7_GPIO3_ADDR = 0x30220000,
371
+ FSL_IMX7_GPIO2_ADDR = 0x30210000,
372
+ FSL_IMX7_GPIO1_ADDR = 0x30200000,
373
+
374
+ FSL_IMX7_AIPS1_CONF_ADDR = 0x301F0000,
375
+ FSL_IMX7_AIPS1_CONF_SIZE = (64 * KiB),
376
377
- FSL_IMX7_A7MPCORE_ADDR = 0x31000000,
378
FSL_IMX7_A7MPCORE_DAP_ADDR = 0x30000000,
379
+ FSL_IMX7_A7MPCORE_DAP_SIZE = (1 * MiB),
380
381
- FSL_IMX7_PCIE_REG_ADDR = 0x33800000,
382
- FSL_IMX7_PCIE_REG_SIZE = 16 * 1024,
383
+ /* AIPS-1 End */
384
385
- FSL_IMX7_GPR_ADDR = 0x30340000,
386
+ FSL_IMX7_EIM_CS0_ADDR = 0x28000000,
387
+ FSL_IMX7_EIM_CS0_SIZE = (128 * MiB),
388
389
- FSL_IMX7_DMA_APBH_ADDR = 0x33000000,
390
- FSL_IMX7_DMA_APBH_SIZE = 0x2000,
391
+ FSL_IMX7_OCRAM_PXP_ADDR = 0x00940000,
392
+ FSL_IMX7_OCRAM_PXP_SIZE = (32 * KiB),
393
+
394
+ FSL_IMX7_OCRAM_EPDC_ADDR = 0x00920000,
395
+ FSL_IMX7_OCRAM_EPDC_SIZE = (128 * KiB),
396
+
397
+ FSL_IMX7_OCRAM_MEM_ADDR = 0x00900000,
398
+ FSL_IMX7_OCRAM_MEM_SIZE = (128 * KiB),
399
+
400
+ FSL_IMX7_TCMU_ADDR = 0x00800000,
401
+ FSL_IMX7_TCMU_SIZE = (32 * KiB),
402
+
403
+ FSL_IMX7_TCML_ADDR = 0x007F8000,
404
+ FSL_IMX7_TCML_SIZE = (32 * KiB),
405
+
406
+ FSL_IMX7_OCRAM_S_ADDR = 0x00180000,
407
+ FSL_IMX7_OCRAM_S_SIZE = (32 * KiB),
408
+
409
+ FSL_IMX7_CAAM_MEM_ADDR = 0x00100000,
410
+ FSL_IMX7_CAAM_MEM_SIZE = (32 * KiB),
411
+
412
+ FSL_IMX7_ROM_ADDR = 0x00000000,
413
+ FSL_IMX7_ROM_SIZE = (96 * KiB),
28
};
414
};
29
415
30
enum FslIMX7IRQs {
416
enum FslIMX7IRQs {
31
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
417
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
32
index XXXXXXX..XXXXXXX 100644
418
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/arm/fsl-imx7.c
419
--- a/hw/arm/fsl-imx7.c
34
+++ b/hw/arm/fsl-imx7.c
420
+++ b/hw/arm/fsl-imx7.c
35
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
421
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj)
36
*/
422
char name[NAME_SIZE];
37
create_unimplemented_device("lcdif", FSL_IMX7_LCDIF_ADDR,
423
int i;
38
FSL_IMX7_LCDIF_SIZE);
424
39
+
425
+ /*
40
+ /*
426
+ * CPUs
41
+ * DMA APBH
427
+ */
42
+ */
428
for (i = 0; i < MIN(ms->smp.cpus, FSL_IMX7_NUM_CPUS); i++) {
43
+ create_unimplemented_device("dma-apbh", FSL_IMX7_DMA_APBH_ADDR,
429
snprintf(name, NAME_SIZE, "cpu%d", i);
44
+ FSL_IMX7_DMA_APBH_SIZE);
430
object_initialize_child(obj, name, &s->cpu[i],
431
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj)
432
TYPE_A15MPCORE_PRIV);
433
434
/*
435
- * GPIOs 1 to 7
436
+ * GPIOs
437
*/
438
for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) {
439
snprintf(name, NAME_SIZE, "gpio%d", i);
440
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj)
441
}
442
443
/*
444
- * GPT1, 2, 3, 4
445
+ * GPTs
446
*/
447
for (i = 0; i < FSL_IMX7_NUM_GPTS; i++) {
448
snprintf(name, NAME_SIZE, "gpt%d", i);
449
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj)
450
*/
451
object_initialize_child(obj, "gpcv2", &s->gpcv2, TYPE_IMX_GPCV2);
452
453
+ /*
454
+ * ECSPIs
455
+ */
456
for (i = 0; i < FSL_IMX7_NUM_ECSPIS; i++) {
457
snprintf(name, NAME_SIZE, "spi%d", i + 1);
458
object_initialize_child(obj, name, &s->spi[i], TYPE_IMX_SPI);
459
}
460
461
-
462
+ /*
463
+ * I2Cs
464
+ */
465
for (i = 0; i < FSL_IMX7_NUM_I2CS; i++) {
466
snprintf(name, NAME_SIZE, "i2c%d", i + 1);
467
object_initialize_child(obj, name, &s->i2c[i], TYPE_IMX_I2C);
468
}
469
470
/*
471
- * UART
472
+ * UARTs
473
*/
474
for (i = 0; i < FSL_IMX7_NUM_UARTS; i++) {
475
snprintf(name, NAME_SIZE, "uart%d", i);
476
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj)
477
}
478
479
/*
480
- * Ethernet
481
+ * Ethernets
482
*/
483
for (i = 0; i < FSL_IMX7_NUM_ETHS; i++) {
484
snprintf(name, NAME_SIZE, "eth%d", i);
485
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj)
486
}
487
488
/*
489
- * SDHCI
490
+ * SDHCIs
491
*/
492
for (i = 0; i < FSL_IMX7_NUM_USDHCS; i++) {
493
snprintf(name, NAME_SIZE, "usdhc%d", i);
494
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj)
495
object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS);
496
497
/*
498
- * Watchdog
499
+ * Watchdogs
500
*/
501
for (i = 0; i < FSL_IMX7_NUM_WDTS; i++) {
502
snprintf(name, NAME_SIZE, "wdt%d", i);
503
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj)
504
*/
505
object_initialize_child(obj, "gpr", &s->gpr, TYPE_IMX7_GPR);
506
507
+ /*
508
+ * PCIE
509
+ */
510
object_initialize_child(obj, "pcie", &s->pcie, TYPE_DESIGNWARE_PCIE_HOST);
511
512
+ /*
513
+ * USBs
514
+ */
515
for (i = 0; i < FSL_IMX7_NUM_USBS; i++) {
516
snprintf(name, NAME_SIZE, "usb%d", i);
517
object_initialize_child(obj, name, &s->usb[i], TYPE_CHIPIDEA);
518
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
519
return;
520
}
521
522
+ /*
523
+ * CPUs
524
+ */
525
for (i = 0; i < smp_cpus; i++) {
526
o = OBJECT(&s->cpu[i]);
527
528
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
529
* A7MPCORE DAP
530
*/
531
create_unimplemented_device("a7mpcore-dap", FSL_IMX7_A7MPCORE_DAP_ADDR,
532
- 0x100000);
533
+ FSL_IMX7_A7MPCORE_DAP_SIZE);
534
535
/*
536
- * GPT1, 2, 3, 4
537
+ * GPTs
538
*/
539
for (i = 0; i < FSL_IMX7_NUM_GPTS; i++) {
540
static const hwaddr FSL_IMX7_GPTn_ADDR[FSL_IMX7_NUM_GPTS] = {
541
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
542
FSL_IMX7_GPTn_IRQ[i]));
543
}
544
545
+ /*
546
+ * GPIOs
547
+ */
548
for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) {
549
static const hwaddr FSL_IMX7_GPIOn_ADDR[FSL_IMX7_NUM_GPIOS] = {
550
FSL_IMX7_GPIO1_ADDR,
551
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
552
/*
553
* IOMUXC and IOMUXC_LPSR
554
*/
555
- for (i = 0; i < FSL_IMX7_NUM_IOMUXCS; i++) {
556
- static const hwaddr FSL_IMX7_IOMUXCn_ADDR[FSL_IMX7_NUM_IOMUXCS] = {
557
- FSL_IMX7_IOMUXC_ADDR,
558
- FSL_IMX7_IOMUXC_LPSR_ADDR,
559
- };
560
-
561
- snprintf(name, NAME_SIZE, "iomuxc%d", i);
562
- create_unimplemented_device(name, FSL_IMX7_IOMUXCn_ADDR[i],
563
- FSL_IMX7_IOMUXCn_SIZE);
564
- }
565
+ create_unimplemented_device("iomuxc", FSL_IMX7_IOMUXC_ADDR,
566
+ FSL_IMX7_IOMUXC_SIZE);
567
+ create_unimplemented_device("iomuxc_lspr", FSL_IMX7_IOMUXC_LPSR_ADDR,
568
+ FSL_IMX7_IOMUXC_LPSR_SIZE);
569
570
/*
571
* CCM
572
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
573
sysbus_realize(SYS_BUS_DEVICE(&s->gpcv2), &error_abort);
574
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpcv2), 0, FSL_IMX7_GPC_ADDR);
575
576
- /* Initialize all ECSPI */
577
+ /*
578
+ * ECSPIs
579
+ */
580
for (i = 0; i < FSL_IMX7_NUM_ECSPIS; i++) {
581
static const hwaddr FSL_IMX7_SPIn_ADDR[FSL_IMX7_NUM_ECSPIS] = {
582
FSL_IMX7_ECSPI1_ADDR,
583
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
584
FSL_IMX7_SPIn_IRQ[i]));
585
}
586
587
+ /*
588
+ * I2Cs
589
+ */
590
for (i = 0; i < FSL_IMX7_NUM_I2CS; i++) {
591
static const hwaddr FSL_IMX7_I2Cn_ADDR[FSL_IMX7_NUM_I2CS] = {
592
FSL_IMX7_I2C1_ADDR,
593
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
594
}
595
596
/*
597
- * UART
598
+ * UARTs
599
*/
600
for (i = 0; i < FSL_IMX7_NUM_UARTS; i++) {
601
static const hwaddr FSL_IMX7_UARTn_ADDR[FSL_IMX7_NUM_UARTS] = {
602
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
603
}
604
605
/*
606
- * Ethernet
607
+ * Ethernets
608
*
609
* We must use two loops since phy_connected affects the other interface
610
* and we have to set all properties before calling sysbus_realize().
611
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
612
}
613
614
/*
615
- * USDHC
616
+ * USDHCs
617
*/
618
for (i = 0; i < FSL_IMX7_NUM_USDHCS; i++) {
619
static const hwaddr FSL_IMX7_USDHCn_ADDR[FSL_IMX7_NUM_USDHCS] = {
620
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
621
* SNVS
622
*/
623
sysbus_realize(SYS_BUS_DEVICE(&s->snvs), &error_abort);
624
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX7_SNVS_ADDR);
625
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX7_SNVS_HP_ADDR);
626
627
/*
628
* SRC
629
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
630
create_unimplemented_device("src", FSL_IMX7_SRC_ADDR, FSL_IMX7_SRC_SIZE);
631
632
/*
633
- * Watchdog
634
+ * Watchdogs
635
*/
636
for (i = 0; i < FSL_IMX7_NUM_WDTS; i++) {
637
static const hwaddr FSL_IMX7_WDOGn_ADDR[FSL_IMX7_NUM_WDTS] = {
638
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
639
create_unimplemented_device("caam", FSL_IMX7_CAAM_ADDR, FSL_IMX7_CAAM_SIZE);
640
641
/*
642
- * PWM
643
+ * PWMs
644
*/
645
- create_unimplemented_device("pwm1", FSL_IMX7_PWM1_ADDR, FSL_IMX7_PWMn_SIZE);
646
- create_unimplemented_device("pwm2", FSL_IMX7_PWM2_ADDR, FSL_IMX7_PWMn_SIZE);
647
- create_unimplemented_device("pwm3", FSL_IMX7_PWM3_ADDR, FSL_IMX7_PWMn_SIZE);
648
- create_unimplemented_device("pwm4", FSL_IMX7_PWM4_ADDR, FSL_IMX7_PWMn_SIZE);
649
+ for (i = 0; i < FSL_IMX7_NUM_PWMS; i++) {
650
+ static const hwaddr FSL_IMX7_PWMn_ADDR[FSL_IMX7_NUM_PWMS] = {
651
+ FSL_IMX7_PWM1_ADDR,
652
+ FSL_IMX7_PWM2_ADDR,
653
+ FSL_IMX7_PWM3_ADDR,
654
+ FSL_IMX7_PWM4_ADDR,
655
+ };
656
+
657
+ snprintf(name, NAME_SIZE, "pwm%d", i);
658
+ create_unimplemented_device(name, FSL_IMX7_PWMn_ADDR[i],
659
+ FSL_IMX7_PWMn_SIZE);
660
+ }
661
662
/*
663
- * CAN
664
+ * CANs
665
*/
666
- create_unimplemented_device("can1", FSL_IMX7_CAN1_ADDR, FSL_IMX7_CANn_SIZE);
667
- create_unimplemented_device("can2", FSL_IMX7_CAN2_ADDR, FSL_IMX7_CANn_SIZE);
668
+ for (i = 0; i < FSL_IMX7_NUM_CANS; i++) {
669
+ static const hwaddr FSL_IMX7_CANn_ADDR[FSL_IMX7_NUM_CANS] = {
670
+ FSL_IMX7_CAN1_ADDR,
671
+ FSL_IMX7_CAN2_ADDR,
672
+ };
673
+
674
+ snprintf(name, NAME_SIZE, "can%d", i);
675
+ create_unimplemented_device(name, FSL_IMX7_CANn_ADDR[i],
676
+ FSL_IMX7_CANn_SIZE);
677
+ }
678
679
/*
680
- * SAI (Audio SSI (Synchronous Serial Interface))
681
+ * SAIs (Audio SSI (Synchronous Serial Interface))
682
*/
683
- create_unimplemented_device("sai1", FSL_IMX7_SAI1_ADDR, FSL_IMX7_SAIn_SIZE);
684
- create_unimplemented_device("sai2", FSL_IMX7_SAI2_ADDR, FSL_IMX7_SAIn_SIZE);
685
- create_unimplemented_device("sai2", FSL_IMX7_SAI3_ADDR, FSL_IMX7_SAIn_SIZE);
686
+ for (i = 0; i < FSL_IMX7_NUM_SAIS; i++) {
687
+ static const hwaddr FSL_IMX7_SAIn_ADDR[FSL_IMX7_NUM_SAIS] = {
688
+ FSL_IMX7_SAI1_ADDR,
689
+ FSL_IMX7_SAI2_ADDR,
690
+ FSL_IMX7_SAI3_ADDR,
691
+ };
692
+
693
+ snprintf(name, NAME_SIZE, "sai%d", i);
694
+ create_unimplemented_device(name, FSL_IMX7_SAIn_ADDR[i],
695
+ FSL_IMX7_SAIn_SIZE);
696
+ }
697
698
/*
699
* OCOTP
700
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
701
create_unimplemented_device("ocotp", FSL_IMX7_OCOTP_ADDR,
702
FSL_IMX7_OCOTP_SIZE);
703
704
+ /*
705
+ * GPR
706
+ */
707
sysbus_realize(SYS_BUS_DEVICE(&s->gpr), &error_abort);
708
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX7_GPR_ADDR);
709
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX7_IOMUXC_GPR_ADDR);
710
711
+ /*
712
+ * PCIE
713
+ */
714
sysbus_realize(SYS_BUS_DEVICE(&s->pcie), &error_abort);
715
sysbus_mmio_map(SYS_BUS_DEVICE(&s->pcie), 0, FSL_IMX7_PCIE_REG_ADDR);
716
717
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
718
irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTD_IRQ);
719
sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 3, irq);
720
721
-
722
+ /*
723
+ * USBs
724
+ */
725
for (i = 0; i < FSL_IMX7_NUM_USBS; i++) {
726
static const hwaddr FSL_IMX7_USBMISCn_ADDR[FSL_IMX7_NUM_USBS] = {
727
FSL_IMX7_USBMISC1_ADDR,
728
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
729
*/
730
create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR,
731
FSL_IMX7_PCIE_PHY_SIZE);
732
+
45
}
733
}
46
734
47
static void fsl_imx7_class_init(ObjectClass *oc, void *data)
735
static Property fsl_imx7_properties[] = {
48
--
736
--
49
2.20.1
737
2.34.1
50
51
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: Jean-Christophe Dubois <jcd@tribudubois.net>
2
2
3
Add no-op/unimplemented PCIE PHY IP block. Needed by new kernels to
3
* Add TZASC as unimplemented device.
4
use PCIE.
4
- Allow bare metal application to access this (unimplemented) device
5
* Add CSU as unimplemented device.
6
- Allow bare metal application to access this (unimplemented) device
7
* Add various memory segments
8
- OCRAM
9
- OCRAM EPDC
10
- OCRAM PXP
11
- OCRAM S
12
- ROM
13
- CAAM
5
14
6
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
15
Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
7
Cc: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Cc: Michael S. Tsirkin <mst@redhat.com>
17
Message-id: f887a3483996ba06d40bd62ffdfb0ecf68621987.1692964892.git.jcd@tribudubois.net
9
Cc: qemu-devel@nongnu.org
10
Cc: qemu-arm@nongnu.org
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
19
---
14
include/hw/arm/fsl-imx7.h | 3 +++
20
include/hw/arm/fsl-imx7.h | 7 +++++
15
hw/arm/fsl-imx7.c | 5 +++++
21
hw/arm/fsl-imx7.c | 63 +++++++++++++++++++++++++++++++++++++++
16
2 files changed, 8 insertions(+)
22
2 files changed, 70 insertions(+)
17
23
18
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
24
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
19
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/arm/fsl-imx7.h
26
--- a/include/hw/arm/fsl-imx7.h
21
+++ b/include/hw/arm/fsl-imx7.h
27
+++ b/include/hw/arm/fsl-imx7.h
22
@@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap {
28
@@ -XXX,XX +XXX,XX @@ struct FslIMX7State {
23
FSL_IMX7_ADC2_ADDR = 0x30620000,
29
IMX7GPRState gpr;
24
FSL_IMX7_ADCn_SIZE = 0x1000,
30
ChipideaState usb[FSL_IMX7_NUM_USBS];
25
31
DesignwarePCIEHost pcie;
26
+ FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000,
32
+ MemoryRegion rom;
27
+ FSL_IMX7_PCIE_PHY_SIZE = 0x10000,
33
+ MemoryRegion caam;
34
+ MemoryRegion ocram;
35
+ MemoryRegion ocram_epdc;
36
+ MemoryRegion ocram_pxp;
37
+ MemoryRegion ocram_s;
28
+
38
+
29
FSL_IMX7_GPC_ADDR = 0x303A0000,
39
uint32_t phy_num[FSL_IMX7_NUM_ETHS];
30
40
bool phy_connected[FSL_IMX7_NUM_ETHS];
31
FSL_IMX7_I2C1_ADDR = 0x30A20000,
41
};
32
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
42
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
33
index XXXXXXX..XXXXXXX 100644
43
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/arm/fsl-imx7.c
44
--- a/hw/arm/fsl-imx7.c
35
+++ b/hw/arm/fsl-imx7.c
45
+++ b/hw/arm/fsl-imx7.c
36
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
46
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
37
*/
47
create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR,
38
create_unimplemented_device("dma-apbh", FSL_IMX7_DMA_APBH_ADDR,
48
FSL_IMX7_PCIE_PHY_SIZE);
39
FSL_IMX7_DMA_APBH_SIZE);
49
40
+ /*
50
+ /*
41
+ * PCIe PHY
51
+ * CSU
42
+ */
52
+ */
43
+ create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR,
53
+ create_unimplemented_device("csu", FSL_IMX7_CSU_ADDR,
44
+ FSL_IMX7_PCIE_PHY_SIZE);
54
+ FSL_IMX7_CSU_SIZE);
55
+
56
+ /*
57
+ * TZASC
58
+ */
59
+ create_unimplemented_device("tzasc", FSL_IMX7_TZASC_ADDR,
60
+ FSL_IMX7_TZASC_SIZE);
61
+
62
+ /*
63
+ * OCRAM memory
64
+ */
65
+ memory_region_init_ram(&s->ocram, NULL, "imx7.ocram",
66
+ FSL_IMX7_OCRAM_MEM_SIZE,
67
+ &error_abort);
68
+ memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_MEM_ADDR,
69
+ &s->ocram);
70
+
71
+ /*
72
+ * OCRAM EPDC memory
73
+ */
74
+ memory_region_init_ram(&s->ocram_epdc, NULL, "imx7.ocram_epdc",
75
+ FSL_IMX7_OCRAM_EPDC_SIZE,
76
+ &error_abort);
77
+ memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_EPDC_ADDR,
78
+ &s->ocram_epdc);
79
+
80
+ /*
81
+ * OCRAM PXP memory
82
+ */
83
+ memory_region_init_ram(&s->ocram_pxp, NULL, "imx7.ocram_pxp",
84
+ FSL_IMX7_OCRAM_PXP_SIZE,
85
+ &error_abort);
86
+ memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_PXP_ADDR,
87
+ &s->ocram_pxp);
88
+
89
+ /*
90
+ * OCRAM_S memory
91
+ */
92
+ memory_region_init_ram(&s->ocram_s, NULL, "imx7.ocram_s",
93
+ FSL_IMX7_OCRAM_S_SIZE,
94
+ &error_abort);
95
+ memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_S_ADDR,
96
+ &s->ocram_s);
97
+
98
+ /*
99
+ * ROM memory
100
+ */
101
+ memory_region_init_rom(&s->rom, OBJECT(dev), "imx7.rom",
102
+ FSL_IMX7_ROM_SIZE, &error_abort);
103
+ memory_region_add_subregion(get_system_memory(), FSL_IMX7_ROM_ADDR,
104
+ &s->rom);
105
+
106
+ /*
107
+ * CAAM memory
108
+ */
109
+ memory_region_init_rom(&s->caam, OBJECT(dev), "imx7.caam",
110
+ FSL_IMX7_CAAM_MEM_SIZE, &error_abort);
111
+ memory_region_add_subregion(get_system_memory(), FSL_IMX7_CAAM_MEM_ADDR,
112
+ &s->caam);
45
}
113
}
46
114
47
static void fsl_imx7_class_init(ObjectClass *oc, void *data)
115
static Property fsl_imx7_properties[] = {
48
--
116
--
49
2.20.1
117
2.34.1
50
118
51
119
diff view generated by jsdifflib
Deleted patch
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
2
1
3
Expression to calculate update_msi_mapping in code handling writes to
4
DESIGNWARE_PCIE_MSI_INTR0_ENABLE is missing an ! operator and should
5
be:
6
7
!!root->msi.intr[0].enable ^ !!val;
8
9
so that MSI mapping is updated when enabled transitions from either
10
"none" -> "any" or "any" -> "none". Since that register shouldn't be
11
written to very often, change the code to update MSI mapping
12
unconditionally instead of trying to fix the update_msi_mapping logic.
13
14
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
15
Cc: Peter Maydell <peter.maydell@linaro.org>
16
Cc: Michael S. Tsirkin <mst@redhat.com>
17
Cc: qemu-devel@nongnu.org
18
Cc: qemu-arm@nongnu.org
19
Acked-by: Michael S. Tsirkin <mst@redhat.com>
20
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
23
hw/pci-host/designware.c | 10 ++--------
24
1 file changed, 2 insertions(+), 8 deletions(-)
25
26
diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
27
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/pci-host/designware.c
29
+++ b/hw/pci-host/designware.c
30
@@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address,
31
root->msi.base |= (uint64_t)val << 32;
32
break;
33
34
- case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: {
35
- const bool update_msi_mapping = !root->msi.intr[0].enable ^ !!val;
36
-
37
+ case DESIGNWARE_PCIE_MSI_INTR0_ENABLE:
38
root->msi.intr[0].enable = val;
39
-
40
- if (update_msi_mapping) {
41
- designware_pcie_root_update_msi_mapping(root);
42
- }
43
+ designware_pcie_root_update_msi_mapping(root);
44
break;
45
- }
46
47
case DESIGNWARE_PCIE_MSI_INTR0_MASK:
48
root->msi.intr[0].mask = val;
49
--
50
2.20.1
51
52
diff view generated by jsdifflib
Deleted patch
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
2
1
3
MSI mapping needs to be update when MSI address changes, so add the
4
code to do so.
5
6
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
7
Cc: Peter Maydell <peter.maydell@linaro.org>
8
Cc: Michael S. Tsirkin <mst@redhat.com>
9
Cc: qemu-devel@nongnu.org
10
Cc: qemu-arm@nongnu.org
11
Acked-by: Michael S. Tsirkin <mst@redhat.com>
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
hw/pci-host/designware.c | 2 ++
16
1 file changed, 2 insertions(+)
17
18
diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/pci-host/designware.c
21
+++ b/hw/pci-host/designware.c
22
@@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address,
23
case DESIGNWARE_PCIE_MSI_ADDR_LO:
24
root->msi.base &= 0xFFFFFFFF00000000ULL;
25
root->msi.base |= val;
26
+ designware_pcie_root_update_msi_mapping(root);
27
break;
28
29
case DESIGNWARE_PCIE_MSI_ADDR_HI:
30
root->msi.base &= 0x00000000FFFFFFFFULL;
31
root->msi.base |= (uint64_t)val << 32;
32
+ designware_pcie_root_update_msi_mapping(root);
33
break;
34
35
case DESIGNWARE_PCIE_MSI_INTR0_ENABLE:
36
--
37
2.20.1
38
39
diff view generated by jsdifflib
1
From: Eddie James <eajames@linux.ibm.com>
1
From: Jean-Christophe Dubois <jcd@tribudubois.net>
2
2
3
The XDMA engine embedded in the Aspeed SOCs performs PCI DMA operations
3
The SRC device is normally used to start the secondary CPU.
4
between the SOC (acting as a BMC) and a host processor in a server.
4
5
5
When running Linux directly, QEMU is emulating a PSCI interface that UBOOT
6
The XDMA engine exists on the AST2400, AST2500, and AST2600 SOCs, so
6
is installing at boot time and therefore the fact that the SRC device is
7
enable it for all of those. Add trace events on the important register
7
unimplemented is hidden as Qemu respond directly to PSCI requets without
8
writes in the XDMA engine.
8
using the SRC device.
9
9
10
Signed-off-by: Eddie James <eajames@linux.ibm.com>
10
But if you try to run a more bare metal application (maybe uboot itself),
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
then it is not possible to start the secondary CPU as the SRC is an
12
Signed-off-by: Cédric Le Goater <clg@kaod.org>
12
unimplemented device.
13
Message-id: 20190618165311.27066-21-clg@kaod.org
13
14
[clg: - changed title ]
14
This patch adds the ability to start the secondary CPU through the SRC
15
Signed-off-by: Cédric Le Goater <clg@kaod.org>
15
device so that you can use this feature in bare metal applications.
16
17
Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
Message-id: ce9a0162defd2acee5dc7f8a674743de0cded569.1692964892.git.jcd@tribudubois.net
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
21
---
18
hw/misc/Makefile.objs | 1 +
22
include/hw/arm/fsl-imx7.h | 3 +-
19
include/hw/arm/aspeed_soc.h | 3 +
23
include/hw/misc/imx7_src.h | 66 +++++++++
20
include/hw/misc/aspeed_xdma.h | 30 +++++++
24
hw/arm/fsl-imx7.c | 8 +-
21
hw/arm/aspeed_soc.c | 17 ++++
25
hw/misc/imx7_src.c | 276 +++++++++++++++++++++++++++++++++++++
22
hw/misc/aspeed_xdma.c | 165 ++++++++++++++++++++++++++++++++++
26
hw/misc/meson.build | 1 +
23
hw/misc/trace-events | 3 +
27
hw/misc/trace-events | 4 +
24
6 files changed, 219 insertions(+)
28
6 files changed, 356 insertions(+), 2 deletions(-)
25
create mode 100644 include/hw/misc/aspeed_xdma.h
29
create mode 100644 include/hw/misc/imx7_src.h
26
create mode 100644 hw/misc/aspeed_xdma.c
30
create mode 100644 hw/misc/imx7_src.c
27
31
28
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
32
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
29
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/misc/Makefile.objs
34
--- a/include/hw/arm/fsl-imx7.h
31
+++ b/hw/misc/Makefile.objs
35
+++ b/include/hw/arm/fsl-imx7.h
32
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_ARMSSE_MHU) += armsse-mhu.o
33
34
obj-$(CONFIG_PVPANIC) += pvpanic.o
35
obj-$(CONFIG_AUX) += auxbus.o
36
+obj-$(CONFIG_ASPEED_SOC) += aspeed_xdma.o
37
obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o
38
obj-$(CONFIG_MSF2) += msf2-sysreg.o
39
obj-$(CONFIG_NRF51_SOC) += nrf51_rng.o
40
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
41
index XXXXXXX..XXXXXXX 100644
42
--- a/include/hw/arm/aspeed_soc.h
43
+++ b/include/hw/arm/aspeed_soc.h
44
@@ -XXX,XX +XXX,XX @@
36
@@ -XXX,XX +XXX,XX @@
45
#include "hw/intc/aspeed_vic.h"
37
#include "hw/misc/imx7_ccm.h"
46
#include "hw/misc/aspeed_scu.h"
38
#include "hw/misc/imx7_snvs.h"
47
#include "hw/misc/aspeed_sdmc.h"
39
#include "hw/misc/imx7_gpr.h"
48
+#include "hw/misc/aspeed_xdma.h"
40
+#include "hw/misc/imx7_src.h"
49
#include "hw/timer/aspeed_timer.h"
41
#include "hw/watchdog/wdt_imx2.h"
50
#include "hw/timer/aspeed_rtc.h"
42
#include "hw/gpio/imx_gpio.h"
51
#include "hw/i2c/aspeed_i2c.h"
43
#include "hw/char/imx_serial.h"
52
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState {
44
@@ -XXX,XX +XXX,XX @@ struct FslIMX7State {
53
AspeedTimerCtrlState timerctrl;
45
IMX7CCMState ccm;
54
AspeedI2CState i2c;
46
IMX7AnalogState analog;
55
AspeedSCUState scu;
47
IMX7SNVSState snvs;
56
+ AspeedXDMAState xdma;
48
+ IMX7SRCState src;
57
AspeedSMCState fmc;
49
IMXGPCv2State gpcv2;
58
AspeedSMCState spi[ASPEED_SPIS_NUM];
50
IMXSPIState spi[FSL_IMX7_NUM_ECSPIS];
59
AspeedSDMCState sdmc;
51
IMXI2CState i2c[FSL_IMX7_NUM_I2CS];
60
@@ -XXX,XX +XXX,XX @@ enum {
52
@@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap {
61
ASPEED_ETH1,
53
FSL_IMX7_GPC_ADDR = 0x303A0000,
62
ASPEED_ETH2,
54
63
ASPEED_SDRAM,
55
FSL_IMX7_SRC_ADDR = 0x30390000,
64
+ ASPEED_XDMA,
56
- FSL_IMX7_SRC_SIZE = (4 * KiB),
65
};
57
66
58
FSL_IMX7_CCM_ADDR = 0x30380000,
67
#endif /* ASPEED_SOC_H */
59
68
diff --git a/include/hw/misc/aspeed_xdma.h b/include/hw/misc/aspeed_xdma.h
60
diff --git a/include/hw/misc/imx7_src.h b/include/hw/misc/imx7_src.h
69
new file mode 100644
61
new file mode 100644
70
index XXXXXXX..XXXXXXX
62
index XXXXXXX..XXXXXXX
71
--- /dev/null
63
--- /dev/null
72
+++ b/include/hw/misc/aspeed_xdma.h
64
+++ b/include/hw/misc/imx7_src.h
73
@@ -XXX,XX +XXX,XX @@
65
@@ -XXX,XX +XXX,XX @@
74
+/*
66
+/*
75
+ * ASPEED XDMA Controller
67
+ * IMX7 System Reset Controller
76
+ * Eddie James <eajames@linux.ibm.com>
77
+ *
68
+ *
78
+ * Copyright (C) 2019 IBM Corp.
69
+ * Copyright (C) 2023 Jean-Christophe Dubois <jcd@tribudubois.net>
79
+ * SPDX-License-Identifer: GPL-2.0-or-later
70
+ *
71
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
72
+ * See the COPYING file in the top-level directory.
80
+ */
73
+ */
81
+
74
+
82
+#ifndef ASPEED_XDMA_H
75
+#ifndef IMX7_SRC_H
83
+#define ASPEED_XDMA_H
76
+#define IMX7_SRC_H
84
+
77
+
85
+#include "hw/sysbus.h"
78
+#include "hw/sysbus.h"
86
+
79
+#include "qemu/bitops.h"
87
+#define TYPE_ASPEED_XDMA "aspeed.xdma"
80
+#include "qom/object.h"
88
+#define ASPEED_XDMA(obj) OBJECT_CHECK(AspeedXDMAState, (obj), TYPE_ASPEED_XDMA)
81
+
89
+
82
+#define SRC_SCR 0
90
+#define ASPEED_XDMA_NUM_REGS (ASPEED_XDMA_REG_SIZE / sizeof(uint32_t))
83
+#define SRC_A7RCR0 1
91
+#define ASPEED_XDMA_REG_SIZE 0x7C
84
+#define SRC_A7RCR1 2
92
+
85
+#define SRC_M4RCR 3
93
+typedef struct AspeedXDMAState {
86
+#define SRC_ERCR 5
94
+ SysBusDevice parent;
87
+#define SRC_HSICPHY_RCR 7
95
+
88
+#define SRC_USBOPHY1_RCR 8
89
+#define SRC_USBOPHY2_RCR 9
90
+#define SRC_MPIPHY_RCR 10
91
+#define SRC_PCIEPHY_RCR 11
92
+#define SRC_SBMR1 22
93
+#define SRC_SRSR 23
94
+#define SRC_SISR 26
95
+#define SRC_SIMR 27
96
+#define SRC_SBMR2 28
97
+#define SRC_GPR1 29
98
+#define SRC_GPR2 30
99
+#define SRC_GPR3 31
100
+#define SRC_GPR4 32
101
+#define SRC_GPR5 33
102
+#define SRC_GPR6 34
103
+#define SRC_GPR7 35
104
+#define SRC_GPR8 36
105
+#define SRC_GPR9 37
106
+#define SRC_GPR10 38
107
+#define SRC_MAX 39
108
+
109
+/* SRC_A7SCR1 */
110
+#define R_CORE1_ENABLE_SHIFT 1
111
+#define R_CORE1_ENABLE_LENGTH 1
112
+/* SRC_A7SCR0 */
113
+#define R_CORE1_RST_SHIFT 5
114
+#define R_CORE1_RST_LENGTH 1
115
+#define R_CORE0_RST_SHIFT 4
116
+#define R_CORE0_RST_LENGTH 1
117
+
118
+#define TYPE_IMX7_SRC "imx7.src"
119
+OBJECT_DECLARE_SIMPLE_TYPE(IMX7SRCState, IMX7_SRC)
120
+
121
+struct IMX7SRCState {
122
+ /* <private> */
123
+ SysBusDevice parent_obj;
124
+
125
+ /* <public> */
96
+ MemoryRegion iomem;
126
+ MemoryRegion iomem;
97
+ qemu_irq irq;
127
+
98
+
128
+ uint32_t regs[SRC_MAX];
99
+ char bmc_cmdq_readp_set;
129
+};
100
+ uint32_t regs[ASPEED_XDMA_NUM_REGS];
130
+
101
+} AspeedXDMAState;
131
+#endif /* IMX7_SRC_H */
102
+
132
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
103
+#endif /* ASPEED_XDMA_H */
104
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
105
index XXXXXXX..XXXXXXX 100644
133
index XXXXXXX..XXXXXXX 100644
106
--- a/hw/arm/aspeed_soc.c
134
--- a/hw/arm/fsl-imx7.c
107
+++ b/hw/arm/aspeed_soc.c
135
+++ b/hw/arm/fsl-imx7.c
108
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2400_memmap[] = {
136
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj)
109
[ASPEED_VIC] = 0x1E6C0000,
137
*/
110
[ASPEED_SDMC] = 0x1E6E0000,
138
object_initialize_child(obj, "gpcv2", &s->gpcv2, TYPE_IMX_GPCV2);
111
[ASPEED_SCU] = 0x1E6E2000,
139
112
+ [ASPEED_XDMA] = 0x1E6E7000,
140
+ /*
113
[ASPEED_ADC] = 0x1E6E9000,
141
+ * SRC
114
[ASPEED_SRAM] = 0x1E720000,
142
+ */
115
[ASPEED_GPIO] = 0x1E780000,
143
+ object_initialize_child(obj, "src", &s->src, TYPE_IMX7_SRC);
116
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2500_memmap[] = {
144
+
117
[ASPEED_VIC] = 0x1E6C0000,
145
/*
118
[ASPEED_SDMC] = 0x1E6E0000,
146
* ECSPIs
119
[ASPEED_SCU] = 0x1E6E2000,
147
*/
120
+ [ASPEED_XDMA] = 0x1E6E7000,
148
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
121
[ASPEED_ADC] = 0x1E6E9000,
149
/*
122
[ASPEED_SRAM] = 0x1E720000,
150
* SRC
123
[ASPEED_GPIO] = 0x1E780000,
151
*/
124
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2400_irqmap[] = {
152
- create_unimplemented_device("src", FSL_IMX7_SRC_ADDR, FSL_IMX7_SRC_SIZE);
125
[ASPEED_I2C] = 12,
153
+ sysbus_realize(SYS_BUS_DEVICE(&s->src), &error_abort);
126
[ASPEED_ETH1] = 2,
154
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->src), 0, FSL_IMX7_SRC_ADDR);
127
[ASPEED_ETH2] = 3,
155
128
+ [ASPEED_XDMA] = 6,
156
/*
129
};
157
* Watchdogs
130
158
diff --git a/hw/misc/imx7_src.c b/hw/misc/imx7_src.c
131
#define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap
132
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
133
sysbus_init_child_obj(obj, "ftgmac100[*]", OBJECT(&s->ftgmac100[i]),
134
sizeof(s->ftgmac100[i]), TYPE_FTGMAC100);
135
}
136
+
137
+ sysbus_init_child_obj(obj, "xdma", OBJECT(&s->xdma), sizeof(s->xdma),
138
+ TYPE_ASPEED_XDMA);
139
}
140
141
static void aspeed_soc_realize(DeviceState *dev, Error **errp)
142
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
143
sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0,
144
aspeed_soc_get_irq(s, ASPEED_ETH1 + i));
145
}
146
+
147
+ /* XDMA */
148
+ object_property_set_bool(OBJECT(&s->xdma), true, "realized", &err);
149
+ if (err) {
150
+ error_propagate(errp, err);
151
+ return;
152
+ }
153
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->xdma), 0,
154
+ sc->info->memmap[ASPEED_XDMA]);
155
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0,
156
+ aspeed_soc_get_irq(s, ASPEED_XDMA));
157
}
158
static Property aspeed_soc_properties[] = {
159
DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0),
160
diff --git a/hw/misc/aspeed_xdma.c b/hw/misc/aspeed_xdma.c
161
new file mode 100644
159
new file mode 100644
162
index XXXXXXX..XXXXXXX
160
index XXXXXXX..XXXXXXX
163
--- /dev/null
161
--- /dev/null
164
+++ b/hw/misc/aspeed_xdma.c
162
+++ b/hw/misc/imx7_src.c
165
@@ -XXX,XX +XXX,XX @@
163
@@ -XXX,XX +XXX,XX @@
166
+/*
164
+/*
167
+ * ASPEED XDMA Controller
165
+ * IMX7 System Reset Controller
168
+ * Eddie James <eajames@linux.ibm.com>
169
+ *
166
+ *
170
+ * Copyright (C) 2019 IBM Corp
167
+ * Copyright (c) 2023 Jean-Christophe Dubois <jcd@tribudubois.net>
171
+ * SPDX-License-Identifer: GPL-2.0-or-later
168
+ *
169
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
170
+ * See the COPYING file in the top-level directory.
171
+ *
172
+ */
172
+ */
173
+
173
+
174
+#include "qemu/osdep.h"
174
+#include "qemu/osdep.h"
175
+#include "hw/misc/imx7_src.h"
176
+#include "migration/vmstate.h"
177
+#include "qemu/bitops.h"
175
+#include "qemu/log.h"
178
+#include "qemu/log.h"
176
+#include "qemu/error-report.h"
179
+#include "qemu/main-loop.h"
177
+#include "hw/misc/aspeed_xdma.h"
180
+#include "qemu/module.h"
178
+#include "qapi/error.h"
181
+#include "target/arm/arm-powerctl.h"
182
+#include "hw/core/cpu.h"
183
+#include "hw/registerfields.h"
179
+
184
+
180
+#include "trace.h"
185
+#include "trace.h"
181
+
186
+
182
+#define XDMA_BMC_CMDQ_ADDR 0x10
187
+static const char *imx7_src_reg_name(uint32_t reg)
183
+#define XDMA_BMC_CMDQ_ENDP 0x14
188
+{
184
+#define XDMA_BMC_CMDQ_WRP 0x18
189
+ static char unknown[20];
185
+#define XDMA_BMC_CMDQ_W_MASK 0x0003FFFF
190
+
186
+#define XDMA_BMC_CMDQ_RDP 0x1C
191
+ switch (reg) {
187
+#define XDMA_BMC_CMDQ_RDP_MAGIC 0xEE882266
192
+ case SRC_SCR:
188
+#define XDMA_IRQ_ENG_CTRL 0x20
193
+ return "SRC_SCR";
189
+#define XDMA_IRQ_ENG_CTRL_US_COMP BIT(4)
194
+ case SRC_A7RCR0:
190
+#define XDMA_IRQ_ENG_CTRL_DS_COMP BIT(5)
195
+ return "SRC_A7RCR0";
191
+#define XDMA_IRQ_ENG_CTRL_W_MASK 0xBFEFF07F
196
+ case SRC_A7RCR1:
192
+#define XDMA_IRQ_ENG_STAT 0x24
197
+ return "SRC_A7RCR1";
193
+#define XDMA_IRQ_ENG_STAT_US_COMP BIT(4)
198
+ case SRC_M4RCR:
194
+#define XDMA_IRQ_ENG_STAT_DS_COMP BIT(5)
199
+ return "SRC_M4RCR";
195
+#define XDMA_IRQ_ENG_STAT_RESET 0xF8000000
200
+ case SRC_ERCR:
196
+#define XDMA_MEM_SIZE 0x1000
201
+ return "SRC_ERCR";
197
+
202
+ case SRC_HSICPHY_RCR:
198
+#define TO_REG(addr) ((addr) / sizeof(uint32_t))
203
+ return "SRC_HSICPHY_RCR";
199
+
204
+ case SRC_USBOPHY1_RCR:
200
+static uint64_t aspeed_xdma_read(void *opaque, hwaddr addr, unsigned int size)
205
+ return "SRC_USBOPHY1_RCR";
201
+{
206
+ case SRC_USBOPHY2_RCR:
202
+ uint32_t val = 0;
207
+ return "SRC_USBOPHY2_RCR";
203
+ AspeedXDMAState *xdma = opaque;
208
+ case SRC_PCIEPHY_RCR:
204
+
209
+ return "SRC_PCIEPHY_RCR";
205
+ if (addr < ASPEED_XDMA_REG_SIZE) {
210
+ case SRC_SBMR1:
206
+ val = xdma->regs[TO_REG(addr)];
211
+ return "SRC_SBMR1";
212
+ case SRC_SRSR:
213
+ return "SRC_SRSR";
214
+ case SRC_SISR:
215
+ return "SRC_SISR";
216
+ case SRC_SIMR:
217
+ return "SRC_SIMR";
218
+ case SRC_SBMR2:
219
+ return "SRC_SBMR2";
220
+ case SRC_GPR1:
221
+ return "SRC_GPR1";
222
+ case SRC_GPR2:
223
+ return "SRC_GPR2";
224
+ case SRC_GPR3:
225
+ return "SRC_GPR3";
226
+ case SRC_GPR4:
227
+ return "SRC_GPR4";
228
+ case SRC_GPR5:
229
+ return "SRC_GPR5";
230
+ case SRC_GPR6:
231
+ return "SRC_GPR6";
232
+ case SRC_GPR7:
233
+ return "SRC_GPR7";
234
+ case SRC_GPR8:
235
+ return "SRC_GPR8";
236
+ case SRC_GPR9:
237
+ return "SRC_GPR9";
238
+ case SRC_GPR10:
239
+ return "SRC_GPR10";
240
+ default:
241
+ sprintf(unknown, "%u ?", reg);
242
+ return unknown;
207
+ }
243
+ }
208
+
244
+}
209
+ return (uint64_t)val;
245
+
210
+}
246
+static const VMStateDescription vmstate_imx7_src = {
211
+
247
+ .name = TYPE_IMX7_SRC,
212
+static void aspeed_xdma_write(void *opaque, hwaddr addr, uint64_t val,
248
+ .version_id = 1,
213
+ unsigned int size)
249
+ .minimum_version_id = 1,
214
+{
250
+ .fields = (VMStateField[]) {
215
+ unsigned int idx;
251
+ VMSTATE_UINT32_ARRAY(regs, IMX7SRCState, SRC_MAX),
216
+ uint32_t val32 = (uint32_t)val;
252
+ VMSTATE_END_OF_LIST()
217
+ AspeedXDMAState *xdma = opaque;
253
+ },
218
+
254
+};
219
+ if (addr >= ASPEED_XDMA_REG_SIZE) {
255
+
256
+static void imx7_src_reset(DeviceState *dev)
257
+{
258
+ IMX7SRCState *s = IMX7_SRC(dev);
259
+
260
+ memset(s->regs, 0, sizeof(s->regs));
261
+
262
+ /* Set reset values */
263
+ s->regs[SRC_SCR] = 0xA0;
264
+ s->regs[SRC_SRSR] = 0x1;
265
+ s->regs[SRC_SIMR] = 0x1F;
266
+}
267
+
268
+static uint64_t imx7_src_read(void *opaque, hwaddr offset, unsigned size)
269
+{
270
+ uint32_t value = 0;
271
+ IMX7SRCState *s = (IMX7SRCState *)opaque;
272
+ uint32_t index = offset >> 2;
273
+
274
+ if (index < SRC_MAX) {
275
+ value = s->regs[index];
276
+ } else {
277
+ qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%"
278
+ HWADDR_PRIx "\n", TYPE_IMX7_SRC, __func__, offset);
279
+ }
280
+
281
+ trace_imx7_src_read(imx7_src_reg_name(index), value);
282
+
283
+ return value;
284
+}
285
+
286
+
287
+/*
288
+ * The reset is asynchronous so we need to defer clearing the reset
289
+ * bit until the work is completed.
290
+ */
291
+
292
+struct SRCSCRResetInfo {
293
+ IMX7SRCState *s;
294
+ uint32_t reset_bit;
295
+};
296
+
297
+static void imx7_clear_reset_bit(CPUState *cpu, run_on_cpu_data data)
298
+{
299
+ struct SRCSCRResetInfo *ri = data.host_ptr;
300
+ IMX7SRCState *s = ri->s;
301
+
302
+ assert(qemu_mutex_iothread_locked());
303
+
304
+ s->regs[SRC_A7RCR0] = deposit32(s->regs[SRC_A7RCR0], ri->reset_bit, 1, 0);
305
+
306
+ trace_imx7_src_write(imx7_src_reg_name(SRC_A7RCR0), s->regs[SRC_A7RCR0]);
307
+
308
+ g_free(ri);
309
+}
310
+
311
+static void imx7_defer_clear_reset_bit(uint32_t cpuid,
312
+ IMX7SRCState *s,
313
+ uint32_t reset_shift)
314
+{
315
+ struct SRCSCRResetInfo *ri;
316
+ CPUState *cpu = arm_get_cpu_by_id(cpuid);
317
+
318
+ if (!cpu) {
220
+ return;
319
+ return;
221
+ }
320
+ }
222
+
321
+
223
+ switch (addr) {
322
+ ri = g_new(struct SRCSCRResetInfo, 1);
224
+ case XDMA_BMC_CMDQ_ENDP:
323
+ ri->s = s;
225
+ xdma->regs[TO_REG(addr)] = val32 & XDMA_BMC_CMDQ_W_MASK;
324
+ ri->reset_bit = reset_shift;
325
+
326
+ async_run_on_cpu(cpu, imx7_clear_reset_bit, RUN_ON_CPU_HOST_PTR(ri));
327
+}
328
+
329
+
330
+static void imx7_src_write(void *opaque, hwaddr offset, uint64_t value,
331
+ unsigned size)
332
+{
333
+ IMX7SRCState *s = (IMX7SRCState *)opaque;
334
+ uint32_t index = offset >> 2;
335
+ long unsigned int change_mask;
336
+ uint32_t current_value = value;
337
+
338
+ if (index >= SRC_MAX) {
339
+ qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%"
340
+ HWADDR_PRIx "\n", TYPE_IMX7_SRC, __func__, offset);
341
+ return;
342
+ }
343
+
344
+ trace_imx7_src_write(imx7_src_reg_name(SRC_A7RCR0), s->regs[SRC_A7RCR0]);
345
+
346
+ change_mask = s->regs[index] ^ (uint32_t)current_value;
347
+
348
+ switch (index) {
349
+ case SRC_A7RCR0:
350
+ if (FIELD_EX32(change_mask, CORE0, RST)) {
351
+ arm_reset_cpu(0);
352
+ imx7_defer_clear_reset_bit(0, s, R_CORE0_RST_SHIFT);
353
+ }
354
+ if (FIELD_EX32(change_mask, CORE1, RST)) {
355
+ arm_reset_cpu(1);
356
+ imx7_defer_clear_reset_bit(1, s, R_CORE1_RST_SHIFT);
357
+ }
358
+ s->regs[index] = current_value;
226
+ break;
359
+ break;
227
+ case XDMA_BMC_CMDQ_WRP:
360
+ case SRC_A7RCR1:
228
+ idx = TO_REG(addr);
361
+ /*
229
+ xdma->regs[idx] = val32 & XDMA_BMC_CMDQ_W_MASK;
362
+ * On real hardware when the system reset controller starts a
230
+ xdma->regs[TO_REG(XDMA_BMC_CMDQ_RDP)] = xdma->regs[idx];
363
+ * secondary CPU it runs through some boot ROM code which reads
231
+
364
+ * the SRC_GPRX registers controlling the start address and branches
232
+ trace_aspeed_xdma_write(addr, val);
365
+ * to it.
233
+
366
+ * Here we are taking a short cut and branching directly to the
234
+ if (xdma->bmc_cmdq_readp_set) {
367
+ * requested address (we don't want to run the boot ROM code inside
235
+ xdma->bmc_cmdq_readp_set = 0;
368
+ * QEMU)
236
+ } else {
369
+ */
237
+ xdma->regs[TO_REG(XDMA_IRQ_ENG_STAT)] |=
370
+ if (FIELD_EX32(change_mask, CORE1, ENABLE)) {
238
+ XDMA_IRQ_ENG_STAT_US_COMP | XDMA_IRQ_ENG_STAT_DS_COMP;
371
+ if (FIELD_EX32(current_value, CORE1, ENABLE)) {
239
+
372
+ /* CORE 1 is brought up */
240
+ if (xdma->regs[TO_REG(XDMA_IRQ_ENG_CTRL)] &
373
+ arm_set_cpu_on(1, s->regs[SRC_GPR3], s->regs[SRC_GPR4],
241
+ (XDMA_IRQ_ENG_CTRL_US_COMP | XDMA_IRQ_ENG_CTRL_DS_COMP))
374
+ 3, false);
242
+ qemu_irq_raise(xdma->irq);
375
+ } else {
376
+ /* CORE 1 is shut down */
377
+ arm_set_cpu_off(1);
378
+ }
379
+ /* We clear the reset bits as the processor changed state */
380
+ imx7_defer_clear_reset_bit(1, s, R_CORE1_RST_SHIFT);
381
+ clear_bit(R_CORE1_RST_SHIFT, &change_mask);
243
+ }
382
+ }
244
+ break;
383
+ s->regs[index] = current_value;
245
+ case XDMA_BMC_CMDQ_RDP:
246
+ trace_aspeed_xdma_write(addr, val);
247
+
248
+ if (val32 == XDMA_BMC_CMDQ_RDP_MAGIC) {
249
+ xdma->bmc_cmdq_readp_set = 1;
250
+ }
251
+ break;
252
+ case XDMA_IRQ_ENG_CTRL:
253
+ xdma->regs[TO_REG(addr)] = val32 & XDMA_IRQ_ENG_CTRL_W_MASK;
254
+ break;
255
+ case XDMA_IRQ_ENG_STAT:
256
+ trace_aspeed_xdma_write(addr, val);
257
+
258
+ idx = TO_REG(addr);
259
+ if (val32 & (XDMA_IRQ_ENG_STAT_US_COMP | XDMA_IRQ_ENG_STAT_DS_COMP)) {
260
+ xdma->regs[idx] &=
261
+ ~(XDMA_IRQ_ENG_STAT_US_COMP | XDMA_IRQ_ENG_STAT_DS_COMP);
262
+ qemu_irq_lower(xdma->irq);
263
+ }
264
+ break;
384
+ break;
265
+ default:
385
+ default:
266
+ xdma->regs[TO_REG(addr)] = val32;
386
+ s->regs[index] = current_value;
267
+ break;
387
+ break;
268
+ }
388
+ }
269
+}
389
+}
270
+
390
+
271
+static const MemoryRegionOps aspeed_xdma_ops = {
391
+static const struct MemoryRegionOps imx7_src_ops = {
272
+ .read = aspeed_xdma_read,
392
+ .read = imx7_src_read,
273
+ .write = aspeed_xdma_write,
393
+ .write = imx7_src_write,
274
+ .endianness = DEVICE_NATIVE_ENDIAN,
394
+ .endianness = DEVICE_NATIVE_ENDIAN,
275
+ .valid.min_access_size = 4,
395
+ .valid = {
276
+ .valid.max_access_size = 4,
396
+ /*
277
+};
397
+ * Our device would not work correctly if the guest was doing
278
+
398
+ * unaligned access. This might not be a limitation on the real
279
+static void aspeed_xdma_realize(DeviceState *dev, Error **errp)
399
+ * device but in practice there is no reason for a guest to access
280
+{
400
+ * this device unaligned.
281
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
401
+ */
282
+ AspeedXDMAState *xdma = ASPEED_XDMA(dev);
402
+ .min_access_size = 4,
283
+
403
+ .max_access_size = 4,
284
+ sysbus_init_irq(sbd, &xdma->irq);
404
+ .unaligned = false,
285
+ memory_region_init_io(&xdma->iomem, OBJECT(xdma), &aspeed_xdma_ops, xdma,
286
+ TYPE_ASPEED_XDMA, XDMA_MEM_SIZE);
287
+ sysbus_init_mmio(sbd, &xdma->iomem);
288
+}
289
+
290
+static void aspeed_xdma_reset(DeviceState *dev)
291
+{
292
+ AspeedXDMAState *xdma = ASPEED_XDMA(dev);
293
+
294
+ xdma->bmc_cmdq_readp_set = 0;
295
+ memset(xdma->regs, 0, ASPEED_XDMA_REG_SIZE);
296
+ xdma->regs[TO_REG(XDMA_IRQ_ENG_STAT)] = XDMA_IRQ_ENG_STAT_RESET;
297
+
298
+ qemu_irq_lower(xdma->irq);
299
+}
300
+
301
+static const VMStateDescription aspeed_xdma_vmstate = {
302
+ .name = TYPE_ASPEED_XDMA,
303
+ .version_id = 1,
304
+ .fields = (VMStateField[]) {
305
+ VMSTATE_UINT32_ARRAY(regs, AspeedXDMAState, ASPEED_XDMA_NUM_REGS),
306
+ VMSTATE_END_OF_LIST(),
307
+ },
405
+ },
308
+};
406
+};
309
+
407
+
310
+static void aspeed_xdma_class_init(ObjectClass *classp, void *data)
408
+static void imx7_src_realize(DeviceState *dev, Error **errp)
311
+{
409
+{
312
+ DeviceClass *dc = DEVICE_CLASS(classp);
410
+ IMX7SRCState *s = IMX7_SRC(dev);
313
+
411
+
314
+ dc->realize = aspeed_xdma_realize;
412
+ memory_region_init_io(&s->iomem, OBJECT(dev), &imx7_src_ops, s,
315
+ dc->reset = aspeed_xdma_reset;
413
+ TYPE_IMX7_SRC, 0x1000);
316
+ dc->vmsd = &aspeed_xdma_vmstate;
414
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
317
+}
415
+}
318
+
416
+
319
+static const TypeInfo aspeed_xdma_info = {
417
+static void imx7_src_class_init(ObjectClass *klass, void *data)
320
+ .name = TYPE_ASPEED_XDMA,
418
+{
419
+ DeviceClass *dc = DEVICE_CLASS(klass);
420
+
421
+ dc->realize = imx7_src_realize;
422
+ dc->reset = imx7_src_reset;
423
+ dc->vmsd = &vmstate_imx7_src;
424
+ dc->desc = "i.MX6 System Reset Controller";
425
+}
426
+
427
+static const TypeInfo imx7_src_info = {
428
+ .name = TYPE_IMX7_SRC,
321
+ .parent = TYPE_SYS_BUS_DEVICE,
429
+ .parent = TYPE_SYS_BUS_DEVICE,
322
+ .instance_size = sizeof(AspeedXDMAState),
430
+ .instance_size = sizeof(IMX7SRCState),
323
+ .class_init = aspeed_xdma_class_init,
431
+ .class_init = imx7_src_class_init,
324
+};
432
+};
325
+
433
+
326
+static void aspeed_xdma_register_type(void)
434
+static void imx7_src_register_types(void)
327
+{
435
+{
328
+ type_register_static(&aspeed_xdma_info);
436
+ type_register_static(&imx7_src_info);
329
+}
437
+}
330
+type_init(aspeed_xdma_register_type);
438
+
439
+type_init(imx7_src_register_types)
440
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
441
index XXXXXXX..XXXXXXX 100644
442
--- a/hw/misc/meson.build
443
+++ b/hw/misc/meson.build
444
@@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_IMX', if_true: files(
445
'imx6_src.c',
446
'imx6ul_ccm.c',
447
'imx7_ccm.c',
448
+ 'imx7_src.c',
449
'imx7_gpr.c',
450
'imx7_snvs.c',
451
'imx_ccm.c',
331
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
452
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
332
index XXXXXXX..XXXXXXX 100644
453
index XXXXXXX..XXXXXXX 100644
333
--- a/hw/misc/trace-events
454
--- a/hw/misc/trace-events
334
+++ b/hw/misc/trace-events
455
+++ b/hw/misc/trace-events
335
@@ -XXX,XX +XXX,XX @@ armsse_cpuid_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 CPU_I
456
@@ -XXX,XX +XXX,XX @@ ccm_clock_freq(uint32_t clock, uint32_t freq) "(Clock = %d) = %d"
336
# armsse-mhu.c
457
ccm_read_reg(const char *reg_name, uint32_t value) "reg[%s] <= 0x%" PRIx32
337
armsse_mhu_read(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
458
ccm_write_reg(const char *reg_name, uint32_t value) "reg[%s] => 0x%" PRIx32
338
armsse_mhu_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
459
339
+
460
+# imx7_src.c
340
+# aspeed_xdma.c
461
+imx7_src_read(const char *reg_name, uint32_t value) "reg[%s] => 0x%" PRIx32
341
+aspeed_xdma_write(uint64_t offset, uint64_t data) "XDMA write: offset 0x%" PRIx64 " data 0x%" PRIx64
462
+imx7_src_write(const char *reg_name, uint32_t value) "reg[%s] <= 0x%" PRIx32
463
+
464
# iotkit-sysinfo.c
465
iotkit_sysinfo_read(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
466
iotkit_sysinfo_write(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
342
--
467
--
343
2.20.1
468
2.34.1
344
345
diff view generated by jsdifflib
1
From: Joel Stanley <joel@jms.id.au>
1
The architecture requires (R_TYTWB) that an attempt to return from EL3
2
when SCR_EL3.{NSE,NS} are {1,0} is an illegal exception return. (This
3
enforces that the CPU can't ever be executing below EL3 with the
4
NSE,NS bits indicating an invalid security state.)
2
5
3
The ast2500 uses the watchdog to reset the SDRAM controller. This
6
We were missing this check; add it.
4
operation is usually performed by u-boot's memory training procedure,
5
and it is enabled by setting a bit in the SCU and then causing the
6
watchdog to expire. Therefore, we need the watchdog to be able to
7
access the SCU's register space.
8
7
9
This causes the watchdog to not perform a system reset when the bit is
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
set. In the future it could perform a reset of the SDMC model.
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20230807150618.101357-1-peter.maydell@linaro.org
11
---
12
target/arm/tcg/helper-a64.c | 9 +++++++++
13
1 file changed, 9 insertions(+)
11
14
12
Signed-off-by: Joel Stanley <joel@jms.id.au>
15
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
13
Signed-off-by: Cédric Le Goater <clg@kaod.org>
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
15
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
16
Message-id: 20190621065242.32535-1-joel@jms.id.au
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
19
include/hw/watchdog/wdt_aspeed.h | 1 +
20
hw/arm/aspeed_soc.c | 2 ++
21
hw/watchdog/wdt_aspeed.c | 20 ++++++++++++++++++++
22
3 files changed, 23 insertions(+)
23
24
diff --git a/include/hw/watchdog/wdt_aspeed.h b/include/hw/watchdog/wdt_aspeed.h
25
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/watchdog/wdt_aspeed.h
17
--- a/target/arm/tcg/helper-a64.c
27
+++ b/include/hw/watchdog/wdt_aspeed.h
18
+++ b/target/arm/tcg/helper-a64.c
28
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedWDTState {
19
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc)
29
MemoryRegion iomem;
20
spsr &= ~PSTATE_SS;
30
uint32_t regs[ASPEED_WDT_REGS_MAX];
31
32
+ AspeedSCUState *scu;
33
uint32_t pclk_freq;
34
uint32_t silicon_rev;
35
uint32_t ext_pulse_width_mask;
36
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/hw/arm/aspeed_soc.c
39
+++ b/hw/arm/aspeed_soc.c
40
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
41
sizeof(s->wdt[i]), TYPE_ASPEED_WDT);
42
qdev_prop_set_uint32(DEVICE(&s->wdt[i]), "silicon-rev",
43
sc->info->silicon_rev);
44
+ object_property_add_const_link(OBJECT(&s->wdt[i]), "scu",
45
+ OBJECT(&s->scu), &error_abort);
46
}
21
}
47
22
48
for (i = 0; i < ASPEED_MACS_NUM; i++) {
23
+ /*
49
diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c
24
+ * FEAT_RME forbids return from EL3 with an invalid security state.
50
index XXXXXXX..XXXXXXX 100644
25
+ * We don't need an explicit check for FEAT_RME here because we enforce
51
--- a/hw/watchdog/wdt_aspeed.c
26
+ * in scr_write() that you can't set the NSE bit without it.
52
+++ b/hw/watchdog/wdt_aspeed.c
27
+ */
53
@@ -XXX,XX +XXX,XX @@
28
+ if (cur_el == 3 && (env->cp15.scr_el3 & (SCR_NS | SCR_NSE)) == SCR_NSE) {
54
29
+ goto illegal_return;
55
#define WDT_RESTART_MAGIC 0x4755
56
57
+#define SCU_RESET_CONTROL1 (0x04 / 4)
58
+#define SCU_RESET_SDRAM BIT(0)
59
+
60
static bool aspeed_wdt_is_enabled(const AspeedWDTState *s)
61
{
62
return s->regs[WDT_CTRL] & WDT_CTRL_ENABLE;
63
@@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_timer_expired(void *dev)
64
{
65
AspeedWDTState *s = ASPEED_WDT(dev);
66
67
+ /* Do not reset on SDRAM controller reset */
68
+ if (s->scu->regs[SCU_RESET_CONTROL1] & SCU_RESET_SDRAM) {
69
+ timer_del(s->timer);
70
+ s->regs[WDT_CTRL] = 0;
71
+ return;
72
+ }
30
+ }
73
+
31
+
74
qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n");
32
new_el = el_from_spsr(spsr);
75
watchdog_perform_action();
33
if (new_el == -1) {
76
timer_del(s->timer);
34
goto illegal_return;
77
@@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp)
78
{
79
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
80
AspeedWDTState *s = ASPEED_WDT(dev);
81
+ Error *err = NULL;
82
+ Object *obj;
83
+
84
+ obj = object_property_get_link(OBJECT(dev), "scu", &err);
85
+ if (!obj) {
86
+ error_propagate(errp, err);
87
+ error_prepend(errp, "required link 'scu' not found: ");
88
+ return;
89
+ }
90
+ s->scu = ASPEED_SCU(obj);
91
92
if (!is_supported_silicon_rev(s->silicon_rev)) {
93
error_setg(errp, "Unknown silicon revision: 0x%" PRIx32,
94
--
35
--
95
2.20.1
36
2.34.1
96
97
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
In the m48t59 device we almost always use 64-bit arithmetic when
2
dealing with time_t deltas. The one exception is in set_alarm(),
3
which currently uses a plain 'int' to hold the difference between two
4
time_t values. Switch to int64_t instead to avoid any possible
5
overflow issues.
2
6
3
To ease the review of the next commit,
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
move the vfp_exceptbits_to_host() function directly after
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
vfp_exceptbits_from_host(). Amusingly the diff shows we
9
---
6
are moving vfp_get_fpscr().
10
hw/rtc/m48t59.c | 2 +-
11
1 file changed, 1 insertion(+), 1 deletion(-)
7
12
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
diff --git a/hw/rtc/m48t59.c b/hw/rtc/m48t59.c
9
Message-id: 20190701132516.26392-15-philmd@redhat.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
target/arm/vfp_helper.c | 52 ++++++++++++++++++++---------------------
14
1 file changed, 26 insertions(+), 26 deletions(-)
15
16
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
17
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/vfp_helper.c
15
--- a/hw/rtc/m48t59.c
19
+++ b/target/arm/vfp_helper.c
16
+++ b/hw/rtc/m48t59.c
20
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_from_host(int host_bits)
17
@@ -XXX,XX +XXX,XX @@ static void alarm_cb (void *opaque)
21
return target_bits;
18
22
}
19
static void set_alarm(M48t59State *NVRAM)
23
24
-uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
25
-{
26
- uint32_t i, fpscr;
27
-
28
- fpscr = env->vfp.xregs[ARM_VFP_FPSCR]
29
- | (env->vfp.vec_len << 16)
30
- | (env->vfp.vec_stride << 20);
31
-
32
- i = get_float_exception_flags(&env->vfp.fp_status);
33
- i |= get_float_exception_flags(&env->vfp.standard_fp_status);
34
- /* FZ16 does not generate an input denormal exception. */
35
- i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
36
- & ~float_flag_input_denormal);
37
- fpscr |= vfp_exceptbits_from_host(i);
38
-
39
- i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3];
40
- fpscr |= i ? FPCR_QC : 0;
41
-
42
- return fpscr;
43
-}
44
-
45
-uint32_t vfp_get_fpscr(CPUARMState *env)
46
-{
47
- return HELPER(vfp_get_fpscr)(env);
48
-}
49
-
50
/* Convert vfp exception flags to target form. */
51
static inline int vfp_exceptbits_to_host(int target_bits)
52
{
20
{
53
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits)
21
- int diff;
54
return host_bits;
22
+ int64_t diff;
55
}
23
if (NVRAM->alrm_timer != NULL) {
56
24
timer_del(NVRAM->alrm_timer);
57
+uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
25
diff = qemu_timedate_diff(&NVRAM->alarm) - NVRAM->time_offset;
58
+{
59
+ uint32_t i, fpscr;
60
+
61
+ fpscr = env->vfp.xregs[ARM_VFP_FPSCR]
62
+ | (env->vfp.vec_len << 16)
63
+ | (env->vfp.vec_stride << 20);
64
+
65
+ i = get_float_exception_flags(&env->vfp.fp_status);
66
+ i |= get_float_exception_flags(&env->vfp.standard_fp_status);
67
+ /* FZ16 does not generate an input denormal exception. */
68
+ i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
69
+ & ~float_flag_input_denormal);
70
+ fpscr |= vfp_exceptbits_from_host(i);
71
+
72
+ i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3];
73
+ fpscr |= i ? FPCR_QC : 0;
74
+
75
+ return fpscr;
76
+}
77
+
78
+uint32_t vfp_get_fpscr(CPUARMState *env)
79
+{
80
+ return HELPER(vfp_get_fpscr)(env);
81
+}
82
+
83
void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
84
{
85
int i;
86
--
26
--
87
2.20.1
27
2.34.1
88
28
89
29
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
In the twl92230 device, use int64_t for the two state fields
2
sec_offset and alm_sec, because we set these to values that
3
are either time_t or differences between two time_t values.
2
4
3
In the next commit we will split the TLB related routines of
5
These fields aren't saved in vmstate anywhere, so we can
4
this file, and this function will also be called in the new
6
safely widen them.
5
file. Declare it in the "internals.h" header.
6
7
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Message-id: 20190701132516.26392-12-philmd@redhat.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
---
10
---
12
target/arm/internals.h | 16 ++++++++++++++++
11
hw/rtc/twl92230.c | 4 ++--
13
target/arm/helper.c | 21 +++++----------------
12
1 file changed, 2 insertions(+), 2 deletions(-)
14
2 files changed, 21 insertions(+), 16 deletions(-)
15
13
16
diff --git a/target/arm/internals.h b/target/arm/internals.h
14
diff --git a/hw/rtc/twl92230.c b/hw/rtc/twl92230.c
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/internals.h
16
--- a/hw/rtc/twl92230.c
19
+++ b/target/arm/internals.h
17
+++ b/hw/rtc/twl92230.c
20
@@ -XXX,XX +XXX,XX @@ static inline int exception_target_el(CPUARMState *env)
18
@@ -XXX,XX +XXX,XX @@ struct MenelausState {
21
return target_el;
19
struct tm tm;
22
}
20
struct tm new;
23
21
struct tm alm;
24
+#ifndef CONFIG_USER_ONLY
22
- int sec_offset;
25
+
23
- int alm_sec;
26
+/* Cacheability and shareability attributes for a memory access */
24
+ int64_t sec_offset;
27
+typedef struct ARMCacheAttrs {
25
+ int64_t alm_sec;
28
+ unsigned int attrs:8; /* as in the MAIR register encoding */
26
int next_comp;
29
+ unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */
27
} rtc;
30
+} ARMCacheAttrs;
28
uint16_t rtc_next_vmstate;
31
+
32
+bool get_phys_addr(CPUARMState *env, target_ulong address,
33
+ MMUAccessType access_type, ARMMMUIdx mmu_idx,
34
+ hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
35
+ target_ulong *page_size,
36
+ ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs);
37
+
38
+#endif /* !CONFIG_USER_ONLY */
39
+
40
#endif
41
diff --git a/target/arm/helper.c b/target/arm/helper.c
42
index XXXXXXX..XXXXXXX 100644
43
--- a/target/arm/helper.c
44
+++ b/target/arm/helper.c
45
@@ -XXX,XX +XXX,XX @@
46
#define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */
47
48
#ifndef CONFIG_USER_ONLY
49
-/* Cacheability and shareability attributes for a memory access */
50
-typedef struct ARMCacheAttrs {
51
- unsigned int attrs:8; /* as in the MAIR register encoding */
52
- unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */
53
-} ARMCacheAttrs;
54
-
55
-static bool get_phys_addr(CPUARMState *env, target_ulong address,
56
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
57
- hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
58
- target_ulong *page_size,
59
- ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs);
60
61
static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
62
MMUAccessType access_type, ARMMMUIdx mmu_idx,
63
@@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2)
64
* @fi: set to fault info if the translation fails
65
* @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes
66
*/
67
-static bool get_phys_addr(CPUARMState *env, target_ulong address,
68
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
69
- hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
70
- target_ulong *page_size,
71
- ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
72
+bool get_phys_addr(CPUARMState *env, target_ulong address,
73
+ MMUAccessType access_type, ARMMMUIdx mmu_idx,
74
+ hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
75
+ target_ulong *page_size,
76
+ ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
77
{
78
if (mmu_idx == ARMMMUIdx_S12NSE0 || mmu_idx == ARMMMUIdx_S12NSE1) {
79
/* Call ourselves recursively to do the stage 1 and then stage 2
80
--
29
--
81
2.20.1
30
2.34.1
82
31
83
32
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
In the aspeed_rtc device we store a difference between two time_t
2
values in an 'int'. This is not really correct when time_t could
3
be 64 bits. Enlarge the field to 'int64_t'.
2
4
3
This will simplify the definition of new SoCs, like the AST2600 which
5
This is a migration compatibility break for the aspeed boards.
4
should use a slightly different address space and have a different set
6
While we are changing the vmstate, remove the accidental
5
of controllers.
7
duplicate of the offset field.
6
8
7
Signed-off-by: Cédric Le Goater <clg@kaod.org>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Joel Stanley <joel@jms.id.au>
10
Message-id: 20190618165311.27066-3-clg@kaod.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Cédric Le Goater <clg@kaod.org>
12
---
11
---
13
include/hw/arm/aspeed_soc.h | 4 +-
12
include/hw/rtc/aspeed_rtc.h | 2 +-
14
hw/arm/aspeed.c | 8 +--
13
hw/rtc/aspeed_rtc.c | 5 ++---
15
hw/arm/aspeed_soc.c | 117 ++++++++++++++++++++++--------------
14
2 files changed, 3 insertions(+), 4 deletions(-)
16
3 files changed, 78 insertions(+), 51 deletions(-)
17
15
18
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
16
diff --git a/include/hw/rtc/aspeed_rtc.h b/include/hw/rtc/aspeed_rtc.h
19
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/arm/aspeed_soc.h
18
--- a/include/hw/rtc/aspeed_rtc.h
21
+++ b/include/hw/arm/aspeed_soc.h
19
+++ b/include/hw/rtc/aspeed_rtc.h
22
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo {
20
@@ -XXX,XX +XXX,XX @@ struct AspeedRtcState {
23
const char *name;
21
qemu_irq irq;
24
const char *cpu_type;
22
25
uint32_t silicon_rev;
23
uint32_t reg[0x18];
26
- hwaddr sdram_base;
24
- int offset;
27
uint64_t sram_size;
25
+ int64_t offset;
28
int spis_num;
26
29
- const hwaddr *spi_bases;
30
const char *fmc_typename;
31
const char **spi_typename;
32
int wdts_num;
33
const int *irqmap;
34
+ const hwaddr *memmap;
35
} AspeedSoCInfo;
36
37
typedef struct AspeedSoCClass {
38
@@ -XXX,XX +XXX,XX @@ enum {
39
ASPEED_I2C,
40
ASPEED_ETH1,
41
ASPEED_ETH2,
42
+ ASPEED_SDRAM,
43
};
27
};
44
28
45
#endif /* ASPEED_SOC_H */
29
diff --git a/hw/rtc/aspeed_rtc.c b/hw/rtc/aspeed_rtc.c
46
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
47
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
48
--- a/hw/arm/aspeed.c
31
--- a/hw/rtc/aspeed_rtc.c
49
+++ b/hw/arm/aspeed.c
32
+++ b/hw/rtc/aspeed_rtc.c
50
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
33
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_rtc_ops = {
51
&error_abort);
34
52
35
static const VMStateDescription vmstate_aspeed_rtc = {
53
memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size);
36
.name = TYPE_ASPEED_RTC,
54
- memory_region_add_subregion(get_system_memory(), sc->info->sdram_base,
37
- .version_id = 1,
55
- &bmc->ram);
38
+ .version_id = 2,
56
+ memory_region_add_subregion(get_system_memory(),
39
.fields = (VMStateField[]) {
57
+ sc->info->memmap[ASPEED_SDRAM], &bmc->ram);
40
VMSTATE_UINT32_ARRAY(reg, AspeedRtcState, 0x18),
58
object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram),
41
- VMSTATE_INT32(offset, AspeedRtcState),
59
&error_abort);
42
- VMSTATE_INT32(offset, AspeedRtcState),
60
43
+ VMSTATE_INT64(offset, AspeedRtcState),
61
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
44
VMSTATE_END_OF_LIST()
62
memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL,
45
}
63
"max_ram", max_ram_size - ram_size);
64
memory_region_add_subregion(get_system_memory(),
65
- sc->info->sdram_base + ram_size,
66
+ sc->info->memmap[ASPEED_SDRAM] + ram_size,
67
&bmc->max_ram);
68
69
aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort);
70
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
71
aspeed_board_binfo.initrd_filename = machine->initrd_filename;
72
aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline;
73
aspeed_board_binfo.ram_size = ram_size;
74
- aspeed_board_binfo.loader_start = sc->info->sdram_base;
75
+ aspeed_board_binfo.loader_start = sc->info->memmap[ASPEED_SDRAM];
76
77
if (cfg->i2c_init) {
78
cfg->i2c_init(bmc);
79
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
80
index XXXXXXX..XXXXXXX 100644
81
--- a/hw/arm/aspeed_soc.c
82
+++ b/hw/arm/aspeed_soc.c
83
@@ -XXX,XX +XXX,XX @@
84
#include "hw/i2c/aspeed_i2c.h"
85
#include "net/net.h"
86
87
-#define ASPEED_SOC_UART_5_BASE 0x00184000
88
#define ASPEED_SOC_IOMEM_SIZE 0x00200000
89
-#define ASPEED_SOC_IOMEM_BASE 0x1E600000
90
-#define ASPEED_SOC_FMC_BASE 0x1E620000
91
-#define ASPEED_SOC_SPI_BASE 0x1E630000
92
-#define ASPEED_SOC_SPI2_BASE 0x1E631000
93
-#define ASPEED_SOC_VIC_BASE 0x1E6C0000
94
-#define ASPEED_SOC_SDMC_BASE 0x1E6E0000
95
-#define ASPEED_SOC_SCU_BASE 0x1E6E2000
96
-#define ASPEED_SOC_SRAM_BASE 0x1E720000
97
-#define ASPEED_SOC_TIMER_BASE 0x1E782000
98
-#define ASPEED_SOC_WDT_BASE 0x1E785000
99
-#define ASPEED_SOC_I2C_BASE 0x1E78A000
100
-#define ASPEED_SOC_ETH1_BASE 0x1E660000
101
-#define ASPEED_SOC_ETH2_BASE 0x1E680000
102
+
103
+static const hwaddr aspeed_soc_ast2400_memmap[] = {
104
+ [ASPEED_IOMEM] = 0x1E600000,
105
+ [ASPEED_FMC] = 0x1E620000,
106
+ [ASPEED_SPI1] = 0x1E630000,
107
+ [ASPEED_VIC] = 0x1E6C0000,
108
+ [ASPEED_SDMC] = 0x1E6E0000,
109
+ [ASPEED_SCU] = 0x1E6E2000,
110
+ [ASPEED_ADC] = 0x1E6E9000,
111
+ [ASPEED_SRAM] = 0x1E720000,
112
+ [ASPEED_GPIO] = 0x1E780000,
113
+ [ASPEED_RTC] = 0x1E781000,
114
+ [ASPEED_TIMER1] = 0x1E782000,
115
+ [ASPEED_WDT] = 0x1E785000,
116
+ [ASPEED_PWM] = 0x1E786000,
117
+ [ASPEED_LPC] = 0x1E789000,
118
+ [ASPEED_IBT] = 0x1E789140,
119
+ [ASPEED_I2C] = 0x1E78A000,
120
+ [ASPEED_ETH1] = 0x1E660000,
121
+ [ASPEED_ETH2] = 0x1E680000,
122
+ [ASPEED_UART1] = 0x1E783000,
123
+ [ASPEED_UART5] = 0x1E784000,
124
+ [ASPEED_VUART] = 0x1E787000,
125
+ [ASPEED_SDRAM] = 0x40000000,
126
+};
127
+
128
+static const hwaddr aspeed_soc_ast2500_memmap[] = {
129
+ [ASPEED_IOMEM] = 0x1E600000,
130
+ [ASPEED_FMC] = 0x1E620000,
131
+ [ASPEED_SPI1] = 0x1E630000,
132
+ [ASPEED_SPI2] = 0x1E631000,
133
+ [ASPEED_VIC] = 0x1E6C0000,
134
+ [ASPEED_SDMC] = 0x1E6E0000,
135
+ [ASPEED_SCU] = 0x1E6E2000,
136
+ [ASPEED_ADC] = 0x1E6E9000,
137
+ [ASPEED_SRAM] = 0x1E720000,
138
+ [ASPEED_GPIO] = 0x1E780000,
139
+ [ASPEED_RTC] = 0x1E781000,
140
+ [ASPEED_TIMER1] = 0x1E782000,
141
+ [ASPEED_WDT] = 0x1E785000,
142
+ [ASPEED_PWM] = 0x1E786000,
143
+ [ASPEED_LPC] = 0x1E789000,
144
+ [ASPEED_IBT] = 0x1E789140,
145
+ [ASPEED_I2C] = 0x1E78A000,
146
+ [ASPEED_ETH1] = 0x1E660000,
147
+ [ASPEED_ETH2] = 0x1E680000,
148
+ [ASPEED_UART1] = 0x1E783000,
149
+ [ASPEED_UART5] = 0x1E784000,
150
+ [ASPEED_VUART] = 0x1E787000,
151
+ [ASPEED_SDRAM] = 0x80000000,
152
+};
153
154
static const int aspeed_soc_ast2400_irqmap[] = {
155
[ASPEED_UART1] = 9,
156
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2400_irqmap[] = {
157
[ASPEED_ETH2] = 3,
158
};
46
};
159
160
-#define AST2400_SDRAM_BASE 0x40000000
161
-#define AST2500_SDRAM_BASE 0x80000000
162
-
163
-/* AST2500 uses the same IRQs as the AST2400 */
164
#define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap
165
166
-static const hwaddr aspeed_soc_ast2400_spi_bases[] = { ASPEED_SOC_SPI_BASE };
167
static const char *aspeed_soc_ast2400_typenames[] = { "aspeed.smc.spi" };
168
-
169
-static const hwaddr aspeed_soc_ast2500_spi_bases[] = { ASPEED_SOC_SPI_BASE,
170
- ASPEED_SOC_SPI2_BASE};
171
static const char *aspeed_soc_ast2500_typenames[] = {
172
"aspeed.smc.ast2500-spi1", "aspeed.smc.ast2500-spi2" };
173
174
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
175
.name = "ast2400-a0",
176
.cpu_type = ARM_CPU_TYPE_NAME("arm926"),
177
.silicon_rev = AST2400_A0_SILICON_REV,
178
- .sdram_base = AST2400_SDRAM_BASE,
179
.sram_size = 0x8000,
180
.spis_num = 1,
181
- .spi_bases = aspeed_soc_ast2400_spi_bases,
182
.fmc_typename = "aspeed.smc.fmc",
183
.spi_typename = aspeed_soc_ast2400_typenames,
184
.wdts_num = 2,
185
.irqmap = aspeed_soc_ast2400_irqmap,
186
+ .memmap = aspeed_soc_ast2400_memmap,
187
}, {
188
.name = "ast2400-a1",
189
.cpu_type = ARM_CPU_TYPE_NAME("arm926"),
190
.silicon_rev = AST2400_A1_SILICON_REV,
191
- .sdram_base = AST2400_SDRAM_BASE,
192
.sram_size = 0x8000,
193
.spis_num = 1,
194
- .spi_bases = aspeed_soc_ast2400_spi_bases,
195
.fmc_typename = "aspeed.smc.fmc",
196
.spi_typename = aspeed_soc_ast2400_typenames,
197
.wdts_num = 2,
198
.irqmap = aspeed_soc_ast2400_irqmap,
199
+ .memmap = aspeed_soc_ast2400_memmap,
200
}, {
201
.name = "ast2400",
202
.cpu_type = ARM_CPU_TYPE_NAME("arm926"),
203
.silicon_rev = AST2400_A0_SILICON_REV,
204
- .sdram_base = AST2400_SDRAM_BASE,
205
.sram_size = 0x8000,
206
.spis_num = 1,
207
- .spi_bases = aspeed_soc_ast2400_spi_bases,
208
.fmc_typename = "aspeed.smc.fmc",
209
.spi_typename = aspeed_soc_ast2400_typenames,
210
.wdts_num = 2,
211
.irqmap = aspeed_soc_ast2400_irqmap,
212
+ .memmap = aspeed_soc_ast2400_memmap,
213
}, {
214
.name = "ast2500-a1",
215
.cpu_type = ARM_CPU_TYPE_NAME("arm1176"),
216
.silicon_rev = AST2500_A1_SILICON_REV,
217
- .sdram_base = AST2500_SDRAM_BASE,
218
.sram_size = 0x9000,
219
.spis_num = 2,
220
- .spi_bases = aspeed_soc_ast2500_spi_bases,
221
.fmc_typename = "aspeed.smc.ast2500-fmc",
222
.spi_typename = aspeed_soc_ast2500_typenames,
223
.wdts_num = 3,
224
.irqmap = aspeed_soc_ast2500_irqmap,
225
+ .memmap = aspeed_soc_ast2500_memmap,
226
},
227
};
228
229
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
230
Error *err = NULL, *local_err = NULL;
231
232
/* IO space */
233
- create_unimplemented_device("aspeed_soc.io",
234
- ASPEED_SOC_IOMEM_BASE, ASPEED_SOC_IOMEM_SIZE);
235
+ create_unimplemented_device("aspeed_soc.io", sc->info->memmap[ASPEED_IOMEM],
236
+ ASPEED_SOC_IOMEM_SIZE);
237
238
/* CPU */
239
object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
240
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
241
error_propagate(errp, err);
242
return;
243
}
244
- memory_region_add_subregion(get_system_memory(), ASPEED_SOC_SRAM_BASE,
245
- &s->sram);
246
+ memory_region_add_subregion(get_system_memory(),
247
+ sc->info->memmap[ASPEED_SRAM], &s->sram);
248
249
/* SCU */
250
object_property_set_bool(OBJECT(&s->scu), true, "realized", &err);
251
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
252
error_propagate(errp, err);
253
return;
254
}
255
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, ASPEED_SOC_SCU_BASE);
256
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->info->memmap[ASPEED_SCU]);
257
258
/* VIC */
259
object_property_set_bool(OBJECT(&s->vic), true, "realized", &err);
260
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
261
error_propagate(errp, err);
262
return;
263
}
264
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->vic), 0, ASPEED_SOC_VIC_BASE);
265
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->vic), 0, sc->info->memmap[ASPEED_VIC]);
266
sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 0,
267
qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ));
268
sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 1,
269
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
270
error_propagate(errp, err);
271
return;
272
}
273
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, ASPEED_SOC_TIMER_BASE);
274
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0,
275
+ sc->info->memmap[ASPEED_TIMER1]);
276
for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) {
277
qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_TIMER1 + i);
278
sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq);
279
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
280
/* UART - attach an 8250 to the IO space as our UART5 */
281
if (serial_hd(0)) {
282
qemu_irq uart5 = aspeed_soc_get_irq(s, ASPEED_UART5);
283
- serial_mm_init(get_system_memory(),
284
- ASPEED_SOC_IOMEM_BASE + ASPEED_SOC_UART_5_BASE, 2,
285
+ serial_mm_init(get_system_memory(), sc->info->memmap[ASPEED_UART5], 2,
286
uart5, 38400, serial_hd(0), DEVICE_LITTLE_ENDIAN);
287
}
288
289
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
290
error_propagate(errp, err);
291
return;
292
}
293
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, ASPEED_SOC_I2C_BASE);
294
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, sc->info->memmap[ASPEED_I2C]);
295
sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c), 0,
296
aspeed_soc_get_irq(s, ASPEED_I2C));
297
298
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
299
error_propagate(errp, err);
300
return;
301
}
302
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, ASPEED_SOC_FMC_BASE);
303
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, sc->info->memmap[ASPEED_FMC]);
304
sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1,
305
s->fmc.ctrl->flash_window_base);
306
sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0,
307
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
308
error_propagate(errp, err);
309
return;
310
}
311
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, sc->info->spi_bases[i]);
312
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0,
313
+ sc->info->memmap[ASPEED_SPI1 + i]);
314
sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 1,
315
s->spi[i].ctrl->flash_window_base);
316
}
317
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
318
error_propagate(errp, err);
319
return;
320
}
321
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, ASPEED_SOC_SDMC_BASE);
322
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, sc->info->memmap[ASPEED_SDMC]);
323
324
/* Watch dog */
325
for (i = 0; i < sc->info->wdts_num; i++) {
326
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
327
return;
328
}
329
sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0,
330
- ASPEED_SOC_WDT_BASE + i * 0x20);
331
+ sc->info->memmap[ASPEED_WDT] + i * 0x20);
332
}
333
334
/* Net */
335
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
336
error_propagate(errp, err);
337
return;
338
}
339
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, ASPEED_SOC_ETH1_BASE);
340
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0,
341
+ sc->info->memmap[ASPEED_ETH1]);
342
sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0,
343
aspeed_soc_get_irq(s, ASPEED_ETH1));
344
}
345
--
47
--
346
2.20.1
48
2.34.1
347
49
348
50
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
The functions qemu_get_timedate() and qemu_timedate_diff() take
2
and return a time offset as an integer. Coverity points out that
3
means that when an RTC device implementation holds an offset
4
as a time_t, as the m48t59 does, the time_t will get truncated.
5
(CID 1507157, 1517772).
2
6
3
Datasheet for i.MX7 is incorrect and i.MX7's PCI IRQ mapping matches
7
The functions work with time_t internally, so make them use that type
4
that of i.MX6:
8
in their APIs.
5
9
6
* INTD/MSI 122
10
Note that this won't help any Y2038 issues where either the device
7
* INTC 123
11
model itself is keeping the offset in a 32-bit integer, or where the
8
* INTB 124
12
hardware under emulation has Y2038 or other rollover problems. If we
9
* INTA 125
13
missed any cases of the former then hopefully Coverity will warn us
14
about them since after this patch we'd be truncating a time_t in
15
assignments from qemu_timedate_diff().)
10
16
11
Fix all of the relevant code to reflect that fact. Needed by latest
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Linux kernels.
18
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
19
---
20
include/sysemu/rtc.h | 4 ++--
21
softmmu/rtc.c | 4 ++--
22
2 files changed, 4 insertions(+), 4 deletions(-)
13
23
14
(Reference: Linux kernel commit 538d6e9d597584e80 from an
24
diff --git a/include/sysemu/rtc.h b/include/sysemu/rtc.h
15
NXP employee confirming that the datasheet is incorrect and
16
with a report of a test against hardware.)
17
18
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
19
Cc: Peter Maydell <peter.maydell@linaro.org>
20
Cc: Michael S. Tsirkin <mst@redhat.com>
21
Cc: qemu-devel@nongnu.org
22
Cc: qemu-arm@nongnu.org
23
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
24
[PMM: added ref to kernel commit confirming the datasheet error]
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
---
27
include/hw/arm/fsl-imx7.h | 8 ++++----
28
hw/pci-host/designware.c | 6 ++++--
29
2 files changed, 8 insertions(+), 6 deletions(-)
30
31
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
32
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
33
--- a/include/hw/arm/fsl-imx7.h
26
--- a/include/sysemu/rtc.h
34
+++ b/include/hw/arm/fsl-imx7.h
27
+++ b/include/sysemu/rtc.h
35
@@ -XXX,XX +XXX,XX @@ enum FslIMX7IRQs {
28
@@ -XXX,XX +XXX,XX @@
36
FSL_IMX7_USB2_IRQ = 42,
29
* The behaviour of the clock whose value this function returns will
37
FSL_IMX7_USB3_IRQ = 40,
30
* depend on the -rtc command line option passed by the user.
38
31
*/
39
- FSL_IMX7_PCI_INTA_IRQ = 122,
32
-void qemu_get_timedate(struct tm *tm, int offset);
40
- FSL_IMX7_PCI_INTB_IRQ = 123,
33
+void qemu_get_timedate(struct tm *tm, time_t offset);
41
- FSL_IMX7_PCI_INTC_IRQ = 124,
34
42
- FSL_IMX7_PCI_INTD_IRQ = 125,
35
/**
43
+ FSL_IMX7_PCI_INTA_IRQ = 125,
36
* qemu_timedate_diff: Return difference between a struct tm and the RTC
44
+ FSL_IMX7_PCI_INTB_IRQ = 124,
37
@@ -XXX,XX +XXX,XX @@ void qemu_get_timedate(struct tm *tm, int offset);
45
+ FSL_IMX7_PCI_INTC_IRQ = 123,
38
* a timestamp one hour further ahead than the current RTC time
46
+ FSL_IMX7_PCI_INTD_IRQ = 122,
39
* then this function will return 3600.
47
40
*/
48
FSL_IMX7_UART7_IRQ = 126,
41
-int qemu_timedate_diff(struct tm *tm);
49
42
+time_t qemu_timedate_diff(struct tm *tm);
50
diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
43
44
#endif
45
diff --git a/softmmu/rtc.c b/softmmu/rtc.c
51
index XXXXXXX..XXXXXXX 100644
46
index XXXXXXX..XXXXXXX 100644
52
--- a/hw/pci-host/designware.c
47
--- a/softmmu/rtc.c
53
+++ b/hw/pci-host/designware.c
48
+++ b/softmmu/rtc.c
54
@@ -XXX,XX +XXX,XX @@
49
@@ -XXX,XX +XXX,XX @@ static time_t qemu_ref_timedate(QEMUClockType clock)
55
#define DESIGNWARE_PCIE_ATU_DEVFN(x) (((x) >> 16) & 0xff)
50
return value;
56
#define DESIGNWARE_PCIE_ATU_UPPER_TARGET 0x91C
51
}
57
52
58
+#define DESIGNWARE_PCIE_IRQ_MSI 3
53
-void qemu_get_timedate(struct tm *tm, int offset)
59
+
54
+void qemu_get_timedate(struct tm *tm, time_t offset)
60
static DesignwarePCIEHost *
61
designware_pcie_root_to_host(DesignwarePCIERoot *root)
62
{
55
{
63
@@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_msi_write(void *opaque, hwaddr addr,
56
time_t ti = qemu_ref_timedate(rtc_clock);
64
root->msi.intr[0].status |= BIT(val) & root->msi.intr[0].enable;
57
65
58
@@ -XXX,XX +XXX,XX @@ void qemu_get_timedate(struct tm *tm, int offset)
66
if (root->msi.intr[0].status & ~root->msi.intr[0].mask) {
67
- qemu_set_irq(host->pci.irqs[0], 1);
68
+ qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 1);
69
}
59
}
70
}
60
}
71
61
72
@@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address,
62
-int qemu_timedate_diff(struct tm *tm)
73
case DESIGNWARE_PCIE_MSI_INTR0_STATUS:
63
+time_t qemu_timedate_diff(struct tm *tm)
74
root->msi.intr[0].status ^= val;
64
{
75
if (!root->msi.intr[0].status) {
65
time_t seconds;
76
- qemu_set_irq(host->pci.irqs[0], 0);
77
+ qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 0);
78
}
79
break;
80
66
81
--
67
--
82
2.20.1
68
2.34.1
83
69
84
70
diff view generated by jsdifflib
Deleted patch
1
From: Cédric Le Goater <clg@kaod.org>
2
1
3
This will simplify the definition of new SoCs, like the AST2600 which
4
should use a different CPU and a different IRQ number layout.
5
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Joel Stanley <joel@jms.id.au>
9
Message-id: 20190618165311.27066-2-clg@kaod.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
include/hw/arm/aspeed_soc.h | 36 +++++++++++++++++++++++
13
hw/arm/aspeed_soc.c | 57 +++++++++++++++++++++++++++++++------
14
2 files changed, 85 insertions(+), 8 deletions(-)
15
16
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/aspeed_soc.h
19
+++ b/include/hw/arm/aspeed_soc.h
20
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo {
21
const char *fmc_typename;
22
const char **spi_typename;
23
int wdts_num;
24
+ const int *irqmap;
25
} AspeedSoCInfo;
26
27
typedef struct AspeedSoCClass {
28
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCClass {
29
#define ASPEED_SOC_GET_CLASS(obj) \
30
OBJECT_GET_CLASS(AspeedSoCClass, (obj), TYPE_ASPEED_SOC)
31
32
+enum {
33
+ ASPEED_IOMEM,
34
+ ASPEED_UART1,
35
+ ASPEED_UART2,
36
+ ASPEED_UART3,
37
+ ASPEED_UART4,
38
+ ASPEED_UART5,
39
+ ASPEED_VUART,
40
+ ASPEED_FMC,
41
+ ASPEED_SPI1,
42
+ ASPEED_SPI2,
43
+ ASPEED_VIC,
44
+ ASPEED_SDMC,
45
+ ASPEED_SCU,
46
+ ASPEED_ADC,
47
+ ASPEED_SRAM,
48
+ ASPEED_GPIO,
49
+ ASPEED_RTC,
50
+ ASPEED_TIMER1,
51
+ ASPEED_TIMER2,
52
+ ASPEED_TIMER3,
53
+ ASPEED_TIMER4,
54
+ ASPEED_TIMER5,
55
+ ASPEED_TIMER6,
56
+ ASPEED_TIMER7,
57
+ ASPEED_TIMER8,
58
+ ASPEED_WDT,
59
+ ASPEED_PWM,
60
+ ASPEED_LPC,
61
+ ASPEED_IBT,
62
+ ASPEED_I2C,
63
+ ASPEED_ETH1,
64
+ ASPEED_ETH2,
65
+};
66
+
67
#endif /* ASPEED_SOC_H */
68
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
69
index XXXXXXX..XXXXXXX 100644
70
--- a/hw/arm/aspeed_soc.c
71
+++ b/hw/arm/aspeed_soc.c
72
@@ -XXX,XX +XXX,XX @@
73
#define ASPEED_SOC_ETH1_BASE 0x1E660000
74
#define ASPEED_SOC_ETH2_BASE 0x1E680000
75
76
-static const int uart_irqs[] = { 9, 32, 33, 34, 10 };
77
-static const int timer_irqs[] = { 16, 17, 18, 35, 36, 37, 38, 39, };
78
+static const int aspeed_soc_ast2400_irqmap[] = {
79
+ [ASPEED_UART1] = 9,
80
+ [ASPEED_UART2] = 32,
81
+ [ASPEED_UART3] = 33,
82
+ [ASPEED_UART4] = 34,
83
+ [ASPEED_UART5] = 10,
84
+ [ASPEED_VUART] = 8,
85
+ [ASPEED_FMC] = 19,
86
+ [ASPEED_SDMC] = 0,
87
+ [ASPEED_SCU] = 21,
88
+ [ASPEED_ADC] = 31,
89
+ [ASPEED_GPIO] = 20,
90
+ [ASPEED_RTC] = 22,
91
+ [ASPEED_TIMER1] = 16,
92
+ [ASPEED_TIMER2] = 17,
93
+ [ASPEED_TIMER3] = 18,
94
+ [ASPEED_TIMER4] = 35,
95
+ [ASPEED_TIMER5] = 36,
96
+ [ASPEED_TIMER6] = 37,
97
+ [ASPEED_TIMER7] = 38,
98
+ [ASPEED_TIMER8] = 39,
99
+ [ASPEED_WDT] = 27,
100
+ [ASPEED_PWM] = 28,
101
+ [ASPEED_LPC] = 8,
102
+ [ASPEED_IBT] = 8, /* LPC */
103
+ [ASPEED_I2C] = 12,
104
+ [ASPEED_ETH1] = 2,
105
+ [ASPEED_ETH2] = 3,
106
+};
107
108
#define AST2400_SDRAM_BASE 0x40000000
109
#define AST2500_SDRAM_BASE 0x80000000
110
111
+/* AST2500 uses the same IRQs as the AST2400 */
112
+#define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap
113
+
114
static const hwaddr aspeed_soc_ast2400_spi_bases[] = { ASPEED_SOC_SPI_BASE };
115
static const char *aspeed_soc_ast2400_typenames[] = { "aspeed.smc.spi" };
116
117
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
118
.fmc_typename = "aspeed.smc.fmc",
119
.spi_typename = aspeed_soc_ast2400_typenames,
120
.wdts_num = 2,
121
+ .irqmap = aspeed_soc_ast2400_irqmap,
122
}, {
123
.name = "ast2400-a1",
124
.cpu_type = ARM_CPU_TYPE_NAME("arm926"),
125
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
126
.fmc_typename = "aspeed.smc.fmc",
127
.spi_typename = aspeed_soc_ast2400_typenames,
128
.wdts_num = 2,
129
+ .irqmap = aspeed_soc_ast2400_irqmap,
130
}, {
131
.name = "ast2400",
132
.cpu_type = ARM_CPU_TYPE_NAME("arm926"),
133
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
134
.fmc_typename = "aspeed.smc.fmc",
135
.spi_typename = aspeed_soc_ast2400_typenames,
136
.wdts_num = 2,
137
+ .irqmap = aspeed_soc_ast2400_irqmap,
138
}, {
139
.name = "ast2500-a1",
140
.cpu_type = ARM_CPU_TYPE_NAME("arm1176"),
141
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
142
.fmc_typename = "aspeed.smc.ast2500-fmc",
143
.spi_typename = aspeed_soc_ast2500_typenames,
144
.wdts_num = 3,
145
+ .irqmap = aspeed_soc_ast2500_irqmap,
146
},
147
};
148
149
+static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl)
150
+{
151
+ AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
152
+
153
+ return qdev_get_gpio_in(DEVICE(&s->vic), sc->info->irqmap[ctrl]);
154
+}
155
+
156
static void aspeed_soc_init(Object *obj)
157
{
158
AspeedSoCState *s = ASPEED_SOC(obj);
159
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
160
return;
161
}
162
sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, ASPEED_SOC_TIMER_BASE);
163
- for (i = 0; i < ARRAY_SIZE(timer_irqs); i++) {
164
- qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->vic), timer_irqs[i]);
165
+ for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) {
166
+ qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_TIMER1 + i);
167
sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq);
168
}
169
170
/* UART - attach an 8250 to the IO space as our UART5 */
171
if (serial_hd(0)) {
172
- qemu_irq uart5 = qdev_get_gpio_in(DEVICE(&s->vic), uart_irqs[4]);
173
+ qemu_irq uart5 = aspeed_soc_get_irq(s, ASPEED_UART5);
174
serial_mm_init(get_system_memory(),
175
ASPEED_SOC_IOMEM_BASE + ASPEED_SOC_UART_5_BASE, 2,
176
uart5, 38400, serial_hd(0), DEVICE_LITTLE_ENDIAN);
177
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
178
}
179
sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, ASPEED_SOC_I2C_BASE);
180
sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c), 0,
181
- qdev_get_gpio_in(DEVICE(&s->vic), 12));
182
+ aspeed_soc_get_irq(s, ASPEED_I2C));
183
184
/* FMC, The number of CS is set at the board level */
185
object_property_set_bool(OBJECT(&s->fmc), true, "realized", &err);
186
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
187
sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1,
188
s->fmc.ctrl->flash_window_base);
189
sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0,
190
- qdev_get_gpio_in(DEVICE(&s->vic), 19));
191
+ aspeed_soc_get_irq(s, ASPEED_FMC));
192
193
/* SPI */
194
for (i = 0; i < sc->info->spis_num; i++) {
195
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
196
}
197
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, ASPEED_SOC_ETH1_BASE);
198
sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0,
199
- qdev_get_gpio_in(DEVICE(&s->vic), 2));
200
+ aspeed_soc_get_irq(s, ASPEED_ETH1));
201
}
202
203
static void aspeed_soc_class_init(ObjectClass *oc, void *data)
204
--
205
2.20.1
206
207
diff view generated by jsdifflib
Deleted patch
1
From: Joel Stanley <joel@jms.id.au>
2
1
3
The RTC is modeled to provide time and date functionality. It is
4
initialised at zero to match the hardware.
5
6
There is no modelling of the alarm functionality, which includes the IRQ
7
line. As there is no guest code to exercise this function that is
8
acceptable for now.
9
10
Signed-off-by: Joel Stanley <joel@jms.id.au>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 20190618165311.27066-4-clg@kaod.org
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
hw/timer/Makefile.objs | 2 +-
16
include/hw/timer/aspeed_rtc.h | 31 ++++++
17
hw/timer/aspeed_rtc.c | 180 ++++++++++++++++++++++++++++++++++
18
hw/timer/trace-events | 4 +
19
4 files changed, 216 insertions(+), 1 deletion(-)
20
create mode 100644 include/hw/timer/aspeed_rtc.h
21
create mode 100644 hw/timer/aspeed_rtc.c
22
23
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
24
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/timer/Makefile.objs
26
+++ b/hw/timer/Makefile.objs
27
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
28
obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o
29
30
common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o
31
-common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o
32
+common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o
33
34
common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
35
common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o
36
diff --git a/include/hw/timer/aspeed_rtc.h b/include/hw/timer/aspeed_rtc.h
37
new file mode 100644
38
index XXXXXXX..XXXXXXX
39
--- /dev/null
40
+++ b/include/hw/timer/aspeed_rtc.h
41
@@ -XXX,XX +XXX,XX @@
42
+/*
43
+ * ASPEED Real Time Clock
44
+ * Joel Stanley <joel@jms.id.au>
45
+ *
46
+ * Copyright 2019 IBM Corp
47
+ * SPDX-License-Identifier: GPL-2.0-or-later
48
+ */
49
+#ifndef ASPEED_RTC_H
50
+#define ASPEED_RTC_H
51
+
52
+#include <stdint.h>
53
+
54
+#include "hw/hw.h"
55
+#include "hw/irq.h"
56
+#include "hw/sysbus.h"
57
+
58
+typedef struct AspeedRtcState {
59
+ SysBusDevice parent_obj;
60
+
61
+ MemoryRegion iomem;
62
+ qemu_irq irq;
63
+
64
+ uint32_t reg[0x18];
65
+ int offset;
66
+
67
+} AspeedRtcState;
68
+
69
+#define TYPE_ASPEED_RTC "aspeed.rtc"
70
+#define ASPEED_RTC(obj) OBJECT_CHECK(AspeedRtcState, (obj), TYPE_ASPEED_RTC)
71
+
72
+#endif /* ASPEED_RTC_H */
73
diff --git a/hw/timer/aspeed_rtc.c b/hw/timer/aspeed_rtc.c
74
new file mode 100644
75
index XXXXXXX..XXXXXXX
76
--- /dev/null
77
+++ b/hw/timer/aspeed_rtc.c
78
@@ -XXX,XX +XXX,XX @@
79
+/*
80
+ * ASPEED Real Time Clock
81
+ * Joel Stanley <joel@jms.id.au>
82
+ *
83
+ * Copyright 2019 IBM Corp
84
+ * SPDX-License-Identifier: GPL-2.0-or-later
85
+ */
86
+
87
+#include "qemu/osdep.h"
88
+#include "qemu-common.h"
89
+#include "hw/timer/aspeed_rtc.h"
90
+#include "qemu/log.h"
91
+#include "qemu/timer.h"
92
+
93
+#include "trace.h"
94
+
95
+#define COUNTER1 (0x00 / 4)
96
+#define COUNTER2 (0x04 / 4)
97
+#define ALARM (0x08 / 4)
98
+#define CONTROL (0x10 / 4)
99
+#define ALARM_STATUS (0x14 / 4)
100
+
101
+#define RTC_UNLOCKED BIT(1)
102
+#define RTC_ENABLED BIT(0)
103
+
104
+static void aspeed_rtc_calc_offset(AspeedRtcState *rtc)
105
+{
106
+ struct tm tm;
107
+ uint32_t year, cent;
108
+ uint32_t reg1 = rtc->reg[COUNTER1];
109
+ uint32_t reg2 = rtc->reg[COUNTER2];
110
+
111
+ tm.tm_mday = (reg1 >> 24) & 0x1f;
112
+ tm.tm_hour = (reg1 >> 16) & 0x1f;
113
+ tm.tm_min = (reg1 >> 8) & 0x3f;
114
+ tm.tm_sec = (reg1 >> 0) & 0x3f;
115
+
116
+ cent = (reg2 >> 16) & 0x1f;
117
+ year = (reg2 >> 8) & 0x7f;
118
+ tm.tm_mon = ((reg2 >> 0) & 0x0f) - 1;
119
+ tm.tm_year = year + (cent * 100) - 1900;
120
+
121
+ rtc->offset = qemu_timedate_diff(&tm);
122
+}
123
+
124
+static uint32_t aspeed_rtc_get_counter(AspeedRtcState *rtc, int r)
125
+{
126
+ uint32_t year, cent;
127
+ struct tm now;
128
+
129
+ qemu_get_timedate(&now, rtc->offset);
130
+
131
+ switch (r) {
132
+ case COUNTER1:
133
+ return (now.tm_mday << 24) | (now.tm_hour << 16) |
134
+ (now.tm_min << 8) | now.tm_sec;
135
+ case COUNTER2:
136
+ cent = (now.tm_year + 1900) / 100;
137
+ year = now.tm_year % 100;
138
+ return ((cent & 0x1f) << 16) | ((year & 0x7f) << 8) |
139
+ ((now.tm_mon + 1) & 0xf);
140
+ default:
141
+ g_assert_not_reached();
142
+ }
143
+}
144
+
145
+static uint64_t aspeed_rtc_read(void *opaque, hwaddr addr,
146
+ unsigned size)
147
+{
148
+ AspeedRtcState *rtc = opaque;
149
+ uint64_t val;
150
+ uint32_t r = addr >> 2;
151
+
152
+ switch (r) {
153
+ case COUNTER1:
154
+ case COUNTER2:
155
+ if (rtc->reg[CONTROL] & RTC_ENABLED) {
156
+ rtc->reg[r] = aspeed_rtc_get_counter(rtc, r);
157
+ }
158
+ /* fall through */
159
+ case CONTROL:
160
+ val = rtc->reg[r];
161
+ break;
162
+ case ALARM:
163
+ case ALARM_STATUS:
164
+ default:
165
+ qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx "\n", __func__, addr);
166
+ return 0;
167
+ }
168
+
169
+ trace_aspeed_rtc_read(addr, val);
170
+
171
+ return val;
172
+}
173
+
174
+static void aspeed_rtc_write(void *opaque, hwaddr addr,
175
+ uint64_t val, unsigned size)
176
+{
177
+ AspeedRtcState *rtc = opaque;
178
+ uint32_t r = addr >> 2;
179
+
180
+ switch (r) {
181
+ case COUNTER1:
182
+ case COUNTER2:
183
+ if (!(rtc->reg[CONTROL] & RTC_UNLOCKED)) {
184
+ break;
185
+ }
186
+ /* fall through */
187
+ case CONTROL:
188
+ rtc->reg[r] = val;
189
+ aspeed_rtc_calc_offset(rtc);
190
+ break;
191
+ case ALARM:
192
+ case ALARM_STATUS:
193
+ default:
194
+ qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx "\n", __func__, addr);
195
+ break;
196
+ }
197
+ trace_aspeed_rtc_write(addr, val);
198
+}
199
+
200
+static void aspeed_rtc_reset(DeviceState *d)
201
+{
202
+ AspeedRtcState *rtc = ASPEED_RTC(d);
203
+
204
+ rtc->offset = 0;
205
+ memset(rtc->reg, 0, sizeof(rtc->reg));
206
+}
207
+
208
+static const MemoryRegionOps aspeed_rtc_ops = {
209
+ .read = aspeed_rtc_read,
210
+ .write = aspeed_rtc_write,
211
+ .endianness = DEVICE_NATIVE_ENDIAN,
212
+};
213
+
214
+static const VMStateDescription vmstate_aspeed_rtc = {
215
+ .name = TYPE_ASPEED_RTC,
216
+ .version_id = 1,
217
+ .fields = (VMStateField[]) {
218
+ VMSTATE_UINT32_ARRAY(reg, AspeedRtcState, 0x18),
219
+ VMSTATE_INT32(offset, AspeedRtcState),
220
+ VMSTATE_INT32(offset, AspeedRtcState),
221
+ VMSTATE_END_OF_LIST()
222
+ }
223
+};
224
+
225
+static void aspeed_rtc_realize(DeviceState *dev, Error **errp)
226
+{
227
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
228
+ AspeedRtcState *s = ASPEED_RTC(dev);
229
+
230
+ sysbus_init_irq(sbd, &s->irq);
231
+
232
+ memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_rtc_ops, s,
233
+ "aspeed-rtc", 0x18ULL);
234
+ sysbus_init_mmio(sbd, &s->iomem);
235
+}
236
+
237
+static void aspeed_rtc_class_init(ObjectClass *klass, void *data)
238
+{
239
+ DeviceClass *dc = DEVICE_CLASS(klass);
240
+
241
+ dc->realize = aspeed_rtc_realize;
242
+ dc->vmsd = &vmstate_aspeed_rtc;
243
+ dc->reset = aspeed_rtc_reset;
244
+}
245
+
246
+static const TypeInfo aspeed_rtc_info = {
247
+ .name = TYPE_ASPEED_RTC,
248
+ .parent = TYPE_SYS_BUS_DEVICE,
249
+ .instance_size = sizeof(AspeedRtcState),
250
+ .class_init = aspeed_rtc_class_init,
251
+};
252
+
253
+static void aspeed_rtc_register_types(void)
254
+{
255
+ type_register_static(&aspeed_rtc_info);
256
+}
257
+
258
+type_init(aspeed_rtc_register_types)
259
diff --git a/hw/timer/trace-events b/hw/timer/trace-events
260
index XXXXXXX..XXXXXXX 100644
261
--- a/hw/timer/trace-events
262
+++ b/hw/timer/trace-events
263
@@ -XXX,XX +XXX,XX @@ cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK A
264
cmsdk_apb_dualtimer_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB dualtimer write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
265
cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset"
266
267
+# hw/timer/aspeed-rtc.c
268
+aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64
269
+aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64
270
+
271
# sun4v-rtc.c
272
sun4v_rtc_read(uint64_t addr, uint64_t value) "read: addr 0x%" PRIx64 " value 0x%" PRIx64
273
sun4v_rtc_write(uint64_t addr, uint64_t value) "write: addr 0x%" PRIx64 " value 0x%" PRIx64
274
--
275
2.20.1
276
277
diff view generated by jsdifflib
Deleted patch
1
From: Joel Stanley <joel@jms.id.au>
2
1
3
All systems have an RTC.
4
5
The IRQ is hooked up but the model does not use it at this stage. There
6
is no guest code that uses it, so this limitation is acceptable.
7
8
Signed-off-by: Joel Stanley <joel@jms.id.au>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20190618165311.27066-5-clg@kaod.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
include/hw/arm/aspeed_soc.h | 2 ++
14
hw/arm/aspeed_soc.c | 13 +++++++++++++
15
2 files changed, 15 insertions(+)
16
17
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/arm/aspeed_soc.h
20
+++ b/include/hw/arm/aspeed_soc.h
21
@@ -XXX,XX +XXX,XX @@
22
#include "hw/misc/aspeed_scu.h"
23
#include "hw/misc/aspeed_sdmc.h"
24
#include "hw/timer/aspeed_timer.h"
25
+#include "hw/timer/aspeed_rtc.h"
26
#include "hw/i2c/aspeed_i2c.h"
27
#include "hw/ssi/aspeed_smc.h"
28
#include "hw/watchdog/wdt_aspeed.h"
29
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState {
30
ARMCPU cpu;
31
MemoryRegion sram;
32
AspeedVICState vic;
33
+ AspeedRtcState rtc;
34
AspeedTimerCtrlState timerctrl;
35
AspeedI2CState i2c;
36
AspeedSCUState scu;
37
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/hw/arm/aspeed_soc.c
40
+++ b/hw/arm/aspeed_soc.c
41
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
42
sysbus_init_child_obj(obj, "vic", OBJECT(&s->vic), sizeof(s->vic),
43
TYPE_ASPEED_VIC);
44
45
+ sysbus_init_child_obj(obj, "rtc", OBJECT(&s->rtc), sizeof(s->rtc),
46
+ TYPE_ASPEED_RTC);
47
+
48
sysbus_init_child_obj(obj, "timerctrl", OBJECT(&s->timerctrl),
49
sizeof(s->timerctrl), TYPE_ASPEED_TIMER);
50
object_property_add_const_link(OBJECT(&s->timerctrl), "scu",
51
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
52
sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 1,
53
qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ));
54
55
+ /* RTC */
56
+ object_property_set_bool(OBJECT(&s->rtc), true, "realized", &err);
57
+ if (err) {
58
+ error_propagate(errp, err);
59
+ return;
60
+ }
61
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, sc->info->memmap[ASPEED_RTC]);
62
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0,
63
+ aspeed_soc_get_irq(s, ASPEED_RTC));
64
+
65
/* Timer */
66
object_property_set_bool(OBJECT(&s->timerctrl), true, "realized", &err);
67
if (err) {
68
--
69
2.20.1
70
71
diff view generated by jsdifflib
Deleted patch
1
From: Cédric Le Goater <clg@kaod.org>
2
1
3
The current models of the Aspeed SoCs only have one CPU but future
4
ones will support SMP. Introduce a new num_cpus field at the SoC class
5
level to define the number of available CPUs per SoC and also
6
introduce a 'num-cpus' property to activate the CPUs configured for
7
the machine.
8
9
The max_cpus limit of the machine should depend on the SoC definition
10
but, unfortunately, these values are not available when the machine
11
class is initialized. This is the reason why we add a check on
12
num_cpus in the AspeedSoC realize handler.
13
14
SMP support will be activated when models for such SoCs are implemented.
15
16
Signed-off-by: Cédric Le Goater <clg@kaod.org>
17
Reviewed-by: Joel Stanley <joel@jms.id.au>
18
Message-id: 20190618165311.27066-6-clg@kaod.org
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
21
include/hw/arm/aspeed_soc.h | 5 ++++-
22
hw/arm/aspeed.c | 7 +++++--
23
hw/arm/aspeed_soc.c | 33 +++++++++++++++++++++++++++------
24
3 files changed, 36 insertions(+), 9 deletions(-)
25
26
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
27
index XXXXXXX..XXXXXXX 100644
28
--- a/include/hw/arm/aspeed_soc.h
29
+++ b/include/hw/arm/aspeed_soc.h
30
@@ -XXX,XX +XXX,XX @@
31
32
#define ASPEED_SPIS_NUM 2
33
#define ASPEED_WDTS_NUM 3
34
+#define ASPEED_CPUS_NUM 2
35
36
typedef struct AspeedSoCState {
37
/*< private >*/
38
DeviceState parent;
39
40
/*< public >*/
41
- ARMCPU cpu;
42
+ ARMCPU cpu[ASPEED_CPUS_NUM];
43
+ uint32_t num_cpus;
44
MemoryRegion sram;
45
AspeedVICState vic;
46
AspeedRtcState rtc;
47
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo {
48
int wdts_num;
49
const int *irqmap;
50
const hwaddr *memmap;
51
+ uint32_t num_cpus;
52
} AspeedSoCInfo;
53
54
typedef struct AspeedSoCClass {
55
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
56
index XXXXXXX..XXXXXXX 100644
57
--- a/hw/arm/aspeed.c
58
+++ b/hw/arm/aspeed.c
59
@@ -XXX,XX +XXX,XX @@
60
#include "hw/misc/tmp105.h"
61
#include "qemu/log.h"
62
#include "sysemu/block-backend.h"
63
+#include "sysemu/sysemu.h"
64
#include "hw/loader.h"
65
#include "qemu/error-report.h"
66
#include "qemu/units.h"
67
68
static struct arm_boot_info aspeed_board_binfo = {
69
.board_id = -1, /* device-tree-only board */
70
- .nb_cpus = 1,
71
};
72
73
struct AspeedBoardState {
74
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
75
&error_abort);
76
object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs",
77
&error_abort);
78
+ object_property_set_int(OBJECT(&bmc->soc), smp_cpus, "num-cpus",
79
+ &error_abort);
80
if (machine->kernel_filename) {
81
/*
82
* When booting with a -kernel command line there is no u-boot
83
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
84
aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline;
85
aspeed_board_binfo.ram_size = ram_size;
86
aspeed_board_binfo.loader_start = sc->info->memmap[ASPEED_SDRAM];
87
+ aspeed_board_binfo.nb_cpus = bmc->soc.num_cpus;
88
89
if (cfg->i2c_init) {
90
cfg->i2c_init(bmc);
91
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_class_init(ObjectClass *oc, void *data)
92
93
mc->desc = board->desc;
94
mc->init = aspeed_machine_init;
95
- mc->max_cpus = 1;
96
+ mc->max_cpus = ASPEED_CPUS_NUM;
97
mc->no_sdcard = 1;
98
mc->no_floppy = 1;
99
mc->no_cdrom = 1;
100
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
101
index XXXXXXX..XXXXXXX 100644
102
--- a/hw/arm/aspeed_soc.c
103
+++ b/hw/arm/aspeed_soc.c
104
@@ -XXX,XX +XXX,XX @@
105
#include "hw/char/serial.h"
106
#include "qemu/log.h"
107
#include "qemu/module.h"
108
+#include "qemu/error-report.h"
109
#include "hw/i2c/aspeed_i2c.h"
110
#include "net/net.h"
111
112
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
113
.wdts_num = 2,
114
.irqmap = aspeed_soc_ast2400_irqmap,
115
.memmap = aspeed_soc_ast2400_memmap,
116
+ .num_cpus = 1,
117
}, {
118
.name = "ast2400-a1",
119
.cpu_type = ARM_CPU_TYPE_NAME("arm926"),
120
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
121
.wdts_num = 2,
122
.irqmap = aspeed_soc_ast2400_irqmap,
123
.memmap = aspeed_soc_ast2400_memmap,
124
+ .num_cpus = 1,
125
}, {
126
.name = "ast2400",
127
.cpu_type = ARM_CPU_TYPE_NAME("arm926"),
128
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
129
.wdts_num = 2,
130
.irqmap = aspeed_soc_ast2400_irqmap,
131
.memmap = aspeed_soc_ast2400_memmap,
132
+ .num_cpus = 1,
133
}, {
134
.name = "ast2500-a1",
135
.cpu_type = ARM_CPU_TYPE_NAME("arm1176"),
136
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
137
.wdts_num = 3,
138
.irqmap = aspeed_soc_ast2500_irqmap,
139
.memmap = aspeed_soc_ast2500_memmap,
140
+ .num_cpus = 1,
141
},
142
};
143
144
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
145
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
146
int i;
147
148
- object_initialize_child(obj, "cpu", OBJECT(&s->cpu), sizeof(s->cpu),
149
- sc->info->cpu_type, &error_abort, NULL);
150
+ for (i = 0; i < sc->info->num_cpus; i++) {
151
+ object_initialize_child(obj, "cpu[*]", OBJECT(&s->cpu[i]),
152
+ sizeof(s->cpu[i]), sc->info->cpu_type,
153
+ &error_abort, NULL);
154
+ }
155
156
sysbus_init_child_obj(obj, "scu", OBJECT(&s->scu), sizeof(s->scu),
157
TYPE_ASPEED_SCU);
158
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
159
create_unimplemented_device("aspeed_soc.io", sc->info->memmap[ASPEED_IOMEM],
160
ASPEED_SOC_IOMEM_SIZE);
161
162
+ if (s->num_cpus > sc->info->num_cpus) {
163
+ warn_report("%s: invalid number of CPUs %d, using default %d",
164
+ sc->info->name, s->num_cpus, sc->info->num_cpus);
165
+ s->num_cpus = sc->info->num_cpus;
166
+ }
167
+
168
/* CPU */
169
- object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
170
- if (err) {
171
- error_propagate(errp, err);
172
- return;
173
+ for (i = 0; i < s->num_cpus; i++) {
174
+ object_property_set_bool(OBJECT(&s->cpu[i]), true, "realized", &err);
175
+ if (err) {
176
+ error_propagate(errp, err);
177
+ return;
178
+ }
179
}
180
181
/* SRAM */
182
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
183
sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0,
184
aspeed_soc_get_irq(s, ASPEED_ETH1));
185
}
186
+static Property aspeed_soc_properties[] = {
187
+ DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0),
188
+ DEFINE_PROP_END_OF_LIST(),
189
+};
190
191
static void aspeed_soc_class_init(ObjectClass *oc, void *data)
192
{
193
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_class_init(ObjectClass *oc, void *data)
194
dc->realize = aspeed_soc_realize;
195
/* Reason: Uses serial_hds and nd_table in realize() directly */
196
dc->user_creatable = false;
197
+ dc->props = aspeed_soc_properties;
198
}
199
200
static const TypeInfo aspeed_soc_type_info = {
201
--
202
2.20.1
203
204
diff view generated by jsdifflib
Deleted patch
1
From: Cédric Le Goater <clg@kaod.org>
2
1
3
The Aspeed SoCs have two MACs. Extend the Aspeed model to support a
4
second NIC.
5
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
7
Reviewed-by: Joel Stanley <joel@jms.id.au>
8
Message-id: 20190618165311.27066-7-clg@kaod.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
include/hw/arm/aspeed_soc.h | 3 ++-
12
hw/arm/aspeed_soc.c | 33 +++++++++++++++++++--------------
13
2 files changed, 21 insertions(+), 15 deletions(-)
14
15
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/arm/aspeed_soc.h
18
+++ b/include/hw/arm/aspeed_soc.h
19
@@ -XXX,XX +XXX,XX @@
20
#define ASPEED_SPIS_NUM 2
21
#define ASPEED_WDTS_NUM 3
22
#define ASPEED_CPUS_NUM 2
23
+#define ASPEED_MACS_NUM 2
24
25
typedef struct AspeedSoCState {
26
/*< private >*/
27
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState {
28
AspeedSMCState spi[ASPEED_SPIS_NUM];
29
AspeedSDMCState sdmc;
30
AspeedWDTState wdt[ASPEED_WDTS_NUM];
31
- FTGMAC100State ftgmac100;
32
+ FTGMAC100State ftgmac100[ASPEED_MACS_NUM];
33
} AspeedSoCState;
34
35
#define TYPE_ASPEED_SOC "aspeed-soc"
36
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/hw/arm/aspeed_soc.c
39
+++ b/hw/arm/aspeed_soc.c
40
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
41
sc->info->silicon_rev);
42
}
43
44
- sysbus_init_child_obj(obj, "ftgmac100", OBJECT(&s->ftgmac100),
45
- sizeof(s->ftgmac100), TYPE_FTGMAC100);
46
+ for (i = 0; i < ASPEED_MACS_NUM; i++) {
47
+ sysbus_init_child_obj(obj, "ftgmac100[*]", OBJECT(&s->ftgmac100[i]),
48
+ sizeof(s->ftgmac100[i]), TYPE_FTGMAC100);
49
+ }
50
}
51
52
static void aspeed_soc_realize(DeviceState *dev, Error **errp)
53
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
54
}
55
56
/* Net */
57
- qdev_set_nic_properties(DEVICE(&s->ftgmac100), &nd_table[0]);
58
- object_property_set_bool(OBJECT(&s->ftgmac100), true, "aspeed", &err);
59
- object_property_set_bool(OBJECT(&s->ftgmac100), true, "realized",
60
- &local_err);
61
- error_propagate(&err, local_err);
62
- if (err) {
63
- error_propagate(errp, err);
64
- return;
65
+ for (i = 0; i < nb_nics; i++) {
66
+ qdev_set_nic_properties(DEVICE(&s->ftgmac100[i]), &nd_table[i]);
67
+ object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "aspeed",
68
+ &err);
69
+ object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "realized",
70
+ &local_err);
71
+ error_propagate(&err, local_err);
72
+ if (err) {
73
+ error_propagate(errp, err);
74
+ return;
75
+ }
76
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0,
77
+ sc->info->memmap[ASPEED_ETH1 + i]);
78
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0,
79
+ aspeed_soc_get_irq(s, ASPEED_ETH1 + i));
80
}
81
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0,
82
- sc->info->memmap[ASPEED_ETH1]);
83
- sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0,
84
- aspeed_soc_get_irq(s, ASPEED_ETH1));
85
}
86
static Property aspeed_soc_properties[] = {
87
DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0),
88
--
89
2.20.1
90
91
diff view generated by jsdifflib
Deleted patch
1
From: Joel Stanley <joel@jms.id.au>
2
1
3
The Linux kernel driver was updated in commit 4451d3f59f2a
4
("clocksource/drivers/fttmr010: Fix set_next_event handler) to fix an
5
issue observed on hardware:
6
7
> RELOAD register is loaded into COUNT register when the aspeed timer
8
> is enabled, which means the next event may be delayed because timer
9
> interrupt won't be generated until <0xFFFFFFFF - current_count +
10
> cycles>.
11
12
When running under Qemu, the system appeared "laggy". The guest is now
13
scheduling timer events too regularly, starving the host of CPU time.
14
15
This patch modifies the timer model to attempt to schedule the timer
16
expiry as the guest requests, but if we have missed the deadline we
17
re interrupt and try again, which allows the guest to catch up.
18
19
Provides expected behaviour with old and new guest code.
20
21
Fixes: c04bd47db6b9 ("hw/timer: Add ASPEED timer device model")
22
Signed-off-by: Joel Stanley <joel@jms.id.au>
23
Signed-off-by: Cédric Le Goater <clg@kaod.org>
24
Message-id: 20190618165311.27066-8-clg@kaod.org
25
[clg: - merged a fix from Andrew Jeffery <andrew@aj.id.au>
26
"Fire interrupt on failure to meet deadline"
27
https://lists.ozlabs.org/pipermail/openbmc/2019-January/014641.html
28
- adapted commit log
29
- checkpatch fixes ]
30
Signed-off-by: Cédric Le Goater <clg@kaod.org>
31
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
32
---
33
hw/timer/aspeed_timer.c | 57 ++++++++++++++++++++++-------------------
34
1 file changed, 30 insertions(+), 27 deletions(-)
35
36
diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/hw/timer/aspeed_timer.c
39
+++ b/hw/timer/aspeed_timer.c
40
@@ -XXX,XX +XXX,XX @@ static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks)
41
42
static uint64_t calculate_next(struct AspeedTimer *t)
43
{
44
- uint64_t next = 0;
45
- uint32_t rate = calculate_rate(t);
46
+ uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
47
+ uint64_t next;
48
49
- while (!next) {
50
- /* We don't know the relationship between the values in the match
51
- * registers, so sort using MAX/MIN/zero. We sort in that order as the
52
- * timer counts down to zero. */
53
- uint64_t seq[] = {
54
- calculate_time(t, MAX(t->match[0], t->match[1])),
55
- calculate_time(t, MIN(t->match[0], t->match[1])),
56
- calculate_time(t, 0),
57
- };
58
- uint64_t reload_ns;
59
- uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
60
+ /*
61
+ * We don't know the relationship between the values in the match
62
+ * registers, so sort using MAX/MIN/zero. We sort in that order as
63
+ * the timer counts down to zero.
64
+ */
65
66
- if (now < seq[0]) {
67
- next = seq[0];
68
- } else if (now < seq[1]) {
69
- next = seq[1];
70
- } else if (now < seq[2]) {
71
- next = seq[2];
72
- } else if (t->reload) {
73
- reload_ns = muldiv64(t->reload, NANOSECONDS_PER_SECOND, rate);
74
- t->start = now - ((now - t->start) % reload_ns);
75
- } else {
76
- /* no reload value, return 0 */
77
- break;
78
- }
79
+ next = calculate_time(t, MAX(t->match[0], t->match[1]));
80
+ if (now < next) {
81
+ return next;
82
}
83
84
- return next;
85
+ next = calculate_time(t, MIN(t->match[0], t->match[1]));
86
+ if (now < next) {
87
+ return next;
88
+ }
89
+
90
+ next = calculate_time(t, 0);
91
+ if (now < next) {
92
+ return next;
93
+ }
94
+
95
+ /* We've missed all deadlines, fire interrupt and try again */
96
+ timer_del(&t->timer);
97
+
98
+ if (timer_overflow_interrupt(t)) {
99
+ t->level = !t->level;
100
+ qemu_set_irq(t->irq, t->level);
101
+ }
102
+
103
+ t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
104
+ return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0));
105
}
106
107
static void aspeed_timer_mod(AspeedTimer *t)
108
--
109
2.20.1
110
111
diff view generated by jsdifflib
Deleted patch
1
From: Andrew Jeffery <andrew@aj.id.au>
2
1
3
From the datasheet:
4
5
This register stores the current status of counter #N. When timer
6
enable bit TMC30[N * b] is disabled, the reload register will be
7
loaded into this counter. When timer bit TMC30[N * b] is set, the
8
counter will start to decrement. CPU can update this register value
9
when enable bit is set.
10
11
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
12
Signed-off-by: Cédric Le Goater <clg@kaod.org>
13
Reviewed-by: Joel Stanley <joel@jms.id.au>
14
Message-id: 20190618165311.27066-9-clg@kaod.org
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
17
hw/timer/aspeed_timer.c | 6 +++++-
18
1 file changed, 5 insertions(+), 1 deletion(-)
19
20
diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/timer/aspeed_timer.c
23
+++ b/hw/timer/aspeed_timer.c
24
@@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_timer_get_value(AspeedTimer *t, int reg)
25
26
switch (reg) {
27
case TIMER_REG_STATUS:
28
- value = calculate_ticks(t, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
29
+ if (timer_enabled(t)) {
30
+ value = calculate_ticks(t, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
31
+ } else {
32
+ value = t->reload;
33
+ }
34
break;
35
case TIMER_REG_RELOAD:
36
value = t->reload;
37
--
38
2.20.1
39
40
diff view generated by jsdifflib
Deleted patch
1
From: Andrew Jeffery <andrew@aj.id.au>
2
1
3
If the match value exceeds reload then we don't want to include it in
4
calculations for the next event.
5
6
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
7
Signed-off-by: Cédric Le Goater <clg@kaod.org>
8
Message-id: 20190618165311.27066-10-clg@kaod.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
hw/timer/aspeed_timer.c | 13 ++++++++++---
12
1 file changed, 10 insertions(+), 3 deletions(-)
13
14
diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/timer/aspeed_timer.c
17
+++ b/hw/timer/aspeed_timer.c
18
@@ -XXX,XX +XXX,XX @@ static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks)
19
return t->start + delta_ns;
20
}
21
22
+static inline uint32_t calculate_match(struct AspeedTimer *t, int i)
23
+{
24
+ return t->match[i] < t->reload ? t->match[i] : 0;
25
+}
26
+
27
static uint64_t calculate_next(struct AspeedTimer *t)
28
{
29
uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
30
@@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t)
31
* the timer counts down to zero.
32
*/
33
34
- next = calculate_time(t, MAX(t->match[0], t->match[1]));
35
+ next = calculate_time(t, MAX(calculate_match(t, 0), calculate_match(t, 1)));
36
if (now < next) {
37
return next;
38
}
39
40
- next = calculate_time(t, MIN(t->match[0], t->match[1]));
41
+ next = calculate_time(t, MIN(calculate_match(t, 0), calculate_match(t, 1)));
42
if (now < next) {
43
return next;
44
}
45
@@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t)
46
qemu_set_irq(t->irq, t->level);
47
}
48
49
+ next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0);
50
t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
51
- return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0));
52
+
53
+ return calculate_time(t, next);
54
}
55
56
static void aspeed_timer_mod(AspeedTimer *t)
57
--
58
2.20.1
59
60
diff view generated by jsdifflib
Deleted patch
1
From: Christian Svensson <bluecmd@google.com>
2
1
3
If the host decrements the counter register that results in a negative
4
delta. This is then passed to muldiv64 which only handles unsigned
5
numbers resulting in bogus results.
6
7
This fix ensures the delta being operated on is positive.
8
9
Test case: kexec a kernel using aspeed_timer and it will freeze on the
10
second bootup when the kernel initializes the timer. With this patch
11
that no longer happens and the timer appears to run OK.
12
13
Signed-off-by: Christian Svensson <bluecmd@google.com>
14
Signed-off-by: Cédric Le Goater <clg@kaod.org>
15
Reviewed-by: Joel Stanley <joel@jms.id.au>
16
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
17
Message-id: 20190618165311.27066-12-clg@kaod.org
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
20
hw/timer/aspeed_timer.c | 6 +++++-
21
1 file changed, 5 insertions(+), 1 deletion(-)
22
23
diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
24
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/timer/aspeed_timer.c
26
+++ b/hw/timer/aspeed_timer.c
27
@@ -XXX,XX +XXX,XX @@ static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg,
28
int64_t delta = (int64_t) value - (int64_t) calculate_ticks(t, now);
29
uint32_t rate = calculate_rate(t);
30
31
- t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate);
32
+ if (delta >= 0) {
33
+ t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate);
34
+ } else {
35
+ t->start -= muldiv64(-delta, NANOSECONDS_PER_SECOND, rate);
36
+ }
37
aspeed_timer_mod(t);
38
}
39
break;
40
--
41
2.20.1
42
43
diff view generated by jsdifflib
Deleted patch
1
From: Cédric Le Goater <clg@kaod.org>
2
1
3
It has never been used as far as I can tell from the git history.
4
5
Signed-off-by: Cédric Le Goater <clg@kaod.org>
6
Reviewed-by: Joel Stanley <joel@jms.id.au>
7
Message-id: 20190618165311.27066-13-clg@kaod.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
hw/arm/aspeed.c | 2 --
11
1 file changed, 2 deletions(-)
12
13
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/aspeed.c
16
+++ b/hw/arm/aspeed.c
17
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
18
memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size);
19
memory_region_add_subregion(get_system_memory(),
20
sc->info->memmap[ASPEED_SDRAM], &bmc->ram);
21
- object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram),
22
- &error_abort);
23
24
max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size",
25
&error_abort);
26
--
27
2.20.1
28
29
diff view generated by jsdifflib
Deleted patch
1
From: Cédric Le Goater <clg@kaod.org>
2
1
3
The RAM memory region is defined after the SoC is realized when the
4
SDMC controller has checked that the defined RAM size for the machine
5
is correct. This is problematic for controller models requiring a link
6
on the RAM region, for DMA support in the SMC controller for instance.
7
8
Introduce a container memory region for the RAM that we can link into
9
the controllers early, before the SoC is realized. It will be
10
populated with the RAM region after the checks have be done.
11
12
Signed-off-by: Cédric Le Goater <clg@kaod.org>
13
Reviewed-by: Joel Stanley <joel@jms.id.au>
14
Message-id: 20190618165311.27066-14-clg@kaod.org
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
17
hw/arm/aspeed.c | 13 +++++++++----
18
1 file changed, 9 insertions(+), 4 deletions(-)
19
20
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/aspeed.c
23
+++ b/hw/arm/aspeed.c
24
@@ -XXX,XX +XXX,XX @@ static struct arm_boot_info aspeed_board_binfo = {
25
26
struct AspeedBoardState {
27
AspeedSoCState soc;
28
+ MemoryRegion ram_container;
29
MemoryRegion ram;
30
MemoryRegion max_ram;
31
};
32
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
33
ram_addr_t max_ram_size;
34
35
bmc = g_new0(AspeedBoardState, 1);
36
+
37
+ memory_region_init(&bmc->ram_container, NULL, "aspeed-ram-container",
38
+ UINT32_MAX);
39
+
40
object_initialize_child(OBJECT(machine), "soc", &bmc->soc,
41
(sizeof(bmc->soc)), cfg->soc_name, &error_abort,
42
NULL);
43
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
44
&error_abort);
45
46
memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size);
47
+ memory_region_add_subregion(&bmc->ram_container, 0, &bmc->ram);
48
memory_region_add_subregion(get_system_memory(),
49
- sc->info->memmap[ASPEED_SDRAM], &bmc->ram);
50
+ sc->info->memmap[ASPEED_SDRAM],
51
+ &bmc->ram_container);
52
53
max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size",
54
&error_abort);
55
memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL,
56
"max_ram", max_ram_size - ram_size);
57
- memory_region_add_subregion(get_system_memory(),
58
- sc->info->memmap[ASPEED_SDRAM] + ram_size,
59
- &bmc->max_ram);
60
+ memory_region_add_subregion(&bmc->ram_container, ram_size, &bmc->max_ram);
61
62
aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort);
63
aspeed_board_init_flashes(&bmc->soc.spi[0], cfg->spi_model, &error_abort);
64
--
65
2.20.1
66
67
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Where architecturally one ARM_FEATURE_X flag implies another
2
2
ARM_FEATURE_Y, we allow the CPU init function to only set X, and then
3
Suggested-by: Samuel Ortiz <sameo@linux.intel.com>
3
set Y for it. Currently we do this in two places -- we set a few
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
flags in arm_cpu_post_init() because we need them to decide which
5
Message-id: 20190701132516.26392-11-philmd@redhat.com
5
properties to create on the CPU object, and then we do the rest in
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
arm_cpu_realizefn(). However, this is fragile, because it's easy to
7
add a new property and not notice that this means that an X-implies-Y
8
check now has to move from realize to post-init.
9
10
As a specific example, the pmsav7-dregion property is conditional
11
on ARM_FEATURE_PMSA && ARM_FEATURE_V7, which means it won't appear
12
on the Cortex-M33 and -M55, because they set ARM_FEATURE_V8 and
13
rely on V8-implies-V7, which doesn't happen until the realizefn.
14
15
Move all of these X-implies-Y checks into a new function, which
16
we call at the top of arm_cpu_post_init(), so the feature bits
17
are available at that point.
18
19
This does now give us the reverse issue, that if there's a feature
20
bit which is enabled or disabled by the setting of a property then
21
then X-implies-Y features that are dependent on that property need to
22
be in realize, not in this new function. But the only one of those
23
is the "EL3 implies VBAR" which is already in the right place, so
24
putting things this way round seems better to me.
25
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
28
Message-id: 20230724174335.2150499-2-peter.maydell@linaro.org
8
---
29
---
9
target/arm/cpu.h | 2 -
30
target/arm/cpu.c | 179 +++++++++++++++++++++++++----------------------
10
target/arm/translate.h | 5 -
31
1 file changed, 97 insertions(+), 82 deletions(-)
11
target/arm/cpu.c | 226 +++++++++++++++++++++++++++++++++++++
32
12
target/arm/translate-a64.c | 128 ---------------------
13
target/arm/translate.c | 88 ---------------
14
5 files changed, 226 insertions(+), 223 deletions(-)
15
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.h
19
+++ b/target/arm/cpu.h
20
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cpu);
21
void arm_v7m_cpu_do_interrupt(CPUState *cpu);
22
bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req);
23
24
-void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags);
25
-
26
hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
27
MemTxAttrs *attrs);
28
29
diff --git a/target/arm/translate.h b/target/arm/translate.h
30
index XXXXXXX..XXXXXXX 100644
31
--- a/target/arm/translate.h
32
+++ b/target/arm/translate.h
33
@@ -XXX,XX +XXX,XX @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn)
34
#ifdef TARGET_AARCH64
35
void a64_translate_init(void);
36
void gen_a64_set_pc_im(uint64_t val);
37
-void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags);
38
extern const TranslatorOps aarch64_translator_ops;
39
#else
40
static inline void a64_translate_init(void)
41
@@ -XXX,XX +XXX,XX @@ static inline void a64_translate_init(void)
42
static inline void gen_a64_set_pc_im(uint64_t val)
43
{
44
}
45
-
46
-static inline void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
47
-{
48
-}
49
#endif
50
51
void arm_test_cc(DisasCompare *cmp, int cc);
52
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
33
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
53
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
54
--- a/target/arm/cpu.c
35
--- a/target/arm/cpu.c
55
+++ b/target/arm/cpu.c
36
+++ b/target/arm/cpu.c
56
@@ -XXX,XX +XXX,XX @@
37
@@ -XXX,XX +XXX,XX @@ unsigned int gt_cntfrq_period_ns(ARMCPU *cpu)
57
*/
38
NANOSECONDS_PER_SECOND / cpu->gt_cntfrq_hz : 1;
58
59
#include "qemu/osdep.h"
60
+#include "qemu/qemu-print.h"
61
#include "qemu-common.h"
62
#include "target/arm/idau.h"
63
#include "qemu/module.h"
64
@@ -XXX,XX +XXX,XX @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info)
65
#endif
66
}
39
}
67
40
68
+#ifdef TARGET_AARCH64
41
+static void arm_cpu_propagate_feature_implications(ARMCPU *cpu)
69
+
70
+static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
71
+{
42
+{
72
+ ARMCPU *cpu = ARM_CPU(cs);
73
+ CPUARMState *env = &cpu->env;
43
+ CPUARMState *env = &cpu->env;
74
+ uint32_t psr = pstate_read(env);
44
+ bool no_aa32 = false;
75
+ int i;
45
+
76
+ int el = arm_current_el(env);
46
+ /*
77
+ const char *ns_status;
47
+ * Some features automatically imply others: set the feature
78
+
48
+ * bits explicitly for these cases.
79
+ qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc);
49
+ */
80
+ for (i = 0; i < 32; i++) {
50
+
81
+ if (i == 31) {
51
+ if (arm_feature(env, ARM_FEATURE_M)) {
82
+ qemu_fprintf(f, " SP=%016" PRIx64 "\n", env->xregs[i]);
52
+ set_feature(env, ARM_FEATURE_PMSA);
53
+ }
54
+
55
+ if (arm_feature(env, ARM_FEATURE_V8)) {
56
+ if (arm_feature(env, ARM_FEATURE_M)) {
57
+ set_feature(env, ARM_FEATURE_V7);
83
+ } else {
58
+ } else {
84
+ qemu_fprintf(f, "X%02d=%016" PRIx64 "%s", i, env->xregs[i],
59
+ set_feature(env, ARM_FEATURE_V7VE);
85
+ (i + 2) % 3 ? " " : "\n");
86
+ }
60
+ }
87
+ }
61
+ }
88
+
62
+
89
+ if (arm_feature(env, ARM_FEATURE_EL3) && el != 3) {
63
+ /*
90
+ ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S ";
64
+ * There exist AArch64 cpus without AArch32 support. When KVM
91
+ } else {
65
+ * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN.
92
+ ns_status = "";
66
+ * Similarly, we cannot check ID_AA64PFR0 without AArch64 support.
93
+ }
67
+ * As a general principle, we also do not make ID register
94
+ qemu_fprintf(f, "PSTATE=%08x %c%c%c%c %sEL%d%c",
68
+ * consistency checks anywhere unless using TCG, because only
95
+ psr,
69
+ * for TCG would a consistency-check failure be a QEMU bug.
96
+ psr & PSTATE_N ? 'N' : '-',
70
+ */
97
+ psr & PSTATE_Z ? 'Z' : '-',
71
+ if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
98
+ psr & PSTATE_C ? 'C' : '-',
72
+ no_aa32 = !cpu_isar_feature(aa64_aa32, cpu);
99
+ psr & PSTATE_V ? 'V' : '-',
73
+ }
100
+ ns_status,
74
+
101
+ el,
75
+ if (arm_feature(env, ARM_FEATURE_V7VE)) {
102
+ psr & PSTATE_SP ? 'h' : 't');
76
+ /*
103
+
77
+ * v7 Virtualization Extensions. In real hardware this implies
104
+ if (cpu_isar_feature(aa64_bti, cpu)) {
78
+ * EL2 and also the presence of the Security Extensions.
105
+ qemu_fprintf(f, " BTYPE=%d", (psr & PSTATE_BTYPE) >> 10);
79
+ * For QEMU, for backwards-compatibility we implement some
106
+ }
80
+ * CPUs or CPU configs which have no actual EL2 or EL3 but do
107
+ if (!(flags & CPU_DUMP_FPU)) {
81
+ * include the various other features that V7VE implies.
108
+ qemu_fprintf(f, "\n");
82
+ * Presence of EL2 itself is ARM_FEATURE_EL2, and of the
109
+ return;
83
+ * Security Extensions is ARM_FEATURE_EL3.
110
+ }
84
+ */
111
+ if (fp_exception_el(env, el) != 0) {
85
+ assert(!tcg_enabled() || no_aa32 ||
112
+ qemu_fprintf(f, " FPU disabled\n");
86
+ cpu_isar_feature(aa32_arm_div, cpu));
113
+ return;
87
+ set_feature(env, ARM_FEATURE_LPAE);
114
+ }
88
+ set_feature(env, ARM_FEATURE_V7);
115
+ qemu_fprintf(f, " FPCR=%08x FPSR=%08x\n",
89
+ }
116
+ vfp_get_fpcr(env), vfp_get_fpsr(env));
90
+ if (arm_feature(env, ARM_FEATURE_V7)) {
117
+
91
+ set_feature(env, ARM_FEATURE_VAPA);
118
+ if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) == 0) {
92
+ set_feature(env, ARM_FEATURE_THUMB2);
119
+ int j, zcr_len = sve_zcr_len_for_el(env, el);
93
+ set_feature(env, ARM_FEATURE_MPIDR);
120
+
94
+ if (!arm_feature(env, ARM_FEATURE_M)) {
121
+ for (i = 0; i <= FFR_PRED_NUM; i++) {
95
+ set_feature(env, ARM_FEATURE_V6K);
122
+ bool eol;
96
+ } else {
123
+ if (i == FFR_PRED_NUM) {
97
+ set_feature(env, ARM_FEATURE_V6);
124
+ qemu_fprintf(f, "FFR=");
125
+ /* It's last, so end the line. */
126
+ eol = true;
127
+ } else {
128
+ qemu_fprintf(f, "P%02d=", i);
129
+ switch (zcr_len) {
130
+ case 0:
131
+ eol = i % 8 == 7;
132
+ break;
133
+ case 1:
134
+ eol = i % 6 == 5;
135
+ break;
136
+ case 2:
137
+ case 3:
138
+ eol = i % 3 == 2;
139
+ break;
140
+ default:
141
+ /* More than one quadword per predicate. */
142
+ eol = true;
143
+ break;
144
+ }
145
+ }
146
+ for (j = zcr_len / 4; j >= 0; j--) {
147
+ int digits;
148
+ if (j * 4 + 4 <= zcr_len + 1) {
149
+ digits = 16;
150
+ } else {
151
+ digits = (zcr_len % 4 + 1) * 4;
152
+ }
153
+ qemu_fprintf(f, "%0*" PRIx64 "%s", digits,
154
+ env->vfp.pregs[i].p[j],
155
+ j ? ":" : eol ? "\n" : " ");
156
+ }
157
+ }
98
+ }
158
+
99
+
159
+ for (i = 0; i < 32; i++) {
100
+ /*
160
+ if (zcr_len == 0) {
101
+ * Always define VBAR for V7 CPUs even if it doesn't exist in
161
+ qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 "%s",
102
+ * non-EL3 configs. This is needed by some legacy boards.
162
+ i, env->vfp.zregs[i].d[1],
103
+ */
163
+ env->vfp.zregs[i].d[0], i & 1 ? "\n" : " ");
104
+ set_feature(env, ARM_FEATURE_VBAR);
164
+ } else if (zcr_len == 1) {
105
+ }
165
+ qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64
106
+ if (arm_feature(env, ARM_FEATURE_V6K)) {
166
+ ":%016" PRIx64 ":%016" PRIx64 "\n",
107
+ set_feature(env, ARM_FEATURE_V6);
167
+ i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].d[2],
108
+ set_feature(env, ARM_FEATURE_MVFR);
168
+ env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0]);
109
+ }
169
+ } else {
110
+ if (arm_feature(env, ARM_FEATURE_V6)) {
170
+ for (j = zcr_len; j >= 0; j--) {
111
+ set_feature(env, ARM_FEATURE_V5);
171
+ bool odd = (zcr_len - j) % 2 != 0;
112
+ if (!arm_feature(env, ARM_FEATURE_M)) {
172
+ if (j == zcr_len) {
113
+ assert(!tcg_enabled() || no_aa32 ||
173
+ qemu_fprintf(f, "Z%02d[%x-%x]=", i, j, j - 1);
114
+ cpu_isar_feature(aa32_jazelle, cpu));
174
+ } else if (!odd) {
115
+ set_feature(env, ARM_FEATURE_AUXCR);
175
+ if (j > 0) {
176
+ qemu_fprintf(f, " [%x-%x]=", j, j - 1);
177
+ } else {
178
+ qemu_fprintf(f, " [%x]=", j);
179
+ }
180
+ }
181
+ qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%s",
182
+ env->vfp.zregs[i].d[j * 2 + 1],
183
+ env->vfp.zregs[i].d[j * 2],
184
+ odd || j == 0 ? "\n" : ":");
185
+ }
186
+ }
187
+ }
116
+ }
188
+ } else {
117
+ }
189
+ for (i = 0; i < 32; i++) {
118
+ if (arm_feature(env, ARM_FEATURE_V5)) {
190
+ uint64_t *q = aa64_vfp_qreg(env, i);
119
+ set_feature(env, ARM_FEATURE_V4T);
191
+ qemu_fprintf(f, "Q%02d=%016" PRIx64 ":%016" PRIx64 "%s",
120
+ }
192
+ i, q[1], q[0], (i & 1 ? "\n" : " "));
121
+ if (arm_feature(env, ARM_FEATURE_LPAE)) {
193
+ }
122
+ set_feature(env, ARM_FEATURE_V7MP);
123
+ }
124
+ if (arm_feature(env, ARM_FEATURE_CBAR_RO)) {
125
+ set_feature(env, ARM_FEATURE_CBAR);
126
+ }
127
+ if (arm_feature(env, ARM_FEATURE_THUMB2) &&
128
+ !arm_feature(env, ARM_FEATURE_M)) {
129
+ set_feature(env, ARM_FEATURE_THUMB_DSP);
194
+ }
130
+ }
195
+}
131
+}
196
+
132
+
197
+#else
133
void arm_cpu_post_init(Object *obj)
198
+
199
+static inline void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
200
+{
201
+ g_assert_not_reached();
202
+}
203
+
204
+#endif
205
+
206
+static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags)
207
+{
208
+ ARMCPU *cpu = ARM_CPU(cs);
209
+ CPUARMState *env = &cpu->env;
210
+ int i;
211
+
212
+ if (is_a64(env)) {
213
+ aarch64_cpu_dump_state(cs, f, flags);
214
+ return;
215
+ }
216
+
217
+ for (i = 0; i < 16; i++) {
218
+ qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]);
219
+ if ((i % 4) == 3) {
220
+ qemu_fprintf(f, "\n");
221
+ } else {
222
+ qemu_fprintf(f, " ");
223
+ }
224
+ }
225
+
226
+ if (arm_feature(env, ARM_FEATURE_M)) {
227
+ uint32_t xpsr = xpsr_read(env);
228
+ const char *mode;
229
+ const char *ns_status = "";
230
+
231
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
232
+ ns_status = env->v7m.secure ? "S " : "NS ";
233
+ }
234
+
235
+ if (xpsr & XPSR_EXCP) {
236
+ mode = "handler";
237
+ } else {
238
+ if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_NPRIV_MASK) {
239
+ mode = "unpriv-thread";
240
+ } else {
241
+ mode = "priv-thread";
242
+ }
243
+ }
244
+
245
+ qemu_fprintf(f, "XPSR=%08x %c%c%c%c %c %s%s\n",
246
+ xpsr,
247
+ xpsr & XPSR_N ? 'N' : '-',
248
+ xpsr & XPSR_Z ? 'Z' : '-',
249
+ xpsr & XPSR_C ? 'C' : '-',
250
+ xpsr & XPSR_V ? 'V' : '-',
251
+ xpsr & XPSR_T ? 'T' : 'A',
252
+ ns_status,
253
+ mode);
254
+ } else {
255
+ uint32_t psr = cpsr_read(env);
256
+ const char *ns_status = "";
257
+
258
+ if (arm_feature(env, ARM_FEATURE_EL3) &&
259
+ (psr & CPSR_M) != ARM_CPU_MODE_MON) {
260
+ ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S ";
261
+ }
262
+
263
+ qemu_fprintf(f, "PSR=%08x %c%c%c%c %c %s%s%d\n",
264
+ psr,
265
+ psr & CPSR_N ? 'N' : '-',
266
+ psr & CPSR_Z ? 'Z' : '-',
267
+ psr & CPSR_C ? 'C' : '-',
268
+ psr & CPSR_V ? 'V' : '-',
269
+ psr & CPSR_T ? 'T' : 'A',
270
+ ns_status,
271
+ aarch32_mode_name(psr), (psr & 0x10) ? 32 : 26);
272
+ }
273
+
274
+ if (flags & CPU_DUMP_FPU) {
275
+ int numvfpregs = 0;
276
+ if (arm_feature(env, ARM_FEATURE_VFP)) {
277
+ numvfpregs += 16;
278
+ }
279
+ if (arm_feature(env, ARM_FEATURE_VFP3)) {
280
+ numvfpregs += 16;
281
+ }
282
+ for (i = 0; i < numvfpregs; i++) {
283
+ uint64_t v = *aa32_vfp_dreg(env, i);
284
+ qemu_fprintf(f, "s%02d=%08x s%02d=%08x d%02d=%016" PRIx64 "\n",
285
+ i * 2, (uint32_t)v,
286
+ i * 2 + 1, (uint32_t)(v >> 32),
287
+ i, v);
288
+ }
289
+ qemu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env));
290
+ }
291
+}
292
+
293
uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz)
294
{
134
{
295
uint32_t Aff1 = idx / clustersz;
135
ARMCPU *cpu = ARM_CPU(obj);
296
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
136
297
index XXXXXXX..XXXXXXX 100644
137
- /* M profile implies PMSA. We have to do this here rather than
298
--- a/target/arm/translate-a64.c
138
- * in realize with the other feature-implication checks because
299
+++ b/target/arm/translate-a64.c
139
- * we look at the PMSA bit to see if we should add some properties.
300
@@ -XXX,XX +XXX,XX @@
140
+ /*
301
#include "translate.h"
141
+ * Some features imply others. Figure this out now, because we
302
#include "internals.h"
142
+ * are going to look at the feature bits in deciding which
303
#include "qemu/host-utils.h"
143
+ * properties to add.
304
-#include "qemu/qemu-print.h"
144
*/
305
145
- if (arm_feature(&cpu->env, ARM_FEATURE_M)) {
306
#include "hw/semihosting/semihost.h"
146
- set_feature(&cpu->env, ARM_FEATURE_PMSA);
307
#include "exec/gen-icount.h"
147
- }
308
@@ -XXX,XX +XXX,XX @@ static void set_btype(DisasContext *s, int val)
148
+ arm_cpu_propagate_feature_implications(cpu);
309
s->btype = -1;
149
310
}
150
if (arm_feature(&cpu->env, ARM_FEATURE_CBAR) ||
311
151
arm_feature(&cpu->env, ARM_FEATURE_CBAR_RO)) {
312
-void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
152
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
313
-{
153
CPUARMState *env = &cpu->env;
314
- ARMCPU *cpu = ARM_CPU(cs);
154
int pagebits;
315
- CPUARMState *env = &cpu->env;
155
Error *local_err = NULL;
316
- uint32_t psr = pstate_read(env);
156
- bool no_aa32 = false;
317
- int i;
157
318
- int el = arm_current_el(env);
158
/* Use pc-relative instructions in system-mode */
319
- const char *ns_status;
159
#ifndef CONFIG_USER_ONLY
160
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
161
cpu->isar.id_isar3 = u;
162
}
163
164
- /* Some features automatically imply others: */
165
- if (arm_feature(env, ARM_FEATURE_V8)) {
166
- if (arm_feature(env, ARM_FEATURE_M)) {
167
- set_feature(env, ARM_FEATURE_V7);
168
- } else {
169
- set_feature(env, ARM_FEATURE_V7VE);
170
- }
171
- }
320
-
172
-
321
- qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc);
173
- /*
322
- for (i = 0; i < 32; i++) {
174
- * There exist AArch64 cpus without AArch32 support. When KVM
323
- if (i == 31) {
175
- * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN.
324
- qemu_fprintf(f, " SP=%016" PRIx64 "\n", env->xregs[i]);
176
- * Similarly, we cannot check ID_AA64PFR0 without AArch64 support.
177
- * As a general principle, we also do not make ID register
178
- * consistency checks anywhere unless using TCG, because only
179
- * for TCG would a consistency-check failure be a QEMU bug.
180
- */
181
- if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
182
- no_aa32 = !cpu_isar_feature(aa64_aa32, cpu);
183
- }
184
-
185
- if (arm_feature(env, ARM_FEATURE_V7VE)) {
186
- /* v7 Virtualization Extensions. In real hardware this implies
187
- * EL2 and also the presence of the Security Extensions.
188
- * For QEMU, for backwards-compatibility we implement some
189
- * CPUs or CPU configs which have no actual EL2 or EL3 but do
190
- * include the various other features that V7VE implies.
191
- * Presence of EL2 itself is ARM_FEATURE_EL2, and of the
192
- * Security Extensions is ARM_FEATURE_EL3.
193
- */
194
- assert(!tcg_enabled() || no_aa32 ||
195
- cpu_isar_feature(aa32_arm_div, cpu));
196
- set_feature(env, ARM_FEATURE_LPAE);
197
- set_feature(env, ARM_FEATURE_V7);
198
- }
199
- if (arm_feature(env, ARM_FEATURE_V7)) {
200
- set_feature(env, ARM_FEATURE_VAPA);
201
- set_feature(env, ARM_FEATURE_THUMB2);
202
- set_feature(env, ARM_FEATURE_MPIDR);
203
- if (!arm_feature(env, ARM_FEATURE_M)) {
204
- set_feature(env, ARM_FEATURE_V6K);
325
- } else {
205
- } else {
326
- qemu_fprintf(f, "X%02d=%016" PRIx64 "%s", i, env->xregs[i],
206
- set_feature(env, ARM_FEATURE_V6);
327
- (i + 2) % 3 ? " " : "\n");
328
- }
329
- }
330
-
331
- if (arm_feature(env, ARM_FEATURE_EL3) && el != 3) {
332
- ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S ";
333
- } else {
334
- ns_status = "";
335
- }
336
- qemu_fprintf(f, "PSTATE=%08x %c%c%c%c %sEL%d%c",
337
- psr,
338
- psr & PSTATE_N ? 'N' : '-',
339
- psr & PSTATE_Z ? 'Z' : '-',
340
- psr & PSTATE_C ? 'C' : '-',
341
- psr & PSTATE_V ? 'V' : '-',
342
- ns_status,
343
- el,
344
- psr & PSTATE_SP ? 'h' : 't');
345
-
346
- if (cpu_isar_feature(aa64_bti, cpu)) {
347
- qemu_fprintf(f, " BTYPE=%d", (psr & PSTATE_BTYPE) >> 10);
348
- }
349
- if (!(flags & CPU_DUMP_FPU)) {
350
- qemu_fprintf(f, "\n");
351
- return;
352
- }
353
- if (fp_exception_el(env, el) != 0) {
354
- qemu_fprintf(f, " FPU disabled\n");
355
- return;
356
- }
357
- qemu_fprintf(f, " FPCR=%08x FPSR=%08x\n",
358
- vfp_get_fpcr(env), vfp_get_fpsr(env));
359
-
360
- if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) == 0) {
361
- int j, zcr_len = sve_zcr_len_for_el(env, el);
362
-
363
- for (i = 0; i <= FFR_PRED_NUM; i++) {
364
- bool eol;
365
- if (i == FFR_PRED_NUM) {
366
- qemu_fprintf(f, "FFR=");
367
- /* It's last, so end the line. */
368
- eol = true;
369
- } else {
370
- qemu_fprintf(f, "P%02d=", i);
371
- switch (zcr_len) {
372
- case 0:
373
- eol = i % 8 == 7;
374
- break;
375
- case 1:
376
- eol = i % 6 == 5;
377
- break;
378
- case 2:
379
- case 3:
380
- eol = i % 3 == 2;
381
- break;
382
- default:
383
- /* More than one quadword per predicate. */
384
- eol = true;
385
- break;
386
- }
387
- }
388
- for (j = zcr_len / 4; j >= 0; j--) {
389
- int digits;
390
- if (j * 4 + 4 <= zcr_len + 1) {
391
- digits = 16;
392
- } else {
393
- digits = (zcr_len % 4 + 1) * 4;
394
- }
395
- qemu_fprintf(f, "%0*" PRIx64 "%s", digits,
396
- env->vfp.pregs[i].p[j],
397
- j ? ":" : eol ? "\n" : " ");
398
- }
399
- }
207
- }
400
-
208
-
401
- for (i = 0; i < 32; i++) {
209
- /* Always define VBAR for V7 CPUs even if it doesn't exist in
402
- if (zcr_len == 0) {
210
- * non-EL3 configs. This is needed by some legacy boards.
403
- qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 "%s",
211
- */
404
- i, env->vfp.zregs[i].d[1],
212
- set_feature(env, ARM_FEATURE_VBAR);
405
- env->vfp.zregs[i].d[0], i & 1 ? "\n" : " ");
213
- }
406
- } else if (zcr_len == 1) {
214
- if (arm_feature(env, ARM_FEATURE_V6K)) {
407
- qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64
215
- set_feature(env, ARM_FEATURE_V6);
408
- ":%016" PRIx64 ":%016" PRIx64 "\n",
216
- set_feature(env, ARM_FEATURE_MVFR);
409
- i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].d[2],
217
- }
410
- env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0]);
218
- if (arm_feature(env, ARM_FEATURE_V6)) {
411
- } else {
219
- set_feature(env, ARM_FEATURE_V5);
412
- for (j = zcr_len; j >= 0; j--) {
220
- if (!arm_feature(env, ARM_FEATURE_M)) {
413
- bool odd = (zcr_len - j) % 2 != 0;
221
- assert(!tcg_enabled() || no_aa32 ||
414
- if (j == zcr_len) {
222
- cpu_isar_feature(aa32_jazelle, cpu));
415
- qemu_fprintf(f, "Z%02d[%x-%x]=", i, j, j - 1);
223
- set_feature(env, ARM_FEATURE_AUXCR);
416
- } else if (!odd) {
417
- if (j > 0) {
418
- qemu_fprintf(f, " [%x-%x]=", j, j - 1);
419
- } else {
420
- qemu_fprintf(f, " [%x]=", j);
421
- }
422
- }
423
- qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%s",
424
- env->vfp.zregs[i].d[j * 2 + 1],
425
- env->vfp.zregs[i].d[j * 2],
426
- odd || j == 0 ? "\n" : ":");
427
- }
428
- }
429
- }
224
- }
430
- } else {
225
- }
431
- for (i = 0; i < 32; i++) {
226
- if (arm_feature(env, ARM_FEATURE_V5)) {
432
- uint64_t *q = aa64_vfp_qreg(env, i);
227
- set_feature(env, ARM_FEATURE_V4T);
433
- qemu_fprintf(f, "Q%02d=%016" PRIx64 ":%016" PRIx64 "%s",
228
- }
434
- i, q[1], q[0], (i & 1 ? "\n" : " "));
229
- if (arm_feature(env, ARM_FEATURE_LPAE)) {
435
- }
230
- set_feature(env, ARM_FEATURE_V7MP);
436
- }
231
- }
437
-}
232
- if (arm_feature(env, ARM_FEATURE_CBAR_RO)) {
438
-
233
- set_feature(env, ARM_FEATURE_CBAR);
439
void gen_a64_set_pc_im(uint64_t val)
234
- }
440
{
235
- if (arm_feature(env, ARM_FEATURE_THUMB2) &&
441
tcg_gen_movi_i64(cpu_pc, val);
236
- !arm_feature(env, ARM_FEATURE_M)) {
442
diff --git a/target/arm/translate.c b/target/arm/translate.c
237
- set_feature(env, ARM_FEATURE_THUMB_DSP);
443
index XXXXXXX..XXXXXXX 100644
238
- }
444
--- a/target/arm/translate.c
239
445
+++ b/target/arm/translate.c
240
/*
446
@@ -XXX,XX +XXX,XX @@
241
* We rely on no XScale CPU having VFP so we can use the same bits in the
447
#include "tcg-op-gvec.h"
448
#include "qemu/log.h"
449
#include "qemu/bitops.h"
450
-#include "qemu/qemu-print.h"
451
#include "arm_ldst.h"
452
#include "hw/semihosting/semihost.h"
453
454
@@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns)
455
translator_loop(ops, &dc.base, cpu, tb, max_insns);
456
}
457
458
-void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags)
459
-{
460
- ARMCPU *cpu = ARM_CPU(cs);
461
- CPUARMState *env = &cpu->env;
462
- int i;
463
-
464
- if (is_a64(env)) {
465
- aarch64_cpu_dump_state(cs, f, flags);
466
- return;
467
- }
468
-
469
- for (i = 0; i < 16; i++) {
470
- qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]);
471
- if ((i % 4) == 3) {
472
- qemu_fprintf(f, "\n");
473
- } else {
474
- qemu_fprintf(f, " ");
475
- }
476
- }
477
-
478
- if (arm_feature(env, ARM_FEATURE_M)) {
479
- uint32_t xpsr = xpsr_read(env);
480
- const char *mode;
481
- const char *ns_status = "";
482
-
483
- if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
484
- ns_status = env->v7m.secure ? "S " : "NS ";
485
- }
486
-
487
- if (xpsr & XPSR_EXCP) {
488
- mode = "handler";
489
- } else {
490
- if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_NPRIV_MASK) {
491
- mode = "unpriv-thread";
492
- } else {
493
- mode = "priv-thread";
494
- }
495
- }
496
-
497
- qemu_fprintf(f, "XPSR=%08x %c%c%c%c %c %s%s\n",
498
- xpsr,
499
- xpsr & XPSR_N ? 'N' : '-',
500
- xpsr & XPSR_Z ? 'Z' : '-',
501
- xpsr & XPSR_C ? 'C' : '-',
502
- xpsr & XPSR_V ? 'V' : '-',
503
- xpsr & XPSR_T ? 'T' : 'A',
504
- ns_status,
505
- mode);
506
- } else {
507
- uint32_t psr = cpsr_read(env);
508
- const char *ns_status = "";
509
-
510
- if (arm_feature(env, ARM_FEATURE_EL3) &&
511
- (psr & CPSR_M) != ARM_CPU_MODE_MON) {
512
- ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S ";
513
- }
514
-
515
- qemu_fprintf(f, "PSR=%08x %c%c%c%c %c %s%s%d\n",
516
- psr,
517
- psr & CPSR_N ? 'N' : '-',
518
- psr & CPSR_Z ? 'Z' : '-',
519
- psr & CPSR_C ? 'C' : '-',
520
- psr & CPSR_V ? 'V' : '-',
521
- psr & CPSR_T ? 'T' : 'A',
522
- ns_status,
523
- aarch32_mode_name(psr), (psr & 0x10) ? 32 : 26);
524
- }
525
-
526
- if (flags & CPU_DUMP_FPU) {
527
- int numvfpregs = 0;
528
- if (arm_feature(env, ARM_FEATURE_VFP)) {
529
- numvfpregs += 16;
530
- }
531
- if (arm_feature(env, ARM_FEATURE_VFP3)) {
532
- numvfpregs += 16;
533
- }
534
- for (i = 0; i < numvfpregs; i++) {
535
- uint64_t v = *aa32_vfp_dreg(env, i);
536
- qemu_fprintf(f, "s%02d=%08x s%02d=%08x d%02d=%016" PRIx64 "\n",
537
- i * 2, (uint32_t)v,
538
- i * 2 + 1, (uint32_t)(v >> 32),
539
- i, v);
540
- }
541
- qemu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env));
542
- }
543
-}
544
-
545
void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb,
546
target_ulong *data)
547
{
548
--
242
--
549
2.20.1
243
2.34.1
550
551
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
M-profile CPUs generally allow configuration of the number of MPU
2
regions that they have. We don't currently model this, so our
3
implementations of some of the board models provide CPUs with the
4
wrong number of regions. RTOSes like Zephyr that hardcode the
5
expected number of regions may therefore not run on the model if they
6
are set up to run on real hardware.
2
7
3
The DRAM address of a DMA transaction depends on the DRAM base address
8
Add properties mpu-ns-regions and mpu-s-regions to the ARMV7M object,
4
of the SoC. Inform the SMC controller model with this value.
9
matching the ability of hardware to configure the number of Secure
10
and NonSecure regions separately. Our actual CPU implementation
11
doesn't currently support that, and it happens that none of the MPS
12
boards we model set the number of regions differently for Secure vs
13
NonSecure, so we provide an interface to the boards and SoCs that
14
won't need to change if we ever do add that functionality in future,
15
but make it an error to configure the two properties to different
16
values.
5
17
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
18
(The property name on the CPU is the somewhat misnamed-for-M-profile
7
Reviewed-by: Joel Stanley <joel@jms.id.au>
19
"pmsav7-dregion", so we don't follow that naming convention for
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
20
the properties here. The TRM doesn't say what the CPU configuration
9
Message-id: 20190618165311.27066-15-clg@kaod.org
21
variable names are, so we pick something, and follow the lowercase
22
convention we already have for properties here.)
23
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
26
Message-id: 20230724174335.2150499-3-peter.maydell@linaro.org
11
---
27
---
12
include/hw/ssi/aspeed_smc.h | 3 +++
28
include/hw/arm/armv7m.h | 8 ++++++++
13
hw/arm/aspeed_soc.c | 6 ++++++
29
hw/arm/armv7m.c | 21 +++++++++++++++++++++
14
hw/ssi/aspeed_smc.c | 1 +
30
2 files changed, 29 insertions(+)
15
3 files changed, 10 insertions(+)
16
31
17
diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h
32
diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h
18
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/ssi/aspeed_smc.h
34
--- a/include/hw/arm/armv7m.h
20
+++ b/include/hw/ssi/aspeed_smc.h
35
+++ b/include/hw/arm/armv7m.h
21
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCState {
36
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(ARMv7MState, ARMV7M)
22
uint8_t r_timings;
37
* + Property "vfp": enable VFP (forwarded to CPU object)
23
uint8_t conf_enable_w0;
38
* + Property "dsp": enable DSP (forwarded to CPU object)
24
39
* + Property "enable-bitband": expose bitbanded IO
25
+ /* for DMA support */
40
+ * + Property "mpu-ns-regions": number of Non-Secure MPU regions (forwarded
26
+ uint64_t sdram_base;
41
+ * to CPU object pmsav7-dregion property; default is whatever the default
27
+
42
+ * for the CPU is)
28
AspeedSMCFlash *flashes;
43
+ * + Property "mpu-s-regions": number of Secure MPU regions (default is
29
44
+ * whatever the default for the CPU is; must currently be set to the same
30
uint8_t snoop_index;
45
+ * value as mpu-ns-regions if the CPU implements the Security Extension)
31
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
46
* + Clock input "refclk" is the external reference clock for the systick timers
47
* + Clock input "cpuclk" is the main CPU clock
48
*/
49
@@ -XXX,XX +XXX,XX @@ struct ARMv7MState {
50
Object *idau;
51
uint32_t init_svtor;
52
uint32_t init_nsvtor;
53
+ uint32_t mpu_ns_regions;
54
+ uint32_t mpu_s_regions;
55
bool enable_bitband;
56
bool start_powered_off;
57
bool vfp;
58
diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
32
index XXXXXXX..XXXXXXX 100644
59
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/arm/aspeed_soc.c
60
--- a/hw/arm/armv7m.c
34
+++ b/hw/arm/aspeed_soc.c
61
+++ b/hw/arm/armv7m.c
35
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
62
@@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp)
36
aspeed_soc_get_irq(s, ASPEED_I2C));
63
}
37
64
}
38
/* FMC, The number of CS is set at the board level */
65
39
+ object_property_set_int(OBJECT(&s->fmc), sc->info->memmap[ASPEED_SDRAM],
66
+ /*
40
+ "sdram-base", &err);
67
+ * Real M-profile hardware can be configured with a different number of
41
+ if (err) {
68
+ * MPU regions for Secure vs NonSecure. QEMU's CPU implementation doesn't
42
+ error_propagate(errp, err);
69
+ * support that yet, so catch attempts to select that.
70
+ */
71
+ if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY) &&
72
+ s->mpu_ns_regions != s->mpu_s_regions) {
73
+ error_setg(errp,
74
+ "mpu-ns-regions and mpu-s-regions properties must have the same value");
43
+ return;
75
+ return;
44
+ }
76
+ }
45
object_property_set_bool(OBJECT(&s->fmc), true, "realized", &err);
77
+ if (s->mpu_ns_regions != UINT_MAX &&
46
if (err) {
78
+ object_property_find(OBJECT(s->cpu), "pmsav7-dregion")) {
47
error_propagate(errp, err);
79
+ if (!object_property_set_uint(OBJECT(s->cpu), "pmsav7-dregion",
48
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
80
+ s->mpu_ns_regions, errp)) {
49
index XXXXXXX..XXXXXXX 100644
81
+ return;
50
--- a/hw/ssi/aspeed_smc.c
82
+ }
51
+++ b/hw/ssi/aspeed_smc.c
83
+ }
52
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_smc = {
84
+
53
85
/*
54
static Property aspeed_smc_properties[] = {
86
* Tell the CPU where the NVIC is; it will fail realize if it doesn't
55
DEFINE_PROP_UINT32("num-cs", AspeedSMCState, num_cs, 1),
87
* have one. Similarly, tell the NVIC where its CPU is.
56
+ DEFINE_PROP_UINT64("sdram-base", AspeedSMCState, sdram_base, 0),
88
@@ -XXX,XX +XXX,XX @@ static Property armv7m_properties[] = {
89
false),
90
DEFINE_PROP_BOOL("vfp", ARMv7MState, vfp, true),
91
DEFINE_PROP_BOOL("dsp", ARMv7MState, dsp, true),
92
+ DEFINE_PROP_UINT32("mpu-ns-regions", ARMv7MState, mpu_ns_regions, UINT_MAX),
93
+ DEFINE_PROP_UINT32("mpu-s-regions", ARMv7MState, mpu_s_regions, UINT_MAX),
57
DEFINE_PROP_END_OF_LIST(),
94
DEFINE_PROP_END_OF_LIST(),
58
};
95
};
59
96
60
--
97
--
61
2.20.1
98
2.34.1
62
99
63
100
diff view generated by jsdifflib
Deleted patch
1
From: Adriana Kobylak <anoo@us.ibm.com>
2
1
3
The Swift board is an OpenPOWER system hosting POWER processors.
4
Add support for their BMC including the I2C devices as found on HW.
5
6
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Reviewed-by: Joel Stanley <joel@jms.id.au>
9
Message-id: 20190618165311.27066-20-clg@kaod.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/arm/aspeed.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
13
1 file changed, 50 insertions(+)
14
15
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/aspeed.c
18
+++ b/hw/arm/aspeed.c
19
@@ -XXX,XX +XXX,XX @@ struct AspeedBoardState {
20
SCU_AST2500_HW_STRAP_ACPI_ENABLE | \
21
SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
22
23
+/* Swift hardware value: 0xF11AD206 */
24
+#define SWIFT_BMC_HW_STRAP1 ( \
25
+ AST2500_HW_STRAP1_DEFAULTS | \
26
+ SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \
27
+ SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \
28
+ SCU_AST2500_HW_STRAP_UART_DEBUG | \
29
+ SCU_AST2500_HW_STRAP_DDR4_ENABLE | \
30
+ SCU_H_PLL_BYPASS_EN | \
31
+ SCU_AST2500_HW_STRAP_ACPI_ENABLE | \
32
+ SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
33
+
34
/* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
35
#define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
36
37
@@ -XXX,XX +XXX,XX @@ static void romulus_bmc_i2c_init(AspeedBoardState *bmc)
38
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
39
}
40
41
+static void swift_bmc_i2c_init(AspeedBoardState *bmc)
42
+{
43
+ AspeedSoCState *soc = &bmc->soc;
44
+
45
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60);
46
+
47
+ /* The swift board expects a TMP275 but a TMP105 is compatible */
48
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x48);
49
+ /* The swift board expects a pca9551 but a pca9552 is compatible */
50
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "pca9552", 0x60);
51
+
52
+ /* The swift board expects an Epson RX8900 RTC but a ds1338 is compatible */
53
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "ds1338", 0x32);
54
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x60);
55
+
56
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp423", 0x4c);
57
+ /* The swift board expects a pca9539 but a pca9552 is compatible */
58
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "pca9552", 0x74);
59
+
60
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "tmp423", 0x4c);
61
+ /* The swift board expects a pca9539 but a pca9552 is compatible */
62
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "pca9552",
63
+ 0x74);
64
+
65
+ /* The swift board expects a TMP275 but a TMP105 is compatible */
66
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x48);
67
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x4a);
68
+}
69
+
70
static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
71
{
72
AspeedSoCState *soc = &bmc->soc;
73
@@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = {
74
.num_cs = 2,
75
.i2c_init = romulus_bmc_i2c_init,
76
.ram = 512 * MiB,
77
+ }, {
78
+ .name = MACHINE_TYPE_NAME("swift-bmc"),
79
+ .desc = "OpenPOWER Swift BMC (ARM1176)",
80
+ .soc_name = "ast2500-a1",
81
+ .hw_strap1 = SWIFT_BMC_HW_STRAP1,
82
+ .fmc_model = "mx66l1g45g",
83
+ .spi_model = "mx66l1g45g",
84
+ .num_cs = 2,
85
+ .i2c_init = swift_bmc_i2c_init,
86
+ .ram = 512 * MiB,
87
}, {
88
.name = MACHINE_TYPE_NAME("witherspoon-bmc"),
89
.desc = "OpenPOWER Witherspoon BMC (ARM1176)",
90
--
91
2.20.1
92
93
diff view generated by jsdifflib
Deleted patch
1
From: Andrew Jeffery <andrew@aj.id.au>
2
1
3
The legacy interface only supported up to 32 IRQs, which became
4
restrictive around the AST2400 generation. QEMU support for the SoCs
5
started with the AST2400 along with an effort to reimplement and
6
upstream drivers for Linux, so up until this point the consumers of the
7
QEMU ASPEED support only required the 64 IRQ register interface.
8
9
In an effort to support older BMC firmware, add support for the 32 IRQ
10
interface.
11
12
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
13
Signed-off-by: Cédric Le Goater <clg@kaod.org>
14
Reviewed-by: Joel Stanley <joel@jms.id.au>
15
Message-id: 20190618165311.27066-22-clg@kaod.org
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
18
hw/intc/aspeed_vic.c | 105 ++++++++++++++++++++++++++-----------------
19
1 file changed, 63 insertions(+), 42 deletions(-)
20
21
diff --git a/hw/intc/aspeed_vic.c b/hw/intc/aspeed_vic.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/intc/aspeed_vic.c
24
+++ b/hw/intc/aspeed_vic.c
25
@@ -XXX,XX +XXX,XX @@ static void aspeed_vic_set_irq(void *opaque, int irq, int level)
26
27
static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size)
28
{
29
- uint64_t val;
30
- const bool high = !!(offset & 0x4);
31
- hwaddr n_offset = (offset & ~0x4);
32
AspeedVICState *s = (AspeedVICState *)opaque;
33
+ hwaddr n_offset;
34
+ uint64_t val;
35
+ bool high;
36
37
if (offset < AVIC_NEW_BASE_OFFSET) {
38
- qemu_log_mask(LOG_UNIMP, "%s: Ignoring read from legacy registers "
39
- "at 0x%" HWADDR_PRIx "[%u]\n", __func__, offset, size);
40
- return 0;
41
+ high = false;
42
+ n_offset = offset;
43
+ } else {
44
+ high = !!(offset & 0x4);
45
+ n_offset = (offset & ~0x4);
46
}
47
48
- n_offset -= AVIC_NEW_BASE_OFFSET;
49
-
50
switch (n_offset) {
51
- case 0x0: /* IRQ Status */
52
+ case 0x80: /* IRQ Status */
53
+ case 0x00:
54
val = s->raw & ~s->select & s->enable;
55
break;
56
- case 0x08: /* FIQ Status */
57
+ case 0x88: /* FIQ Status */
58
+ case 0x04:
59
val = s->raw & s->select & s->enable;
60
break;
61
- case 0x10: /* Raw Interrupt Status */
62
+ case 0x90: /* Raw Interrupt Status */
63
+ case 0x08:
64
val = s->raw;
65
break;
66
- case 0x18: /* Interrupt Selection */
67
+ case 0x98: /* Interrupt Selection */
68
+ case 0x0c:
69
val = s->select;
70
break;
71
- case 0x20: /* Interrupt Enable */
72
+ case 0xa0: /* Interrupt Enable */
73
+ case 0x10:
74
val = s->enable;
75
break;
76
- case 0x30: /* Software Interrupt */
77
+ case 0xb0: /* Software Interrupt */
78
+ case 0x18:
79
val = s->trigger;
80
break;
81
- case 0x40: /* Interrupt Sensitivity */
82
+ case 0xc0: /* Interrupt Sensitivity */
83
+ case 0x24:
84
val = s->sense;
85
break;
86
- case 0x48: /* Interrupt Both Edge Trigger Control */
87
+ case 0xc8: /* Interrupt Both Edge Trigger Control */
88
+ case 0x28:
89
val = s->dual_edge;
90
break;
91
- case 0x50: /* Interrupt Event */
92
+ case 0xd0: /* Interrupt Event */
93
+ case 0x2c:
94
val = s->event;
95
break;
96
- case 0x60: /* Edge Triggered Interrupt Status */
97
+ case 0xe0: /* Edge Triggered Interrupt Status */
98
val = s->raw & ~s->sense;
99
break;
100
/* Illegal */
101
- case 0x28: /* Interrupt Enable Clear */
102
- case 0x38: /* Software Interrupt Clear */
103
- case 0x58: /* Edge Triggered Interrupt Clear */
104
+ case 0xa8: /* Interrupt Enable Clear */
105
+ case 0xb8: /* Software Interrupt Clear */
106
+ case 0xd8: /* Edge Triggered Interrupt Clear */
107
qemu_log_mask(LOG_GUEST_ERROR,
108
"%s: Read of write-only register with offset 0x%"
109
HWADDR_PRIx "\n", __func__, offset);
110
@@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size)
111
}
112
if (high) {
113
val = extract64(val, 32, 19);
114
+ } else {
115
+ val = extract64(val, 0, 32);
116
}
117
trace_aspeed_vic_read(offset, size, val);
118
return val;
119
@@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size)
120
static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data,
121
unsigned size)
122
{
123
- const bool high = !!(offset & 0x4);
124
- hwaddr n_offset = (offset & ~0x4);
125
AspeedVICState *s = (AspeedVICState *)opaque;
126
+ hwaddr n_offset;
127
+ bool high;
128
129
if (offset < AVIC_NEW_BASE_OFFSET) {
130
- qemu_log_mask(LOG_UNIMP,
131
- "%s: Ignoring write to legacy registers at 0x%"
132
- HWADDR_PRIx "[%u] <- 0x%" PRIx64 "\n", __func__, offset,
133
- size, data);
134
- return;
135
+ high = false;
136
+ n_offset = offset;
137
+ } else {
138
+ high = !!(offset & 0x4);
139
+ n_offset = (offset & ~0x4);
140
}
141
142
- n_offset -= AVIC_NEW_BASE_OFFSET;
143
trace_aspeed_vic_write(offset, size, data);
144
145
/* Given we have members using separate enable/clear registers, deposit64()
146
@@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data,
147
}
148
149
switch (n_offset) {
150
- case 0x18: /* Interrupt Selection */
151
+ case 0x98: /* Interrupt Selection */
152
+ case 0x0c:
153
/* Register has deposit64() semantics - overwrite requested 32 bits */
154
if (high) {
155
s->select &= AVIC_L_MASK;
156
@@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data,
157
}
158
s->select |= data;
159
break;
160
- case 0x20: /* Interrupt Enable */
161
+ case 0xa0: /* Interrupt Enable */
162
+ case 0x10:
163
s->enable |= data;
164
break;
165
- case 0x28: /* Interrupt Enable Clear */
166
+ case 0xa8: /* Interrupt Enable Clear */
167
+ case 0x14:
168
s->enable &= ~data;
169
break;
170
- case 0x30: /* Software Interrupt */
171
+ case 0xb0: /* Software Interrupt */
172
+ case 0x18:
173
qemu_log_mask(LOG_UNIMP, "%s: Software interrupts unavailable. "
174
"IRQs requested: 0x%016" PRIx64 "\n", __func__, data);
175
break;
176
- case 0x38: /* Software Interrupt Clear */
177
+ case 0xb8: /* Software Interrupt Clear */
178
+ case 0x1c:
179
qemu_log_mask(LOG_UNIMP, "%s: Software interrupts unavailable. "
180
"IRQs to be cleared: 0x%016" PRIx64 "\n", __func__, data);
181
break;
182
- case 0x50: /* Interrupt Event */
183
+ case 0xd0: /* Interrupt Event */
184
/* Register has deposit64() semantics - overwrite the top four valid
185
* IRQ bits, as only the top four IRQs (GPIOs) can change their event
186
* type */
187
@@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data,
188
"Ignoring invalid write to interrupt event register");
189
}
190
break;
191
- case 0x58: /* Edge Triggered Interrupt Clear */
192
+ case 0xd8: /* Edge Triggered Interrupt Clear */
193
+ case 0x38:
194
s->raw &= ~(data & ~s->sense);
195
break;
196
- case 0x00: /* IRQ Status */
197
- case 0x08: /* FIQ Status */
198
- case 0x10: /* Raw Interrupt Status */
199
- case 0x40: /* Interrupt Sensitivity */
200
- case 0x48: /* Interrupt Both Edge Trigger Control */
201
- case 0x60: /* Edge Triggered Interrupt Status */
202
+ case 0x80: /* IRQ Status */
203
+ case 0x00:
204
+ case 0x88: /* FIQ Status */
205
+ case 0x04:
206
+ case 0x90: /* Raw Interrupt Status */
207
+ case 0x08:
208
+ case 0xc0: /* Interrupt Sensitivity */
209
+ case 0x24:
210
+ case 0xc8: /* Interrupt Both Edge Trigger Control */
211
+ case 0x28:
212
+ case 0xe0: /* Edge Triggered Interrupt Status */
213
qemu_log_mask(LOG_GUEST_ERROR,
214
"%s: Write of read-only register with offset 0x%"
215
HWADDR_PRIx "\n", __func__, offset);
216
--
217
2.20.1
218
219
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Group Aarch64 rules together, TCG related ones at the bottom.
4
This will help when restricting TCG-only objects.
5
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Message-id: 20190701132516.26392-2-philmd@redhat.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/Makefile.objs | 5 +++--
12
1 file changed, 3 insertions(+), 2 deletions(-)
13
14
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/Makefile.objs
17
+++ b/target/arm/Makefile.objs
18
@@ -XXX,XX +XXX,XX @@ obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
19
obj-y += translate.o op_helper.o helper.o cpu.o
20
obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o
21
obj-y += gdbstub.o
22
-obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o
23
-obj-$(TARGET_AARCH64) += pauth_helper.o
24
+obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o
25
obj-y += crypto_helper.o
26
obj-$(CONFIG_SOFTMMU) += arm-powerctl.o
27
28
@@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c
29
target/arm/translate.o: target/arm/decode-vfp.inc.c
30
target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c
31
32
+obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o
33
obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o
34
+obj-$(TARGET_AARCH64) += pauth_helper.o
35
--
36
2.20.1
37
38
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Group ARM objects together, TCG related ones at the bottom.
4
This will help when restricting TCG-only objects.
5
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Message-id: 20190701132516.26392-3-philmd@redhat.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/Makefile.objs | 10 ++++++----
12
1 file changed, 6 insertions(+), 4 deletions(-)
13
14
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/Makefile.objs
17
+++ b/target/arm/Makefile.objs
18
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_KVM) += kvm.o
19
obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o
20
obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o
21
obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
22
-obj-y += translate.o op_helper.o helper.o cpu.o
23
-obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o
24
-obj-y += gdbstub.o
25
+obj-y += helper.o vfp_helper.o
26
+obj-y += cpu.o gdbstub.o
27
obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o
28
-obj-y += crypto_helper.o
29
obj-$(CONFIG_SOFTMMU) += arm-powerctl.o
30
31
DECODETREE = $(SRC_PATH)/scripts/decodetree.py
32
@@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c
33
target/arm/translate.o: target/arm/decode-vfp.inc.c
34
target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c
35
36
+obj-y += translate.o op_helper.o
37
+obj-y += crypto_helper.o
38
+obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o
39
+
40
obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o
41
obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o
42
obj-$(TARGET_AARCH64) += pauth_helper.o
43
--
44
2.20.1
45
46
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Group KVM rules together.
4
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Message-id: 20190701132516.26392-4-philmd@redhat.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
target/arm/Makefile.objs | 9 +++++----
11
1 file changed, 5 insertions(+), 4 deletions(-)
12
13
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/Makefile.objs
16
+++ b/target/arm/Makefile.objs
17
@@ -XXX,XX +XXX,XX @@
18
obj-y += arm-semi.o
19
obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o
20
-obj-$(CONFIG_KVM) += kvm.o
21
-obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o
22
-obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o
23
-obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
24
obj-y += helper.o vfp_helper.o
25
obj-y += cpu.o gdbstub.o
26
obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o
27
obj-$(CONFIG_SOFTMMU) += arm-powerctl.o
28
29
+obj-$(CONFIG_KVM) += kvm.o
30
+obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o
31
+obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o
32
+obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
33
+
34
DECODETREE = $(SRC_PATH)/scripts/decodetree.py
35
36
target/arm/decode-sve.inc.c: $(SRC_PATH)/target/arm/sve.decode $(DECODETREE)
37
--
38
2.20.1
39
40
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Group SOFTMMU objects together.
4
Since PSCI is TCG specific, keep it separate.
5
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Message-id: 20190701132516.26392-5-philmd@redhat.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/Makefile.objs | 5 ++++-
12
1 file changed, 4 insertions(+), 1 deletion(-)
13
14
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/Makefile.objs
17
+++ b/target/arm/Makefile.objs
18
@@ -XXX,XX +XXX,XX @@
19
obj-y += arm-semi.o
20
-obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o
21
obj-y += helper.o vfp_helper.o
22
obj-y += cpu.o gdbstub.o
23
obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o
24
+
25
+obj-$(CONFIG_SOFTMMU) += machine.o arch_dump.o monitor.o
26
obj-$(CONFIG_SOFTMMU) += arm-powerctl.o
27
28
obj-$(CONFIG_KVM) += kvm.o
29
@@ -XXX,XX +XXX,XX @@ obj-y += translate.o op_helper.o
30
obj-y += crypto_helper.o
31
obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o
32
33
+obj-$(CONFIG_SOFTMMU) += psci.o
34
+
35
obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o
36
obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o
37
obj-$(TARGET_AARCH64) += pauth_helper.o
38
--
39
2.20.1
40
41
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Reviewed-by: Robert Bradford <robert.bradford@intel.com>
4
Reviewed-by: Samuel Ortiz <sameo@linux.intel.com>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Message-id: 20190701132516.26392-6-philmd@redhat.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
target/arm/helper.c | 7 +++++++
11
1 file changed, 7 insertions(+)
12
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
16
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@
18
+/*
19
+ * ARM generic helpers.
20
+ *
21
+ * This code is licensed under the GNU GPL v2 or later.
22
+ *
23
+ * SPDX-License-Identifier: GPL-2.0-or-later
24
+ */
25
#include "qemu/osdep.h"
26
#include "qemu/units.h"
27
#include "target/arm/idau.h"
28
--
29
2.20.1
30
31
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
Message-id: 20190701132516.26392-7-philmd@redhat.com
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/helper.c | 2 --
9
1 file changed, 2 deletions(-)
10
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
14
+++ b/target/arm/helper.c
15
@@ -XXX,XX +XXX,XX @@
16
#include "exec/gdbstub.h"
17
#include "exec/helper-proto.h"
18
#include "qemu/host-utils.h"
19
-#include "sysemu/arch_init.h"
20
#include "sysemu/sysemu.h"
21
#include "qemu/bitops.h"
22
#include "qemu/crc32c.h"
23
@@ -XXX,XX +XXX,XX @@
24
#include "hw/semihosting/semihost.h"
25
#include "sysemu/cpus.h"
26
#include "sysemu/kvm.h"
27
-#include "fpu/softfloat.h"
28
#include "qemu/range.h"
29
#include "qapi/qapi-commands-target.h"
30
#include "qapi/error.h"
31
--
32
2.20.1
33
34
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
The IoTKit, SSE200 and SSE300 all default to 8 MPU regions. The
2
2
MPS2/MPS3 FPGA images don't override these except in the case of
3
Since commit 8c06fbdf36b checkpatch.pl enforce a new multiline
3
AN547, which uses 16 MPU regions.
4
comment syntax. Since we'll move this code around, fix its style
4
5
first.
5
Define properties on the ARMSSE object for the MPU regions (using the
6
6
same names as the documented RTL configuration settings, and
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
following the pattern we already have for this device of using
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
all-caps names as the RTL does), and set them in the board code.
9
Message-id: 20190701132516.26392-8-philmd@redhat.com
9
10
We don't actually need to override the default except on AN547,
11
but it's simpler code to have the board code set them always
12
rather than tracking which board subtypes want to set them to
13
a non-default value separately from what that value is.
14
15
Tho overall effect is that for mps2-an505, mps2-an521 and mps3-an524
16
we now correctly use 8 MPU regions, while mps3-an547 stays at its
17
current 16 regions.
18
19
It's possible some guest code wrongly depended on the previous
20
incorrectly modeled number of memory regions. (Such guest code
21
should ideally check the number of regions via the MPU_TYPE
22
register.) The old behaviour can be obtained with additional
23
-global arguments to QEMU:
24
25
For mps2-an521 and mps2-an524:
26
-global sse-200.CPU0_MPU_NS=16 -global sse-200.CPU0_MPU_S=16 -global sse-200.CPU1_MPU_NS=16 -global sse-200.CPU1_MPU_S=16
27
28
For mps2-an505:
29
-global sse-200.CPU0_MPU_NS=16 -global sse-200.CPU0_MPU_S=16
30
31
NB that the way the implementation allows this use of -global
32
is slightly fragile: if the board code explicitly sets the
33
properties on the sse-200 object, this overrides the -global
34
command line option. So we rely on:
35
- the boards that need fixing all happen to use the SSE defaults
36
- we can write the board code to only set the property if it
37
is different from the default, rather than having all boards
38
explicitly set the property
39
- the board that does need to use a non-default value happens
40
to need to set it to the same value (16) we previously used
41
This works, but there are some kinds of refactoring of the
42
mps2-tz.c code that would break the support for -global here.
43
44
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1772
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
45
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
46
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
47
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
48
Message-id: 20230724174335.2150499-4-peter.maydell@linaro.org
11
---
49
---
12
target/arm/helper.c | 237 ++++++++++++++++++++++++++--------------
50
include/hw/arm/armsse.h | 5 +++++
13
target/arm/op_helper.c | 54 ++++++---
51
hw/arm/armsse.c | 16 ++++++++++++++++
14
target/arm/vfp_helper.c | 3 +-
52
hw/arm/mps2-tz.c | 29 +++++++++++++++++++++++++++++
15
3 files changed, 196 insertions(+), 98 deletions(-)
53
3 files changed, 50 insertions(+)
16
54
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
55
diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h
18
index XXXXXXX..XXXXXXX 100644
56
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.c
57
--- a/include/hw/arm/armsse.h
20
+++ b/target/arm/helper.c
58
+++ b/include/hw/arm/armsse.h
21
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr)
59
@@ -XXX,XX +XXX,XX @@
22
60
* (matching the hardware) is that for CPU0 in an IoTKit and CPU1 in an
23
uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
61
* SSE-200 both are present; CPU0 in an SSE-200 has neither.
24
{
62
* Since the IoTKit has only one CPU, it does not have the CPU1_* properties.
25
- /* The TT instructions can be used by unprivileged code, but in
63
+ * + QOM properties "CPU0_MPU_NS", "CPU0_MPU_S", "CPU1_MPU_NS" and "CPU1_MPU_S"
26
+ /*
64
+ * which set the number of MPU regions on the CPUs. If there is only one
27
+ * The TT instructions can be used by unprivileged code, but in
65
+ * CPU the CPU1 properties are not present.
28
* user-only emulation we don't have the MPU.
66
* + Named GPIO inputs "EXP_IRQ" 0..n are the expansion interrupts for CPU 0,
29
* Luckily since we know we are NonSecure unprivileged (and that in
67
* which are wired to its NVIC lines 32 .. n+32
30
* turn means that the A flag wasn't specified), all the bits in the
68
* + Named GPIO inputs "EXP_CPU1_IRQ" 0..n are the expansion interrupts for
31
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
69
@@ -XXX,XX +XXX,XX @@ struct ARMSSE {
32
return true;
70
uint32_t exp_numirq;
33
71
uint32_t sram_addr_width;
34
pend_fault:
72
uint32_t init_svtor;
35
- /* By pending the exception at this point we are making
73
+ uint32_t cpu_mpu_ns[SSE_MAX_CPUS];
36
+ /*
74
+ uint32_t cpu_mpu_s[SSE_MAX_CPUS];
37
+ * By pending the exception at this point we are making
75
bool cpu_fpu[SSE_MAX_CPUS];
38
* the IMPDEF choice "overridden exceptions pended" (see the
76
bool cpu_dsp[SSE_MAX_CPUS];
39
* MergeExcInfo() pseudocode). The other choice would be to not
77
};
40
* pend them now and then make a choice about which to throw away
78
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
41
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr,
79
index XXXXXXX..XXXXXXX 100644
42
return true;
80
--- a/hw/arm/armsse.c
43
81
+++ b/hw/arm/armsse.c
44
pend_fault:
82
@@ -XXX,XX +XXX,XX @@ static Property iotkit_properties[] = {
45
- /* By pending the exception at this point we are making
83
DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000),
46
+ /*
84
DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true),
47
+ * By pending the exception at this point we are making
85
DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true),
48
* the IMPDEF choice "overridden exceptions pended" (see the
86
+ DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8),
49
* MergeExcInfo() pseudocode). The other choice would be to not
87
+ DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8),
50
* pend them now and then make a choice about which to throw away
88
DEFINE_PROP_END_OF_LIST()
51
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env)
89
};
52
*/
90
53
}
91
@@ -XXX,XX +XXX,XX @@ static Property sse200_properties[] = {
54
92
DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], false),
55
-/* Write to v7M CONTROL.SPSEL bit for the specified security bank.
93
DEFINE_PROP_BOOL("CPU1_FPU", ARMSSE, cpu_fpu[1], true),
56
+/*
94
DEFINE_PROP_BOOL("CPU1_DSP", ARMSSE, cpu_dsp[1], true),
57
+ * Write to v7M CONTROL.SPSEL bit for the specified security bank.
95
+ DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8),
58
* This may change the current stack pointer between Main and Process
96
+ DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8),
59
* stack pointers if it is done for the CONTROL register for the current
97
+ DEFINE_PROP_UINT32("CPU1_MPU_NS", ARMSSE, cpu_mpu_ns[1], 8),
60
* security state.
98
+ DEFINE_PROP_UINT32("CPU1_MPU_S", ARMSSE, cpu_mpu_s[1], 8),
61
@@ -XXX,XX +XXX,XX @@ static void write_v7m_control_spsel_for_secstate(CPUARMState *env,
99
DEFINE_PROP_END_OF_LIST()
62
}
100
};
63
}
101
64
102
@@ -XXX,XX +XXX,XX @@ static Property sse300_properties[] = {
65
-/* Write to v7M CONTROL.SPSEL bit. This may change the current
103
DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000),
66
+/*
104
DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true),
67
+ * Write to v7M CONTROL.SPSEL bit. This may change the current
105
DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true),
68
* stack pointer between Main and Process stack pointers.
106
+ DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8),
69
*/
107
+ DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8),
70
static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel)
108
DEFINE_PROP_END_OF_LIST()
71
@@ -XXX,XX +XXX,XX @@ static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel)
109
};
72
110
73
void write_v7m_exception(CPUARMState *env, uint32_t new_exc)
111
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
74
{
112
return;
75
- /* Write a new value to v7m.exception, thus transitioning into or out
76
+ /*
77
+ * Write a new value to v7m.exception, thus transitioning into or out
78
* of Handler mode; this may result in a change of active stack pointer.
79
*/
80
bool new_is_psp, old_is_psp = v7m_using_psp(env);
81
@@ -XXX,XX +XXX,XX @@ static void switch_v7m_security_state(CPUARMState *env, bool new_secstate)
82
return;
83
}
84
85
- /* All the banked state is accessed by looking at env->v7m.secure
86
+ /*
87
+ * All the banked state is accessed by looking at env->v7m.secure
88
* except for the stack pointer; rearrange the SP appropriately.
89
*/
90
new_ss_msp = env->v7m.other_ss_msp;
91
@@ -XXX,XX +XXX,XX @@ static void switch_v7m_security_state(CPUARMState *env, bool new_secstate)
92
93
void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest)
94
{
95
- /* Handle v7M BXNS:
96
+ /*
97
+ * Handle v7M BXNS:
98
* - if the return value is a magic value, do exception return (like BX)
99
* - otherwise bit 0 of the return value is the target security state
100
*/
101
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest)
102
}
103
104
if (dest >= min_magic) {
105
- /* This is an exception return magic value; put it where
106
+ /*
107
+ * This is an exception return magic value; put it where
108
* do_v7m_exception_exit() expects and raise EXCEPTION_EXIT.
109
* Note that if we ever add gen_ss_advance() singlestep support to
110
* M profile this should count as an "instruction execution complete"
111
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest)
112
113
void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest)
114
{
115
- /* Handle v7M BLXNS:
116
+ /*
117
+ * Handle v7M BLXNS:
118
* - bit 0 of the destination address is the target security state
119
*/
120
121
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest)
122
assert(env->v7m.secure);
123
124
if (dest & 1) {
125
- /* target is Secure, so this is just a normal BLX,
126
+ /*
127
+ * Target is Secure, so this is just a normal BLX,
128
* except that the low bit doesn't indicate Thumb/not.
129
*/
130
env->regs[14] = nextinst;
131
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest)
132
env->regs[13] = sp;
133
env->regs[14] = 0xfeffffff;
134
if (arm_v7m_is_handler_mode(env)) {
135
- /* Write a dummy value to IPSR, to avoid leaking the current secure
136
+ /*
137
+ * Write a dummy value to IPSR, to avoid leaking the current secure
138
* exception number to non-secure code. This is guaranteed not
139
* to cause write_v7m_exception() to actually change stacks.
140
*/
141
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest)
142
static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool threadmode,
143
bool spsel)
144
{
145
- /* Return a pointer to the location where we currently store the
146
+ /*
147
+ * Return a pointer to the location where we currently store the
148
* stack pointer for the requested security state and thread mode.
149
* This pointer will become invalid if the CPU state is updated
150
* such that the stack pointers are switched around (eg changing
151
@@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure,
152
153
mmu_idx = arm_v7m_mmu_idx_for_secstate_and_priv(env, targets_secure, true);
154
155
- /* We don't do a get_phys_addr() here because the rules for vector
156
+ /*
157
+ * We don't do a get_phys_addr() here because the rules for vector
158
* loads are special: they always use the default memory map, and
159
* the default memory map permits reads from all addresses.
160
* Since there's no easy way to pass through to pmsav8_mpu_lookup()
161
@@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure,
162
return true;
163
164
load_fail:
165
- /* All vector table fetch fails are reported as HardFault, with
166
+ /*
167
+ * All vector table fetch fails are reported as HardFault, with
168
* HFSR.VECTTBL and .FORCED set. (FORCED is set because
169
* technically the underlying exception is a MemManage or BusFault
170
* that is escalated to HardFault.) This is a terminal exception,
171
@@ -XXX,XX +XXX,XX @@ static uint32_t v7m_integrity_sig(CPUARMState *env, uint32_t lr)
172
static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
173
bool ignore_faults)
174
{
175
- /* For v8M, push the callee-saves register part of the stack frame.
176
+ /*
177
+ * For v8M, push the callee-saves register part of the stack frame.
178
* Compare the v8M pseudocode PushCalleeStack().
179
* In the tailchaining case this may not be the current stack.
180
*/
181
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
182
return true;
183
}
184
185
- /* Write as much of the stack frame as we can. A write failure may
186
+ /*
187
+ * Write as much of the stack frame as we can. A write failure may
188
* cause us to pend a derived exception.
189
*/
190
sig = v7m_integrity_sig(env, lr);
191
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
192
static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
193
bool ignore_stackfaults)
194
{
195
- /* Do the "take the exception" parts of exception entry,
196
+ /*
197
+ * Do the "take the exception" parts of exception entry,
198
* but not the pushing of state to the stack. This is
199
* similar to the pseudocode ExceptionTaken() function.
200
*/
201
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
202
if (arm_feature(env, ARM_FEATURE_V8)) {
203
if (arm_feature(env, ARM_FEATURE_M_SECURITY) &&
204
(lr & R_V7M_EXCRET_S_MASK)) {
205
- /* The background code (the owner of the registers in the
206
+ /*
207
+ * The background code (the owner of the registers in the
208
* exception frame) is Secure. This means it may either already
209
* have or now needs to push callee-saves registers.
210
*/
211
if (targets_secure) {
212
if (dotailchain && !(lr & R_V7M_EXCRET_ES_MASK)) {
213
- /* We took an exception from Secure to NonSecure
214
+ /*
215
+ * We took an exception from Secure to NonSecure
216
* (which means the callee-saved registers got stacked)
217
* and are now tailchaining to a Secure exception.
218
* Clear DCRS so eventual return from this Secure
219
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
220
lr &= ~R_V7M_EXCRET_DCRS_MASK;
221
}
222
} else {
223
- /* We're going to a non-secure exception; push the
224
+ /*
225
+ * We're going to a non-secure exception; push the
226
* callee-saves registers to the stack now, if they're
227
* not already saved.
228
*/
229
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
230
lr |= R_V7M_EXCRET_SPSEL_MASK;
231
}
232
233
- /* Clear registers if necessary to prevent non-secure exception
234
+ /*
235
+ * Clear registers if necessary to prevent non-secure exception
236
* code being able to see register values from secure code.
237
* Where register values become architecturally UNKNOWN we leave
238
* them with their previous values.
239
*/
240
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
241
if (!targets_secure) {
242
- /* Always clear the caller-saved registers (they have been
243
+ /*
244
+ * Always clear the caller-saved registers (they have been
245
* pushed to the stack earlier in v7m_push_stack()).
246
* Clear callee-saved registers if the background code is
247
* Secure (in which case these regs were saved in
248
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
249
}
250
251
if (push_failed && !ignore_stackfaults) {
252
- /* Derived exception on callee-saves register stacking:
253
+ /*
254
+ * Derived exception on callee-saves register stacking:
255
* we might now want to take a different exception which
256
* targets a different security state, so try again from the top.
257
*/
258
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
259
return;
260
}
261
262
- /* Now we've done everything that might cause a derived exception
263
+ /*
264
+ * Now we've done everything that might cause a derived exception
265
* we can go ahead and activate whichever exception we're going to
266
* take (which might now be the derived exception).
267
*/
268
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr)
269
270
static bool v7m_push_stack(ARMCPU *cpu)
271
{
272
- /* Do the "set up stack frame" part of exception entry,
273
+ /*
274
+ * Do the "set up stack frame" part of exception entry,
275
* similar to pseudocode PushStack().
276
* Return true if we generate a derived exception (and so
277
* should ignore further stack faults trying to process
278
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
279
}
280
}
281
282
- /* Write as much of the stack frame as we can. If we fail a stack
283
+ /*
284
+ * Write as much of the stack frame as we can. If we fail a stack
285
* write this will result in a derived exception being pended
286
* (which may be taken in preference to the one we started with
287
* if it has higher priority).
288
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
289
bool ftype;
290
bool restore_s16_s31;
291
292
- /* If we're not in Handler mode then jumps to magic exception-exit
293
+ /*
294
+ * If we're not in Handler mode then jumps to magic exception-exit
295
* addresses don't have magic behaviour. However for the v8M
296
* security extensions the magic secure-function-return has to
297
* work in thread mode too, so to avoid doing an extra check in
298
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
299
return;
300
}
301
302
- /* In the spec pseudocode ExceptionReturn() is called directly
303
+ /*
304
+ * In the spec pseudocode ExceptionReturn() is called directly
305
* from BXWritePC() and gets the full target PC value including
306
* bit zero. In QEMU's implementation we treat it as a normal
307
* jump-to-register (which is then caught later on), and so split
308
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
309
}
310
311
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
312
- /* EXC_RETURN.ES validation check (R_SMFL). We must do this before
313
+ /*
314
+ * EXC_RETURN.ES validation check (R_SMFL). We must do this before
315
* we pick which FAULTMASK to clear.
316
*/
317
if (!env->v7m.secure &&
318
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
319
}
320
321
if (env->v7m.exception != ARMV7M_EXCP_NMI) {
322
- /* Auto-clear FAULTMASK on return from other than NMI.
323
+ /*
324
+ * Auto-clear FAULTMASK on return from other than NMI.
325
* If the security extension is implemented then this only
326
* happens if the raw execution priority is >= 0; the
327
* value of the ES bit in the exception return value indicates
328
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
329
/* still an irq active now */
330
break;
331
case 1:
332
- /* we returned to base exception level, no nesting.
333
+ /*
334
+ * We returned to base exception level, no nesting.
335
* (In the pseudocode this is written using "NestedActivation != 1"
336
* where we have 'rettobase == false'.)
337
*/
338
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
339
340
if (arm_feature(env, ARM_FEATURE_V8)) {
341
if (!arm_feature(env, ARM_FEATURE_M_SECURITY)) {
342
- /* UNPREDICTABLE if S == 1 or DCRS == 0 or ES == 1 (R_XLCP);
343
+ /*
344
+ * UNPREDICTABLE if S == 1 or DCRS == 0 or ES == 1 (R_XLCP);
345
* we choose to take the UsageFault.
346
*/
347
if ((excret & R_V7M_EXCRET_S_MASK) ||
348
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
349
break;
350
case 13: /* Return to Thread using Process stack */
351
case 9: /* Return to Thread using Main stack */
352
- /* We only need to check NONBASETHRDENA for v7M, because in
353
+ /*
354
+ * We only need to check NONBASETHRDENA for v7M, because in
355
* v8M this bit does not exist (it is RES1).
356
*/
357
if (!rettobase &&
358
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
359
}
360
361
if (ufault) {
362
- /* Bad exception return: instead of popping the exception
363
+ /*
364
+ * Bad exception return: instead of popping the exception
365
* stack, directly take a usage fault on the current stack.
366
*/
367
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK;
368
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
369
switch_v7m_security_state(env, return_to_secure);
370
371
{
372
- /* The stack pointer we should be reading the exception frame from
373
+ /*
374
+ * The stack pointer we should be reading the exception frame from
375
* depends on bits in the magic exception return type value (and
376
* for v8M isn't necessarily the stack pointer we will eventually
377
* end up resuming execution with). Get a pointer to the location
378
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
379
v7m_stack_read(cpu, &xpsr, frameptr + 0x1c, mmu_idx);
380
381
if (!pop_ok) {
382
- /* v7m_stack_read() pended a fault, so take it (as a tail
383
+ /*
384
+ * v7m_stack_read() pended a fault, so take it (as a tail
385
* chained exception on the same stack frame)
386
*/
387
qemu_log_mask(CPU_LOG_INT, "...derived exception on unstacking\n");
388
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
389
return;
390
}
391
392
- /* Returning from an exception with a PC with bit 0 set is defined
393
+ /*
394
+ * Returning from an exception with a PC with bit 0 set is defined
395
* behaviour on v8M (bit 0 is ignored), but for v7M it was specified
396
* to be UNPREDICTABLE. In practice actual v7M hardware seems to ignore
397
* the lsbit, and there are several RTOSes out there which incorrectly
398
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
399
}
400
401
if (arm_feature(env, ARM_FEATURE_V8)) {
402
- /* For v8M we have to check whether the xPSR exception field
403
+ /*
404
+ * For v8M we have to check whether the xPSR exception field
405
* matches the EXCRET value for return to handler/thread
406
* before we commit to changing the SP and xPSR.
407
*/
408
bool will_be_handler = (xpsr & XPSR_EXCP) != 0;
409
if (return_to_handler != will_be_handler) {
410
- /* Take an INVPC UsageFault on the current stack.
411
+ /*
412
+ * Take an INVPC UsageFault on the current stack.
413
* By this point we will have switched to the security state
414
* for the background state, so this UsageFault will target
415
* that state.
416
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
417
frameptr += 0x40;
418
}
113
}
419
}
114
}
420
- /* Undo stack alignment (the SPREALIGN bit indicates that the original
115
+ if (!object_property_set_uint(cpuobj, "mpu-ns-regions",
421
+ /*
116
+ s->cpu_mpu_ns[i], errp)) {
422
+ * Undo stack alignment (the SPREALIGN bit indicates that the original
117
+ return;
423
* pre-exception SP was not 8-aligned and we added a padding word to
118
+ }
424
* align it, so we undo this by ORing in the bit that increases it
119
+ if (!object_property_set_uint(cpuobj, "mpu-s-regions",
425
* from the current 8-aligned value to the 8-unaligned value. (Adding 4
120
+ s->cpu_mpu_s[i], errp)) {
426
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
121
+ return;
427
V7M_CONTROL, SFPA, sfpa);
122
+ }
428
}
123
429
124
if (i > 0) {
430
- /* The restored xPSR exception field will be zero if we're
125
memory_region_add_subregion_overlap(&s->cpu_container[i], 0,
431
+ /*
126
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
432
+ * The restored xPSR exception field will be zero if we're
127
index XXXXXXX..XXXXXXX 100644
433
* resuming in Thread mode. If that doesn't match what the
128
--- a/hw/arm/mps2-tz.c
434
* exception return excret specified then this is a UsageFault.
129
+++ b/hw/arm/mps2-tz.c
435
* v7M requires we make this check here; v8M did it earlier.
130
@@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineClass {
436
*/
131
int uart_overflow_irq; /* number of the combined UART overflow IRQ */
437
if (return_to_handler != arm_v7m_is_handler_mode(env)) {
132
uint32_t init_svtor; /* init-svtor setting for SSE */
438
- /* Take an INVPC UsageFault by pushing the stack again;
133
uint32_t sram_addr_width; /* SRAM_ADDR_WIDTH setting for SSE */
439
+ /*
134
+ uint32_t cpu0_mpu_ns; /* CPU0_MPU_NS setting for SSE */
440
+ * Take an INVPC UsageFault by pushing the stack again;
135
+ uint32_t cpu0_mpu_s; /* CPU0_MPU_S setting for SSE */
441
* we know we're v7M so this is never a Secure UsageFault.
136
+ uint32_t cpu1_mpu_ns; /* CPU1_MPU_NS setting for SSE */
442
*/
137
+ uint32_t cpu1_mpu_s; /* CPU1_MPU_S setting for SSE */
443
bool ignore_stackfaults;
138
const RAMInfo *raminfo;
444
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
139
const char *armsse_type;
445
140
uint32_t boot_ram_size; /* size of ram at address 0; 0 == find in raminfo */
446
static bool do_v7m_function_return(ARMCPU *cpu)
141
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MPS2TZMachineState, MPS2TZMachineClass, MPS2TZ_MACHINE)
142
#define MPS3_DDR_SIZE (2 * GiB)
143
#endif
144
145
+/* For cpu{0,1}_mpu_{ns,s}, means "leave at SSE's default value" */
146
+#define MPU_REGION_DEFAULT UINT32_MAX
147
+
148
static const uint32_t an505_oscclk[] = {
149
40000000,
150
24580000,
151
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
152
OBJECT(system_memory), &error_abort);
153
qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", mmc->numirq);
154
qdev_prop_set_uint32(iotkitdev, "init-svtor", mmc->init_svtor);
155
+ if (mmc->cpu0_mpu_ns != MPU_REGION_DEFAULT) {
156
+ qdev_prop_set_uint32(iotkitdev, "CPU0_MPU_NS", mmc->cpu0_mpu_ns);
157
+ }
158
+ if (mmc->cpu0_mpu_s != MPU_REGION_DEFAULT) {
159
+ qdev_prop_set_uint32(iotkitdev, "CPU0_MPU_S", mmc->cpu0_mpu_s);
160
+ }
161
+ if (object_property_find(OBJECT(iotkitdev), "CPU1_MPU_NS")) {
162
+ if (mmc->cpu1_mpu_ns != MPU_REGION_DEFAULT) {
163
+ qdev_prop_set_uint32(iotkitdev, "CPU1_MPU_NS", mmc->cpu1_mpu_ns);
164
+ }
165
+ if (mmc->cpu1_mpu_s != MPU_REGION_DEFAULT) {
166
+ qdev_prop_set_uint32(iotkitdev, "CPU1_MPU_S", mmc->cpu1_mpu_s);
167
+ }
168
+ }
169
qdev_prop_set_uint32(iotkitdev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width);
170
qdev_connect_clock_in(iotkitdev, "MAINCLK", mms->sysclk);
171
qdev_connect_clock_in(iotkitdev, "S32KCLK", mms->s32kclk);
172
@@ -XXX,XX +XXX,XX @@ static void mps2tz_class_init(ObjectClass *oc, void *data)
447
{
173
{
448
- /* v8M security extensions magic function return.
174
MachineClass *mc = MACHINE_CLASS(oc);
449
+ /*
175
IDAUInterfaceClass *iic = IDAU_INTERFACE_CLASS(oc);
450
+ * v8M security extensions magic function return.
176
+ MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_CLASS(oc);
451
* We may either:
177
452
* (1) throw an exception (longjump)
178
mc->init = mps2tz_common_init;
453
* (2) return true if we successfully handled the function return
179
mc->reset = mps2_machine_reset;
454
@@ -XXX,XX +XXX,XX @@ static bool do_v7m_function_return(ARMCPU *cpu)
180
iic->check = mps2_tz_idau_check;
455
frame_sp_p = get_v7m_sp_ptr(env, true, threadmode, spsel);
181
+
456
frameptr = *frame_sp_p;
182
+ /* Most machines leave these at the SSE defaults */
457
183
+ mmc->cpu0_mpu_ns = MPU_REGION_DEFAULT;
458
- /* These loads may throw an exception (for MPU faults). We want to
184
+ mmc->cpu0_mpu_s = MPU_REGION_DEFAULT;
459
+ /*
185
+ mmc->cpu1_mpu_ns = MPU_REGION_DEFAULT;
460
+ * These loads may throw an exception (for MPU faults). We want to
186
+ mmc->cpu1_mpu_s = MPU_REGION_DEFAULT;
461
* do them as secure, so work out what MMU index that is.
462
*/
463
mmu_idx = arm_v7m_mmu_idx_for_secstate(env, true);
464
@@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx)
465
static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx,
466
uint32_t addr, uint16_t *insn)
467
{
468
- /* Load a 16-bit portion of a v7M instruction, returning true on success,
469
+ /*
470
+ * Load a 16-bit portion of a v7M instruction, returning true on success,
471
* or false on failure (in which case we will have pended the appropriate
472
* exception).
473
* We need to do the instruction fetch's MPU and SAU checks
474
@@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx,
475
476
v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx, &sattrs);
477
if (!sattrs.nsc || sattrs.ns) {
478
- /* This must be the second half of the insn, and it straddles a
479
+ /*
480
+ * This must be the second half of the insn, and it straddles a
481
* region boundary with the second half not being S&NSC.
482
*/
483
env->v7m.sfsr |= R_V7M_SFSR_INVEP_MASK;
484
@@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx,
485
486
static bool v7m_handle_execute_nsc(ARMCPU *cpu)
487
{
488
- /* Check whether this attempt to execute code in a Secure & NS-Callable
489
+ /*
490
+ * Check whether this attempt to execute code in a Secure & NS-Callable
491
* memory region is for an SG instruction; if so, then emulate the
492
* effect of the SG instruction and return true. Otherwise pend
493
* the correct kind of exception and return false.
494
@@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu)
495
ARMMMUIdx mmu_idx;
496
uint16_t insn;
497
498
- /* We should never get here unless get_phys_addr_pmsav8() caused
499
+ /*
500
+ * We should never get here unless get_phys_addr_pmsav8() caused
501
* an exception for NS executing in S&NSC memory.
502
*/
503
assert(!env->v7m.secure);
504
@@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu)
505
}
506
507
if (insn != 0xe97f) {
508
- /* Not an SG instruction first half (we choose the IMPDEF
509
+ /*
510
+ * Not an SG instruction first half (we choose the IMPDEF
511
* early-SG-check option).
512
*/
513
goto gen_invep;
514
@@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu)
515
}
516
517
if (insn != 0xe97f) {
518
- /* Not an SG instruction second half (yes, both halves of the SG
519
+ /*
520
+ * Not an SG instruction second half (yes, both halves of the SG
521
* insn have the same hex value)
522
*/
523
goto gen_invep;
524
}
525
526
- /* OK, we have confirmed that we really have an SG instruction.
527
+ /*
528
+ * OK, we have confirmed that we really have an SG instruction.
529
* We know we're NS in S memory so don't need to repeat those checks.
530
*/
531
qemu_log_mask(CPU_LOG_INT, "...really an SG instruction at 0x%08" PRIx32
532
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
533
534
arm_log_exception(cs->exception_index);
535
536
- /* For exceptions we just mark as pending on the NVIC, and let that
537
- handle it. */
538
+ /*
539
+ * For exceptions we just mark as pending on the NVIC, and let that
540
+ * handle it.
541
+ */
542
switch (cs->exception_index) {
543
case EXCP_UDEF:
544
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
545
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
546
break;
547
case EXCP_PREFETCH_ABORT:
548
case EXCP_DATA_ABORT:
549
- /* Note that for M profile we don't have a guest facing FSR, but
550
+ /*
551
+ * Note that for M profile we don't have a guest facing FSR, but
552
* the env->exception.fsr will be populated by the code that
553
* raises the fault, in the A profile short-descriptor format.
554
*/
555
switch (env->exception.fsr & 0xf) {
556
case M_FAKE_FSR_NSC_EXEC:
557
- /* Exception generated when we try to execute code at an address
558
+ /*
559
+ * Exception generated when we try to execute code at an address
560
* which is marked as Secure & Non-Secure Callable and the CPU
561
* is in the Non-Secure state. The only instruction which can
562
* be executed like this is SG (and that only if both halves of
563
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
564
}
565
break;
566
case M_FAKE_FSR_SFAULT:
567
- /* Various flavours of SecureFault for attempts to execute or
568
+ /*
569
+ * Various flavours of SecureFault for attempts to execute or
570
* access data in the wrong security state.
571
*/
572
switch (cs->exception_index) {
573
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
574
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false);
575
break;
576
default:
577
- /* All other FSR values are either MPU faults or "can't happen
578
+ /*
579
+ * All other FSR values are either MPU faults or "can't happen
580
* for M profile" cases.
581
*/
582
switch (cs->exception_index) {
583
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
584
if (arm_feature(env, ARM_FEATURE_V8)) {
585
lr = R_V7M_EXCRET_RES1_MASK |
586
R_V7M_EXCRET_DCRS_MASK;
587
- /* The S bit indicates whether we should return to Secure
588
+ /*
589
+ * The S bit indicates whether we should return to Secure
590
* or NonSecure (ie our current state).
591
* The ES bit indicates whether we're taking this exception
592
* to Secure or NonSecure (ie our target state). We set it
593
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
594
v7m_exception_taken(cpu, lr, false, ignore_stackfaults);
595
}
187
}
596
188
597
-/* Function used to synchronize QEMU's AArch64 register set with AArch32
189
static void mps2tz_set_default_ram_info(MPS2TZMachineClass *mmc)
598
+/*
190
@@ -XXX,XX +XXX,XX @@ static void mps3tz_an547_class_init(ObjectClass *oc, void *data)
599
+ * Function used to synchronize QEMU's AArch64 register set with AArch32
191
mmc->numirq = 96;
600
* register set. This is necessary when switching between AArch32 and AArch64
192
mmc->uart_overflow_irq = 48;
601
* execution state.
193
mmc->init_svtor = 0x00000000;
602
*/
194
+ mmc->cpu0_mpu_s = mmc->cpu0_mpu_ns = 16;
603
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env)
195
mmc->sram_addr_width = 21;
604
env->xregs[i] = env->regs[i];
196
mmc->raminfo = an547_raminfo;
605
}
197
mmc->armsse_type = TYPE_SSE300;
606
607
- /* Unless we are in FIQ mode, x8-x12 come from the user registers r8-r12.
608
+ /*
609
+ * Unless we are in FIQ mode, x8-x12 come from the user registers r8-r12.
610
* Otherwise, they come from the banked user regs.
611
*/
612
if (mode == ARM_CPU_MODE_FIQ) {
613
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env)
614
}
615
}
616
617
- /* Registers x13-x23 are the various mode SP and FP registers. Registers
618
+ /*
619
+ * Registers x13-x23 are the various mode SP and FP registers. Registers
620
* r13 and r14 are only copied if we are in that mode, otherwise we copy
621
* from the mode banked register.
622
*/
623
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env)
624
env->xregs[23] = env->banked_r13[bank_number(ARM_CPU_MODE_UND)];
625
}
626
627
- /* Registers x24-x30 are mapped to r8-r14 in FIQ mode. If we are in FIQ
628
+ /*
629
+ * Registers x24-x30 are mapped to r8-r14 in FIQ mode. If we are in FIQ
630
* mode, then we can copy from r8-r14. Otherwise, we copy from the
631
* FIQ bank for r8-r14.
632
*/
633
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env)
634
env->pc = env->regs[15];
635
}
636
637
-/* Function used to synchronize QEMU's AArch32 register set with AArch64
638
+/*
639
+ * Function used to synchronize QEMU's AArch32 register set with AArch64
640
* register set. This is necessary when switching between AArch32 and AArch64
641
* execution state.
642
*/
643
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env)
644
env->regs[i] = env->xregs[i];
645
}
646
647
- /* Unless we are in FIQ mode, r8-r12 come from the user registers x8-x12.
648
+ /*
649
+ * Unless we are in FIQ mode, r8-r12 come from the user registers x8-x12.
650
* Otherwise, we copy x8-x12 into the banked user regs.
651
*/
652
if (mode == ARM_CPU_MODE_FIQ) {
653
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env)
654
}
655
}
656
657
- /* Registers r13 & r14 depend on the current mode.
658
+ /*
659
+ * Registers r13 & r14 depend on the current mode.
660
* If we are in a given mode, we copy the corresponding x registers to r13
661
* and r14. Otherwise, we copy the x register to the banked r13 and r14
662
* for the mode.
663
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env)
664
} else {
665
env->banked_r13[bank_number(ARM_CPU_MODE_USR)] = env->xregs[13];
666
667
- /* HYP is an exception in that it does not have its own banked r14 but
668
+ /*
669
+ * HYP is an exception in that it does not have its own banked r14 but
670
* shares the USR r14
671
*/
672
if (mode == ARM_CPU_MODE_HYP) {
673
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
674
return value;
675
}
676
case 0x94: /* CONTROL_NS */
677
- /* We have to handle this here because unprivileged Secure code
678
+ /*
679
+ * We have to handle this here because unprivileged Secure code
680
* can read the NS CONTROL register.
681
*/
682
if (!env->v7m.secure) {
683
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
684
return env->v7m.faultmask[M_REG_NS];
685
case 0x98: /* SP_NS */
686
{
687
- /* This gives the non-secure SP selected based on whether we're
688
+ /*
689
+ * This gives the non-secure SP selected based on whether we're
690
* currently in handler mode or not, using the NS CONTROL.SPSEL.
691
*/
692
bool spsel = env->v7m.control[M_REG_NS] & R_V7M_CONTROL_SPSEL_MASK;
693
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
694
695
void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
696
{
697
- /* We're passed bits [11..0] of the instruction; extract
698
+ /*
699
+ * We're passed bits [11..0] of the instruction; extract
700
* SYSm and the mask bits.
701
* Invalid combinations of SYSm and mask are UNPREDICTABLE;
702
* we choose to treat them as if the mask bits were valid.
703
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
704
return;
705
case 0x98: /* SP_NS */
706
{
707
- /* This gives the non-secure SP selected based on whether we're
708
+ /*
709
+ * This gives the non-secure SP selected based on whether we're
710
* currently in handler mode or not, using the NS CONTROL.SPSEL.
711
*/
712
bool spsel = env->v7m.control[M_REG_NS] & R_V7M_CONTROL_SPSEL_MASK;
713
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
714
bool targetsec = env->v7m.secure;
715
bool is_subpage;
716
717
- /* Work out what the security state and privilege level we're
718
+ /*
719
+ * Work out what the security state and privilege level we're
720
* interested in is...
721
*/
722
if (alt) {
723
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
724
/* ...and then figure out which MMU index this is */
725
mmu_idx = arm_v7m_mmu_idx_for_secstate_and_priv(env, targetsec, targetpriv);
726
727
- /* We know that the MPU and SAU don't care about the access type
728
+ /*
729
+ * We know that the MPU and SAU don't care about the access type
730
* for our purposes beyond that we don't want to claim to be
731
* an insn fetch, so we arbitrarily call this a read.
732
*/
733
734
- /* MPU region info only available for privileged or if
735
+ /*
736
+ * MPU region info only available for privileged or if
737
* inspecting the other MPU state.
738
*/
739
if (arm_current_el(env) != 0 || alt) {
740
@@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
741
742
void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)
743
{
744
- /* Implement DC ZVA, which zeroes a fixed-length block of memory.
745
+ /*
746
+ * Implement DC ZVA, which zeroes a fixed-length block of memory.
747
* Note that we do not implement the (architecturally mandated)
748
* alignment fault for attempts to use this on Device memory
749
* (which matches the usual QEMU behaviour of not implementing either
750
@@ -XXX,XX +XXX,XX @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)
751
752
#ifndef CONFIG_USER_ONLY
753
{
754
- /* Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than
755
+ /*
756
+ * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than
757
* the block size so we might have to do more than one TLB lookup.
758
* We know that in fact for any v8 CPU the page size is at least 4K
759
* and the block size must be 2K or less, but TARGET_PAGE_SIZE is only
760
@@ -XXX,XX +XXX,XX @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)
761
}
762
}
763
if (i == maxidx) {
764
- /* If it's all in the TLB it's fair game for just writing to;
765
+ /*
766
+ * If it's all in the TLB it's fair game for just writing to;
767
* we know we don't need to update dirty status, etc.
768
*/
769
for (i = 0; i < maxidx - 1; i++) {
770
@@ -XXX,XX +XXX,XX @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)
771
memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE));
772
return;
773
}
774
- /* OK, try a store and see if we can populate the tlb. This
775
+ /*
776
+ * OK, try a store and see if we can populate the tlb. This
777
* might cause an exception if the memory isn't writable,
778
* in which case we will longjmp out of here. We must for
779
* this purpose use the actual register value passed to us
780
@@ -XXX,XX +XXX,XX @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)
781
}
782
}
783
784
- /* Slow path (probably attempt to do this to an I/O device or
785
+ /*
786
+ * Slow path (probably attempt to do this to an I/O device or
787
* similar, or clearing of a block of code we have translations
788
* cached for). Just do a series of byte writes as the architecture
789
* demands. It's not worth trying to use a cpu_physical_memory_map(),
790
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
791
index XXXXXXX..XXXXXXX 100644
792
--- a/target/arm/op_helper.c
793
+++ b/target/arm/op_helper.c
794
@@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn,
795
{
796
uint32_t syn;
797
798
- /* ISV is only set for data aborts routed to EL2 and
799
+ /*
800
+ * ISV is only set for data aborts routed to EL2 and
801
* never for stage-1 page table walks faulting on stage 2.
802
*
803
* Furthermore, ISV is only set for certain kinds of load/stores.
804
@@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn,
805
syn = syn_data_abort_no_iss(same_el,
806
ea, 0, s1ptw, is_write, fsc);
807
} else {
808
- /* Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template
809
+ /*
810
+ * Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template
811
* syndrome created at translation time.
812
* Now we create the runtime syndrome with the remaining fields.
813
*/
814
@@ -XXX,XX +XXX,XX @@ void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type,
815
816
if (target_el == 2 || arm_el_is_aa64(env, target_el) ||
817
arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) {
818
- /* LPAE format fault status register : bottom 6 bits are
819
+ /*
820
+ * LPAE format fault status register : bottom 6 bits are
821
* status code in the same form as needed for syndrome
822
*/
823
fsr = arm_fi_to_lfsc(fi);
824
fsc = extract32(fsr, 0, 6);
825
} else {
826
fsr = arm_fi_to_sfsc(fi);
827
- /* Short format FSR : this fault will never actually be reported
828
+ /*
829
+ * Short format FSR : this fault will never actually be reported
830
* to an EL that uses a syndrome register. Use a (currently)
831
* reserved FSR code in case the constructed syndrome does leak
832
* into the guest somehow.
833
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
834
arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi);
835
}
836
837
-/* arm_cpu_do_transaction_failed: handle a memory system error response
838
+/*
839
+ * arm_cpu_do_transaction_failed: handle a memory system error response
840
* (eg "no device/memory present at address") by raising an external abort
841
* exception
842
*/
843
@@ -XXX,XX +XXX,XX @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn)
844
int bt;
845
uint32_t contextidr;
846
847
- /* Links to unimplemented or non-context aware breakpoints are
848
+ /*
849
+ * Links to unimplemented or non-context aware breakpoints are
850
* CONSTRAINED UNPREDICTABLE: either behave as if disabled, or
851
* as if linked to an UNKNOWN context-aware breakpoint (in which
852
* case DBGWCR<n>_EL1.LBN must indicate that breakpoint).
853
@@ -XXX,XX +XXX,XX @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn)
854
855
bt = extract64(bcr, 20, 4);
856
857
- /* We match the whole register even if this is AArch32 using the
858
+ /*
859
+ * We match the whole register even if this is AArch32 using the
860
* short descriptor format (in which case it holds both PROCID and ASID),
861
* since we don't implement the optional v7 context ID masking.
862
*/
863
@@ -XXX,XX +XXX,XX @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn)
864
case 9: /* linked VMID match (reserved if no EL2) */
865
case 11: /* linked context ID and VMID match (reserved if no EL2) */
866
default:
867
- /* Links to Unlinked context breakpoints must generate no
868
+ /*
869
+ * Links to Unlinked context breakpoints must generate no
870
* events; we choose to do the same for reserved values too.
871
*/
872
return false;
873
@@ -XXX,XX +XXX,XX @@ static bool bp_wp_matches(ARMCPU *cpu, int n, bool is_wp)
874
CPUARMState *env = &cpu->env;
875
uint64_t cr;
876
int pac, hmc, ssc, wt, lbn;
877
- /* Note that for watchpoints the check is against the CPU security
878
+ /*
879
+ * Note that for watchpoints the check is against the CPU security
880
* state, not the S/NS attribute on the offending data access.
881
*/
882
bool is_secure = arm_is_secure(env);
883
@@ -XXX,XX +XXX,XX @@ static bool bp_wp_matches(ARMCPU *cpu, int n, bool is_wp)
884
}
885
cr = env->cp15.dbgwcr[n];
886
if (wp->hitattrs.user) {
887
- /* The LDRT/STRT/LDT/STT "unprivileged access" instructions should
888
+ /*
889
+ * The LDRT/STRT/LDT/STT "unprivileged access" instructions should
890
* match watchpoints as if they were accesses done at EL0, even if
891
* the CPU is at EL1 or higher.
892
*/
893
@@ -XXX,XX +XXX,XX @@ static bool bp_wp_matches(ARMCPU *cpu, int n, bool is_wp)
894
}
895
cr = env->cp15.dbgbcr[n];
896
}
897
- /* The WATCHPOINT_HIT flag guarantees us that the watchpoint is
898
+ /*
899
+ * The WATCHPOINT_HIT flag guarantees us that the watchpoint is
900
* enabled and that the address and access type match; for breakpoints
901
* we know the address matched; check the remaining fields, including
902
* linked breakpoints. We rely on WCR and BCR having the same layout
903
@@ -XXX,XX +XXX,XX @@ static bool check_watchpoints(ARMCPU *cpu)
904
CPUARMState *env = &cpu->env;
905
int n;
906
907
- /* If watchpoints are disabled globally or we can't take debug
908
+ /*
909
+ * If watchpoints are disabled globally or we can't take debug
910
* exceptions here then watchpoint firings are ignored.
911
*/
912
if (extract32(env->cp15.mdscr_el1, 15, 1) == 0
913
@@ -XXX,XX +XXX,XX @@ static bool check_breakpoints(ARMCPU *cpu)
914
CPUARMState *env = &cpu->env;
915
int n;
916
917
- /* If breakpoints are disabled globally or we can't take debug
918
+ /*
919
+ * If breakpoints are disabled globally or we can't take debug
920
* exceptions here then breakpoint firings are ignored.
921
*/
922
if (extract32(env->cp15.mdscr_el1, 15, 1) == 0
923
@@ -XXX,XX +XXX,XX @@ void HELPER(check_breakpoints)(CPUARMState *env)
924
925
bool arm_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp)
926
{
927
- /* Called by core code when a CPU watchpoint fires; need to check if this
928
+ /*
929
+ * Called by core code when a CPU watchpoint fires; need to check if this
930
* is also an architectural watchpoint match.
931
*/
932
ARMCPU *cpu = ARM_CPU(cs);
933
@@ -XXX,XX +XXX,XX @@ vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len)
934
ARMCPU *cpu = ARM_CPU(cs);
935
CPUARMState *env = &cpu->env;
936
937
- /* In BE32 system mode, target memory is stored byteswapped (on a
938
+ /*
939
+ * In BE32 system mode, target memory is stored byteswapped (on a
940
* little-endian host system), and by the time we reach here (via an
941
* opcode helper) the addresses of subword accesses have been adjusted
942
* to account for that, which means that watchpoints will not match.
943
@@ -XXX,XX +XXX,XX @@ vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len)
944
945
void arm_debug_excp_handler(CPUState *cs)
946
{
947
- /* Called by core code when a watchpoint or breakpoint fires;
948
+ /*
949
+ * Called by core code when a watchpoint or breakpoint fires;
950
* need to check which one and raise the appropriate exception.
951
*/
952
ARMCPU *cpu = ARM_CPU(cs);
953
@@ -XXX,XX +XXX,XX @@ void arm_debug_excp_handler(CPUState *cs)
954
uint64_t pc = is_a64(env) ? env->pc : env->regs[15];
955
bool same_el = (arm_debug_target_el(env) == arm_current_el(env));
956
957
- /* (1) GDB breakpoints should be handled first.
958
+ /*
959
+ * (1) GDB breakpoints should be handled first.
960
* (2) Do not raise a CPU exception if no CPU breakpoint has fired,
961
* since singlestep is also done by generating a debug internal
962
* exception.
963
@@ -XXX,XX +XXX,XX @@ void arm_debug_excp_handler(CPUState *cs)
964
}
965
966
env->exception.fsr = arm_debug_exception_fsr(env);
967
- /* FAR is UNKNOWN: clear vaddress to avoid potentially exposing
968
+ /*
969
+ * FAR is UNKNOWN: clear vaddress to avoid potentially exposing
970
* values to the guest that it shouldn't be able to see at its
971
* exception/security level.
972
*/
973
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
974
index XXXXXXX..XXXXXXX 100644
975
--- a/target/arm/vfp_helper.c
976
+++ b/target/arm/vfp_helper.c
977
@@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
978
set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16);
979
}
980
981
- /* The exception flags are ORed together when we read fpscr so we
982
+ /*
983
+ * The exception flags are ORed together when we read fpscr so we
984
* only need to preserve the current state in one of our
985
* float_status values.
986
*/
987
--
198
--
988
2.20.1
199
2.34.1
989
200
990
201
diff view generated by jsdifflib