1
target-arm queue for softfreeze: this is quite big as I
1
Most of this is the Neon decodetree patches, followed by Edgar's versal cleanups.
2
was on holiday last week, so this is all just sneaking in
3
under the wire. I particularly wanted to get Philippe's
4
patches in before freeze as that sort of code-movement
5
patchset is painful to have to rebase.
6
2
7
thanks
3
thanks
8
-- PMM
4
-- PMM
9
5
10
The following changes since commit ae9108f8f0746ce64d02afb1a216153a50926132:
11
6
12
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-4.1-pull-request' into staging (2019-07-01 15:55:40 +0100)
7
The following changes since commit 2ef486e76d64436be90f7359a3071fb2a56ce835:
8
9
Merge remote-tracking branch 'remotes/marcel/tags/rdma-pull-request' into staging (2020-05-03 14:12:56 +0100)
13
10
14
are available in the Git repository at:
11
are available in the Git repository at:
15
12
16
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190701
13
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200504
17
14
18
for you to fetch changes up to 787a7e76c2e93a48c47b324fea592c9910a70483:
15
for you to fetch changes up to 9aefc6cf9b73f66062d2f914a0136756e7a28211:
19
16
20
target/arm: Declare some M-profile functions publicly (2019-07-01 17:29:01 +0100)
17
target/arm: Move gen_ function typedefs to translate.h (2020-05-04 12:59:26 +0100)
21
18
22
----------------------------------------------------------------
19
----------------------------------------------------------------
23
target-arm queue:
20
target-arm queue:
24
* hw/arm/boot: fix direct kernel boot with initrd
21
* Start of conversion of Neon insns to decodetree
25
* hw/arm/msf2-som: Exit when the cpu is not the expected one
22
* versal board: support SD and RTC
26
* i.mx7: fix bugs in PCI controller needed to boot recent kernels
23
* Implement ARMv8.2-TTS2UXN
27
* aspeed: add RTC device
24
* Make VQDMULL undefined when U=1
28
* aspeed: fix some timer device bugs
25
* Some minor code cleanups
29
* aspeed: add swift-bmc board
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
26
36
----------------------------------------------------------------
27
----------------------------------------------------------------
37
Adriana Kobylak (1):
28
Edgar E. Iglesias (11):
38
aspeed: Add support for the swift-bmc board
29
hw/arm: versal: Remove inclusion of arm_gicv3_common.h
30
hw/arm: versal: Move misplaced comment
31
hw/arm: versal-virt: Fix typo xlnx-ve -> xlnx-versal
32
hw/arm: versal: Embed the UARTs into the SoC type
33
hw/arm: versal: Embed the GEMs into the SoC type
34
hw/arm: versal: Embed the ADMAs into the SoC type
35
hw/arm: versal: Embed the APUs into the SoC type
36
hw/arm: versal: Add support for SD
37
hw/arm: versal: Add support for the RTC
38
hw/arm: versal-virt: Add support for SD
39
hw/arm: versal-virt: Add support for the RTC
39
40
40
Andrew Jeffery (3):
41
Fredrik Strupe (1):
41
aspeed/timer: Status register contains reload for stopped timer
42
target/arm: Make VQDMULL undefined when U=1
42
aspeed/timer: Fix match calculations
43
aspeed: vic: Add support for legacy register interface
44
43
45
Andrew Jones (1):
44
Peter Maydell (25):
46
hw/arm/boot: fix direct kernel boot with initrd
45
target/arm: Don't use a TLB for ARMMMUIdx_Stage2
46
target/arm: Use enum constant in get_phys_addr_lpae() call
47
target/arm: Add new 's1_is_el0' argument to get_phys_addr_lpae()
48
target/arm: Implement ARMv8.2-TTS2UXN
49
target/arm: Use correct variable for setting 'max' cpu's ID_AA64DFR0
50
target/arm/translate-vfp.inc.c: Remove duplicate simd_r32 check
51
target/arm: Don't allow Thumb Neon insns without FEATURE_NEON
52
target/arm: Add stubs for AArch32 Neon decodetree
53
target/arm: Convert VCMLA (vector) to decodetree
54
target/arm: Convert VCADD (vector) to decodetree
55
target/arm: Convert V[US]DOT (vector) to decodetree
56
target/arm: Convert VFM[AS]L (vector) to decodetree
57
target/arm: Convert VCMLA (scalar) to decodetree
58
target/arm: Convert V[US]DOT (scalar) to decodetree
59
target/arm: Convert VFM[AS]L (scalar) to decodetree
60
target/arm: Convert Neon load/store multiple structures to decodetree
61
target/arm: Convert Neon 'load single structure to all lanes' to decodetree
62
target/arm: Convert Neon 'load/store single structure' to decodetree
63
target/arm: Convert Neon 3-reg-same VADD/VSUB to decodetree
64
target/arm: Convert Neon 3-reg-same logic ops to decodetree
65
target/arm: Convert Neon 3-reg-same VMAX/VMIN to decodetree
66
target/arm: Convert Neon 3-reg-same comparisons to decodetree
67
target/arm: Convert Neon 3-reg-same VQADD/VQSUB to decodetree
68
target/arm: Convert Neon 3-reg-same VMUL, VMLA, VMLS, VSHL to decodetree
69
target/arm: Move gen_ function typedefs to translate.h
47
70
48
Andrey Smirnov (5):
71
Philippe Mathieu-Daudé (2):
49
i.mx7d: Add no-op/unimplemented APBH DMA module
72
hw/arm/mps2-tz: Use TYPE_IOTKIT instead of hardcoded string
50
i.mx7d: Add no-op/unimplemented PCIE PHY IP block
73
target/arm: Use uint64_t for midr field in CPU state struct
51
pci: designware: Update MSI mapping unconditionally
52
pci: designware: Update MSI mapping when MSI address changes
53
i.mx7d: pci: Update PCI IRQ mapping to match HW
54
74
55
Christian Svensson (1):
75
include/hw/arm/xlnx-versal.h | 31 +-
56
aspeed/timer: Ensure positive muldiv delta
76
target/arm/cpu-param.h | 2 +-
77
target/arm/cpu.h | 38 ++-
78
target/arm/translate-a64.h | 9 -
79
target/arm/translate.h | 26 ++
80
target/arm/neon-dp.decode | 86 +++++
81
target/arm/neon-ls.decode | 52 +++
82
target/arm/neon-shared.decode | 66 ++++
83
hw/arm/mps2-tz.c | 2 +-
84
hw/arm/xlnx-versal-virt.c | 74 ++++-
85
hw/arm/xlnx-versal.c | 115 +++++--
86
target/arm/cpu.c | 3 +-
87
target/arm/cpu64.c | 8 +-
88
target/arm/helper.c | 183 ++++------
89
target/arm/translate-a64.c | 17 -
90
target/arm/translate-neon.inc.c | 714 +++++++++++++++++++++++++++++++++++++++
91
target/arm/translate-vfp.inc.c | 6 -
92
target/arm/translate.c | 716 +++-------------------------------------
93
target/arm/Makefile.objs | 18 +
94
19 files changed, 1302 insertions(+), 864 deletions(-)
95
create mode 100644 target/arm/neon-dp.decode
96
create mode 100644 target/arm/neon-ls.decode
97
create mode 100644 target/arm/neon-shared.decode
98
create mode 100644 target/arm/translate-neon.inc.c
57
99
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
Deleted patch
1
From: Andrew Jones <drjones@redhat.com>
2
1
3
Fix the condition used to check whether the initrd fits
4
into RAM; in some cases if an initrd was also passed on
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
10
Fixes: 852dc64d665f ("hw/arm/boot: Diagnose layouts that put initrd or
11
DTB off the end of RAM")
12
Signed-off-by: Andrew Jones <drjones@redhat.com>
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>
16
---
17
hw/arm/boot.c | 3 ++-
18
1 file changed, 2 insertions(+), 1 deletion(-)
19
20
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/boot.c
23
+++ b/hw/arm/boot.c
24
@@ -XXX,XX +XXX,XX @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
25
info->initrd_filename);
26
exit(1);
27
}
28
- if (info->initrd_start + initrd_size > info->ram_size) {
29
+ if (info->initrd_start + initrd_size > ram_end) {
30
error_report("could not load initrd '%s': "
31
"too big to fit into RAM after the kernel",
32
info->initrd_filename);
33
+ exit(1);
34
}
35
} else {
36
initrd_size = 0;
37
--
38
2.20.1
39
40
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Fredrik Strupe <fredrik@strupe.net>
2
2
3
Under KVM, the kernel gets the HVC call and handle the PSCI requests.
3
According to Arm ARM, VQDMULL is only valid when U=0, while having
4
U=1 is unallocated.
4
5
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Signed-off-by: Fredrik Strupe <fredrik@strupe.net>
6
Message-id: 20190701132516.26392-20-philmd@redhat.com
7
Fixes: 695272dcb976 ("target-arm: Handle UNDEF cases for Neon 3-regs-different-widths")
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
---
10
target/arm/internals.h | 6 +++++-
11
target/arm/translate.c | 2 +-
11
1 file changed, 5 insertions(+), 1 deletion(-)
12
1 file changed, 1 insertion(+), 1 deletion(-)
12
13
13
diff --git a/target/arm/internals.h b/target/arm/internals.h
14
diff --git a/target/arm/translate.c b/target/arm/translate.c
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/internals.h
16
--- a/target/arm/translate.c
16
+++ b/target/arm/internals.h
17
+++ b/target/arm/translate.c
17
@@ -XXX,XX +XXX,XX @@ vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len);
18
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
18
/* Callback function for when a watchpoint or breakpoint triggers. */
19
{0, 0, 0, 0}, /* VMLSL */
19
void arm_debug_excp_handler(CPUState *cs);
20
{0, 0, 0, 9}, /* VQDMLSL */
20
21
{0, 0, 0, 0}, /* Integer VMULL */
21
-#ifdef CONFIG_USER_ONLY
22
- {0, 0, 0, 1}, /* VQDMULL */
22
+#if defined(CONFIG_USER_ONLY) || !defined(CONFIG_TCG)
23
+ {0, 0, 0, 9}, /* VQDMULL */
23
static inline bool arm_is_psci_call(ARMCPU *cpu, int excp_type)
24
{0, 0, 0, 0xa}, /* Polynomial VMULL */
24
{
25
{0, 0, 0, 7}, /* Reserved: always UNDEF */
25
return false;
26
};
26
}
27
+static inline void arm_handle_psci_call(ARMCPU *cpu)
28
+{
29
+ g_assert_not_reached();
30
+}
31
#else
32
/* Return true if the r0/x0 value indicates that this SMC/HVC is a PSCI call. */
33
bool arm_is_psci_call(ARMCPU *cpu, int excp_type);
34
--
27
--
35
2.20.1
28
2.20.1
36
29
37
30
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
The vfp_set_fpscr() helper contains code specific to the host
3
By using the TYPE_* definitions for devices, we can:
4
floating point implementation (here the SoftFloat library).
4
- quickly find where devices are used with 'git-grep'
5
Extract this code to vfp_set_fpscr_from_host().
5
- easily rename a device (one-line change).
6
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20190701132516.26392-17-philmd@redhat.com
8
Message-id: 20200428154650.21991-1-f4bug@amsat.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
11
---
12
target/arm/vfp_helper.c | 19 +++++++++++++------
12
hw/arm/mps2-tz.c | 2 +-
13
1 file changed, 13 insertions(+), 6 deletions(-)
13
1 file changed, 1 insertion(+), 1 deletion(-)
14
14
15
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
15
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/vfp_helper.c
17
--- a/hw/arm/mps2-tz.c
18
+++ b/target/arm/vfp_helper.c
18
+++ b/hw/arm/mps2-tz.c
19
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits)
19
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
20
return host_bits;
20
exit(EXIT_FAILURE);
21
}
21
}
22
22
23
+static uint32_t vfp_get_fpscr_from_host(CPUARMState *env)
23
- sysbus_init_child_obj(OBJECT(machine), "iotkit", &mms->iotkit,
24
+{
24
+ sysbus_init_child_obj(OBJECT(machine), TYPE_IOTKIT, &mms->iotkit,
25
+ uint32_t i;
25
sizeof(mms->iotkit), mmc->armsse_type);
26
+
26
iotkitdev = DEVICE(&mms->iotkit);
27
+ i = get_float_exception_flags(&env->vfp.fp_status);
27
object_property_set_link(OBJECT(&mms->iotkit), OBJECT(system_memory),
28
+ i |= get_float_exception_flags(&env->vfp.standard_fp_status);
29
+ /* FZ16 does not generate an input denormal exception. */
30
+ i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
31
+ & ~float_flag_input_denormal);
32
+ return vfp_exceptbits_from_host(i);
33
+}
34
+
35
static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val)
36
{
37
int i;
38
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
39
| (env->vfp.vec_len << 16)
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
--
28
--
53
2.20.1
29
2.20.1
54
30
55
31
diff view generated by jsdifflib
1
From: Samuel Ortiz <sameo@linux.intel.com>
1
We define ARMMMUIdx_Stage2 as being an MMU index which uses a QEMU
2
2
TLB. However we never actually use the TLB -- all stage 2 lookups
3
Those helpers are a software implementation of the ARM v8 memory zeroing
3
are done by direct calls to get_phys_addr_lpae() followed by a
4
op code. They should be moved to the op helper file, which is going to
4
physical address load via address_space_ld*().
5
eventually be built only when TCG is enabled.
5
6
6
Remove Stage2 from the list of ARM MMU indexes which correspond to
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
real core MMU indexes, and instead put it in the set of "NOTLB" ARM
8
Reviewed-by: Robert Bradford <robert.bradford@intel.com>
8
MMU indexes.
9
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
10
This allows us to drop NB_MMU_MODES to 11. It also means we can
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
safely add support for the ARMv8.3-TTS2UXN extension, which adds
12
Message-id: 20190701132516.26392-10-philmd@redhat.com
12
permission bits to the stage 2 descriptors which define execute
13
[PMD: Rebased]
13
permission separatel for EL0 and EL1; supporting that while keeping
14
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
Stage2 in a QEMU TLB would require us to use separate TLBs for
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
"Stage2 for an EL0 access" and "Stage2 for an EL1 access", which is a
16
lot of extra complication given we aren't even using the QEMU TLB.
17
18
In the process of updating the comment on our MMU index use,
19
fix a couple of other minor errors:
20
* NS EL2 EL2&0 was missing from the list in the comment
21
* some text hadn't been updated from when we bumped NB_MMU_MODES
22
above 8
23
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
26
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
27
Message-id: 20200330210400.11724-2-peter.maydell@linaro.org
17
---
28
---
18
target/arm/helper.c | 92 -----------------------------------------
29
target/arm/cpu-param.h | 2 +-
19
target/arm/op_helper.c | 93 ++++++++++++++++++++++++++++++++++++++++++
30
target/arm/cpu.h | 21 +++++---
20
2 files changed, 93 insertions(+), 92 deletions(-)
31
target/arm/helper.c | 112 ++++-------------------------------------
21
32
3 files changed, 27 insertions(+), 108 deletions(-)
33
34
diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h
35
index XXXXXXX..XXXXXXX 100644
36
--- a/target/arm/cpu-param.h
37
+++ b/target/arm/cpu-param.h
38
@@ -XXX,XX +XXX,XX @@
39
# define TARGET_PAGE_BITS_MIN 10
40
#endif
41
42
-#define NB_MMU_MODES 12
43
+#define NB_MMU_MODES 11
44
45
#endif
46
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
47
index XXXXXXX..XXXXXXX 100644
48
--- a/target/arm/cpu.h
49
+++ b/target/arm/cpu.h
50
@@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);
51
* handling via the TLB. The only way to do a stage 1 translation without
52
* the immediate stage 2 translation is via the ATS or AT system insns,
53
* which can be slow-pathed and always do a page table walk.
54
+ * The only use of stage 2 translations is either as part of an s1+2
55
+ * lookup or when loading the descriptors during a stage 1 page table walk,
56
+ * and in both those cases we don't use the TLB.
57
* 4. we can also safely fold together the "32 bit EL3" and "64 bit EL3"
58
* translation regimes, because they map reasonably well to each other
59
* and they can't both be active at the same time.
60
@@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);
61
* NS EL1 EL1&0 stage 1+2 (aka NS PL1)
62
* NS EL1 EL1&0 stage 1+2 +PAN
63
* NS EL0 EL2&0
64
+ * NS EL2 EL2&0
65
* NS EL2 EL2&0 +PAN
66
* NS EL2 (aka NS PL2)
67
* S EL0 EL1&0 (aka S PL0)
68
* S EL1 EL1&0 (not used if EL3 is 32 bit)
69
* S EL1 EL1&0 +PAN
70
* S EL3 (aka S PL1)
71
- * NS EL1&0 stage 2
72
*
73
- * for a total of 12 different mmu_idx.
74
+ * for a total of 11 different mmu_idx.
75
*
76
* R profile CPUs have an MPU, but can use the same set of MMU indexes
77
* as A profile. They only need to distinguish NS EL0 and NS EL1 (and
78
@@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);
79
* are not quite the same -- different CPU types (most notably M profile
80
* vs A/R profile) would like to use MMU indexes with different semantics,
81
* but since we don't ever need to use all of those in a single CPU we
82
- * can avoid setting NB_MMU_MODES to more than 8. The lower bits of
83
+ * can avoid having to set NB_MMU_MODES to "total number of A profile MMU
84
+ * modes + total number of M profile MMU modes". The lower bits of
85
* ARMMMUIdx are the core TLB mmu index, and the higher bits are always
86
* the same for any particular CPU.
87
* Variables of type ARMMUIdx are always full values, and the core
88
@@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdx {
89
ARMMMUIdx_SE10_1_PAN = 9 | ARM_MMU_IDX_A,
90
ARMMMUIdx_SE3 = 10 | ARM_MMU_IDX_A,
91
92
- ARMMMUIdx_Stage2 = 11 | ARM_MMU_IDX_A,
93
-
94
/*
95
* These are not allocated TLBs and are used only for AT system
96
* instructions or for the first stage of an S12 page table walk.
97
@@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdx {
98
ARMMMUIdx_Stage1_E0 = 0 | ARM_MMU_IDX_NOTLB,
99
ARMMMUIdx_Stage1_E1 = 1 | ARM_MMU_IDX_NOTLB,
100
ARMMMUIdx_Stage1_E1_PAN = 2 | ARM_MMU_IDX_NOTLB,
101
+ /*
102
+ * Not allocated a TLB: used only for second stage of an S12 page
103
+ * table walk, or for descriptor loads during first stage of an S1
104
+ * page table walk. Note that if we ever want to have a TLB for this
105
+ * then various TLB flush insns which currently are no-ops or flush
106
+ * only stage 1 MMU indexes will need to change to flush stage 2.
107
+ */
108
+ ARMMMUIdx_Stage2 = 3 | ARM_MMU_IDX_NOTLB,
109
110
/*
111
* M-profile.
112
@@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdxBit {
113
TO_CORE_BIT(SE10_1),
114
TO_CORE_BIT(SE10_1_PAN),
115
TO_CORE_BIT(SE3),
116
- TO_CORE_BIT(Stage2),
117
118
TO_CORE_BIT(MUser),
119
TO_CORE_BIT(MPriv),
22
diff --git a/target/arm/helper.c b/target/arm/helper.c
120
diff --git a/target/arm/helper.c b/target/arm/helper.c
23
index XXXXXXX..XXXXXXX 100644
121
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/helper.c
122
--- a/target/arm/helper.c
25
+++ b/target/arm/helper.c
123
+++ b/target/arm/helper.c
26
@@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
124
@@ -XXX,XX +XXX,XX @@ static void tlbiall_nsnh_write(CPUARMState *env, const ARMCPRegInfo *ri,
27
#endif
125
tlb_flush_by_mmuidx(cs,
126
ARMMMUIdxBit_E10_1 |
127
ARMMMUIdxBit_E10_1_PAN |
128
- ARMMMUIdxBit_E10_0 |
129
- ARMMMUIdxBit_Stage2);
130
+ ARMMMUIdxBit_E10_0);
28
}
131
}
29
132
30
-void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)
133
static void tlbiall_nsnh_is_write(CPUARMState *env, const ARMCPRegInfo *ri,
134
@@ -XXX,XX +XXX,XX @@ static void tlbiall_nsnh_is_write(CPUARMState *env, const ARMCPRegInfo *ri,
135
tlb_flush_by_mmuidx_all_cpus_synced(cs,
136
ARMMMUIdxBit_E10_1 |
137
ARMMMUIdxBit_E10_1_PAN |
138
- ARMMMUIdxBit_E10_0 |
139
- ARMMMUIdxBit_Stage2);
140
+ ARMMMUIdxBit_E10_0);
141
}
142
143
-static void tlbiipas2_write(CPUARMState *env, const ARMCPRegInfo *ri,
144
- uint64_t value)
31
-{
145
-{
32
- /*
146
- /* Invalidate by IPA. This has to invalidate any structures that
33
- * Implement DC ZVA, which zeroes a fixed-length block of memory.
147
- * contain only stage 2 translation information, but does not need
34
- * Note that we do not implement the (architecturally mandated)
148
- * to apply to structures that contain combined stage 1 and stage 2
35
- * alignment fault for attempts to use this on Device memory
149
- * translation information.
36
- * (which matches the usual QEMU behaviour of not implementing either
150
- * This must NOP if EL2 isn't implemented or SCR_EL3.NS is zero.
37
- * alignment faults or any memory attribute handling).
38
- */
151
- */
39
-
152
- CPUState *cs = env_cpu(env);
40
- ARMCPU *cpu = env_archcpu(env);
153
- uint64_t pageaddr;
41
- uint64_t blocklen = 4 << cpu->dcz_blocksize;
154
-
42
- uint64_t vaddr = vaddr_in & ~(blocklen - 1);
155
- if (!arm_feature(env, ARM_FEATURE_EL2) || !(env->cp15.scr_el3 & SCR_NS)) {
43
-
156
- return;
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
- }
157
- }
117
-#else
158
-
118
- memset(g2h(vaddr), 0, blocklen);
159
- pageaddr = sextract64(value << 12, 0, 40);
119
-#endif
160
-
161
- tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_Stage2);
120
-}
162
-}
121
-
163
-
122
/* Note that signed overflow is undefined in C. The following routines are
164
-static void tlbiipas2_is_write(CPUARMState *env, const ARMCPRegInfo *ri,
123
careful to use unsigned types where modulo arithmetic is required.
165
- uint64_t value)
124
Failure to do so _will_ break on newer gcc. */
166
-{
125
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
167
- CPUState *cs = env_cpu(env);
126
index XXXXXXX..XXXXXXX 100644
168
- uint64_t pageaddr;
127
--- a/target/arm/op_helper.c
169
-
128
+++ b/target/arm/op_helper.c
170
- if (!arm_feature(env, ARM_FEATURE_EL2) || !(env->cp15.scr_el3 & SCR_NS)) {
129
@@ -XXX,XX +XXX,XX @@
171
- return;
130
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
172
- }
131
*/
173
-
132
#include "qemu/osdep.h"
174
- pageaddr = sextract64(value << 12, 0, 40);
133
+#include "qemu/units.h"
175
-
134
#include "qemu/log.h"
176
- tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr,
135
#include "qemu/main-loop.h"
177
- ARMMMUIdxBit_Stage2);
136
#include "cpu.h"
178
-}
137
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(ror_cc)(CPUARMState *env, uint32_t x, uint32_t i)
179
138
return ((uint32_t)x >> shift) | (x << (32 - shift));
180
static void tlbiall_hyp_write(CPUARMState *env, const ARMCPRegInfo *ri,
181
uint64_t value)
182
@@ -XXX,XX +XXX,XX @@ static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri,
183
tlb_flush_by_mmuidx(cs,
184
ARMMMUIdxBit_E10_1 |
185
ARMMMUIdxBit_E10_1_PAN |
186
- ARMMMUIdxBit_E10_0 |
187
- ARMMMUIdxBit_Stage2);
188
+ ARMMMUIdxBit_E10_0);
189
raw_write(env, ri, value);
139
}
190
}
140
}
191
}
141
+
192
@@ -XXX,XX +XXX,XX @@ static int alle1_tlbmask(CPUARMState *env)
142
+void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)
193
return ARMMMUIdxBit_SE10_1 |
143
+{
194
ARMMMUIdxBit_SE10_1_PAN |
144
+ /*
195
ARMMMUIdxBit_SE10_0;
145
+ * Implement DC ZVA, which zeroes a fixed-length block of memory.
196
- } else if (arm_feature(env, ARM_FEATURE_EL2)) {
146
+ * Note that we do not implement the (architecturally mandated)
197
- return ARMMMUIdxBit_E10_1 |
147
+ * alignment fault for attempts to use this on Device memory
198
- ARMMMUIdxBit_E10_1_PAN |
148
+ * (which matches the usual QEMU behaviour of not implementing either
199
- ARMMMUIdxBit_E10_0 |
149
+ * alignment faults or any memory attribute handling).
200
- ARMMMUIdxBit_Stage2;
150
+ */
201
} else {
151
+
202
return ARMMMUIdxBit_E10_1 |
152
+ ARMCPU *cpu = env_archcpu(env);
203
ARMMMUIdxBit_E10_1_PAN |
153
+ uint64_t blocklen = 4 << cpu->dcz_blocksize;
204
@@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vae3is_write(CPUARMState *env, const ARMCPRegInfo *ri,
154
+ uint64_t vaddr = vaddr_in & ~(blocklen - 1);
205
ARMMMUIdxBit_SE3);
155
+
206
}
156
+#ifndef CONFIG_USER_ONLY
207
157
+ {
208
-static void tlbi_aa64_ipas2e1_write(CPUARMState *env, const ARMCPRegInfo *ri,
158
+ /*
209
- uint64_t value)
159
+ * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than
210
-{
160
+ * the block size so we might have to do more than one TLB lookup.
211
- /* Invalidate by IPA. This has to invalidate any structures that
161
+ * We know that in fact for any v8 CPU the page size is at least 4K
212
- * contain only stage 2 translation information, but does not need
162
+ * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only
213
- * to apply to structures that contain combined stage 1 and stage 2
163
+ * 1K as an artefact of legacy v5 subpage support being present in the
214
- * translation information.
164
+ * same QEMU executable. So in practice the hostaddr[] array has
215
- * This must NOP if EL2 isn't implemented or SCR_EL3.NS is zero.
165
+ * two entries, given the current setting of TARGET_PAGE_BITS_MIN.
216
- */
166
+ */
217
- ARMCPU *cpu = env_archcpu(env);
167
+ int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE);
218
- CPUState *cs = CPU(cpu);
168
+ void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)];
219
- uint64_t pageaddr;
169
+ int try, i;
220
-
170
+ unsigned mmu_idx = cpu_mmu_index(env, false);
221
- if (!arm_feature(env, ARM_FEATURE_EL2) || !(env->cp15.scr_el3 & SCR_NS)) {
171
+ TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx);
222
- return;
172
+
223
- }
173
+ assert(maxidx <= ARRAY_SIZE(hostaddr));
224
-
174
+
225
- pageaddr = sextract64(value << 12, 0, 48);
175
+ for (try = 0; try < 2; try++) {
226
-
176
+
227
- tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_Stage2);
177
+ for (i = 0; i < maxidx; i++) {
228
-}
178
+ hostaddr[i] = tlb_vaddr_to_host(env,
229
-
179
+ vaddr + TARGET_PAGE_SIZE * i,
230
-static void tlbi_aa64_ipas2e1is_write(CPUARMState *env, const ARMCPRegInfo *ri,
180
+ 1, mmu_idx);
231
- uint64_t value)
181
+ if (!hostaddr[i]) {
232
-{
182
+ break;
233
- CPUState *cs = env_cpu(env);
183
+ }
234
- uint64_t pageaddr;
184
+ }
235
-
185
+ if (i == maxidx) {
236
- if (!arm_feature(env, ARM_FEATURE_EL2) || !(env->cp15.scr_el3 & SCR_NS)) {
186
+ /*
237
- return;
187
+ * If it's all in the TLB it's fair game for just writing to;
238
- }
188
+ * we know we don't need to update dirty status, etc.
239
-
189
+ */
240
- pageaddr = sextract64(value << 12, 0, 48);
190
+ for (i = 0; i < maxidx - 1; i++) {
241
-
191
+ memset(hostaddr[i], 0, TARGET_PAGE_SIZE);
242
- tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr,
192
+ }
243
- ARMMMUIdxBit_Stage2);
193
+ memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE));
244
-}
194
+ return;
245
-
195
+ }
246
static CPAccessResult aa64_zva_access(CPUARMState *env, const ARMCPRegInfo *ri,
196
+ /*
247
bool isread)
197
+ * OK, try a store and see if we can populate the tlb. This
248
{
198
+ * might cause an exception if the memory isn't writable,
249
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
199
+ * in which case we will longjmp out of here. We must for
250
.writefn = tlbi_aa64_vae1_write },
200
+ * this purpose use the actual register value passed to us
251
{ .name = "TLBI_IPAS2E1IS", .state = ARM_CP_STATE_AA64,
201
+ * so that we get the fault address right.
252
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 1,
202
+ */
253
- .access = PL2_W, .type = ARM_CP_NO_RAW,
203
+ helper_ret_stb_mmu(env, vaddr_in, 0, oi, GETPC());
254
- .writefn = tlbi_aa64_ipas2e1is_write },
204
+ /* Now we can populate the other TLB entries, if any */
255
+ .access = PL2_W, .type = ARM_CP_NOP },
205
+ for (i = 0; i < maxidx; i++) {
256
{ .name = "TLBI_IPAS2LE1IS", .state = ARM_CP_STATE_AA64,
206
+ uint64_t va = vaddr + TARGET_PAGE_SIZE * i;
257
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 5,
207
+ if (va != (vaddr_in & TARGET_PAGE_MASK)) {
258
- .access = PL2_W, .type = ARM_CP_NO_RAW,
208
+ helper_ret_stb_mmu(env, va, 0, oi, GETPC());
259
- .writefn = tlbi_aa64_ipas2e1is_write },
209
+ }
260
+ .access = PL2_W, .type = ARM_CP_NOP },
210
+ }
261
{ .name = "TLBI_ALLE1IS", .state = ARM_CP_STATE_AA64,
211
+ }
262
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 4,
212
+
263
.access = PL2_W, .type = ARM_CP_NO_RAW,
213
+ /*
264
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
214
+ * Slow path (probably attempt to do this to an I/O device or
265
.writefn = tlbi_aa64_alle1is_write },
215
+ * similar, or clearing of a block of code we have translations
266
{ .name = "TLBI_IPAS2E1", .state = ARM_CP_STATE_AA64,
216
+ * cached for). Just do a series of byte writes as the architecture
267
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 1,
217
+ * demands. It's not worth trying to use a cpu_physical_memory_map(),
268
- .access = PL2_W, .type = ARM_CP_NO_RAW,
218
+ * memset(), unmap() sequence here because:
269
- .writefn = tlbi_aa64_ipas2e1_write },
219
+ * + we'd need to account for the blocksize being larger than a page
270
+ .access = PL2_W, .type = ARM_CP_NOP },
220
+ * + the direct-RAM access case is almost always going to be dealt
271
{ .name = "TLBI_IPAS2LE1", .state = ARM_CP_STATE_AA64,
221
+ * with in the fastpath code above, so there's no speed benefit
272
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 5,
222
+ * + we would have to deal with the map returning NULL because the
273
- .access = PL2_W, .type = ARM_CP_NO_RAW,
223
+ * bounce buffer was in use
274
- .writefn = tlbi_aa64_ipas2e1_write },
224
+ */
275
+ .access = PL2_W, .type = ARM_CP_NOP },
225
+ for (i = 0; i < blocklen; i++) {
276
{ .name = "TLBI_ALLE1", .state = ARM_CP_STATE_AA64,
226
+ helper_ret_stb_mmu(env, vaddr + i, 0, oi, GETPC());
277
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 4,
227
+ }
278
.access = PL2_W, .type = ARM_CP_NO_RAW,
228
+ }
279
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
229
+#else
280
.writefn = tlbimva_hyp_is_write },
230
+ memset(g2h(vaddr), 0, blocklen);
281
{ .name = "TLBIIPAS2",
231
+#endif
282
.cp = 15, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 1,
232
+}
283
- .type = ARM_CP_NO_RAW, .access = PL2_W,
284
- .writefn = tlbiipas2_write },
285
+ .type = ARM_CP_NOP, .access = PL2_W },
286
{ .name = "TLBIIPAS2IS",
287
.cp = 15, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 1,
288
- .type = ARM_CP_NO_RAW, .access = PL2_W,
289
- .writefn = tlbiipas2_is_write },
290
+ .type = ARM_CP_NOP, .access = PL2_W },
291
{ .name = "TLBIIPAS2L",
292
.cp = 15, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 5,
293
- .type = ARM_CP_NO_RAW, .access = PL2_W,
294
- .writefn = tlbiipas2_write },
295
+ .type = ARM_CP_NOP, .access = PL2_W },
296
{ .name = "TLBIIPAS2LIS",
297
.cp = 15, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 5,
298
- .type = ARM_CP_NO_RAW, .access = PL2_W,
299
- .writefn = tlbiipas2_is_write },
300
+ .type = ARM_CP_NOP, .access = PL2_W },
301
/* 32 bit cache operations */
302
{ .name = "ICIALLUIS", .cp = 15, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 0,
303
.type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access },
233
--
304
--
234
2.20.1
305
2.20.1
235
306
236
307
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
The access_type argument to get_phys_addr_lpae() is an MMUAccessType;
2
use the enum constant MMU_DATA_LOAD rather than a literal 0 when we
3
call it in S1_ptw_translate().
2
4
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>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20200330210400.11724-3-peter.maydell@linaro.org
7
---
9
---
8
target/arm/helper.c | 2 --
10
target/arm/helper.c | 5 +++--
9
1 file changed, 2 deletions(-)
11
1 file changed, 3 insertions(+), 2 deletions(-)
10
12
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
15
--- a/target/arm/helper.c
14
+++ b/target/arm/helper.c
16
+++ b/target/arm/helper.c
15
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
16
#include "exec/gdbstub.h"
18
pcacheattrs = &cacheattrs;
17
#include "exec/helper-proto.h"
19
}
18
#include "qemu/host-utils.h"
20
19
-#include "sysemu/arch_init.h"
21
- ret = get_phys_addr_lpae(env, addr, 0, ARMMMUIdx_Stage2, &s2pa,
20
#include "sysemu/sysemu.h"
22
- &txattrs, &s2prot, &s2size, fi, pcacheattrs);
21
#include "qemu/bitops.h"
23
+ ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, ARMMMUIdx_Stage2,
22
#include "qemu/crc32c.h"
24
+ &s2pa, &txattrs, &s2prot, &s2size, fi,
23
@@ -XXX,XX +XXX,XX @@
25
+ pcacheattrs);
24
#include "hw/semihosting/semihost.h"
26
if (ret) {
25
#include "sysemu/cpus.h"
27
assert(fi->type != ARMFault_None);
26
#include "sysemu/kvm.h"
28
fi->s2addr = addr;
27
-#include "fpu/softfloat.h"
28
#include "qemu/range.h"
29
#include "qapi/qapi-commands-target.h"
30
#include "qapi/error.h"
31
--
29
--
32
2.20.1
30
2.20.1
33
31
34
32
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
For ARMv8.2-TTS2UXN, the stage 2 page table walk wants to know
2
whether the stage 1 access is for EL0 or not, because whether
3
exec permission is given can depend on whether this is an EL0
4
or EL1 access. Add a new argument to get_phys_addr_lpae() so
5
the call sites can pass this information in.
2
6
3
In the next commit we will split the TLB related routines of
7
Since get_phys_addr_lpae() doesn't already have a doc comment,
4
this file, and this function will also be called in the new
8
add one so we have a place to put the documentation of the
5
file. Declare it in the "internals.h" header.
9
semantics of the new s1_is_el0 argument.
6
10
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>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20200330210400.11724-4-peter.maydell@linaro.org
11
---
15
---
12
target/arm/internals.h | 16 ++++++++++++++++
16
target/arm/helper.c | 29 ++++++++++++++++++++++++++++-
13
target/arm/helper.c | 21 +++++----------------
17
1 file changed, 28 insertions(+), 1 deletion(-)
14
2 files changed, 21 insertions(+), 16 deletions(-)
15
18
16
diff --git a/target/arm/internals.h b/target/arm/internals.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/internals.h
19
+++ b/target/arm/internals.h
20
@@ -XXX,XX +XXX,XX @@ static inline int exception_target_el(CPUARMState *env)
21
return target_el;
22
}
23
24
+#ifndef CONFIG_USER_ONLY
25
+
26
+/* Cacheability and shareability attributes for a memory access */
27
+typedef struct ARMCacheAttrs {
28
+ unsigned int attrs:8; /* as in the MAIR register encoding */
29
+ unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */
30
+} ARMCacheAttrs;
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
19
diff --git a/target/arm/helper.c b/target/arm/helper.c
42
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
43
--- a/target/arm/helper.c
21
--- a/target/arm/helper.c
44
+++ b/target/arm/helper.c
22
+++ b/target/arm/helper.c
45
@@ -XXX,XX +XXX,XX @@
23
@@ -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
24
61
static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
25
static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
62
MMUAccessType access_type, ARMMMUIdx mmu_idx,
26
MMUAccessType access_type, ARMMMUIdx mmu_idx,
63
@@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2)
27
+ bool s1_is_el0,
64
* @fi: set to fault info if the translation fails
28
hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot,
65
* @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes
29
target_ulong *page_size_ptr,
66
*/
30
ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs);
67
-static bool get_phys_addr(CPUARMState *env, target_ulong address,
31
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
68
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
32
}
69
- hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
33
70
- target_ulong *page_size,
34
ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, ARMMMUIdx_Stage2,
71
- ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
35
+ false,
72
+bool get_phys_addr(CPUARMState *env, target_ulong address,
36
&s2pa, &txattrs, &s2prot, &s2size, fi,
73
+ MMUAccessType access_type, ARMMMUIdx mmu_idx,
37
pcacheattrs);
74
+ hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
38
if (ret) {
75
+ target_ulong *page_size,
39
@@ -XXX,XX +XXX,XX @@ static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va,
76
+ ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
40
};
77
{
41
}
78
if (mmu_idx == ARMMMUIdx_S12NSE0 || mmu_idx == ARMMMUIdx_S12NSE1) {
42
79
/* Call ourselves recursively to do the stage 1 and then stage 2
43
+/**
44
+ * get_phys_addr_lpae: perform one stage of page table walk, LPAE format
45
+ *
46
+ * Returns false if the translation was successful. Otherwise, phys_ptr, attrs,
47
+ * prot and page_size may not be filled in, and the populated fsr value provides
48
+ * information on why the translation aborted, in the format of a long-format
49
+ * DFSR/IFSR fault register, with the following caveats:
50
+ * * the WnR bit is never set (the caller must do this).
51
+ *
52
+ * @env: CPUARMState
53
+ * @address: virtual address to get physical address for
54
+ * @access_type: MMU_DATA_LOAD, MMU_DATA_STORE or MMU_INST_FETCH
55
+ * @mmu_idx: MMU index indicating required translation regime
56
+ * @s1_is_el0: if @mmu_idx is ARMMMUIdx_Stage2 (so this is a stage 2 page table
57
+ * walk), must be true if this is stage 2 of a stage 1+2 walk for an
58
+ * EL0 access). If @mmu_idx is anything else, @s1_is_el0 is ignored.
59
+ * @phys_ptr: set to the physical address corresponding to the virtual address
60
+ * @attrs: set to the memory transaction attributes to use
61
+ * @prot: set to the permissions for the page containing phys_ptr
62
+ * @page_size_ptr: set to the size of the page containing phys_ptr
63
+ * @fi: set to fault info if the translation fails
64
+ * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes
65
+ */
66
static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
67
MMUAccessType access_type, ARMMMUIdx mmu_idx,
68
+ bool s1_is_el0,
69
hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot,
70
target_ulong *page_size_ptr,
71
ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
72
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
73
74
/* S1 is done. Now do S2 translation. */
75
ret = get_phys_addr_lpae(env, ipa, access_type, ARMMMUIdx_Stage2,
76
+ mmu_idx == ARMMMUIdx_E10_0,
77
phys_ptr, attrs, &s2_prot,
78
page_size, fi,
79
cacheattrs != NULL ? &cacheattrs2 : NULL);
80
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
81
}
82
83
if (regime_using_lpae_format(env, mmu_idx)) {
84
- return get_phys_addr_lpae(env, address, access_type, mmu_idx,
85
+ return get_phys_addr_lpae(env, address, access_type, mmu_idx, false,
86
phys_ptr, attrs, prot, page_size,
87
fi, cacheattrs);
88
} else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) {
80
--
89
--
81
2.20.1
90
2.20.1
82
91
83
92
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
The ARMv8.2-TTS2UXN feature extends the XN field in stage 2
2
translation table descriptors from just bit [54] to bits [54:53],
3
allowing stage 2 to control execution permissions separately for EL0
4
and EL1. Implement the new semantics of the XN field and enable
5
the feature for our 'max' CPU.
2
6
3
Since commit 8c06fbdf36b checkpatch.pl enforce a new multiline
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
comment syntax. Since we'll move this code around, fix its style
8
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
5
first.
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20200330210400.11724-5-peter.maydell@linaro.org
11
---
12
target/arm/cpu.h | 15 +++++++++++++++
13
target/arm/cpu.c | 1 +
14
target/arm/cpu64.c | 2 ++
15
target/arm/helper.c | 37 +++++++++++++++++++++++++++++++------
16
4 files changed, 49 insertions(+), 6 deletions(-)
6
17
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
18
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
19
index XXXXXXX..XXXXXXX 100644
9
Message-id: 20190701132516.26392-8-philmd@redhat.com
20
--- a/target/arm/cpu.h
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
+++ b/target/arm/cpu.h
11
---
22
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_ccidx(const ARMISARegisters *id)
12
target/arm/helper.c | 237 ++++++++++++++++++++++++++--------------
23
return FIELD_EX32(id->id_mmfr4, ID_MMFR4, CCIDX) != 0;
13
target/arm/op_helper.c | 54 ++++++---
24
}
14
target/arm/vfp_helper.c | 3 +-
25
15
3 files changed, 196 insertions(+), 98 deletions(-)
26
+static inline bool isar_feature_aa32_tts2uxn(const ARMISARegisters *id)
16
27
+{
28
+ return FIELD_EX32(id->id_mmfr4, ID_MMFR4, XNX) != 0;
29
+}
30
+
31
/*
32
* 64-bit feature tests via id registers.
33
*/
34
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ccidx(const ARMISARegisters *id)
35
return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, CCIDX) != 0;
36
}
37
38
+static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id)
39
+{
40
+ return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) != 0;
41
+}
42
+
43
/*
44
* Feature tests for "does this exist in either 32-bit or 64-bit?"
45
*/
46
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_ccidx(const ARMISARegisters *id)
47
return isar_feature_aa64_ccidx(id) || isar_feature_aa32_ccidx(id);
48
}
49
50
+static inline bool isar_feature_any_tts2uxn(const ARMISARegisters *id)
51
+{
52
+ return isar_feature_aa64_tts2uxn(id) || isar_feature_aa32_tts2uxn(id);
53
+}
54
+
55
/*
56
* Forward to the above feature tests given an ARMCPU pointer.
57
*/
58
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
59
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/cpu.c
61
+++ b/target/arm/cpu.c
62
@@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj)
63
t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */
64
t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
65
t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */
66
+ t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */
67
cpu->isar.id_mmfr4 = t;
68
}
69
#endif
70
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
71
index XXXXXXX..XXXXXXX 100644
72
--- a/target/arm/cpu64.c
73
+++ b/target/arm/cpu64.c
74
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
75
t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1);
76
t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* ATS1E1 */
77
t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* VMID16 */
78
+ t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* TTS2UXN */
79
cpu->isar.id_aa64mmfr1 = t;
80
81
t = cpu->isar.id_aa64mmfr2;
82
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
83
u = FIELD_DP32(u, ID_MMFR4, HPDS, 1); /* AA32HPD */
84
u = FIELD_DP32(u, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
85
u = FIELD_DP32(u, ID_MMFR4, CNP, 1); /* TTCNP */
86
+ u = FIELD_DP32(u, ID_MMFR4, XNX, 1); /* TTS2UXN */
87
cpu->isar.id_mmfr4 = u;
88
89
u = cpu->isar.id_aa64dfr0;
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
90
diff --git a/target/arm/helper.c b/target/arm/helper.c
18
index XXXXXXX..XXXXXXX 100644
91
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.c
92
--- a/target/arm/helper.c
20
+++ b/target/arm/helper.c
93
+++ b/target/arm/helper.c
21
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr)
94
@@ -XXX,XX +XXX,XX @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)
22
95
*
23
uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
96
* @env: CPUARMState
97
* @s2ap: The 2-bit stage2 access permissions (S2AP)
98
- * @xn: XN (execute-never) bit
99
+ * @xn: XN (execute-never) bits
100
+ * @s1_is_el0: true if this is S2 of an S1+2 walk for EL0
101
*/
102
-static int get_S2prot(CPUARMState *env, int s2ap, int xn)
103
+static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0)
24
{
104
{
25
- /* The TT instructions can be used by unprivileged code, but in
105
int prot = 0;
26
+ /*
106
27
+ * The TT instructions can be used by unprivileged code, but in
107
@@ -XXX,XX +XXX,XX @@ static int get_S2prot(CPUARMState *env, int s2ap, int xn)
28
* user-only emulation we don't have the MPU.
108
if (s2ap & 2) {
29
* Luckily since we know we are NonSecure unprivileged (and that in
109
prot |= PAGE_WRITE;
30
* turn means that the A flag wasn't specified), all the bits in the
31
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
32
return true;
33
34
pend_fault:
35
- /* By pending the exception at this point we are making
36
+ /*
37
+ * By pending the exception at this point we are making
38
* the IMPDEF choice "overridden exceptions pended" (see the
39
* MergeExcInfo() pseudocode). The other choice would be to not
40
* pend them now and then make a choice about which to throw away
41
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr,
42
return true;
43
44
pend_fault:
45
- /* By pending the exception at this point we are making
46
+ /*
47
+ * By pending the exception at this point we are making
48
* the IMPDEF choice "overridden exceptions pended" (see the
49
* MergeExcInfo() pseudocode). The other choice would be to not
50
* pend them now and then make a choice about which to throw away
51
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env)
52
*/
53
}
54
55
-/* Write to v7M CONTROL.SPSEL bit for the specified security bank.
56
+/*
57
+ * Write to v7M CONTROL.SPSEL bit for the specified security bank.
58
* This may change the current stack pointer between Main and Process
59
* stack pointers if it is done for the CONTROL register for the current
60
* security state.
61
@@ -XXX,XX +XXX,XX @@ static void write_v7m_control_spsel_for_secstate(CPUARMState *env,
62
}
110
}
63
}
111
- if (!xn) {
64
112
- if (arm_el_is_aa64(env, 2) || prot & PAGE_READ) {
65
-/* Write to v7M CONTROL.SPSEL bit. This may change the current
113
+
66
+/*
114
+ if (cpu_isar_feature(any_tts2uxn, env_archcpu(env))) {
67
+ * Write to v7M CONTROL.SPSEL bit. This may change the current
115
+ switch (xn) {
68
* stack pointer between Main and Process stack pointers.
116
+ case 0:
69
*/
117
prot |= PAGE_EXEC;
70
static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel)
118
+ break;
71
@@ -XXX,XX +XXX,XX @@ static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel)
119
+ case 1:
72
120
+ if (s1_is_el0) {
73
void write_v7m_exception(CPUARMState *env, uint32_t new_exc)
121
+ prot |= PAGE_EXEC;
74
{
122
+ }
75
- /* Write a new value to v7m.exception, thus transitioning into or out
123
+ break;
76
+ /*
124
+ case 2:
77
+ * Write a new value to v7m.exception, thus transitioning into or out
125
+ break;
78
* of Handler mode; this may result in a change of active stack pointer.
126
+ case 3:
79
*/
127
+ if (!s1_is_el0) {
80
bool new_is_psp, old_is_psp = v7m_using_psp(env);
128
+ prot |= PAGE_EXEC;
81
@@ -XXX,XX +XXX,XX @@ static void switch_v7m_security_state(CPUARMState *env, bool new_secstate)
129
+ }
82
return;
130
+ break;
83
}
131
+ default:
84
132
+ g_assert_not_reached();
85
- /* All the banked state is accessed by looking at env->v7m.secure
133
+ }
86
+ /*
134
+ } else {
87
+ * All the banked state is accessed by looking at env->v7m.secure
135
+ if (!extract32(xn, 1, 1)) {
88
* except for the stack pointer; rearrange the SP appropriately.
136
+ if (arm_el_is_aa64(env, 2) || prot & PAGE_READ) {
89
*/
137
+ prot |= PAGE_EXEC;
90
new_ss_msp = env->v7m.other_ss_msp;
138
+ }
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
}
139
}
280
}
140
}
281
141
return prot;
282
- /* Write as much of the stack frame as we can. If we fail a stack
142
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
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
}
143
}
301
144
302
- /* In the spec pseudocode ExceptionReturn() is called directly
145
ap = extract32(attrs, 4, 2);
303
+ /*
146
- xn = extract32(attrs, 12, 1);
304
+ * In the spec pseudocode ExceptionReturn() is called directly
147
305
* from BXWritePC() and gets the full target PC value including
148
if (mmu_idx == ARMMMUIdx_Stage2) {
306
* bit zero. In QEMU's implementation we treat it as a normal
149
ns = true;
307
* jump-to-register (which is then caught later on), and so split
150
- *prot = get_S2prot(env, ap, xn);
308
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
151
+ xn = extract32(attrs, 11, 2);
152
+ *prot = get_S2prot(env, ap, xn, s1_is_el0);
153
} else {
154
ns = extract32(attrs, 3, 1);
155
+ xn = extract32(attrs, 12, 1);
156
pxn = extract32(attrs, 11, 1);
157
*prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn);
309
}
158
}
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
}
419
}
420
- /* Undo stack alignment (the SPREALIGN bit indicates that the original
421
+ /*
422
+ * Undo stack alignment (the SPREALIGN bit indicates that the original
423
* pre-exception SP was not 8-aligned and we added a padding word to
424
* align it, so we undo this by ORing in the bit that increases it
425
* from the current 8-aligned value to the 8-unaligned value. (Adding 4
426
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
427
V7M_CONTROL, SFPA, sfpa);
428
}
429
430
- /* The restored xPSR exception field will be zero if we're
431
+ /*
432
+ * The restored xPSR exception field will be zero if we're
433
* resuming in Thread mode. If that doesn't match what the
434
* exception return excret specified then this is a UsageFault.
435
* v7M requires we make this check here; v8M did it earlier.
436
*/
437
if (return_to_handler != arm_v7m_is_handler_mode(env)) {
438
- /* Take an INVPC UsageFault by pushing the stack again;
439
+ /*
440
+ * Take an INVPC UsageFault by pushing the stack again;
441
* we know we're v7M so this is never a Secure UsageFault.
442
*/
443
bool ignore_stackfaults;
444
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
445
446
static bool do_v7m_function_return(ARMCPU *cpu)
447
{
448
- /* v8M security extensions magic function return.
449
+ /*
450
+ * v8M security extensions magic function return.
451
* We may either:
452
* (1) throw an exception (longjump)
453
* (2) return true if we successfully handled the function return
454
@@ -XXX,XX +XXX,XX @@ static bool do_v7m_function_return(ARMCPU *cpu)
455
frame_sp_p = get_v7m_sp_ptr(env, true, threadmode, spsel);
456
frameptr = *frame_sp_p;
457
458
- /* These loads may throw an exception (for MPU faults). We want to
459
+ /*
460
+ * These loads may throw an exception (for MPU faults). We want to
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
}
596
597
-/* Function used to synchronize QEMU's AArch64 register set with AArch32
598
+/*
599
+ * Function used to synchronize QEMU's AArch64 register set with AArch32
600
* register set. This is necessary when switching between AArch32 and AArch64
601
* execution state.
602
*/
603
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env)
604
env->xregs[i] = env->regs[i];
605
}
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
--
159
--
988
2.20.1
160
2.20.1
989
161
990
162
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
In aarch64_max_initfn() we update both 32-bit and 64-bit ID
2
registers. The intended pattern is that for 64-bit ID registers we
3
use FIELD_DP64 and the uint64_t 't' register, while 32-bit ID
4
registers use FIELD_DP32 and the uint32_t 'u' register. For
5
ID_AA64DFR0 we accidentally used 'u', meaning that the top 32 bits of
6
this 64-bit ID register would end up always zero. Luckily at the
7
moment that's what they should be anyway, so this bug has no visible
8
effects.
2
9
3
Reviewed-by: Robert Bradford <robert.bradford@intel.com>
10
Use the right-sized variable.
4
Reviewed-by: Samuel Ortiz <sameo@linux.intel.com>
11
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
12
Fixes: 3bec78447a958d481991
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>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com>
15
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Message-id: 20200423110915.10527-1-peter.maydell@linaro.org
9
---
17
---
10
target/arm/helper.c | 7 +++++++
18
target/arm/cpu64.c | 6 +++---
11
1 file changed, 7 insertions(+)
19
1 file changed, 3 insertions(+), 3 deletions(-)
12
20
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
21
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
14
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
23
--- a/target/arm/cpu64.c
16
+++ b/target/arm/helper.c
24
+++ b/target/arm/cpu64.c
17
@@ -XXX,XX +XXX,XX @@
25
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
18
+/*
26
u = FIELD_DP32(u, ID_MMFR4, XNX, 1); /* TTS2UXN */
19
+ * ARM generic helpers.
27
cpu->isar.id_mmfr4 = u;
20
+ *
28
21
+ * This code is licensed under the GNU GPL v2 or later.
29
- u = cpu->isar.id_aa64dfr0;
22
+ *
30
- u = FIELD_DP64(u, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */
23
+ * SPDX-License-Identifier: GPL-2.0-or-later
31
- cpu->isar.id_aa64dfr0 = u;
24
+ */
32
+ t = cpu->isar.id_aa64dfr0;
25
#include "qemu/osdep.h"
33
+ t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */
26
#include "qemu/units.h"
34
+ cpu->isar.id_aa64dfr0 = t;
27
#include "target/arm/idau.h"
35
36
u = cpu->isar.id_dfr0;
37
u = FIELD_DP32(u, ID_DFR0, PERFMON, 5); /* v8.4-PMU */
28
--
38
--
29
2.20.1
39
2.20.1
30
40
31
41
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
These routines are TCG specific.
3
MIDR_EL1 is a 64-bit system register with the top 32-bit being RES0.
4
The arm_deliver_fault() function is only used within the new
4
Represent it in QEMU's ARMCPU struct with a uint64_t, not a
5
helper. Make it static.
5
uint32_t.
6
6
7
Suggested-by: Alex Bennée <alex.bennee@linaro.org>
7
This fixes an error when compiling with -Werror=conversion
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
because we were manipulating the register value using a
9
Message-id: 20190701132516.26392-13-philmd@redhat.com
9
local uint64_t variable:
10
11
target/arm/cpu64.c: In function ‘aarch64_max_initfn’:
12
target/arm/cpu64.c:628:21: error: conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘uint32_t’ {aka ‘unsigned int’} may change value [-Werror=conversion]
13
628 | cpu->midr = t;
14
| ^
15
16
and future-proofs us against a possible future architecture
17
change using some of the top 32 bits.
18
19
Suggested-by: Laurent Desnogues <laurent.desnogues@gmail.com>
20
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
22
Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com>
23
Message-id: 20200428172634.29707-1-f4bug@amsat.org
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
24
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
26
---
13
target/arm/Makefile.objs | 1 +
27
target/arm/cpu.h | 2 +-
14
target/arm/internals.h | 3 -
28
target/arm/cpu.c | 2 +-
15
target/arm/cpu.c | 6 +-
29
2 files changed, 2 insertions(+), 2 deletions(-)
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
30
22
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
31
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
23
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/Makefile.objs
33
--- a/target/arm/cpu.h
25
+++ b/target/arm/Makefile.objs
34
+++ b/target/arm/cpu.h
26
@@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c
35
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
27
target/arm/translate.o: target/arm/decode-vfp.inc.c
36
uint64_t id_aa64dfr0;
28
target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c
37
uint64_t id_aa64dfr1;
29
38
} isar;
30
+obj-y += tlb_helper.o
39
- uint32_t midr;
31
obj-y += translate.o op_helper.o
40
+ uint64_t midr;
32
obj-y += crypto_helper.o
41
uint32_t revidr;
33
obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o
42
uint32_t reset_fpsid;
34
diff --git a/target/arm/internals.h b/target/arm/internals.h
43
uint32_t ctr;
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
44
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
49
index XXXXXXX..XXXXXXX 100644
45
index XXXXXXX..XXXXXXX 100644
50
--- a/target/arm/cpu.c
46
--- a/target/arm/cpu.c
51
+++ b/target/arm/cpu.c
47
+++ b/target/arm/cpu.c
52
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
48
@@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_cpus[] = {
53
cc->gdb_write_register = arm_cpu_gdb_write_register;
49
static Property arm_cpu_properties[] = {
54
#ifndef CONFIG_USER_ONLY
50
DEFINE_PROP_BOOL("start-powered-off", ARMCPU, start_powered_off, false),
55
cc->do_interrupt = arm_cpu_do_interrupt;
51
DEFINE_PROP_UINT32("psci-conduit", ARMCPU, psci_conduit, 0),
56
- cc->do_unaligned_access = arm_cpu_do_unaligned_access;
52
- DEFINE_PROP_UINT32("midr", ARMCPU, midr, 0),
57
- cc->do_transaction_failed = arm_cpu_do_transaction_failed;
53
+ DEFINE_PROP_UINT64("midr", ARMCPU, midr, 0),
58
cc->get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug;
54
DEFINE_PROP_UINT64("mp-affinity", ARMCPU,
59
cc->asidx_from_attrs = arm_asidx_from_attrs;
55
mp_affinity, ARM64_AFFINITY_INVALID),
60
cc->vmsd = &vmstate_arm_cpu;
56
DEFINE_PROP_INT32("node-id", ARMCPU, node_id, CPU_UNSET_NUMA_NODE_ID),
61
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
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
--
57
--
489
2.20.1
58
2.20.1
490
59
491
60
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
2
2
3
Group SOFTMMU objects together.
3
Remove inclusion of arm_gicv3_common.h, this already gets
4
Since PSCI is TCG specific, keep it separate.
4
included via xlnx-versal.h.
5
5
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Message-id: 20190701132516.26392-5-philmd@redhat.com
8
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
9
Message-id: 20200427181649.26851-2-edgar.iglesias@gmail.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
---
11
target/arm/Makefile.objs | 5 ++++-
12
hw/arm/xlnx-versal.c | 1 -
12
1 file changed, 4 insertions(+), 1 deletion(-)
13
1 file changed, 1 deletion(-)
13
14
14
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
15
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/Makefile.objs
17
--- a/hw/arm/xlnx-versal.c
17
+++ b/target/arm/Makefile.objs
18
+++ b/hw/arm/xlnx-versal.c
18
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
19
obj-y += arm-semi.o
20
#include "hw/arm/boot.h"
20
-obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o
21
#include "kvm_arm.h"
21
obj-y += helper.o vfp_helper.o
22
#include "hw/misc/unimp.h"
22
obj-y += cpu.o gdbstub.o
23
-#include "hw/intc/arm_gicv3_common.h"
23
obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o
24
#include "hw/arm/xlnx-versal.h"
24
+
25
#include "hw/char/pl011.h"
25
+obj-$(CONFIG_SOFTMMU) += machine.o arch_dump.o monitor.o
26
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
--
27
--
39
2.20.1
28
2.20.1
40
29
41
30
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
2
2
3
Group KVM rules together.
3
Move misplaced comment.
4
4
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Message-id: 20190701132516.26392-4-philmd@redhat.com
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
9
Message-id: 20200427181649.26851-3-edgar.iglesias@gmail.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
11
---
10
target/arm/Makefile.objs | 9 +++++----
12
hw/arm/xlnx-versal.c | 2 +-
11
1 file changed, 5 insertions(+), 4 deletions(-)
13
1 file changed, 1 insertion(+), 1 deletion(-)
12
14
13
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
15
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/Makefile.objs
17
--- a/hw/arm/xlnx-versal.c
16
+++ b/target/arm/Makefile.objs
18
+++ b/hw/arm/xlnx-versal.c
17
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s)
18
obj-y += arm-semi.o
20
19
obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o
21
obj = object_new(XLNX_VERSAL_ACPU_TYPE);
20
-obj-$(CONFIG_KVM) += kvm.o
22
if (!obj) {
21
-obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o
23
- /* Secondary CPUs start in PSCI powered-down state */
22
-obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o
24
error_report("Unable to create apu.cpu[%d] of type %s",
23
-obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
25
i, XLNX_VERSAL_ACPU_TYPE);
24
obj-y += helper.o vfp_helper.o
26
exit(EXIT_FAILURE);
25
obj-y += cpu.o gdbstub.o
27
@@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s)
26
obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o
28
object_property_set_int(obj, s->cfg.psci_conduit,
27
obj-$(CONFIG_SOFTMMU) += arm-powerctl.o
29
"psci-conduit", &error_abort);
28
30
if (i) {
29
+obj-$(CONFIG_KVM) += kvm.o
31
+ /* Secondary CPUs start in PSCI powered-down state */
30
+obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o
32
object_property_set_bool(obj, true,
31
+obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o
33
"start-powered-off", &error_abort);
32
+obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
34
}
33
+
34
DECODETREE = $(SRC_PATH)/scripts/decodetree.py
35
36
target/arm/decode-sve.inc.c: $(SRC_PATH)/target/arm/sve.decode $(DECODETREE)
37
--
35
--
38
2.20.1
36
2.20.1
39
37
40
38
diff view generated by jsdifflib
1
From: Andrew Jeffery <andrew@aj.id.au>
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
2
2
3
The legacy interface only supported up to 32 IRQs, which became
3
Fix typo xlnx-ve -> xlnx-versal.
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
4
9
In an effort to support older BMC firmware, add support for the 32 IRQ
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
10
interface.
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
11
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
8
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
13
Signed-off-by: Cédric Le Goater <clg@kaod.org>
9
Message-id: 20200427181649.26851-4-edgar.iglesias@gmail.com
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>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
11
---
18
hw/intc/aspeed_vic.c | 105 ++++++++++++++++++++++++++-----------------
12
hw/arm/xlnx-versal-virt.c | 2 +-
19
1 file changed, 63 insertions(+), 42 deletions(-)
13
1 file changed, 1 insertion(+), 1 deletion(-)
20
14
21
diff --git a/hw/intc/aspeed_vic.c b/hw/intc/aspeed_vic.c
15
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
22
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/intc/aspeed_vic.c
17
--- a/hw/arm/xlnx-versal-virt.c
24
+++ b/hw/intc/aspeed_vic.c
18
+++ b/hw/arm/xlnx-versal-virt.c
25
@@ -XXX,XX +XXX,XX @@ static void aspeed_vic_set_irq(void *opaque, int irq, int level)
19
@@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine)
26
20
psci_conduit = QEMU_PSCI_CONDUIT_SMC;
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
}
21
}
47
22
48
- n_offset -= AVIC_NEW_BASE_OFFSET;
23
- sysbus_init_child_obj(OBJECT(machine), "xlnx-ve", &s->soc,
49
-
24
+ sysbus_init_child_obj(OBJECT(machine), "xlnx-versal", &s->soc,
50
switch (n_offset) {
25
sizeof(s->soc), TYPE_XLNX_VERSAL);
51
- case 0x0: /* IRQ Status */
26
object_property_set_link(OBJECT(&s->soc), OBJECT(machine->ram),
52
+ case 0x80: /* IRQ Status */
27
"ddr", &error_abort);
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
--
28
--
217
2.20.1
29
2.20.1
218
30
219
31
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
2
2
3
Group ARM objects together, TCG related ones at the bottom.
3
Embed the UARTs into the SoC type.
4
This will help when restricting TCG-only objects.
5
4
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
8
Message-id: 20190701132516.26392-3-philmd@redhat.com
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
10
Message-id: 20200427181649.26851-5-edgar.iglesias@gmail.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
12
---
11
target/arm/Makefile.objs | 10 ++++++----
13
include/hw/arm/xlnx-versal.h | 3 ++-
12
1 file changed, 6 insertions(+), 4 deletions(-)
14
hw/arm/xlnx-versal.c | 12 ++++++------
15
2 files changed, 8 insertions(+), 7 deletions(-)
13
16
14
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
17
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
15
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/Makefile.objs
19
--- a/include/hw/arm/xlnx-versal.h
17
+++ b/target/arm/Makefile.objs
20
+++ b/include/hw/arm/xlnx-versal.h
18
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_KVM) += kvm.o
21
@@ -XXX,XX +XXX,XX @@
19
obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o
22
#include "hw/sysbus.h"
20
obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o
23
#include "hw/arm/boot.h"
21
obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
24
#include "hw/intc/arm_gicv3.h"
22
-obj-y += translate.o op_helper.o helper.o cpu.o
25
+#include "hw/char/pl011.h"
23
-obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o
26
24
-obj-y += gdbstub.o
27
#define TYPE_XLNX_VERSAL "xlnx-versal"
25
+obj-y += helper.o vfp_helper.o
28
#define XLNX_VERSAL(obj) OBJECT_CHECK(Versal, (obj), TYPE_XLNX_VERSAL)
26
+obj-y += cpu.o gdbstub.o
29
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
27
obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o
30
MemoryRegion mr_ocm;
28
-obj-y += crypto_helper.o
31
29
obj-$(CONFIG_SOFTMMU) += arm-powerctl.o
32
struct {
30
33
- SysBusDevice *uart[XLNX_VERSAL_NR_UARTS];
31
DECODETREE = $(SRC_PATH)/scripts/decodetree.py
34
+ PL011State uart[XLNX_VERSAL_NR_UARTS];
32
@@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c
35
SysBusDevice *gem[XLNX_VERSAL_NR_GEMS];
33
target/arm/translate.o: target/arm/decode-vfp.inc.c
36
SysBusDevice *adma[XLNX_VERSAL_NR_ADMAS];
34
target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c
37
} iou;
35
38
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
36
+obj-y += translate.o op_helper.o
39
index XXXXXXX..XXXXXXX 100644
37
+obj-y += crypto_helper.o
40
--- a/hw/arm/xlnx-versal.c
38
+obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o
41
+++ b/hw/arm/xlnx-versal.c
39
+
42
@@ -XXX,XX +XXX,XX @@
40
obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o
43
#include "kvm_arm.h"
41
obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o
44
#include "hw/misc/unimp.h"
42
obj-$(TARGET_AARCH64) += pauth_helper.o
45
#include "hw/arm/xlnx-versal.h"
46
-#include "hw/char/pl011.h"
47
48
#define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72")
49
#define GEM_REVISION 0x40070106
50
@@ -XXX,XX +XXX,XX @@ static void versal_create_uarts(Versal *s, qemu_irq *pic)
51
DeviceState *dev;
52
MemoryRegion *mr;
53
54
- dev = qdev_create(NULL, TYPE_PL011);
55
- s->lpd.iou.uart[i] = SYS_BUS_DEVICE(dev);
56
+ sysbus_init_child_obj(OBJECT(s), name,
57
+ &s->lpd.iou.uart[i], sizeof(s->lpd.iou.uart[i]),
58
+ TYPE_PL011);
59
+ dev = DEVICE(&s->lpd.iou.uart[i]);
60
qdev_prop_set_chr(dev, "chardev", serial_hd(i));
61
- object_property_add_child(OBJECT(s), name, OBJECT(dev), &error_fatal);
62
qdev_init_nofail(dev);
63
64
- mr = sysbus_mmio_get_region(s->lpd.iou.uart[i], 0);
65
+ mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
66
memory_region_add_subregion(&s->mr_ps, addrs[i], mr);
67
68
- sysbus_connect_irq(s->lpd.iou.uart[i], 0, pic[irqs[i]]);
69
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irqs[i]]);
70
g_free(name);
71
}
72
}
43
--
73
--
44
2.20.1
74
2.20.1
45
75
46
76
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
2
2
3
Expression to calculate update_msi_mapping in code handling writes to
3
Embed the GEMs into the SoC type.
4
DESIGNWARE_PCIE_MSI_INTR0_ENABLE is missing an ! operator and should
5
be:
6
4
7
!!root->msi.intr[0].enable ^ !!val;
5
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
8
6
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9
so that MSI mapping is updated when enabled transitions from either
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
"none" -> "any" or "any" -> "none". Since that register shouldn't be
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
written to very often, change the code to update MSI mapping
9
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
12
unconditionally instead of trying to fix the update_msi_mapping logic.
10
Message-id: 20200427181649.26851-6-edgar.iglesias@gmail.com
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>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
12
---
23
hw/pci-host/designware.c | 10 ++--------
13
include/hw/arm/xlnx-versal.h | 3 ++-
24
1 file changed, 2 insertions(+), 8 deletions(-)
14
hw/arm/xlnx-versal.c | 15 ++++++++-------
15
2 files changed, 10 insertions(+), 8 deletions(-)
25
16
26
diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
17
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
27
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/pci-host/designware.c
19
--- a/include/hw/arm/xlnx-versal.h
29
+++ b/hw/pci-host/designware.c
20
+++ b/include/hw/arm/xlnx-versal.h
30
@@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address,
21
@@ -XXX,XX +XXX,XX @@
31
root->msi.base |= (uint64_t)val << 32;
22
#include "hw/arm/boot.h"
32
break;
23
#include "hw/intc/arm_gicv3.h"
33
24
#include "hw/char/pl011.h"
34
- case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: {
25
+#include "hw/net/cadence_gem.h"
35
- const bool update_msi_mapping = !root->msi.intr[0].enable ^ !!val;
26
36
-
27
#define TYPE_XLNX_VERSAL "xlnx-versal"
37
+ case DESIGNWARE_PCIE_MSI_INTR0_ENABLE:
28
#define XLNX_VERSAL(obj) OBJECT_CHECK(Versal, (obj), TYPE_XLNX_VERSAL)
38
root->msi.intr[0].enable = val;
29
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
39
-
30
40
- if (update_msi_mapping) {
31
struct {
41
- designware_pcie_root_update_msi_mapping(root);
32
PL011State uart[XLNX_VERSAL_NR_UARTS];
42
- }
33
- SysBusDevice *gem[XLNX_VERSAL_NR_GEMS];
43
+ designware_pcie_root_update_msi_mapping(root);
34
+ CadenceGEMState gem[XLNX_VERSAL_NR_GEMS];
44
break;
35
SysBusDevice *adma[XLNX_VERSAL_NR_ADMAS];
45
- }
36
} iou;
46
37
} lpd;
47
case DESIGNWARE_PCIE_MSI_INTR0_MASK:
38
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
48
root->msi.intr[0].mask = val;
39
index XXXXXXX..XXXXXXX 100644
40
--- a/hw/arm/xlnx-versal.c
41
+++ b/hw/arm/xlnx-versal.c
42
@@ -XXX,XX +XXX,XX @@ static void versal_create_gems(Versal *s, qemu_irq *pic)
43
DeviceState *dev;
44
MemoryRegion *mr;
45
46
- dev = qdev_create(NULL, "cadence_gem");
47
- s->lpd.iou.gem[i] = SYS_BUS_DEVICE(dev);
48
- object_property_add_child(OBJECT(s), name, OBJECT(dev), &error_fatal);
49
+ sysbus_init_child_obj(OBJECT(s), name,
50
+ &s->lpd.iou.gem[i], sizeof(s->lpd.iou.gem[i]),
51
+ TYPE_CADENCE_GEM);
52
+ dev = DEVICE(&s->lpd.iou.gem[i]);
53
if (nd->used) {
54
qemu_check_nic_model(nd, "cadence_gem");
55
qdev_set_nic_properties(dev, nd);
56
}
57
- object_property_set_int(OBJECT(s->lpd.iou.gem[i]),
58
+ object_property_set_int(OBJECT(dev),
59
2, "num-priority-queues",
60
&error_abort);
61
- object_property_set_link(OBJECT(s->lpd.iou.gem[i]),
62
+ object_property_set_link(OBJECT(dev),
63
OBJECT(&s->mr_ps), "dma",
64
&error_abort);
65
qdev_init_nofail(dev);
66
67
- mr = sysbus_mmio_get_region(s->lpd.iou.gem[i], 0);
68
+ mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
69
memory_region_add_subregion(&s->mr_ps, addrs[i], mr);
70
71
- sysbus_connect_irq(s->lpd.iou.gem[i], 0, pic[irqs[i]]);
72
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irqs[i]]);
73
g_free(name);
74
}
75
}
49
--
76
--
50
2.20.1
77
2.20.1
51
78
52
79
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
2
2
3
This will simplify the definition of new SoCs, like the AST2600 which
3
Embed the ADMAs into the SoC type.
4
should use a slightly different address space and have a different set
5
of controllers.
6
4
7
Signed-off-by: Cédric Le Goater <clg@kaod.org>
5
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9
Reviewed-by: Joel Stanley <joel@jms.id.au>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Message-id: 20190618165311.27066-3-clg@kaod.org
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
10
Message-id: 20200427181649.26851-7-edgar.iglesias@gmail.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
12
---
13
include/hw/arm/aspeed_soc.h | 4 +-
13
include/hw/arm/xlnx-versal.h | 3 ++-
14
hw/arm/aspeed.c | 8 +--
14
hw/arm/xlnx-versal.c | 14 +++++++-------
15
hw/arm/aspeed_soc.c | 117 ++++++++++++++++++++++--------------
15
2 files changed, 9 insertions(+), 8 deletions(-)
16
3 files changed, 78 insertions(+), 51 deletions(-)
17
16
18
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
17
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
19
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/arm/aspeed_soc.h
19
--- a/include/hw/arm/xlnx-versal.h
21
+++ b/include/hw/arm/aspeed_soc.h
20
+++ b/include/hw/arm/xlnx-versal.h
22
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo {
21
@@ -XXX,XX +XXX,XX @@
23
const char *name;
22
#include "hw/arm/boot.h"
24
const char *cpu_type;
23
#include "hw/intc/arm_gicv3.h"
25
uint32_t silicon_rev;
24
#include "hw/char/pl011.h"
26
- hwaddr sdram_base;
25
+#include "hw/dma/xlnx-zdma.h"
27
uint64_t sram_size;
26
#include "hw/net/cadence_gem.h"
28
int spis_num;
27
29
- const hwaddr *spi_bases;
28
#define TYPE_XLNX_VERSAL "xlnx-versal"
30
const char *fmc_typename;
29
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
31
const char **spi_typename;
30
struct {
32
int wdts_num;
31
PL011State uart[XLNX_VERSAL_NR_UARTS];
33
const int *irqmap;
32
CadenceGEMState gem[XLNX_VERSAL_NR_GEMS];
34
+ const hwaddr *memmap;
33
- SysBusDevice *adma[XLNX_VERSAL_NR_ADMAS];
35
} AspeedSoCInfo;
34
+ XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS];
36
35
} iou;
37
typedef struct AspeedSoCClass {
36
} lpd;
38
@@ -XXX,XX +XXX,XX @@ enum {
37
39
ASPEED_I2C,
38
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
40
ASPEED_ETH1,
41
ASPEED_ETH2,
42
+ ASPEED_SDRAM,
43
};
44
45
#endif /* ASPEED_SOC_H */
46
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
47
index XXXXXXX..XXXXXXX 100644
39
index XXXXXXX..XXXXXXX 100644
48
--- a/hw/arm/aspeed.c
40
--- a/hw/arm/xlnx-versal.c
49
+++ b/hw/arm/aspeed.c
41
+++ b/hw/arm/xlnx-versal.c
50
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
42
@@ -XXX,XX +XXX,XX @@ static void versal_create_admas(Versal *s, qemu_irq *pic)
51
&error_abort);
43
DeviceState *dev;
52
44
MemoryRegion *mr;
53
memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size);
45
54
- memory_region_add_subregion(get_system_memory(), sc->info->sdram_base,
46
- dev = qdev_create(NULL, "xlnx.zdma");
55
- &bmc->ram);
47
- s->lpd.iou.adma[i] = SYS_BUS_DEVICE(dev);
56
+ memory_region_add_subregion(get_system_memory(),
48
- object_property_set_int(OBJECT(s->lpd.iou.adma[i]), 128, "bus-width",
57
+ sc->info->memmap[ASPEED_SDRAM], &bmc->ram);
49
- &error_abort);
58
object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram),
50
- object_property_add_child(OBJECT(s), name, OBJECT(dev), &error_fatal);
59
&error_abort);
51
+ sysbus_init_child_obj(OBJECT(s), name,
60
52
+ &s->lpd.iou.adma[i], sizeof(s->lpd.iou.adma[i]),
61
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
53
+ TYPE_XLNX_ZDMA);
62
memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL,
54
+ dev = DEVICE(&s->lpd.iou.adma[i]);
63
"max_ram", max_ram_size - ram_size);
55
+ object_property_set_int(OBJECT(dev), 128, "bus-width", &error_abort);
64
memory_region_add_subregion(get_system_memory(),
56
qdev_init_nofail(dev);
65
- sc->info->sdram_base + ram_size,
57
66
+ sc->info->memmap[ASPEED_SDRAM] + ram_size,
58
- mr = sysbus_mmio_get_region(s->lpd.iou.adma[i], 0);
67
&bmc->max_ram);
59
+ mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
68
60
memory_region_add_subregion(&s->mr_ps,
69
aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort);
61
MM_ADMA_CH0 + i * MM_ADMA_CH0_SIZE, mr);
70
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
62
71
aspeed_board_binfo.initrd_filename = machine->initrd_filename;
63
- sysbus_connect_irq(s->lpd.iou.adma[i], 0, pic[VERSAL_ADMA_IRQ_0 + i]);
72
aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline;
64
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[VERSAL_ADMA_IRQ_0 + i]);
73
aspeed_board_binfo.ram_size = ram_size;
65
g_free(name);
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
};
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
}
66
}
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
}
67
}
345
--
68
--
346
2.20.1
69
2.20.1
347
70
348
71
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
2
2
3
The Aspeed SoCs have two MACs. Extend the Aspeed model to support a
3
Embed the APUs into the SoC type.
4
second NIC.
5
4
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
5
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Joel Stanley <joel@jms.id.au>
6
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
8
Message-id: 20190618165311.27066-7-clg@kaod.org
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
10
Message-id: 20200427181649.26851-8-edgar.iglesias@gmail.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
12
---
11
include/hw/arm/aspeed_soc.h | 3 ++-
13
include/hw/arm/xlnx-versal.h | 2 +-
12
hw/arm/aspeed_soc.c | 33 +++++++++++++++++++--------------
14
hw/arm/xlnx-versal-virt.c | 4 ++--
13
2 files changed, 21 insertions(+), 15 deletions(-)
15
hw/arm/xlnx-versal.c | 19 +++++--------------
16
3 files changed, 8 insertions(+), 17 deletions(-)
14
17
15
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
18
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
16
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/arm/aspeed_soc.h
20
--- a/include/hw/arm/xlnx-versal.h
18
+++ b/include/hw/arm/aspeed_soc.h
21
+++ b/include/hw/arm/xlnx-versal.h
19
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
20
#define ASPEED_SPIS_NUM 2
23
struct {
21
#define ASPEED_WDTS_NUM 3
24
struct {
22
#define ASPEED_CPUS_NUM 2
25
MemoryRegion mr;
23
+#define ASPEED_MACS_NUM 2
26
- ARMCPU *cpu[XLNX_VERSAL_NR_ACPUS];
24
27
+ ARMCPU cpu[XLNX_VERSAL_NR_ACPUS];
25
typedef struct AspeedSoCState {
28
GICv3State gic;
26
/*< private >*/
29
} apu;
27
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState {
30
} fpd;
28
AspeedSMCState spi[ASPEED_SPIS_NUM];
31
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
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
32
index XXXXXXX..XXXXXXX 100644
38
--- a/hw/arm/aspeed_soc.c
33
--- a/hw/arm/xlnx-versal-virt.c
39
+++ b/hw/arm/aspeed_soc.c
34
+++ b/hw/arm/xlnx-versal-virt.c
40
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
35
@@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine)
41
sc->info->silicon_rev);
36
s->binfo.get_dtb = versal_virt_get_dtb;
37
s->binfo.modify_dtb = versal_virt_modify_dtb;
38
if (machine->kernel_filename) {
39
- arm_load_kernel(s->soc.fpd.apu.cpu[0], machine, &s->binfo);
40
+ arm_load_kernel(&s->soc.fpd.apu.cpu[0], machine, &s->binfo);
41
} else {
42
- AddressSpace *as = arm_boot_address_space(s->soc.fpd.apu.cpu[0],
43
+ AddressSpace *as = arm_boot_address_space(&s->soc.fpd.apu.cpu[0],
44
&s->binfo);
45
/* Some boot-loaders (e.g u-boot) don't like blobs at address 0 (NULL).
46
* Offset things by 4K. */
47
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/hw/arm/xlnx-versal.c
50
+++ b/hw/arm/xlnx-versal.c
51
@@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s)
52
53
for (i = 0; i < ARRAY_SIZE(s->fpd.apu.cpu); i++) {
54
Object *obj;
55
- char *name;
56
-
57
- obj = object_new(XLNX_VERSAL_ACPU_TYPE);
58
- if (!obj) {
59
- error_report("Unable to create apu.cpu[%d] of type %s",
60
- i, XLNX_VERSAL_ACPU_TYPE);
61
- exit(EXIT_FAILURE);
62
- }
63
-
64
- name = g_strdup_printf("apu-cpu[%d]", i);
65
- object_property_add_child(OBJECT(s), name, obj, &error_fatal);
66
- g_free(name);
67
68
+ object_initialize_child(OBJECT(s), "apu-cpu[*]",
69
+ &s->fpd.apu.cpu[i], sizeof(s->fpd.apu.cpu[i]),
70
+ XLNX_VERSAL_ACPU_TYPE, &error_abort, NULL);
71
+ obj = OBJECT(&s->fpd.apu.cpu[i]);
72
object_property_set_int(obj, s->cfg.psci_conduit,
73
"psci-conduit", &error_abort);
74
if (i) {
75
@@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s)
76
object_property_set_link(obj, OBJECT(&s->fpd.apu.mr), "memory",
77
&error_abort);
78
object_property_set_bool(obj, true, "realized", &error_fatal);
79
- s->fpd.apu.cpu[i] = ARM_CPU(obj);
42
}
80
}
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
}
81
}
51
82
52
static void aspeed_soc_realize(DeviceState *dev, Error **errp)
83
@@ -XXX,XX +XXX,XX @@ static void versal_create_apu_gic(Versal *s, qemu_irq *pic)
53
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
54
}
84
}
55
85
56
/* Net */
86
for (i = 0; i < nr_apu_cpus; i++) {
57
- qdev_set_nic_properties(DEVICE(&s->ftgmac100), &nd_table[0]);
87
- DeviceState *cpudev = DEVICE(s->fpd.apu.cpu[i]);
58
- object_property_set_bool(OBJECT(&s->ftgmac100), true, "aspeed", &err);
88
+ DeviceState *cpudev = DEVICE(&s->fpd.apu.cpu[i]);
59
- object_property_set_bool(OBJECT(&s->ftgmac100), true, "realized",
89
int ppibase = XLNX_VERSAL_NR_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS;
60
- &local_err);
90
qemu_irq maint_irq;
61
- error_propagate(&err, local_err);
91
int ti;
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
--
92
--
89
2.20.1
93
2.20.1
90
94
91
95
diff view generated by jsdifflib
1
From: Adriana Kobylak <anoo@us.ibm.com>
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
2
2
3
The Swift board is an OpenPOWER system hosting POWER processors.
3
Add support for SD.
4
Add support for their BMC including the I2C devices as found on HW.
5
4
6
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Joel Stanley <joel@jms.id.au>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20190618165311.27066-20-clg@kaod.org
8
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
9
Message-id: 20200427181649.26851-9-edgar.iglesias@gmail.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
11
---
12
hw/arm/aspeed.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
12
include/hw/arm/xlnx-versal.h | 12 ++++++++++++
13
1 file changed, 50 insertions(+)
13
hw/arm/xlnx-versal.c | 31 +++++++++++++++++++++++++++++++
14
2 files changed, 43 insertions(+)
14
15
15
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
16
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
16
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/aspeed.c
18
--- a/include/hw/arm/xlnx-versal.h
18
+++ b/hw/arm/aspeed.c
19
+++ b/include/hw/arm/xlnx-versal.h
19
@@ -XXX,XX +XXX,XX @@ struct AspeedBoardState {
20
@@ -XXX,XX +XXX,XX @@
20
SCU_AST2500_HW_STRAP_ACPI_ENABLE | \
21
21
SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
22
#include "hw/sysbus.h"
22
23
#include "hw/arm/boot.h"
23
+/* Swift hardware value: 0xF11AD206 */
24
+#include "hw/sd/sdhci.h"
24
+#define SWIFT_BMC_HW_STRAP1 ( \
25
#include "hw/intc/arm_gicv3.h"
25
+ AST2500_HW_STRAP1_DEFAULTS | \
26
#include "hw/char/pl011.h"
26
+ SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \
27
#include "hw/dma/xlnx-zdma.h"
27
+ SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \
28
@@ -XXX,XX +XXX,XX @@
28
+ SCU_AST2500_HW_STRAP_UART_DEBUG | \
29
#define XLNX_VERSAL_NR_UARTS 2
29
+ SCU_AST2500_HW_STRAP_DDR4_ENABLE | \
30
#define XLNX_VERSAL_NR_GEMS 2
30
+ SCU_H_PLL_BYPASS_EN | \
31
#define XLNX_VERSAL_NR_ADMAS 8
31
+ SCU_AST2500_HW_STRAP_ACPI_ENABLE | \
32
+#define XLNX_VERSAL_NR_SDS 2
32
+ SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
33
#define XLNX_VERSAL_NR_IRQS 192
34
35
typedef struct Versal {
36
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
37
} iou;
38
} lpd;
39
40
+ /* The Platform Management Controller subsystem. */
41
+ struct {
42
+ struct {
43
+ SDHCIState sd[XLNX_VERSAL_NR_SDS];
44
+ } iou;
45
+ } pmc;
33
+
46
+
34
/* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
47
struct {
35
#define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
48
MemoryRegion *mr_ddr;
36
49
uint32_t psci_conduit;
37
@@ -XXX,XX +XXX,XX @@ static void romulus_bmc_i2c_init(AspeedBoardState *bmc)
50
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
38
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
51
#define VERSAL_GEM1_IRQ_0 58
52
#define VERSAL_GEM1_WAKE_IRQ_0 59
53
#define VERSAL_ADMA_IRQ_0 60
54
+#define VERSAL_SD0_IRQ_0 126
55
56
/* Architecturally reserved IRQs suitable for virtualization. */
57
#define VERSAL_RSVD_IRQ_FIRST 111
58
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
59
#define MM_FPD_CRF 0xfd1a0000U
60
#define MM_FPD_CRF_SIZE 0x140000
61
62
+#define MM_PMC_SD0 0xf1040000U
63
+#define MM_PMC_SD0_SIZE 0x10000
64
#define MM_PMC_CRP 0xf1260000U
65
#define MM_PMC_CRP_SIZE 0x10000
66
#endif
67
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
68
index XXXXXXX..XXXXXXX 100644
69
--- a/hw/arm/xlnx-versal.c
70
+++ b/hw/arm/xlnx-versal.c
71
@@ -XXX,XX +XXX,XX @@ static void versal_create_admas(Versal *s, qemu_irq *pic)
72
}
39
}
73
}
40
74
41
+static void swift_bmc_i2c_init(AspeedBoardState *bmc)
75
+#define SDHCI_CAPABILITIES 0x280737ec6481 /* Same as on ZynqMP. */
76
+static void versal_create_sds(Versal *s, qemu_irq *pic)
42
+{
77
+{
43
+ AspeedSoCState *soc = &bmc->soc;
78
+ int i;
44
+
79
+
45
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60);
80
+ for (i = 0; i < ARRAY_SIZE(s->pmc.iou.sd); i++) {
81
+ DeviceState *dev;
82
+ MemoryRegion *mr;
46
+
83
+
47
+ /* The swift board expects a TMP275 but a TMP105 is compatible */
84
+ sysbus_init_child_obj(OBJECT(s), "sd[*]",
48
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x48);
85
+ &s->pmc.iou.sd[i], sizeof(s->pmc.iou.sd[i]),
49
+ /* The swift board expects a pca9551 but a pca9552 is compatible */
86
+ TYPE_SYSBUS_SDHCI);
50
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "pca9552", 0x60);
87
+ dev = DEVICE(&s->pmc.iou.sd[i]);
51
+
88
+
52
+ /* The swift board expects an Epson RX8900 RTC but a ds1338 is compatible */
89
+ object_property_set_uint(OBJECT(dev),
53
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "ds1338", 0x32);
90
+ 3, "sd-spec-version", &error_fatal);
54
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x60);
91
+ object_property_set_uint(OBJECT(dev), SDHCI_CAPABILITIES, "capareg",
92
+ &error_fatal);
93
+ object_property_set_uint(OBJECT(dev), UHS_I, "uhs", &error_fatal);
94
+ qdev_init_nofail(dev);
55
+
95
+
56
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp423", 0x4c);
96
+ mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
57
+ /* The swift board expects a pca9539 but a pca9552 is compatible */
97
+ memory_region_add_subregion(&s->mr_ps,
58
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "pca9552", 0x74);
98
+ MM_PMC_SD0 + i * MM_PMC_SD0_SIZE, mr);
59
+
99
+
60
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "tmp423", 0x4c);
100
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
61
+ /* The swift board expects a pca9539 but a pca9552 is compatible */
101
+ pic[VERSAL_SD0_IRQ_0 + i * 2]);
62
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "pca9552",
102
+ }
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
+}
103
+}
69
+
104
+
70
static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
105
/* This takes the board allocated linear DDR memory and creates aliases
71
{
106
* for each split DDR range/aperture on the Versal address map.
72
AspeedSoCState *soc = &bmc->soc;
107
*/
73
@@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = {
108
@@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp)
74
.num_cs = 2,
109
versal_create_uarts(s, pic);
75
.i2c_init = romulus_bmc_i2c_init,
110
versal_create_gems(s, pic);
76
.ram = 512 * MiB,
111
versal_create_admas(s, pic);
77
+ }, {
112
+ versal_create_sds(s, pic);
78
+ .name = MACHINE_TYPE_NAME("swift-bmc"),
113
versal_map_ddr(s);
79
+ .desc = "OpenPOWER Swift BMC (ARM1176)",
114
versal_unimp(s);
80
+ .soc_name = "ast2500-a1",
115
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
--
116
--
91
2.20.1
117
2.20.1
92
118
93
119
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
2
2
3
Datasheet for i.MX7 is incorrect and i.MX7's PCI IRQ mapping matches
3
hw/arm: versal: Add support for the RTC.
4
that of i.MX6:
5
4
6
* INTD/MSI 122
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
7
* INTC 123
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
* INTB 124
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
* INTA 125
8
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
10
9
Message-id: 20200427181649.26851-10-edgar.iglesias@gmail.com
11
Fix all of the relevant code to reflect that fact. Needed by latest
12
Linux kernels.
13
14
(Reference: Linux kernel commit 538d6e9d597584e80 from an
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>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
---
11
---
27
include/hw/arm/fsl-imx7.h | 8 ++++----
12
include/hw/arm/xlnx-versal.h | 8 ++++++++
28
hw/pci-host/designware.c | 6 ++++--
13
hw/arm/xlnx-versal.c | 21 +++++++++++++++++++++
29
2 files changed, 8 insertions(+), 6 deletions(-)
14
2 files changed, 29 insertions(+)
30
15
31
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
16
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
32
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
33
--- a/include/hw/arm/fsl-imx7.h
18
--- a/include/hw/arm/xlnx-versal.h
34
+++ b/include/hw/arm/fsl-imx7.h
19
+++ b/include/hw/arm/xlnx-versal.h
35
@@ -XXX,XX +XXX,XX @@ enum FslIMX7IRQs {
20
@@ -XXX,XX +XXX,XX @@
36
FSL_IMX7_USB2_IRQ = 42,
21
#include "hw/char/pl011.h"
37
FSL_IMX7_USB3_IRQ = 40,
22
#include "hw/dma/xlnx-zdma.h"
38
23
#include "hw/net/cadence_gem.h"
39
- FSL_IMX7_PCI_INTA_IRQ = 122,
24
+#include "hw/rtc/xlnx-zynqmp-rtc.h"
40
- FSL_IMX7_PCI_INTB_IRQ = 123,
25
41
- FSL_IMX7_PCI_INTC_IRQ = 124,
26
#define TYPE_XLNX_VERSAL "xlnx-versal"
42
- FSL_IMX7_PCI_INTD_IRQ = 125,
27
#define XLNX_VERSAL(obj) OBJECT_CHECK(Versal, (obj), TYPE_XLNX_VERSAL)
43
+ FSL_IMX7_PCI_INTA_IRQ = 125,
28
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
44
+ FSL_IMX7_PCI_INTB_IRQ = 124,
29
struct {
45
+ FSL_IMX7_PCI_INTC_IRQ = 123,
30
SDHCIState sd[XLNX_VERSAL_NR_SDS];
46
+ FSL_IMX7_PCI_INTD_IRQ = 122,
31
} iou;
47
32
+
48
FSL_IMX7_UART7_IRQ = 126,
33
+ XlnxZynqMPRTC rtc;
49
34
} pmc;
50
diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
35
36
struct {
37
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
38
#define VERSAL_GEM1_IRQ_0 58
39
#define VERSAL_GEM1_WAKE_IRQ_0 59
40
#define VERSAL_ADMA_IRQ_0 60
41
+#define VERSAL_RTC_APB_ERR_IRQ 121
42
#define VERSAL_SD0_IRQ_0 126
43
+#define VERSAL_RTC_ALARM_IRQ 142
44
+#define VERSAL_RTC_SECONDS_IRQ 143
45
46
/* Architecturally reserved IRQs suitable for virtualization. */
47
#define VERSAL_RSVD_IRQ_FIRST 111
48
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
49
#define MM_PMC_SD0_SIZE 0x10000
50
#define MM_PMC_CRP 0xf1260000U
51
#define MM_PMC_CRP_SIZE 0x10000
52
+#define MM_PMC_RTC 0xf12a0000
53
+#define MM_PMC_RTC_SIZE 0x10000
54
#endif
55
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
51
index XXXXXXX..XXXXXXX 100644
56
index XXXXXXX..XXXXXXX 100644
52
--- a/hw/pci-host/designware.c
57
--- a/hw/arm/xlnx-versal.c
53
+++ b/hw/pci-host/designware.c
58
+++ b/hw/arm/xlnx-versal.c
54
@@ -XXX,XX +XXX,XX @@
59
@@ -XXX,XX +XXX,XX @@ static void versal_create_sds(Versal *s, qemu_irq *pic)
55
#define DESIGNWARE_PCIE_ATU_DEVFN(x) (((x) >> 16) & 0xff)
56
#define DESIGNWARE_PCIE_ATU_UPPER_TARGET 0x91C
57
58
+#define DESIGNWARE_PCIE_IRQ_MSI 3
59
+
60
static DesignwarePCIEHost *
61
designware_pcie_root_to_host(DesignwarePCIERoot *root)
62
{
63
@@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_msi_write(void *opaque, hwaddr addr,
64
root->msi.intr[0].status |= BIT(val) & root->msi.intr[0].enable;
65
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
}
60
}
70
}
61
}
71
62
72
@@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address,
63
+static void versal_create_rtc(Versal *s, qemu_irq *pic)
73
case DESIGNWARE_PCIE_MSI_INTR0_STATUS:
64
+{
74
root->msi.intr[0].status ^= val;
65
+ SysBusDevice *sbd;
75
if (!root->msi.intr[0].status) {
66
+ MemoryRegion *mr;
76
- qemu_set_irq(host->pci.irqs[0], 0);
67
+
77
+ qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 0);
68
+ sysbus_init_child_obj(OBJECT(s), "rtc", &s->pmc.rtc, sizeof(s->pmc.rtc),
78
}
69
+ TYPE_XLNX_ZYNQMP_RTC);
79
break;
70
+ sbd = SYS_BUS_DEVICE(&s->pmc.rtc);
71
+ qdev_init_nofail(DEVICE(sbd));
72
+
73
+ mr = sysbus_mmio_get_region(sbd, 0);
74
+ memory_region_add_subregion(&s->mr_ps, MM_PMC_RTC, mr);
75
+
76
+ /*
77
+ * TODO: Connect the ALARM and SECONDS interrupts once our RTC model
78
+ * supports them.
79
+ */
80
+ sysbus_connect_irq(sbd, 1, pic[VERSAL_RTC_APB_ERR_IRQ]);
81
+}
82
+
83
/* This takes the board allocated linear DDR memory and creates aliases
84
* for each split DDR range/aperture on the Versal address map.
85
*/
86
@@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp)
87
versal_create_gems(s, pic);
88
versal_create_admas(s, pic);
89
versal_create_sds(s, pic);
90
+ versal_create_rtc(s, pic);
91
versal_map_ddr(s);
92
versal_unimp(s);
80
93
81
--
94
--
82
2.20.1
95
2.20.1
83
96
84
97
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
2
2
3
In the next commit we will split the M-profile functions from this
3
Add support for SD.
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
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-id: 20190701132516.26392-22-philmd@redhat.com
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
Message-id: 20200427181649.26851-11-edgar.iglesias@gmail.com
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
hw/arm/xlnx-versal-virt.c | 46 +++++++++++++++++++++++++++++++++++++++
13
target/arm/helper.c | 38 ++------------------------------------
12
1 file changed, 46 insertions(+)
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/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/internals.h
16
--- a/hw/arm/xlnx-versal-virt.c
19
+++ b/target/arm/internals.h
17
+++ b/hw/arm/xlnx-versal-virt.c
20
@@ -XXX,XX +XXX,XX @@ static inline uint32_t v7m_sp_limit(CPUARMState *env)
18
@@ -XXX,XX +XXX,XX @@
19
#include "hw/arm/sysbus-fdt.h"
20
#include "hw/arm/fdt.h"
21
#include "cpu.h"
22
+#include "hw/qdev-properties.h"
23
#include "hw/arm/xlnx-versal.h"
24
25
#define TYPE_XLNX_VERSAL_VIRT_MACHINE MACHINE_TYPE_NAME("xlnx-versal-virt")
26
@@ -XXX,XX +XXX,XX @@ static void fdt_add_zdma_nodes(VersalVirt *s)
21
}
27
}
22
}
28
}
23
29
24
+/**
30
+static void fdt_add_sd_nodes(VersalVirt *s)
25
+ * v7m_cpacr_pass:
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
+{
31
+{
32
+ switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) {
32
+ const char clocknames[] = "clk_xin\0clk_ahb";
33
+ case 0:
33
+ const char compat[] = "arasan,sdhci-8.9a";
34
+ case 2: /* UNPREDICTABLE: we treat like 0 */
34
+ int i;
35
+ return false;
35
+
36
+ case 1:
36
+ for (i = ARRAY_SIZE(s->soc.pmc.iou.sd) - 1; i >= 0; i--) {
37
+ return is_priv;
37
+ uint64_t addr = MM_PMC_SD0 + MM_PMC_SD0_SIZE * i;
38
+ case 3:
38
+ char *name = g_strdup_printf("/sdhci@%" PRIx64, addr);
39
+ return true;
39
+
40
+ default:
40
+ qemu_fdt_add_subnode(s->fdt, name);
41
+ g_assert_not_reached();
41
+
42
+ qemu_fdt_setprop_cells(s->fdt, name, "clocks",
43
+ s->phandle.clk_25Mhz, s->phandle.clk_25Mhz);
44
+ qemu_fdt_setprop(s->fdt, name, "clock-names",
45
+ clocknames, sizeof(clocknames));
46
+ qemu_fdt_setprop_cells(s->fdt, name, "interrupts",
47
+ GIC_FDT_IRQ_TYPE_SPI, VERSAL_SD0_IRQ_0 + i * 2,
48
+ GIC_FDT_IRQ_FLAGS_LEVEL_HI);
49
+ qemu_fdt_setprop_sized_cells(s->fdt, name, "reg",
50
+ 2, addr, 2, MM_PMC_SD0_SIZE);
51
+ qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat));
52
+ g_free(name);
42
+ }
53
+ }
43
+}
54
+}
44
+
55
+
45
/**
56
static void fdt_nop_memory_nodes(void *fdt, Error **errp)
46
* aarch32_mode_name(): Return name of the AArch32 CPU mode
57
{
47
* @psr: Program Status Register indicating CPU mode
58
Error *err = NULL;
48
@@ -XXX,XX +XXX,XX @@ static inline int exception_target_el(CPUARMState *env)
59
@@ -XXX,XX +XXX,XX @@ static void create_virtio_regions(VersalVirt *s)
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
}
60
}
104
}
61
}
105
62
106
-/*
63
+static void sd_plugin_card(SDHCIState *sd, DriveInfo *di)
107
- * Return true if the v7M CPACR permits access to the FPU for the specified
64
+{
108
- * security state and privilege level.
65
+ BlockBackend *blk = di ? blk_by_legacy_dinfo(di) : NULL;
109
- */
66
+ DeviceState *card;
110
-static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv)
67
+
111
-{
68
+ card = qdev_create(qdev_get_child_bus(DEVICE(sd), "sd-bus"), TYPE_SD_CARD);
112
- switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) {
69
+ object_property_add_child(OBJECT(sd), "card[*]", OBJECT(card),
113
- case 0:
70
+ &error_fatal);
114
- case 2: /* UNPREDICTABLE: we treat like 0 */
71
+ qdev_prop_set_drive(card, "drive", blk, &error_fatal);
115
- return false;
72
+ object_property_set_bool(OBJECT(card), true, "realized", &error_fatal);
116
- case 1:
73
+}
117
- return is_priv;
74
+
118
- case 3:
75
static void versal_virt_init(MachineState *machine)
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
{
76
{
137
@@ -XXX,XX +XXX,XX @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address,
77
VersalVirt *s = XLNX_VERSAL_VIRT_MACHINE(machine);
138
}
78
int psci_conduit = QEMU_PSCI_CONDUIT_DISABLED;
139
}
79
+ int i;
140
80
141
-static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
81
/*
142
+bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
82
* If the user provides an Operating System to be loaded, we expect them
143
MMUAccessType access_type, ARMMMUIdx mmu_idx,
83
@@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine)
144
hwaddr *phys_ptr, MemTxAttrs *txattrs,
84
fdt_add_gic_nodes(s);
145
int *prot, bool *is_subpage,
85
fdt_add_timer_nodes(s);
86
fdt_add_zdma_nodes(s);
87
+ fdt_add_sd_nodes(s);
88
fdt_add_cpu_nodes(s, psci_conduit);
89
fdt_add_clk_node(s, "/clk125", 125000000, s->phandle.clk_125Mhz);
90
fdt_add_clk_node(s, "/clk25", 25000000, s->phandle.clk_25Mhz);
91
@@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine)
92
memory_region_add_subregion_overlap(get_system_memory(),
93
0, &s->soc.fpd.apu.mr, 0);
94
95
+ /* Plugin SD cards. */
96
+ for (i = 0; i < ARRAY_SIZE(s->soc.pmc.iou.sd); i++) {
97
+ sd_plugin_card(&s->soc.pmc.iou.sd[i], drive_get_next(IF_SD));
98
+ }
99
+
100
s->binfo.ram_size = machine->ram_size;
101
s->binfo.loader_start = 0x0;
102
s->binfo.get_dtb = versal_virt_get_dtb;
146
--
103
--
147
2.20.1
104
2.20.1
148
105
149
106
diff view generated by jsdifflib
1
From: Andrew Jeffery <andrew@aj.id.au>
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
2
2
3
If the match value exceeds reload then we don't want to include it in
3
Add support for the RTC.
4
calculations for the next event.
5
4
6
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
7
Signed-off-by: Cédric Le Goater <clg@kaod.org>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Message-id: 20190618165311.27066-10-clg@kaod.org
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
Message-id: 20200427181649.26851-12-edgar.iglesias@gmail.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
10
---
11
hw/timer/aspeed_timer.c | 13 ++++++++++---
11
hw/arm/xlnx-versal-virt.c | 22 ++++++++++++++++++++++
12
1 file changed, 10 insertions(+), 3 deletions(-)
12
1 file changed, 22 insertions(+)
13
13
14
diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
14
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/timer/aspeed_timer.c
16
--- a/hw/arm/xlnx-versal-virt.c
17
+++ b/hw/timer/aspeed_timer.c
17
+++ b/hw/arm/xlnx-versal-virt.c
18
@@ -XXX,XX +XXX,XX @@ static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks)
18
@@ -XXX,XX +XXX,XX @@ static void fdt_add_sd_nodes(VersalVirt *s)
19
return t->start + delta_ns;
19
}
20
}
20
}
21
21
22
+static inline uint32_t calculate_match(struct AspeedTimer *t, int i)
22
+static void fdt_add_rtc_node(VersalVirt *s)
23
+{
23
+{
24
+ return t->match[i] < t->reload ? t->match[i] : 0;
24
+ const char compat[] = "xlnx,zynqmp-rtc";
25
+ const char interrupt_names[] = "alarm\0sec";
26
+ char *name = g_strdup_printf("/rtc@%x", MM_PMC_RTC);
27
+
28
+ qemu_fdt_add_subnode(s->fdt, name);
29
+
30
+ qemu_fdt_setprop_cells(s->fdt, name, "interrupts",
31
+ GIC_FDT_IRQ_TYPE_SPI, VERSAL_RTC_ALARM_IRQ,
32
+ GIC_FDT_IRQ_FLAGS_LEVEL_HI,
33
+ GIC_FDT_IRQ_TYPE_SPI, VERSAL_RTC_SECONDS_IRQ,
34
+ GIC_FDT_IRQ_FLAGS_LEVEL_HI);
35
+ qemu_fdt_setprop(s->fdt, name, "interrupt-names",
36
+ interrupt_names, sizeof(interrupt_names));
37
+ qemu_fdt_setprop_sized_cells(s->fdt, name, "reg",
38
+ 2, MM_PMC_RTC, 2, MM_PMC_RTC_SIZE);
39
+ qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat));
40
+ g_free(name);
25
+}
41
+}
26
+
42
+
27
static uint64_t calculate_next(struct AspeedTimer *t)
43
static void fdt_nop_memory_nodes(void *fdt, Error **errp)
28
{
44
{
29
uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
45
Error *err = NULL;
30
@@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t)
46
@@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine)
31
* the timer counts down to zero.
47
fdt_add_timer_nodes(s);
32
*/
48
fdt_add_zdma_nodes(s);
33
49
fdt_add_sd_nodes(s);
34
- next = calculate_time(t, MAX(t->match[0], t->match[1]));
50
+ fdt_add_rtc_node(s);
35
+ next = calculate_time(t, MAX(calculate_match(t, 0), calculate_match(t, 1)));
51
fdt_add_cpu_nodes(s, psci_conduit);
36
if (now < next) {
52
fdt_add_clk_node(s, "/clk125", 125000000, s->phandle.clk_125Mhz);
37
return next;
53
fdt_add_clk_node(s, "/clk25", 25000000, s->phandle.clk_25Mhz);
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
--
54
--
58
2.20.1
55
2.20.1
59
56
60
57
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Somewhere along theline we accidentally added a duplicate
2
"using D16-D31 when they don't exist" check to do_vfm_dp()
3
(probably an artifact of a patchseries rebase). Remove it.
2
4
3
This machine correctly defines its default_cpu_type to cortex-m3
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
and report an error if the user requested another cpu_type,
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
however it does not exit, and this can confuse users trying
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
to use another core:
8
Message-id: 20200430181003.21682-2-peter.maydell@linaro.org
9
---
10
target/arm/translate-vfp.inc.c | 6 ------
11
1 file changed, 6 deletions(-)
7
12
8
$ qemu-system-arm -M emcraft-sf2 -cpu cortex-m4 -kernel test-m4.elf
13
diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c
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
14
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/arm/msf2-som.c
15
--- a/target/arm/translate-vfp.inc.c
35
+++ b/hw/arm/msf2-som.c
16
+++ b/target/arm/translate-vfp.inc.c
36
@@ -XXX,XX +XXX,XX @@ static void emcraft_sf2_s2s010_init(MachineState *machine)
17
@@ -XXX,XX +XXX,XX @@ static bool do_vfm_dp(DisasContext *s, arg_VFMA_dp *a, bool neg_n, bool neg_d)
37
if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) {
18
return false;
38
error_report("This board can only be used with CPU %s",
39
mc->default_cpu_type);
40
+ exit(1);
41
}
19
}
42
20
43
memory_region_init_ram(ddr, NULL, "ddr-ram", DDR_SIZE,
21
- /* UNDEF accesses to D16-D31 if they don't exist. */
22
- if (!dc_isar_feature(aa32_simd_r32, s) &&
23
- ((a->vd | a->vn | a->vm) & 0x10)) {
24
- return false;
25
- }
26
-
27
if (!vfp_access_check(s)) {
28
return true;
29
}
44
--
30
--
45
2.20.1
31
2.20.1
46
32
47
33
diff view generated by jsdifflib
1
From: Joel Stanley <joel@jms.id.au>
1
We were accidentally permitting decode of Thumb Neon insns even if
2
the CPU didn't have the FEATURE_NEON bit set, because the feature
3
check was being done before the call to disas_neon_data_insn() and
4
disas_neon_ls_insn() in the Arm decoder but was omitted from the
5
Thumb decoder. Push the feature bit check down into the called
6
functions so it is done for both Arm and Thumb encodings.
2
7
3
The RTC is modeled to provide time and date functionality. It is
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
initialised at zero to match the hardware.
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 20200430181003.21682-3-peter.maydell@linaro.org
12
---
13
target/arm/translate.c | 16 ++++++++--------
14
1 file changed, 8 insertions(+), 8 deletions(-)
5
15
6
There is no modelling of the alarm functionality, which includes the IRQ
16
diff --git a/target/arm/translate.c b/target/arm/translate.c
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
17
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/timer/Makefile.objs
18
--- a/target/arm/translate.c
26
+++ b/hw/timer/Makefile.objs
19
+++ b/target/arm/translate.c
27
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
20
@@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn)
28
obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o
21
TCGv_i32 tmp2;
29
22
TCGv_i64 tmp64;
30
common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o
23
31
-common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o
24
+ if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
32
+common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o
25
+ return 1;
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
+ }
26
+ }
168
+
27
+
169
+ trace_aspeed_rtc_read(addr, val);
28
/* FIXME: this access check should not take precedence over UNDEF
29
* for invalid encodings; we will generate incorrect syndrome information
30
* for attempts to execute invalid vfp/neon encodings with FP disabled.
31
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
32
TCGv_ptr ptr1, ptr2, ptr3;
33
TCGv_i64 tmp64;
34
35
+ if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
36
+ return 1;
37
+ }
170
+
38
+
171
+ return val;
39
/* FIXME: this access check should not take precedence over UNDEF
172
+}
40
* for invalid encodings; we will generate incorrect syndrome information
173
+
41
* for attempts to execute invalid vfp/neon encodings with FP disabled.
174
+static void aspeed_rtc_write(void *opaque, hwaddr addr,
42
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
175
+ uint64_t val, unsigned size)
43
176
+{
44
if (((insn >> 25) & 7) == 1) {
177
+ AspeedRtcState *rtc = opaque;
45
/* NEON Data processing. */
178
+ uint32_t r = addr >> 2;
46
- if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
179
+
47
- goto illegal_op;
180
+ switch (r) {
48
- }
181
+ case COUNTER1:
49
-
182
+ case COUNTER2:
50
if (disas_neon_data_insn(s, insn)) {
183
+ if (!(rtc->reg[CONTROL] & RTC_UNLOCKED)) {
51
goto illegal_op;
184
+ break;
52
}
185
+ }
53
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
186
+ /* fall through */
54
}
187
+ case CONTROL:
55
if ((insn & 0x0f100000) == 0x04000000) {
188
+ rtc->reg[r] = val;
56
/* NEON load/store. */
189
+ aspeed_rtc_calc_offset(rtc);
57
- if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
190
+ break;
58
- goto illegal_op;
191
+ case ALARM:
59
- }
192
+ case ALARM_STATUS:
60
-
193
+ default:
61
if (disas_neon_ls_insn(s, insn)) {
194
+ qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx "\n", __func__, addr);
62
goto illegal_op;
195
+ break;
63
}
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
--
64
--
275
2.20.1
65
2.20.1
276
66
277
67
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Add the infrastructure for building and invoking a decodetree decoder
2
2
for the AArch32 Neon encodings. At the moment the new decoder covers
3
Group Aarch64 rules together, TCG related ones at the bottom.
3
nothing, so we always fall back to the existing hand-written decode.
4
This will help when restricting TCG-only objects.
4
5
5
We follow the same pattern we did for the VFP decodetree conversion
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
(commit 78e138bc1f672c145ef6ace74617d and following): code that deals
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
with Neon will be moving gradually out to translate-neon.vfp.inc,
8
Message-id: 20190701132516.26392-2-philmd@redhat.com
8
which we #include into translate.c.
9
10
In order to share the decode files between A32 and T32, we
11
split Neon into 3 parts:
12
* data-processing
13
* load-store
14
* 'shared' encodings
15
16
The first two groups of instructions have similar but not identical
17
A32 and T32 encodings, so we need to manually transform the T32
18
encoding into the A32 one before calling the decoder; the third group
19
covers the Neon instructions which are identical in A32 and T32.
20
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
23
Message-id: 20200430181003.21682-4-peter.maydell@linaro.org
10
---
24
---
11
target/arm/Makefile.objs | 5 +++--
25
target/arm/neon-dp.decode | 29 ++++++++++++++++++++++++++
12
1 file changed, 3 insertions(+), 2 deletions(-)
26
target/arm/neon-ls.decode | 29 ++++++++++++++++++++++++++
13
27
target/arm/neon-shared.decode | 27 +++++++++++++++++++++++++
28
target/arm/translate-neon.inc.c | 32 +++++++++++++++++++++++++++++
29
target/arm/translate.c | 36 +++++++++++++++++++++++++++++++--
30
target/arm/Makefile.objs | 18 +++++++++++++++++
31
6 files changed, 169 insertions(+), 2 deletions(-)
32
create mode 100644 target/arm/neon-dp.decode
33
create mode 100644 target/arm/neon-ls.decode
34
create mode 100644 target/arm/neon-shared.decode
35
create mode 100644 target/arm/translate-neon.inc.c
36
37
diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode
38
new file mode 100644
39
index XXXXXXX..XXXXXXX
40
--- /dev/null
41
+++ b/target/arm/neon-dp.decode
42
@@ -XXX,XX +XXX,XX @@
43
+# AArch32 Neon data-processing instruction descriptions
44
+#
45
+# Copyright (c) 2020 Linaro, Ltd
46
+#
47
+# This library is free software; you can redistribute it and/or
48
+# modify it under the terms of the GNU Lesser General Public
49
+# License as published by the Free Software Foundation; either
50
+# version 2 of the License, or (at your option) any later version.
51
+#
52
+# This library is distributed in the hope that it will be useful,
53
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
54
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
55
+# Lesser General Public License for more details.
56
+#
57
+# You should have received a copy of the GNU Lesser General Public
58
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
59
+
60
+#
61
+# This file is processed by scripts/decodetree.py
62
+#
63
+
64
+# Encodings for Neon data processing instructions where the T32 encoding
65
+# is a simple transformation of the A32 encoding.
66
+# More specifically, this file covers instructions where the A32 encoding is
67
+# 0b1111_001p_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq
68
+# and the T32 encoding is
69
+# 0b111p_1111_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq
70
+# This file works on the A32 encoding only; calling code for T32 has to
71
+# transform the insn into the A32 version first.
72
diff --git a/target/arm/neon-ls.decode b/target/arm/neon-ls.decode
73
new file mode 100644
74
index XXXXXXX..XXXXXXX
75
--- /dev/null
76
+++ b/target/arm/neon-ls.decode
77
@@ -XXX,XX +XXX,XX @@
78
+# AArch32 Neon load/store instruction descriptions
79
+#
80
+# Copyright (c) 2020 Linaro, Ltd
81
+#
82
+# This library is free software; you can redistribute it and/or
83
+# modify it under the terms of the GNU Lesser General Public
84
+# License as published by the Free Software Foundation; either
85
+# version 2 of the License, or (at your option) any later version.
86
+#
87
+# This library is distributed in the hope that it will be useful,
88
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
89
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
90
+# Lesser General Public License for more details.
91
+#
92
+# You should have received a copy of the GNU Lesser General Public
93
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
94
+
95
+#
96
+# This file is processed by scripts/decodetree.py
97
+#
98
+
99
+# Encodings for Neon load/store instructions where the T32 encoding
100
+# is a simple transformation of the A32 encoding.
101
+# More specifically, this file covers instructions where the A32 encoding is
102
+# 0b1111_0100_xxx0_xxxx_xxxx_xxxx_xxxx_xxxx
103
+# and the T32 encoding is
104
+# 0b1111_1001_xxx0_xxxx_xxxx_xxxx_xxxx_xxxx
105
+# This file works on the A32 encoding only; calling code for T32 has to
106
+# transform the insn into the A32 version first.
107
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
108
new file mode 100644
109
index XXXXXXX..XXXXXXX
110
--- /dev/null
111
+++ b/target/arm/neon-shared.decode
112
@@ -XXX,XX +XXX,XX @@
113
+# AArch32 Neon instruction descriptions
114
+#
115
+# Copyright (c) 2020 Linaro, Ltd
116
+#
117
+# This library is free software; you can redistribute it and/or
118
+# modify it under the terms of the GNU Lesser General Public
119
+# License as published by the Free Software Foundation; either
120
+# version 2 of the License, or (at your option) any later version.
121
+#
122
+# This library is distributed in the hope that it will be useful,
123
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
124
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
125
+# Lesser General Public License for more details.
126
+#
127
+# You should have received a copy of the GNU Lesser General Public
128
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
129
+
130
+#
131
+# This file is processed by scripts/decodetree.py
132
+#
133
+
134
+# Encodings for Neon instructions whose encoding is the same for
135
+# both A32 and T32.
136
+
137
+# More specifically, this covers:
138
+# 2reg scalar ext: 0b1111_1110_xxxx_xxxx_xxxx_1x0x_xxxx_xxxx
139
+# 3same ext: 0b1111_110x_xxxx_xxxx_xxxx_1x0x_xxxx_xxxx
140
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
141
new file mode 100644
142
index XXXXXXX..XXXXXXX
143
--- /dev/null
144
+++ b/target/arm/translate-neon.inc.c
145
@@ -XXX,XX +XXX,XX @@
146
+/*
147
+ * ARM translation: AArch32 Neon instructions
148
+ *
149
+ * Copyright (c) 2003 Fabrice Bellard
150
+ * Copyright (c) 2005-2007 CodeSourcery
151
+ * Copyright (c) 2007 OpenedHand, Ltd.
152
+ * Copyright (c) 2020 Linaro, Ltd.
153
+ *
154
+ * This library is free software; you can redistribute it and/or
155
+ * modify it under the terms of the GNU Lesser General Public
156
+ * License as published by the Free Software Foundation; either
157
+ * version 2 of the License, or (at your option) any later version.
158
+ *
159
+ * This library is distributed in the hope that it will be useful,
160
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
161
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
162
+ * Lesser General Public License for more details.
163
+ *
164
+ * You should have received a copy of the GNU Lesser General Public
165
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
166
+ */
167
+
168
+/*
169
+ * This file is intended to be included from translate.c; it uses
170
+ * some macros and definitions provided by that file.
171
+ * It might be possible to convert it to a standalone .c file eventually.
172
+ */
173
+
174
+/* Include the generated Neon decoder */
175
+#include "decode-neon-dp.inc.c"
176
+#include "decode-neon-ls.inc.c"
177
+#include "decode-neon-shared.inc.c"
178
diff --git a/target/arm/translate.c b/target/arm/translate.c
179
index XXXXXXX..XXXXXXX 100644
180
--- a/target/arm/translate.c
181
+++ b/target/arm/translate.c
182
@@ -XXX,XX +XXX,XX @@ static TCGv_ptr vfp_reg_ptr(bool dp, int reg)
183
184
#define ARM_CP_RW_BIT (1 << 20)
185
186
-/* Include the VFP decoder */
187
+/* Include the VFP and Neon decoders */
188
#include "translate-vfp.inc.c"
189
+#include "translate-neon.inc.c"
190
191
static inline void iwmmxt_load_reg(TCGv_i64 var, int reg)
192
{
193
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
194
/* Unconditional instructions. */
195
/* TODO: Perhaps merge these into one decodetree output file. */
196
if (disas_a32_uncond(s, insn) ||
197
- disas_vfp_uncond(s, insn)) {
198
+ disas_vfp_uncond(s, insn) ||
199
+ disas_neon_dp(s, insn) ||
200
+ disas_neon_ls(s, insn) ||
201
+ disas_neon_shared(s, insn)) {
202
return;
203
}
204
/* fall back to legacy decoder */
205
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
206
ARCH(6T2);
207
}
208
209
+ if ((insn & 0xef000000) == 0xef000000) {
210
+ /*
211
+ * T32 encodings 0b111p_1111_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq
212
+ * transform into
213
+ * A32 encodings 0b1111_001p_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq
214
+ */
215
+ uint32_t a32_insn = (insn & 0xe2ffffff) |
216
+ ((insn & (1 << 28)) >> 4) | (1 << 28);
217
+
218
+ if (disas_neon_dp(s, a32_insn)) {
219
+ return;
220
+ }
221
+ }
222
+
223
+ if ((insn & 0xff100000) == 0xf9000000) {
224
+ /*
225
+ * T32 encodings 0b1111_1001_ppp0_qqqq_qqqq_qqqq_qqqq_qqqq
226
+ * transform into
227
+ * A32 encodings 0b1111_0100_ppp0_qqqq_qqqq_qqqq_qqqq_qqqq
228
+ */
229
+ uint32_t a32_insn = (insn & 0x00ffffff) | 0xf4000000;
230
+
231
+ if (disas_neon_ls(s, a32_insn)) {
232
+ return;
233
+ }
234
+ }
235
+
236
/*
237
* TODO: Perhaps merge these into one decodetree output file.
238
* Note disas_vfp is written for a32 with cond field in the
239
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
240
*/
241
if (disas_t32(s, insn) ||
242
disas_vfp_uncond(s, insn) ||
243
+ disas_neon_shared(s, insn) ||
244
((insn >> 28) == 0xe && disas_vfp(s, insn))) {
245
return;
246
}
14
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
247
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
15
index XXXXXXX..XXXXXXX 100644
248
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/Makefile.objs
249
--- a/target/arm/Makefile.objs
17
+++ b/target/arm/Makefile.objs
250
+++ b/target/arm/Makefile.objs
18
@@ -XXX,XX +XXX,XX @@ obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
251
@@ -XXX,XX +XXX,XX @@ target/arm/decode-sve.inc.c: $(SRC_PATH)/target/arm/sve.decode $(DECODETREE)
19
obj-y += translate.o op_helper.o helper.o cpu.o
252
     $(PYTHON) $(DECODETREE) --decode disas_sve -o $@ $<,\
20
obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o
253
     "GEN", $(TARGET_DIR)$@)
21
obj-y += gdbstub.o
254
22
-obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o
255
+target/arm/decode-neon-shared.inc.c: $(SRC_PATH)/target/arm/neon-shared.decode $(DECODETREE)
23
-obj-$(TARGET_AARCH64) += pauth_helper.o
256
+    $(call quiet-command,\
24
+obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o
257
+     $(PYTHON) $(DECODETREE) --static-decode disas_neon_shared -o $@ $<,\
25
obj-y += crypto_helper.o
258
+     "GEN", $(TARGET_DIR)$@)
26
obj-$(CONFIG_SOFTMMU) += arm-powerctl.o
259
+
27
260
+target/arm/decode-neon-dp.inc.c: $(SRC_PATH)/target/arm/neon-dp.decode $(DECODETREE)
28
@@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c
261
+    $(call quiet-command,\
262
+     $(PYTHON) $(DECODETREE) --static-decode disas_neon_dp -o $@ $<,\
263
+     "GEN", $(TARGET_DIR)$@)
264
+
265
+target/arm/decode-neon-ls.inc.c: $(SRC_PATH)/target/arm/neon-ls.decode $(DECODETREE)
266
+    $(call quiet-command,\
267
+     $(PYTHON) $(DECODETREE) --static-decode disas_neon_ls -o $@ $<,\
268
+     "GEN", $(TARGET_DIR)$@)
269
+
270
target/arm/decode-vfp.inc.c: $(SRC_PATH)/target/arm/vfp.decode $(DECODETREE)
271
    $(call quiet-command,\
272
     $(PYTHON) $(DECODETREE) --static-decode disas_vfp -o $@ $<,\
273
@@ -XXX,XX +XXX,XX @@ target/arm/decode-t16.inc.c: $(SRC_PATH)/target/arm/t16.decode $(DECODETREE)
274
     "GEN", $(TARGET_DIR)$@)
275
276
target/arm/translate-sve.o: target/arm/decode-sve.inc.c
277
+target/arm/translate.o: target/arm/decode-neon-shared.inc.c
278
+target/arm/translate.o: target/arm/decode-neon-dp.inc.c
279
+target/arm/translate.o: target/arm/decode-neon-ls.inc.c
29
target/arm/translate.o: target/arm/decode-vfp.inc.c
280
target/arm/translate.o: target/arm/decode-vfp.inc.c
30
target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c
281
target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c
31
282
target/arm/translate.o: target/arm/decode-a32.inc.c
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
--
283
--
36
2.20.1
284
2.20.1
37
285
38
286
diff view generated by jsdifflib
1
From: Hongbo Zhang <hongbo.zhang@linaro.org>
1
Convert the VCMLA (vector) insns in the 3same extension group to
2
decodetree.
2
3
3
Following the previous patch, this patch adds peripheral devices to the
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
newly introduced SBSA-ref machine.
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20200430181003.21682-5-peter.maydell@linaro.org
7
---
8
target/arm/neon-shared.decode | 11 ++++++++++
9
target/arm/translate-neon.inc.c | 37 +++++++++++++++++++++++++++++++++
10
target/arm/translate.c | 11 +---------
11
3 files changed, 49 insertions(+), 10 deletions(-)
5
12
6
Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
13
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
7
Message-id: 1561890034-15921-3-git-send-email-hongbo.zhang@linaro.org
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
hw/arm/sbsa-ref.c | 535 ++++++++++++++++++++++++++++++++++++++++++++++
12
1 file changed, 535 insertions(+)
13
14
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/sbsa-ref.c
15
--- a/target/arm/neon-shared.decode
17
+++ b/hw/arm/sbsa-ref.c
16
+++ b/target/arm/neon-shared.decode
18
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@
19
*/
18
# More specifically, this covers:
20
19
# 2reg scalar ext: 0b1111_1110_xxxx_xxxx_xxxx_1x0x_xxxx_xxxx
21
#include "qemu/osdep.h"
20
# 3same ext: 0b1111_110x_xxxx_xxxx_xxxx_1x0x_xxxx_xxxx
22
+#include "qemu-common.h"
23
#include "qapi/error.h"
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
+
21
+
50
+#define VIRTUAL_PMU_IRQ 7
22
+# VFP/Neon register fields; same as vfp.decode
51
+#define ARCH_GIC_MAINT_IRQ 9
23
+%vm_dp 5:1 0:4
52
+#define ARCH_TIMER_VIRT_IRQ 11
24
+%vm_sp 0:4 5:1
53
+#define ARCH_TIMER_S_EL1_IRQ 13
25
+%vn_dp 7:1 16:4
54
+#define ARCH_TIMER_NS_EL1_IRQ 14
26
+%vn_sp 16:4 7:1
55
+#define ARCH_TIMER_NS_EL2_IRQ 10
27
+%vd_dp 22:1 12:4
28
+%vd_sp 12:4 22:1
56
+
29
+
57
enum {
30
+VCMLA 1111 110 rot:2 . 1 size:1 .... .... 1000 . q:1 . 0 .... \
58
SBSA_FLASH,
31
+ vm=%vm_dp vn=%vn_dp vd=%vd_dp
59
SBSA_MEM,
32
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
60
@@ -XXX,XX +XXX,XX @@ typedef struct {
33
index XXXXXXX..XXXXXXX 100644
61
void *fdt;
34
--- a/target/arm/translate-neon.inc.c
62
int fdt_size;
35
+++ b/target/arm/translate-neon.inc.c
63
int psci_conduit;
36
@@ -XXX,XX +XXX,XX @@
64
+ PFlashCFI01 *flash[2];
37
#include "decode-neon-dp.inc.c"
65
} SBSAMachineState;
38
#include "decode-neon-ls.inc.c"
66
39
#include "decode-neon-shared.inc.c"
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
};
71
72
+static const int sbsa_ref_irqmap[] = {
73
+ [SBSA_UART] = 1,
74
+ [SBSA_RTC] = 2,
75
+ [SBSA_PCIE] = 3, /* ... to 6 */
76
+ [SBSA_GPIO] = 7,
77
+ [SBSA_SECURE_UART] = 8,
78
+ [SBSA_SECURE_UART_MM] = 9,
79
+ [SBSA_AHCI] = 10,
80
+ [SBSA_EHCI] = 11,
81
+};
82
+
40
+
83
+/*
41
+static bool trans_VCMLA(DisasContext *s, arg_VCMLA *a)
84
+ * Firmware on this machine only uses ACPI table to load OS, these limited
85
+ * device tree nodes are just to let firmware know the info which varies from
86
+ * command line parameters, so it is not necessary to be fully compatible
87
+ * with the kernel CPU and NUMA binding rules.
88
+ */
89
+static void create_fdt(SBSAMachineState *sms)
90
+{
42
+{
91
+ void *fdt = create_device_tree(&sms->fdt_size);
43
+ int opr_sz;
92
+ const MachineState *ms = MACHINE(sms);
44
+ TCGv_ptr fpst;
93
+ int cpu;
45
+ gen_helper_gvec_3_ptr *fn_gvec_ptr;
94
+
46
+
95
+ if (!fdt) {
47
+ if (!dc_isar_feature(aa32_vcma, s)
96
+ error_report("create_device_tree() failed");
48
+ || (!a->size && !dc_isar_feature(aa32_fp16_arith, s))) {
97
+ exit(1);
49
+ return false;
98
+ }
50
+ }
99
+
51
+
100
+ sms->fdt = fdt;
52
+ /* UNDEF accesses to D16-D31 if they don't exist. */
101
+
53
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
102
+ qemu_fdt_setprop_string(fdt, "/", "compatible", "linux,sbsa-ref");
54
+ ((a->vd | a->vn | a->vm) & 0x10)) {
103
+ qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2);
55
+ return false;
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
+ }
56
+ }
125
+
57
+
126
+ qemu_fdt_add_subnode(sms->fdt, "/cpus");
58
+ if ((a->vn | a->vm | a->vd) & a->q) {
127
+
59
+ return false;
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
+ /*
151
+ * Create a single flash device. We use the same parameters as
152
+ * the flash devices on the Versatile Express board.
153
+ */
154
+ DeviceState *dev = qdev_create(NULL, TYPE_PFLASH_CFI01);
155
+
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
+ }
60
+ }
227
+
61
+
228
+ sbsa_flash_map(sms, sysmem, secure_sysmem);
62
+ if (!vfp_access_check(s)) {
229
+
63
+ return true;
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
+ }
64
+ }
259
+
65
+
260
+ return pflash_blk0 || bios_name;
66
+ opr_sz = (1 + a->q) * 8;
67
+ fpst = get_fpstatus_ptr(1);
68
+ fn_gvec_ptr = a->size ? gen_helper_gvec_fcmlas : gen_helper_gvec_fcmlah;
69
+ tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd),
70
+ vfp_reg_offset(1, a->vn),
71
+ vfp_reg_offset(1, a->vm),
72
+ fpst, opr_sz, opr_sz, a->rot,
73
+ fn_gvec_ptr);
74
+ tcg_temp_free_ptr(fpst);
75
+ return true;
261
+}
76
+}
262
+
77
diff --git a/target/arm/translate.c b/target/arm/translate.c
263
+static void create_secure_ram(SBSAMachineState *sms,
78
index XXXXXXX..XXXXXXX 100644
264
+ MemoryRegion *secure_sysmem)
79
--- a/target/arm/translate.c
265
+{
80
+++ b/target/arm/translate.c
266
+ MemoryRegion *secram = g_new(MemoryRegion, 1);
81
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
267
+ hwaddr base = sbsa_ref_memmap[SBSA_SECURE_MEM].base;
82
bool is_long = false, q = extract32(insn, 6, 1);
268
+ hwaddr size = sbsa_ref_memmap[SBSA_SECURE_MEM].size;
83
bool ptr_is_env = false;
269
+
84
270
+ memory_region_init_ram(secram, NULL, "sbsa-ref.secure-ram", size,
85
- if ((insn & 0xfe200f10) == 0xfc200800) {
271
+ &error_fatal);
86
- /* VCMLA -- 1111 110R R.1S .... .... 1000 ...0 .... */
272
+ memory_region_add_subregion(secure_sysmem, base, secram);
87
- int size = extract32(insn, 20, 1);
273
+}
88
- data = extract32(insn, 23, 2); /* rot */
274
+
89
- if (!dc_isar_feature(aa32_vcma, s)
275
+static void create_gic(SBSAMachineState *sms, qemu_irq *pic)
90
- || (!size && !dc_isar_feature(aa32_fp16_arith, s))) {
276
+{
91
- return 1;
277
+ DeviceState *gicdev;
92
- }
278
+ SysBusDevice *gicbusdev;
93
- fn_gvec_ptr = size ? gen_helper_gvec_fcmlas : gen_helper_gvec_fcmlah;
279
+ const char *gictype;
94
- } else if ((insn & 0xfea00f10) == 0xfc800800) {
280
+ uint32_t redist0_capacity, redist0_count;
95
+ if ((insn & 0xfea00f10) == 0xfc800800) {
281
+ int i;
96
/* VCADD -- 1111 110R 1.0S .... .... 1000 ...0 .... */
282
+
97
int size = extract32(insn, 20, 1);
283
+ gictype = gicv3_class_name();
98
data = extract32(insn, 24, 1); /* rot */
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
+
307
+ /*
308
+ * Wire the outputs from each CPU's generic timer and the GICv3
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
+ */
312
+ for (i = 0; i < smp_cpus; i++) {
313
+ DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
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
+
571
/*
572
* This machine has EL3 enabled, external firmware should supply PSCI
573
* implementation, so the QEMU's internal PSCI is disabled.
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
--
99
--
632
2.20.1
100
2.20.1
633
101
634
102
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
Convert the VCADD (vector) insns to decodetree.
2
2
3
The current models of the Aspeed SoCs only have one CPU but future
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
ones will support SMP. Introduce a new num_cpus field at the SoC class
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
level to define the number of available CPUs per SoC and also
5
Message-id: 20200430181003.21682-6-peter.maydell@linaro.org
6
introduce a 'num-cpus' property to activate the CPUs configured for
6
---
7
the machine.
7
target/arm/neon-shared.decode | 3 +++
8
target/arm/translate-neon.inc.c | 37 +++++++++++++++++++++++++++++++++
9
target/arm/translate.c | 11 +---------
10
3 files changed, 41 insertions(+), 10 deletions(-)
8
11
9
The max_cpus limit of the machine should depend on the SoC definition
12
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
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
13
index XXXXXXX..XXXXXXX 100644
28
--- a/include/hw/arm/aspeed_soc.h
14
--- a/target/arm/neon-shared.decode
29
+++ b/include/hw/arm/aspeed_soc.h
15
+++ b/target/arm/neon-shared.decode
30
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@
31
17
32
#define ASPEED_SPIS_NUM 2
18
VCMLA 1111 110 rot:2 . 1 size:1 .... .... 1000 . q:1 . 0 .... \
33
#define ASPEED_WDTS_NUM 3
19
vm=%vm_dp vn=%vn_dp vd=%vd_dp
34
+#define ASPEED_CPUS_NUM 2
20
+
35
21
+VCADD 1111 110 rot:1 1 . 0 size:1 .... .... 1000 . q:1 . 0 .... \
36
typedef struct AspeedSoCState {
22
+ vm=%vm_dp vn=%vn_dp vd=%vd_dp
37
/*< private >*/
23
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
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
24
index XXXXXXX..XXXXXXX 100644
57
--- a/hw/arm/aspeed.c
25
--- a/target/arm/translate-neon.inc.c
58
+++ b/hw/arm/aspeed.c
26
+++ b/target/arm/translate-neon.inc.c
59
@@ -XXX,XX +XXX,XX @@
27
@@ -XXX,XX +XXX,XX @@ static bool trans_VCMLA(DisasContext *s, arg_VCMLA *a)
60
#include "hw/misc/tmp105.h"
28
tcg_temp_free_ptr(fpst);
61
#include "qemu/log.h"
29
return true;
62
#include "sysemu/block-backend.h"
30
}
63
+#include "sysemu/sysemu.h"
31
+
64
#include "hw/loader.h"
32
+static bool trans_VCADD(DisasContext *s, arg_VCADD *a)
65
#include "qemu/error-report.h"
33
+{
66
#include "qemu/units.h"
34
+ int opr_sz;
67
35
+ TCGv_ptr fpst;
68
static struct arm_boot_info aspeed_board_binfo = {
36
+ gen_helper_gvec_3_ptr *fn_gvec_ptr;
69
.board_id = -1, /* device-tree-only board */
37
+
70
- .nb_cpus = 1,
38
+ if (!dc_isar_feature(aa32_vcma, s)
71
};
39
+ || (!a->size && !dc_isar_feature(aa32_fp16_arith, s))) {
72
40
+ return false;
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
+ }
41
+ }
167
+
42
+
168
/* CPU */
43
+ /* UNDEF accesses to D16-D31 if they don't exist. */
169
- object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err);
44
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
170
- if (err) {
45
+ ((a->vd | a->vn | a->vm) & 0x10)) {
171
- error_propagate(errp, err);
46
+ return false;
172
- return;
47
+ }
173
+ for (i = 0; i < s->num_cpus; i++) {
48
+
174
+ object_property_set_bool(OBJECT(&s->cpu[i]), true, "realized", &err);
49
+ if ((a->vn | a->vm | a->vd) & a->q) {
175
+ if (err) {
50
+ return false;
176
+ error_propagate(errp, err);
51
+ }
177
+ return;
52
+
178
+ }
53
+ if (!vfp_access_check(s)) {
179
}
54
+ return true;
180
55
+ }
181
/* SRAM */
56
+
182
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
57
+ opr_sz = (1 + a->q) * 8;
183
sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0,
58
+ fpst = get_fpstatus_ptr(1);
184
aspeed_soc_get_irq(s, ASPEED_ETH1));
59
+ fn_gvec_ptr = a->size ? gen_helper_gvec_fcadds : gen_helper_gvec_fcaddh;
185
}
60
+ tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd),
186
+static Property aspeed_soc_properties[] = {
61
+ vfp_reg_offset(1, a->vn),
187
+ DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0),
62
+ vfp_reg_offset(1, a->vm),
188
+ DEFINE_PROP_END_OF_LIST(),
63
+ fpst, opr_sz, opr_sz, a->rot,
189
+};
64
+ fn_gvec_ptr);
190
65
+ tcg_temp_free_ptr(fpst);
191
static void aspeed_soc_class_init(ObjectClass *oc, void *data)
66
+ return true;
192
{
67
+}
193
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_class_init(ObjectClass *oc, void *data)
68
diff --git a/target/arm/translate.c b/target/arm/translate.c
194
dc->realize = aspeed_soc_realize;
69
index XXXXXXX..XXXXXXX 100644
195
/* Reason: Uses serial_hds and nd_table in realize() directly */
70
--- a/target/arm/translate.c
196
dc->user_creatable = false;
71
+++ b/target/arm/translate.c
197
+ dc->props = aspeed_soc_properties;
72
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
198
}
73
bool is_long = false, q = extract32(insn, 6, 1);
199
74
bool ptr_is_env = false;
200
static const TypeInfo aspeed_soc_type_info = {
75
76
- if ((insn & 0xfea00f10) == 0xfc800800) {
77
- /* VCADD -- 1111 110R 1.0S .... .... 1000 ...0 .... */
78
- int size = extract32(insn, 20, 1);
79
- data = extract32(insn, 24, 1); /* rot */
80
- if (!dc_isar_feature(aa32_vcma, s)
81
- || (!size && !dc_isar_feature(aa32_fp16_arith, s))) {
82
- return 1;
83
- }
84
- fn_gvec_ptr = size ? gen_helper_gvec_fcadds : gen_helper_gvec_fcaddh;
85
- } else if ((insn & 0xfeb00f00) == 0xfc200d00) {
86
+ if ((insn & 0xfeb00f00) == 0xfc200d00) {
87
/* V[US]DOT -- 1111 1100 0.10 .... .... 1101 .Q.U .... */
88
bool u = extract32(insn, 4, 1);
89
if (!dc_isar_feature(aa32_dp, s)) {
201
--
90
--
202
2.20.1
91
2.20.1
203
92
204
93
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Convert the V[US]DOT (vector) insns to decodetree.
2
2
3
This code is specific to the SoftFloat floating-point
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
implementation, which is only used by TCG.
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20200430181003.21682-7-peter.maydell@linaro.org
6
---
7
target/arm/neon-shared.decode | 4 ++++
8
target/arm/translate-neon.inc.c | 32 ++++++++++++++++++++++++++++++++
9
target/arm/translate.c | 9 +--------
10
3 files changed, 37 insertions(+), 8 deletions(-)
5
11
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
7
Message-id: 20190701132516.26392-18-philmd@redhat.com
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/vfp_helper.c | 26 +++++++++++++++++++++++---
12
1 file changed, 23 insertions(+), 3 deletions(-)
13
14
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
15
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/vfp_helper.c
14
--- a/target/arm/neon-shared.decode
17
+++ b/target/arm/vfp_helper.c
15
+++ b/target/arm/neon-shared.decode
18
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@ VCMLA 1111 110 rot:2 . 1 size:1 .... .... 1000 . q:1 . 0 .... \
19
*/
17
20
18
VCADD 1111 110 rot:1 1 . 0 size:1 .... .... 1000 . q:1 . 0 .... \
21
#include "qemu/osdep.h"
19
vm=%vm_dp vn=%vn_dp vd=%vd_dp
22
-#include "qemu/log.h"
23
#include "cpu.h"
24
#include "exec/helper-proto.h"
25
-#include "fpu/softfloat.h"
26
#include "internals.h"
27
-
28
+#ifdef CONFIG_TCG
29
+#include "qemu/log.h"
30
+#include "fpu/softfloat.h"
31
+#endif
32
33
/* VFP support. We follow the convention used for VFP instructions:
34
Single precision routines have a "s" suffix, double precision a
35
"d" suffix. */
36
37
+#ifdef CONFIG_TCG
38
+
20
+
39
/* Convert host exception flags to vfp form. */
21
+# VUDOT and VSDOT
40
static inline int vfp_exceptbits_from_host(int host_bits)
22
+VDOT 1111 110 00 . 10 .... .... 1101 . q:1 . u:1 .... \
41
{
23
+ vm=%vm_dp vn=%vn_dp vd=%vd_dp
42
@@ -XXX,XX +XXX,XX @@ static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val)
24
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
43
set_float_exception_flags(0, &env->vfp.standard_fp_status);
25
index XXXXXXX..XXXXXXX 100644
44
}
26
--- a/target/arm/translate-neon.inc.c
45
27
+++ b/target/arm/translate-neon.inc.c
46
+#else
28
@@ -XXX,XX +XXX,XX @@ static bool trans_VCADD(DisasContext *s, arg_VCADD *a)
47
+
29
tcg_temp_free_ptr(fpst);
48
+static uint32_t vfp_get_fpscr_from_host(CPUARMState *env)
30
return true;
49
+{
50
+ return 0;
51
+}
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
}
31
}
75
+
32
+
76
+#endif
33
+static bool trans_VDOT(DisasContext *s, arg_VDOT *a)
34
+{
35
+ int opr_sz;
36
+ gen_helper_gvec_3 *fn_gvec;
37
+
38
+ if (!dc_isar_feature(aa32_dp, s)) {
39
+ return false;
40
+ }
41
+
42
+ /* UNDEF accesses to D16-D31 if they don't exist. */
43
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
44
+ ((a->vd | a->vn | a->vm) & 0x10)) {
45
+ return false;
46
+ }
47
+
48
+ if ((a->vn | a->vm | a->vd) & a->q) {
49
+ return false;
50
+ }
51
+
52
+ if (!vfp_access_check(s)) {
53
+ return true;
54
+ }
55
+
56
+ opr_sz = (1 + a->q) * 8;
57
+ fn_gvec = a->u ? gen_helper_gvec_udot_b : gen_helper_gvec_sdot_b;
58
+ tcg_gen_gvec_3_ool(vfp_reg_offset(1, a->vd),
59
+ vfp_reg_offset(1, a->vn),
60
+ vfp_reg_offset(1, a->vm),
61
+ opr_sz, opr_sz, 0, fn_gvec);
62
+ return true;
63
+}
64
diff --git a/target/arm/translate.c b/target/arm/translate.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/target/arm/translate.c
67
+++ b/target/arm/translate.c
68
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
69
bool is_long = false, q = extract32(insn, 6, 1);
70
bool ptr_is_env = false;
71
72
- if ((insn & 0xfeb00f00) == 0xfc200d00) {
73
- /* V[US]DOT -- 1111 1100 0.10 .... .... 1101 .Q.U .... */
74
- bool u = extract32(insn, 4, 1);
75
- if (!dc_isar_feature(aa32_dp, s)) {
76
- return 1;
77
- }
78
- fn_gvec = u ? gen_helper_gvec_udot_b : gen_helper_gvec_sdot_b;
79
- } else if ((insn & 0xff300f10) == 0xfc200810) {
80
+ if ((insn & 0xff300f10) == 0xfc200810) {
81
/* VFM[AS]L -- 1111 1100 S.10 .... .... 1000 .Q.1 .... */
82
int is_s = extract32(insn, 23, 1);
83
if (!dc_isar_feature(aa32_fhm, s)) {
77
--
84
--
78
2.20.1
85
2.20.1
79
86
80
87
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Convert the VFM[AS]L (vector) insns to decodetree. This is the last
2
insn in the legacy decoder for the 3same_ext group, so we can
3
delete the legacy decoder function for the group entirely.
2
4
3
Suggested-by: Samuel Ortiz <sameo@linux.intel.com>
5
Note that in disas_thumb2_insn() the parts of this encoding space
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
where the decodetree decoder returns false will correctly be directed
5
Message-id: 20190701132516.26392-11-philmd@redhat.com
7
to illegal_op by the "(insn & (1 << 28))" check so they won't fall
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
into disas_coproc_insn() by mistake.
9
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20200430181003.21682-8-peter.maydell@linaro.org
8
---
13
---
9
target/arm/cpu.h | 2 -
14
target/arm/neon-shared.decode | 6 +++
10
target/arm/translate.h | 5 -
15
target/arm/translate-neon.inc.c | 31 +++++++++++
11
target/arm/cpu.c | 226 +++++++++++++++++++++++++++++++++++++
16
target/arm/translate.c | 92 +--------------------------------
12
target/arm/translate-a64.c | 128 ---------------------
17
3 files changed, 38 insertions(+), 91 deletions(-)
13
target/arm/translate.c | 88 ---------------
14
5 files changed, 226 insertions(+), 223 deletions(-)
15
18
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
19
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
17
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.h
21
--- a/target/arm/neon-shared.decode
19
+++ b/target/arm/cpu.h
22
+++ b/target/arm/neon-shared.decode
20
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cpu);
23
@@ -XXX,XX +XXX,XX @@ VCADD 1111 110 rot:1 1 . 0 size:1 .... .... 1000 . q:1 . 0 .... \
21
void arm_v7m_cpu_do_interrupt(CPUState *cpu);
24
# VUDOT and VSDOT
22
bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req);
25
VDOT 1111 110 00 . 10 .... .... 1101 . q:1 . u:1 .... \
23
26
vm=%vm_dp vn=%vn_dp vd=%vd_dp
24
-void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags);
27
+
25
-
28
+# VFM[AS]L
26
hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
29
+VFML 1111 110 0 s:1 . 10 .... .... 1000 . 0 . 1 .... \
27
MemTxAttrs *attrs);
30
+ vm=%vm_sp vn=%vn_sp vd=%vd_dp q=0
28
31
+VFML 1111 110 0 s:1 . 10 .... .... 1000 . 1 . 1 .... \
29
diff --git a/target/arm/translate.h b/target/arm/translate.h
32
+ vm=%vm_dp vn=%vn_dp vd=%vd_dp q=1
33
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
30
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
31
--- a/target/arm/translate.h
35
--- a/target/arm/translate-neon.inc.c
32
+++ b/target/arm/translate.h
36
+++ b/target/arm/translate-neon.inc.c
33
@@ -XXX,XX +XXX,XX @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn)
37
@@ -XXX,XX +XXX,XX @@ static bool trans_VDOT(DisasContext *s, arg_VDOT *a)
34
#ifdef TARGET_AARCH64
38
opr_sz, opr_sz, 0, fn_gvec);
35
void a64_translate_init(void);
39
return true;
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
}
40
}
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
53
index XXXXXXX..XXXXXXX 100644
54
--- a/target/arm/cpu.c
55
+++ b/target/arm/cpu.c
56
@@ -XXX,XX +XXX,XX @@
57
*/
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
}
67
68
+#ifdef TARGET_AARCH64
69
+
41
+
70
+static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
42
+static bool trans_VFML(DisasContext *s, arg_VFML *a)
71
+{
43
+{
72
+ ARMCPU *cpu = ARM_CPU(cs);
44
+ int opr_sz;
73
+ CPUARMState *env = &cpu->env;
74
+ uint32_t psr = pstate_read(env);
75
+ int i;
76
+ int el = arm_current_el(env);
77
+ const char *ns_status;
78
+
45
+
79
+ qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc);
46
+ if (!dc_isar_feature(aa32_fhm, s)) {
80
+ for (i = 0; i < 32; i++) {
47
+ return false;
81
+ if (i == 31) {
82
+ qemu_fprintf(f, " SP=%016" PRIx64 "\n", env->xregs[i]);
83
+ } else {
84
+ qemu_fprintf(f, "X%02d=%016" PRIx64 "%s", i, env->xregs[i],
85
+ (i + 2) % 3 ? " " : "\n");
86
+ }
87
+ }
48
+ }
88
+
49
+
89
+ if (arm_feature(env, ARM_FEATURE_EL3) && el != 3) {
50
+ /* UNDEF accesses to D16-D31 if they don't exist. */
90
+ ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S ";
51
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
91
+ } else {
52
+ (a->vd & 0x10)) {
92
+ ns_status = "";
53
+ return false;
93
+ }
94
+ qemu_fprintf(f, "PSTATE=%08x %c%c%c%c %sEL%d%c",
95
+ psr,
96
+ psr & PSTATE_N ? 'N' : '-',
97
+ psr & PSTATE_Z ? 'Z' : '-',
98
+ psr & PSTATE_C ? 'C' : '-',
99
+ psr & PSTATE_V ? 'V' : '-',
100
+ ns_status,
101
+ el,
102
+ psr & PSTATE_SP ? 'h' : 't');
103
+
104
+ if (cpu_isar_feature(aa64_bti, cpu)) {
105
+ qemu_fprintf(f, " BTYPE=%d", (psr & PSTATE_BTYPE) >> 10);
106
+ }
107
+ if (!(flags & CPU_DUMP_FPU)) {
108
+ qemu_fprintf(f, "\n");
109
+ return;
110
+ }
111
+ if (fp_exception_el(env, el) != 0) {
112
+ qemu_fprintf(f, " FPU disabled\n");
113
+ return;
114
+ }
115
+ qemu_fprintf(f, " FPCR=%08x FPSR=%08x\n",
116
+ vfp_get_fpcr(env), vfp_get_fpsr(env));
117
+
118
+ if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) == 0) {
119
+ int j, zcr_len = sve_zcr_len_for_el(env, el);
120
+
121
+ for (i = 0; i <= FFR_PRED_NUM; i++) {
122
+ bool eol;
123
+ if (i == FFR_PRED_NUM) {
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
+ }
158
+
159
+ for (i = 0; i < 32; i++) {
160
+ if (zcr_len == 0) {
161
+ qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 "%s",
162
+ i, env->vfp.zregs[i].d[1],
163
+ env->vfp.zregs[i].d[0], i & 1 ? "\n" : " ");
164
+ } else if (zcr_len == 1) {
165
+ qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64
166
+ ":%016" PRIx64 ":%016" PRIx64 "\n",
167
+ i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].d[2],
168
+ env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0]);
169
+ } else {
170
+ for (j = zcr_len; j >= 0; j--) {
171
+ bool odd = (zcr_len - j) % 2 != 0;
172
+ if (j == zcr_len) {
173
+ qemu_fprintf(f, "Z%02d[%x-%x]=", i, j, j - 1);
174
+ } else if (!odd) {
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
+ }
188
+ } else {
189
+ for (i = 0; i < 32; i++) {
190
+ uint64_t *q = aa64_vfp_qreg(env, i);
191
+ qemu_fprintf(f, "Q%02d=%016" PRIx64 ":%016" PRIx64 "%s",
192
+ i, q[1], q[0], (i & 1 ? "\n" : " "));
193
+ }
194
+ }
195
+}
196
+
197
+#else
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
+ }
54
+ }
216
+
55
+
217
+ for (i = 0; i < 16; i++) {
56
+ if (a->vd & a->q) {
218
+ qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]);
57
+ return false;
219
+ if ((i % 4) == 3) {
220
+ qemu_fprintf(f, "\n");
221
+ } else {
222
+ qemu_fprintf(f, " ");
223
+ }
224
+ }
58
+ }
225
+
59
+
226
+ if (arm_feature(env, ARM_FEATURE_M)) {
60
+ if (!vfp_access_check(s)) {
227
+ uint32_t xpsr = xpsr_read(env);
61
+ return true;
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
+ }
62
+ }
273
+
63
+
274
+ if (flags & CPU_DUMP_FPU) {
64
+ opr_sz = (1 + a->q) * 8;
275
+ int numvfpregs = 0;
65
+ tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd),
276
+ if (arm_feature(env, ARM_FEATURE_VFP)) {
66
+ vfp_reg_offset(a->q, a->vn),
277
+ numvfpregs += 16;
67
+ vfp_reg_offset(a->q, a->vm),
278
+ }
68
+ cpu_env, opr_sz, opr_sz, a->s, /* is_2 == 0 */
279
+ if (arm_feature(env, ARM_FEATURE_VFP3)) {
69
+ gen_helper_gvec_fmlal_a32);
280
+ numvfpregs += 16;
70
+ return true;
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
+}
71
+}
292
+
293
uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz)
294
{
295
uint32_t Aff1 = idx / clustersz;
296
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
297
index XXXXXXX..XXXXXXX 100644
298
--- a/target/arm/translate-a64.c
299
+++ b/target/arm/translate-a64.c
300
@@ -XXX,XX +XXX,XX @@
301
#include "translate.h"
302
#include "internals.h"
303
#include "qemu/host-utils.h"
304
-#include "qemu/qemu-print.h"
305
306
#include "hw/semihosting/semihost.h"
307
#include "exec/gen-icount.h"
308
@@ -XXX,XX +XXX,XX @@ static void set_btype(DisasContext *s, int val)
309
s->btype = -1;
310
}
311
312
-void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
313
-{
314
- ARMCPU *cpu = ARM_CPU(cs);
315
- CPUARMState *env = &cpu->env;
316
- uint32_t psr = pstate_read(env);
317
- int i;
318
- int el = arm_current_el(env);
319
- const char *ns_status;
320
-
321
- qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc);
322
- for (i = 0; i < 32; i++) {
323
- if (i == 31) {
324
- qemu_fprintf(f, " SP=%016" PRIx64 "\n", env->xregs[i]);
325
- } else {
326
- qemu_fprintf(f, "X%02d=%016" PRIx64 "%s", i, env->xregs[i],
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
- }
400
-
401
- for (i = 0; i < 32; i++) {
402
- if (zcr_len == 0) {
403
- qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 "%s",
404
- i, env->vfp.zregs[i].d[1],
405
- env->vfp.zregs[i].d[0], i & 1 ? "\n" : " ");
406
- } else if (zcr_len == 1) {
407
- qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64
408
- ":%016" PRIx64 ":%016" PRIx64 "\n",
409
- i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].d[2],
410
- env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0]);
411
- } else {
412
- for (j = zcr_len; j >= 0; j--) {
413
- bool odd = (zcr_len - j) % 2 != 0;
414
- if (j == zcr_len) {
415
- qemu_fprintf(f, "Z%02d[%x-%x]=", i, j, j - 1);
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
- }
430
- } else {
431
- for (i = 0; i < 32; i++) {
432
- uint64_t *q = aa64_vfp_qreg(env, i);
433
- qemu_fprintf(f, "Q%02d=%016" PRIx64 ":%016" PRIx64 "%s",
434
- i, q[1], q[0], (i & 1 ? "\n" : " "));
435
- }
436
- }
437
-}
438
-
439
void gen_a64_set_pc_im(uint64_t val)
440
{
441
tcg_gen_movi_i64(cpu_pc, val);
442
diff --git a/target/arm/translate.c b/target/arm/translate.c
72
diff --git a/target/arm/translate.c b/target/arm/translate.c
443
index XXXXXXX..XXXXXXX 100644
73
index XXXXXXX..XXXXXXX 100644
444
--- a/target/arm/translate.c
74
--- a/target/arm/translate.c
445
+++ b/target/arm/translate.c
75
+++ b/target/arm/translate.c
446
@@ -XXX,XX +XXX,XX @@
76
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
447
#include "tcg-op-gvec.h"
77
return 0;
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
}
78
}
457
79
458
-void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags)
80
-/* Advanced SIMD three registers of the same length extension.
81
- * 31 25 23 22 20 16 12 11 10 9 8 3 0
82
- * +---------------+-----+---+-----+----+----+---+----+---+----+---------+----+
83
- * | 1 1 1 1 1 1 0 | op1 | D | op2 | Vn | Vd | 1 | o3 | 0 | o4 | N Q M U | Vm |
84
- * +---------------+-----+---+-----+----+----+---+----+---+----+---------+----+
85
- */
86
-static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
459
-{
87
-{
460
- ARMCPU *cpu = ARM_CPU(cs);
88
- gen_helper_gvec_3 *fn_gvec = NULL;
461
- CPUARMState *env = &cpu->env;
89
- gen_helper_gvec_3_ptr *fn_gvec_ptr = NULL;
462
- int i;
90
- int rd, rn, rm, opr_sz;
91
- int data = 0;
92
- int off_rn, off_rm;
93
- bool is_long = false, q = extract32(insn, 6, 1);
94
- bool ptr_is_env = false;
463
-
95
-
464
- if (is_a64(env)) {
96
- if ((insn & 0xff300f10) == 0xfc200810) {
465
- aarch64_cpu_dump_state(cs, f, flags);
97
- /* VFM[AS]L -- 1111 1100 S.10 .... .... 1000 .Q.1 .... */
466
- return;
98
- int is_s = extract32(insn, 23, 1);
99
- if (!dc_isar_feature(aa32_fhm, s)) {
100
- return 1;
101
- }
102
- is_long = true;
103
- data = is_s; /* is_2 == 0 */
104
- fn_gvec_ptr = gen_helper_gvec_fmlal_a32;
105
- ptr_is_env = true;
106
- } else {
107
- return 1;
467
- }
108
- }
468
-
109
-
469
- for (i = 0; i < 16; i++) {
110
- VFP_DREG_D(rd, insn);
470
- qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]);
111
- if (rd & q) {
471
- if ((i % 4) == 3) {
112
- return 1;
472
- qemu_fprintf(f, "\n");
113
- }
473
- } else {
114
- if (q || !is_long) {
474
- qemu_fprintf(f, " ");
115
- VFP_DREG_N(rn, insn);
116
- VFP_DREG_M(rm, insn);
117
- if ((rn | rm) & q & !is_long) {
118
- return 1;
475
- }
119
- }
120
- off_rn = vfp_reg_offset(1, rn);
121
- off_rm = vfp_reg_offset(1, rm);
122
- } else {
123
- rn = VFP_SREG_N(insn);
124
- rm = VFP_SREG_M(insn);
125
- off_rn = vfp_reg_offset(0, rn);
126
- off_rm = vfp_reg_offset(0, rm);
476
- }
127
- }
477
-
128
-
478
- if (arm_feature(env, ARM_FEATURE_M)) {
129
- if (s->fp_excp_el) {
479
- uint32_t xpsr = xpsr_read(env);
130
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
480
- const char *mode;
131
- syn_simd_access_trap(1, 0xe, false), s->fp_excp_el);
481
- const char *ns_status = "";
132
- return 0;
482
-
133
- }
483
- if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
134
- if (!s->vfp_enabled) {
484
- ns_status = env->v7m.secure ? "S " : "NS ";
135
- return 1;
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
- }
136
- }
525
-
137
-
526
- if (flags & CPU_DUMP_FPU) {
138
- opr_sz = (1 + q) * 8;
527
- int numvfpregs = 0;
139
- if (fn_gvec_ptr) {
528
- if (arm_feature(env, ARM_FEATURE_VFP)) {
140
- TCGv_ptr ptr;
529
- numvfpregs += 16;
141
- if (ptr_is_env) {
142
- ptr = cpu_env;
143
- } else {
144
- ptr = get_fpstatus_ptr(1);
530
- }
145
- }
531
- if (arm_feature(env, ARM_FEATURE_VFP3)) {
146
- tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd), off_rn, off_rm, ptr,
532
- numvfpregs += 16;
147
- opr_sz, opr_sz, data, fn_gvec_ptr);
148
- if (!ptr_is_env) {
149
- tcg_temp_free_ptr(ptr);
533
- }
150
- }
534
- for (i = 0; i < numvfpregs; i++) {
151
- } else {
535
- uint64_t v = *aa32_vfp_dreg(env, i);
152
- tcg_gen_gvec_3_ool(vfp_reg_offset(1, rd), off_rn, off_rm,
536
- qemu_fprintf(f, "s%02d=%08x s%02d=%08x d%02d=%016" PRIx64 "\n",
153
- opr_sz, opr_sz, data, fn_gvec);
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
- }
154
- }
155
- return 0;
543
-}
156
-}
544
-
157
-
545
void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb,
158
/* Advanced SIMD two registers and a scalar extension.
546
target_ulong *data)
159
* 31 24 23 22 20 16 12 11 10 9 8 3 0
547
{
160
* +-----------------+----+---+----+----+----+---+----+---+----+---------+----+
161
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
162
}
163
}
164
}
165
- } else if ((insn & 0x0e000a00) == 0x0c000800
166
- && arm_dc_feature(s, ARM_FEATURE_V8)) {
167
- if (disas_neon_insn_3same_ext(s, insn)) {
168
- goto illegal_op;
169
- }
170
- return;
171
} else if ((insn & 0x0f000a00) == 0x0e000800
172
&& arm_dc_feature(s, ARM_FEATURE_V8)) {
173
if (disas_neon_insn_2reg_scalar_ext(s, insn)) {
174
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
175
}
176
break;
177
}
178
- if ((insn & 0xfe000a00) == 0xfc000800
179
+ if ((insn & 0xff000a00) == 0xfe000800
180
&& arm_dc_feature(s, ARM_FEATURE_V8)) {
181
/* The Thumb2 and ARM encodings are identical. */
182
- if (disas_neon_insn_3same_ext(s, insn)) {
183
- goto illegal_op;
184
- }
185
- } else if ((insn & 0xff000a00) == 0xfe000800
186
- && arm_dc_feature(s, ARM_FEATURE_V8)) {
187
- /* The Thumb2 and ARM encodings are identical. */
188
if (disas_neon_insn_2reg_scalar_ext(s, insn)) {
189
goto illegal_op;
190
}
548
--
191
--
549
2.20.1
192
2.20.1
550
193
551
194
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
Convert VCMLA (scalar) in the 2reg-scalar-ext group to decodetree.
2
2
3
The DRAM address of a DMA transaction depends on the DRAM base address
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
of the SoC. Inform the SMC controller model with this value.
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20200430181003.21682-9-peter.maydell@linaro.org
6
---
7
target/arm/neon-shared.decode | 5 +++++
8
target/arm/translate-neon.inc.c | 40 +++++++++++++++++++++++++++++++++
9
target/arm/translate.c | 26 +--------------------
10
3 files changed, 46 insertions(+), 25 deletions(-)
5
11
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
12
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
7
Reviewed-by: Joel Stanley <joel@jms.id.au>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Message-id: 20190618165311.27066-15-clg@kaod.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
include/hw/ssi/aspeed_smc.h | 3 +++
13
hw/arm/aspeed_soc.c | 6 ++++++
14
hw/ssi/aspeed_smc.c | 1 +
15
3 files changed, 10 insertions(+)
16
17
diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h
18
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/ssi/aspeed_smc.h
14
--- a/target/arm/neon-shared.decode
20
+++ b/include/hw/ssi/aspeed_smc.h
15
+++ b/target/arm/neon-shared.decode
21
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCState {
16
@@ -XXX,XX +XXX,XX @@ VFML 1111 110 0 s:1 . 10 .... .... 1000 . 0 . 1 .... \
22
uint8_t r_timings;
17
vm=%vm_sp vn=%vn_sp vd=%vd_dp q=0
23
uint8_t conf_enable_w0;
18
VFML 1111 110 0 s:1 . 10 .... .... 1000 . 1 . 1 .... \
24
19
vm=%vm_dp vn=%vn_dp vd=%vd_dp q=1
25
+ /* for DMA support */
26
+ uint64_t sdram_base;
27
+
20
+
28
AspeedSMCFlash *flashes;
21
+VCMLA_scalar 1111 1110 0 . rot:2 .... .... 1000 . q:1 index:1 0 vm:4 \
29
22
+ vn=%vn_dp vd=%vd_dp size=0
30
uint8_t snoop_index;
23
+VCMLA_scalar 1111 1110 1 . rot:2 .... .... 1000 . q:1 . 0 .... \
31
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
24
+ vm=%vm_dp vn=%vn_dp vd=%vd_dp size=1 index=0
25
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
32
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/arm/aspeed_soc.c
27
--- a/target/arm/translate-neon.inc.c
34
+++ b/hw/arm/aspeed_soc.c
28
+++ b/target/arm/translate-neon.inc.c
35
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
29
@@ -XXX,XX +XXX,XX @@ static bool trans_VFML(DisasContext *s, arg_VFML *a)
36
aspeed_soc_get_irq(s, ASPEED_I2C));
30
gen_helper_gvec_fmlal_a32);
37
31
return true;
38
/* FMC, The number of CS is set at the board level */
32
}
39
+ object_property_set_int(OBJECT(&s->fmc), sc->info->memmap[ASPEED_SDRAM],
33
+
40
+ "sdram-base", &err);
34
+static bool trans_VCMLA_scalar(DisasContext *s, arg_VCMLA_scalar *a)
41
+ if (err) {
35
+{
42
+ error_propagate(errp, err);
36
+ gen_helper_gvec_3_ptr *fn_gvec_ptr;
43
+ return;
37
+ int opr_sz;
38
+ TCGv_ptr fpst;
39
+
40
+ if (!dc_isar_feature(aa32_vcma, s)) {
41
+ return false;
44
+ }
42
+ }
45
object_property_set_bool(OBJECT(&s->fmc), true, "realized", &err);
43
+ if (a->size == 0 && !dc_isar_feature(aa32_fp16_arith, s)) {
46
if (err) {
44
+ return false;
47
error_propagate(errp, err);
45
+ }
48
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
46
+
47
+ /* UNDEF accesses to D16-D31 if they don't exist. */
48
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
49
+ ((a->vd | a->vn | a->vm) & 0x10)) {
50
+ return false;
51
+ }
52
+
53
+ if ((a->vd | a->vn) & a->q) {
54
+ return false;
55
+ }
56
+
57
+ if (!vfp_access_check(s)) {
58
+ return true;
59
+ }
60
+
61
+ fn_gvec_ptr = (a->size ? gen_helper_gvec_fcmlas_idx
62
+ : gen_helper_gvec_fcmlah_idx);
63
+ opr_sz = (1 + a->q) * 8;
64
+ fpst = get_fpstatus_ptr(1);
65
+ tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd),
66
+ vfp_reg_offset(1, a->vn),
67
+ vfp_reg_offset(1, a->vm),
68
+ fpst, opr_sz, opr_sz,
69
+ (a->index << 2) | a->rot, fn_gvec_ptr);
70
+ tcg_temp_free_ptr(fpst);
71
+ return true;
72
+}
73
diff --git a/target/arm/translate.c b/target/arm/translate.c
49
index XXXXXXX..XXXXXXX 100644
74
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/ssi/aspeed_smc.c
75
--- a/target/arm/translate.c
51
+++ b/hw/ssi/aspeed_smc.c
76
+++ b/target/arm/translate.c
52
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_smc = {
77
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
53
78
bool is_long = false, q = extract32(insn, 6, 1);
54
static Property aspeed_smc_properties[] = {
79
bool ptr_is_env = false;
55
DEFINE_PROP_UINT32("num-cs", AspeedSMCState, num_cs, 1),
80
56
+ DEFINE_PROP_UINT64("sdram-base", AspeedSMCState, sdram_base, 0),
81
- if ((insn & 0xff000f10) == 0xfe000800) {
57
DEFINE_PROP_END_OF_LIST(),
82
- /* VCMLA (indexed) -- 1111 1110 S.RR .... .... 1000 ...0 .... */
58
};
83
- int rot = extract32(insn, 20, 2);
84
- int size = extract32(insn, 23, 1);
85
- int index;
86
-
87
- if (!dc_isar_feature(aa32_vcma, s)) {
88
- return 1;
89
- }
90
- if (size == 0) {
91
- if (!dc_isar_feature(aa32_fp16_arith, s)) {
92
- return 1;
93
- }
94
- /* For fp16, rm is just Vm, and index is M. */
95
- rm = extract32(insn, 0, 4);
96
- index = extract32(insn, 5, 1);
97
- } else {
98
- /* For fp32, rm is the usual M:Vm, and index is 0. */
99
- VFP_DREG_M(rm, insn);
100
- index = 0;
101
- }
102
- data = (index << 2) | rot;
103
- fn_gvec_ptr = (size ? gen_helper_gvec_fcmlas_idx
104
- : gen_helper_gvec_fcmlah_idx);
105
- } else if ((insn & 0xffb00f00) == 0xfe200d00) {
106
+ if ((insn & 0xffb00f00) == 0xfe200d00) {
107
/* V[US]DOT -- 1111 1110 0.10 .... .... 1101 .Q.U .... */
108
int u = extract32(insn, 4, 1);
59
109
60
--
110
--
61
2.20.1
111
2.20.1
62
112
63
113
diff view generated by jsdifflib
1
From: Joel Stanley <joel@jms.id.au>
1
Convert the V[US]DOT (scalar) insns in the 2reg-scalar-ext group
2
to decodetree.
2
3
3
The Linux kernel driver was updated in commit 4451d3f59f2a
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
("clocksource/drivers/fttmr010: Fix set_next_event handler) to fix an
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
issue observed on hardware:
6
Message-id: 20200430181003.21682-10-peter.maydell@linaro.org
7
---
8
target/arm/neon-shared.decode | 3 +++
9
target/arm/translate-neon.inc.c | 35 +++++++++++++++++++++++++++++++++
10
target/arm/translate.c | 13 +-----------
11
3 files changed, 39 insertions(+), 12 deletions(-)
6
12
7
> RELOAD register is loaded into COUNT register when the aspeed timer
13
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
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
14
index XXXXXXX..XXXXXXX 100644
38
--- a/hw/timer/aspeed_timer.c
15
--- a/target/arm/neon-shared.decode
39
+++ b/hw/timer/aspeed_timer.c
16
+++ b/target/arm/neon-shared.decode
40
@@ -XXX,XX +XXX,XX @@ static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks)
17
@@ -XXX,XX +XXX,XX @@ VCMLA_scalar 1111 1110 0 . rot:2 .... .... 1000 . q:1 index:1 0 vm:4 \
41
18
vn=%vn_dp vd=%vd_dp size=0
42
static uint64_t calculate_next(struct AspeedTimer *t)
19
VCMLA_scalar 1111 1110 1 . rot:2 .... .... 1000 . q:1 . 0 .... \
43
{
20
vm=%vm_dp vn=%vn_dp vd=%vd_dp size=1 index=0
44
- uint64_t next = 0;
21
+
45
- uint32_t rate = calculate_rate(t);
22
+VDOT_scalar 1111 1110 0 . 10 .... .... 1101 . q:1 index:1 u:1 rm:4 \
46
+ uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
23
+ vm=%vm_dp vn=%vn_dp vd=%vd_dp
47
+ uint64_t next;
24
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
48
25
index XXXXXXX..XXXXXXX 100644
49
- while (!next) {
26
--- a/target/arm/translate-neon.inc.c
50
- /* We don't know the relationship between the values in the match
27
+++ b/target/arm/translate-neon.inc.c
51
- * registers, so sort using MAX/MIN/zero. We sort in that order as the
28
@@ -XXX,XX +XXX,XX @@ static bool trans_VCMLA_scalar(DisasContext *s, arg_VCMLA_scalar *a)
52
- * timer counts down to zero. */
29
tcg_temp_free_ptr(fpst);
53
- uint64_t seq[] = {
30
return true;
54
- calculate_time(t, MAX(t->match[0], t->match[1])),
31
}
55
- calculate_time(t, MIN(t->match[0], t->match[1])),
32
+
56
- calculate_time(t, 0),
33
+static bool trans_VDOT_scalar(DisasContext *s, arg_VDOT_scalar *a)
57
- };
34
+{
58
- uint64_t reload_ns;
35
+ gen_helper_gvec_3 *fn_gvec;
59
- uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
36
+ int opr_sz;
60
+ /*
37
+ TCGv_ptr fpst;
61
+ * We don't know the relationship between the values in the match
38
+
62
+ * registers, so sort using MAX/MIN/zero. We sort in that order as
39
+ if (!dc_isar_feature(aa32_dp, s)) {
63
+ * the timer counts down to zero.
40
+ return false;
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
+ }
41
+ }
89
+
42
+
90
+ next = calculate_time(t, 0);
43
+ /* UNDEF accesses to D16-D31 if they don't exist. */
91
+ if (now < next) {
44
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
92
+ return next;
45
+ ((a->vd | a->vn) & 0x10)) {
46
+ return false;
93
+ }
47
+ }
94
+
48
+
95
+ /* We've missed all deadlines, fire interrupt and try again */
49
+ if ((a->vd | a->vn) & a->q) {
96
+ timer_del(&t->timer);
50
+ return false;
97
+
98
+ if (timer_overflow_interrupt(t)) {
99
+ t->level = !t->level;
100
+ qemu_set_irq(t->irq, t->level);
101
+ }
51
+ }
102
+
52
+
103
+ t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
53
+ if (!vfp_access_check(s)) {
104
+ return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0));
54
+ return true;
105
}
55
+ }
106
56
+
107
static void aspeed_timer_mod(AspeedTimer *t)
57
+ fn_gvec = a->u ? gen_helper_gvec_udot_idx_b : gen_helper_gvec_sdot_idx_b;
58
+ opr_sz = (1 + a->q) * 8;
59
+ fpst = get_fpstatus_ptr(1);
60
+ tcg_gen_gvec_3_ool(vfp_reg_offset(1, a->vd),
61
+ vfp_reg_offset(1, a->vn),
62
+ vfp_reg_offset(1, a->rm),
63
+ opr_sz, opr_sz, a->index, fn_gvec);
64
+ tcg_temp_free_ptr(fpst);
65
+ return true;
66
+}
67
diff --git a/target/arm/translate.c b/target/arm/translate.c
68
index XXXXXXX..XXXXXXX 100644
69
--- a/target/arm/translate.c
70
+++ b/target/arm/translate.c
71
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
72
bool is_long = false, q = extract32(insn, 6, 1);
73
bool ptr_is_env = false;
74
75
- if ((insn & 0xffb00f00) == 0xfe200d00) {
76
- /* V[US]DOT -- 1111 1110 0.10 .... .... 1101 .Q.U .... */
77
- int u = extract32(insn, 4, 1);
78
-
79
- if (!dc_isar_feature(aa32_dp, s)) {
80
- return 1;
81
- }
82
- fn_gvec = u ? gen_helper_gvec_udot_idx_b : gen_helper_gvec_sdot_idx_b;
83
- /* rm is just Vm, and index is M. */
84
- data = extract32(insn, 5, 1); /* index */
85
- rm = extract32(insn, 0, 4);
86
- } else if ((insn & 0xffa00f10) == 0xfe000810) {
87
+ if ((insn & 0xffa00f10) == 0xfe000810) {
88
/* VFM[AS]L -- 1111 1110 0.0S .... .... 1000 .Q.1 .... */
89
int is_s = extract32(insn, 20, 1);
90
int vm20 = extract32(insn, 0, 3);
108
--
91
--
109
2.20.1
92
2.20.1
110
93
111
94
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Convert the VFM[AS]L (scalar) insns in the 2reg-scalar-ext group
2
2
to decodetree. These are the last ones in the group so we can remove
3
Since we'll move this code around, fix its style first.
3
all the legacy decode for the group.
4
4
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Note that in disas_thumb2_insn() the parts of this encoding space
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
where the decodetree decoder returns false will correctly be directed
7
Message-id: 20190701132516.26392-9-philmd@redhat.com
7
to illegal_op by the "(insn & (1 << 28))" check so they won't fall
8
into disas_coproc_insn() by mistake.
9
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20200430181003.21682-11-peter.maydell@linaro.org
9
---
13
---
10
target/arm/translate.c | 11 ++++++-----
14
target/arm/neon-shared.decode | 7 +++
11
target/arm/vfp_helper.c | 36 ++++++++++++++++++++++++------------
15
target/arm/translate-neon.inc.c | 32 ++++++++++
12
2 files changed, 30 insertions(+), 17 deletions(-)
16
target/arm/translate.c | 107 +-------------------------------
13
17
3 files changed, 40 insertions(+), 106 deletions(-)
18
19
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
20
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/neon-shared.decode
22
+++ b/target/arm/neon-shared.decode
23
@@ -XXX,XX +XXX,XX @@ VCMLA_scalar 1111 1110 1 . rot:2 .... .... 1000 . q:1 . 0 .... \
24
25
VDOT_scalar 1111 1110 0 . 10 .... .... 1101 . q:1 index:1 u:1 rm:4 \
26
vm=%vm_dp vn=%vn_dp vd=%vd_dp
27
+
28
+%vfml_scalar_q0_rm 0:3 5:1
29
+%vfml_scalar_q1_index 5:1 3:1
30
+VFML_scalar 1111 1110 0 . 0 s:1 .... .... 1000 . 0 . 1 index:1 ... \
31
+ rm=%vfml_scalar_q0_rm vn=%vn_sp vd=%vd_dp q=0
32
+VFML_scalar 1111 1110 0 . 0 s:1 .... .... 1000 . 1 . 1 . rm:3 \
33
+ index=%vfml_scalar_q1_index vn=%vn_dp vd=%vd_dp q=1
34
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/target/arm/translate-neon.inc.c
37
+++ b/target/arm/translate-neon.inc.c
38
@@ -XXX,XX +XXX,XX @@ static bool trans_VDOT_scalar(DisasContext *s, arg_VDOT_scalar *a)
39
tcg_temp_free_ptr(fpst);
40
return true;
41
}
42
+
43
+static bool trans_VFML_scalar(DisasContext *s, arg_VFML_scalar *a)
44
+{
45
+ int opr_sz;
46
+
47
+ if (!dc_isar_feature(aa32_fhm, s)) {
48
+ return false;
49
+ }
50
+
51
+ /* UNDEF accesses to D16-D31 if they don't exist. */
52
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
53
+ ((a->vd & 0x10) || (a->q && (a->vn & 0x10)))) {
54
+ return false;
55
+ }
56
+
57
+ if (a->vd & a->q) {
58
+ return false;
59
+ }
60
+
61
+ if (!vfp_access_check(s)) {
62
+ return true;
63
+ }
64
+
65
+ opr_sz = (1 + a->q) * 8;
66
+ tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd),
67
+ vfp_reg_offset(a->q, a->vn),
68
+ vfp_reg_offset(a->q, a->rm),
69
+ cpu_env, opr_sz, opr_sz,
70
+ (a->index << 2) | a->s, /* is_2 == 0 */
71
+ gen_helper_gvec_fmlal_idx_a32);
72
+ return true;
73
+}
14
diff --git a/target/arm/translate.c b/target/arm/translate.c
74
diff --git a/target/arm/translate.c b/target/arm/translate.c
15
index XXXXXXX..XXXXXXX 100644
75
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate.c
76
--- a/target/arm/translate.c
17
+++ b/target/arm/translate.c
77
+++ b/target/arm/translate.c
18
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
78
@@ -XXX,XX +XXX,XX @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn)
19
loaded_base = 0;
79
}
20
loaded_var = NULL;
80
21
n = 0;
81
#define VFP_REG_SHR(x, n) (((n) > 0) ? (x) >> (n) : (x) << -(n))
22
- for(i=0;i<16;i++) {
82
-#define VFP_SREG(insn, bigbit, smallbit) \
23
+ for (i = 0; i < 16; i++) {
83
- ((VFP_REG_SHR(insn, bigbit - 1) & 0x1e) | (((insn) >> (smallbit)) & 1))
24
if (insn & (1 << i))
84
#define VFP_DREG(reg, insn, bigbit, smallbit) do { \
25
n++;
85
if (dc_isar_feature(aa32_simd_r32, s)) { \
26
}
86
reg = (((insn) >> (bigbit)) & 0x0f) \
87
@@ -XXX,XX +XXX,XX @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn)
88
reg = ((insn) >> (bigbit)) & 0x0f; \
89
}} while (0)
90
91
-#define VFP_SREG_D(insn) VFP_SREG(insn, 12, 22)
92
#define VFP_DREG_D(reg, insn) VFP_DREG(reg, insn, 12, 22)
93
-#define VFP_SREG_N(insn) VFP_SREG(insn, 16, 7)
94
#define VFP_DREG_N(reg, insn) VFP_DREG(reg, insn, 16, 7)
95
-#define VFP_SREG_M(insn) VFP_SREG(insn, 0, 5)
96
#define VFP_DREG_M(reg, insn) VFP_DREG(reg, insn, 0, 5)
97
98
static void gen_neon_dup_low16(TCGv_i32 var)
99
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
100
return 0;
101
}
102
103
-/* Advanced SIMD two registers and a scalar extension.
104
- * 31 24 23 22 20 16 12 11 10 9 8 3 0
105
- * +-----------------+----+---+----+----+----+---+----+---+----+---------+----+
106
- * | 1 1 1 1 1 1 1 0 | o1 | D | o2 | Vn | Vd | 1 | o3 | 0 | o4 | N Q M U | Vm |
107
- * +-----------------+----+---+----+----+----+---+----+---+----+---------+----+
108
- *
109
- */
110
-
111
-static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
112
-{
113
- gen_helper_gvec_3 *fn_gvec = NULL;
114
- gen_helper_gvec_3_ptr *fn_gvec_ptr = NULL;
115
- int rd, rn, rm, opr_sz, data;
116
- int off_rn, off_rm;
117
- bool is_long = false, q = extract32(insn, 6, 1);
118
- bool ptr_is_env = false;
119
-
120
- if ((insn & 0xffa00f10) == 0xfe000810) {
121
- /* VFM[AS]L -- 1111 1110 0.0S .... .... 1000 .Q.1 .... */
122
- int is_s = extract32(insn, 20, 1);
123
- int vm20 = extract32(insn, 0, 3);
124
- int vm3 = extract32(insn, 3, 1);
125
- int m = extract32(insn, 5, 1);
126
- int index;
127
-
128
- if (!dc_isar_feature(aa32_fhm, s)) {
129
- return 1;
130
- }
131
- if (q) {
132
- rm = vm20;
133
- index = m * 2 + vm3;
134
- } else {
135
- rm = vm20 * 2 + m;
136
- index = vm3;
137
- }
138
- is_long = true;
139
- data = (index << 2) | is_s; /* is_2 == 0 */
140
- fn_gvec_ptr = gen_helper_gvec_fmlal_idx_a32;
141
- ptr_is_env = true;
142
- } else {
143
- return 1;
144
- }
145
-
146
- VFP_DREG_D(rd, insn);
147
- if (rd & q) {
148
- return 1;
149
- }
150
- if (q || !is_long) {
151
- VFP_DREG_N(rn, insn);
152
- if (rn & q & !is_long) {
153
- return 1;
154
- }
155
- off_rn = vfp_reg_offset(1, rn);
156
- off_rm = vfp_reg_offset(1, rm);
157
- } else {
158
- rn = VFP_SREG_N(insn);
159
- off_rn = vfp_reg_offset(0, rn);
160
- off_rm = vfp_reg_offset(0, rm);
161
- }
162
- if (s->fp_excp_el) {
163
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
164
- syn_simd_access_trap(1, 0xe, false), s->fp_excp_el);
165
- return 0;
166
- }
167
- if (!s->vfp_enabled) {
168
- return 1;
169
- }
170
-
171
- opr_sz = (1 + q) * 8;
172
- if (fn_gvec_ptr) {
173
- TCGv_ptr ptr;
174
- if (ptr_is_env) {
175
- ptr = cpu_env;
176
- } else {
177
- ptr = get_fpstatus_ptr(1);
178
- }
179
- tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd), off_rn, off_rm, ptr,
180
- opr_sz, opr_sz, data, fn_gvec_ptr);
181
- if (!ptr_is_env) {
182
- tcg_temp_free_ptr(ptr);
183
- }
184
- } else {
185
- tcg_gen_gvec_3_ool(vfp_reg_offset(1, rd), off_rn, off_rm,
186
- opr_sz, opr_sz, data, fn_gvec);
187
- }
188
- return 0;
189
-}
190
-
191
static int disas_coproc_insn(DisasContext *s, uint32_t insn)
192
{
193
int cpnum, is64, crn, crm, opc1, opc2, isread, rt, rt2;
27
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
194
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
28
}
195
}
29
}
196
}
30
j = 0;
197
}
31
- for(i=0;i<16;i++) {
198
- } else if ((insn & 0x0f000a00) == 0x0e000800
32
+ for (i = 0; i < 16; i++) {
199
- && arm_dc_feature(s, ARM_FEATURE_V8)) {
33
if (insn & (1 << i)) {
200
- if (disas_neon_insn_2reg_scalar_ext(s, insn)) {
34
if (is_load) {
201
- goto illegal_op;
35
/* load */
202
- }
36
@@ -XXX,XX +XXX,XX @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags)
203
- return;
37
return;
204
}
205
goto illegal_op;
38
}
206
}
39
207
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
40
- for(i=0;i<16;i++) {
208
}
41
+ for (i = 0; i < 16; i++) {
209
break;
42
qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]);
210
}
43
- if ((i % 4) == 3)
211
- if ((insn & 0xff000a00) == 0xfe000800
44
+ if ((i % 4) == 3) {
212
- && arm_dc_feature(s, ARM_FEATURE_V8)) {
45
qemu_fprintf(f, "\n");
213
- /* The Thumb2 and ARM encodings are identical. */
46
- else
214
- if (disas_neon_insn_2reg_scalar_ext(s, insn)) {
47
+ } else {
215
- goto illegal_op;
48
qemu_fprintf(f, " ");
216
- }
49
+ }
217
- } else if (((insn >> 24) & 3) == 3) {
50
}
218
+ if (((insn >> 24) & 3) == 3) {
51
219
/* Translate into the equivalent ARM encoding. */
52
if (arm_feature(env, ARM_FEATURE_M)) {
220
insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4) | (1 << 28);
53
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
221
if (disas_neon_data_insn(s, insn)) {
54
index XXXXXXX..XXXXXXX 100644
55
--- a/target/arm/vfp_helper.c
56
+++ b/target/arm/vfp_helper.c
57
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_from_host(int host_bits)
58
{
59
int target_bits = 0;
60
61
- if (host_bits & float_flag_invalid)
62
+ if (host_bits & float_flag_invalid) {
63
target_bits |= 1;
64
- if (host_bits & float_flag_divbyzero)
65
+ }
66
+ if (host_bits & float_flag_divbyzero) {
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
--
222
--
120
2.20.1
223
2.20.1
121
224
122
225
diff view generated by jsdifflib
1
From: Eddie James <eajames@linux.ibm.com>
1
Convert the Neon "load/store multiple structures" insns to decodetree.
2
2
3
The XDMA engine embedded in the Aspeed SOCs performs PCI DMA operations
4
between the SOC (acting as a BMC) and a host processor in a server.
5
6
The XDMA engine exists on the AST2400, AST2500, and AST2600 SOCs, so
7
enable it for all of those. Add trace events on the important register
8
writes in the XDMA engine.
9
10
Signed-off-by: Eddie James <eajames@linux.ibm.com>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Signed-off-by: Cédric Le Goater <clg@kaod.org>
13
Message-id: 20190618165311.27066-21-clg@kaod.org
14
[clg: - changed title ]
15
Signed-off-by: Cédric Le Goater <clg@kaod.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20200430181003.21682-12-peter.maydell@linaro.org
17
---
6
---
18
hw/misc/Makefile.objs | 1 +
7
target/arm/neon-ls.decode | 7 ++
19
include/hw/arm/aspeed_soc.h | 3 +
8
target/arm/translate-neon.inc.c | 124 ++++++++++++++++++++++++++++++++
20
include/hw/misc/aspeed_xdma.h | 30 +++++++
9
target/arm/translate.c | 91 +----------------------
21
hw/arm/aspeed_soc.c | 17 ++++
10
3 files changed, 133 insertions(+), 89 deletions(-)
22
hw/misc/aspeed_xdma.c | 165 ++++++++++++++++++++++++++++++++++
11
23
hw/misc/trace-events | 3 +
12
diff --git a/target/arm/neon-ls.decode b/target/arm/neon-ls.decode
24
6 files changed, 219 insertions(+)
25
create mode 100644 include/hw/misc/aspeed_xdma.h
26
create mode 100644 hw/misc/aspeed_xdma.c
27
28
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
29
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/misc/Makefile.objs
14
--- a/target/arm/neon-ls.decode
31
+++ b/hw/misc/Makefile.objs
15
+++ b/target/arm/neon-ls.decode
32
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_ARMSSE_MHU) += armsse-mhu.o
16
@@ -XXX,XX +XXX,XX @@
33
17
# 0b1111_1001_xxx0_xxxx_xxxx_xxxx_xxxx_xxxx
34
obj-$(CONFIG_PVPANIC) += pvpanic.o
18
# This file works on the A32 encoding only; calling code for T32 has to
35
obj-$(CONFIG_AUX) += auxbus.o
19
# transform the insn into the A32 version first.
36
+obj-$(CONFIG_ASPEED_SOC) += aspeed_xdma.o
20
+
37
obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o
21
+%vd_dp 22:1 12:4
38
obj-$(CONFIG_MSF2) += msf2-sysreg.o
22
+
39
obj-$(CONFIG_NRF51_SOC) += nrf51_rng.o
23
+# Neon load/store multiple structures
40
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
24
+
25
+VLDST_multiple 1111 0100 0 . l:1 0 rn:4 .... itype:4 size:2 align:2 rm:4 \
26
+ vd=%vd_dp
27
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
41
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
42
--- a/include/hw/arm/aspeed_soc.h
29
--- a/target/arm/translate-neon.inc.c
43
+++ b/include/hw/arm/aspeed_soc.h
30
+++ b/target/arm/translate-neon.inc.c
44
@@ -XXX,XX +XXX,XX @@
31
@@ -XXX,XX +XXX,XX @@ static bool trans_VFML_scalar(DisasContext *s, arg_VFML_scalar *a)
45
#include "hw/intc/aspeed_vic.h"
32
gen_helper_gvec_fmlal_idx_a32);
46
#include "hw/misc/aspeed_scu.h"
33
return true;
47
#include "hw/misc/aspeed_sdmc.h"
48
+#include "hw/misc/aspeed_xdma.h"
49
#include "hw/timer/aspeed_timer.h"
50
#include "hw/timer/aspeed_rtc.h"
51
#include "hw/i2c/aspeed_i2c.h"
52
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState {
53
AspeedTimerCtrlState timerctrl;
54
AspeedI2CState i2c;
55
AspeedSCUState scu;
56
+ AspeedXDMAState xdma;
57
AspeedSMCState fmc;
58
AspeedSMCState spi[ASPEED_SPIS_NUM];
59
AspeedSDMCState sdmc;
60
@@ -XXX,XX +XXX,XX @@ enum {
61
ASPEED_ETH1,
62
ASPEED_ETH2,
63
ASPEED_SDRAM,
64
+ ASPEED_XDMA,
65
};
66
67
#endif /* ASPEED_SOC_H */
68
diff --git a/include/hw/misc/aspeed_xdma.h b/include/hw/misc/aspeed_xdma.h
69
new file mode 100644
70
index XXXXXXX..XXXXXXX
71
--- /dev/null
72
+++ b/include/hw/misc/aspeed_xdma.h
73
@@ -XXX,XX +XXX,XX @@
74
+/*
75
+ * ASPEED XDMA Controller
76
+ * Eddie James <eajames@linux.ibm.com>
77
+ *
78
+ * Copyright (C) 2019 IBM Corp.
79
+ * SPDX-License-Identifer: GPL-2.0-or-later
80
+ */
81
+
82
+#ifndef ASPEED_XDMA_H
83
+#define ASPEED_XDMA_H
84
+
85
+#include "hw/sysbus.h"
86
+
87
+#define TYPE_ASPEED_XDMA "aspeed.xdma"
88
+#define ASPEED_XDMA(obj) OBJECT_CHECK(AspeedXDMAState, (obj), TYPE_ASPEED_XDMA)
89
+
90
+#define ASPEED_XDMA_NUM_REGS (ASPEED_XDMA_REG_SIZE / sizeof(uint32_t))
91
+#define ASPEED_XDMA_REG_SIZE 0x7C
92
+
93
+typedef struct AspeedXDMAState {
94
+ SysBusDevice parent;
95
+
96
+ MemoryRegion iomem;
97
+ qemu_irq irq;
98
+
99
+ char bmc_cmdq_readp_set;
100
+ uint32_t regs[ASPEED_XDMA_NUM_REGS];
101
+} AspeedXDMAState;
102
+
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
106
--- a/hw/arm/aspeed_soc.c
107
+++ b/hw/arm/aspeed_soc.c
108
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2400_memmap[] = {
109
[ASPEED_VIC] = 0x1E6C0000,
110
[ASPEED_SDMC] = 0x1E6E0000,
111
[ASPEED_SCU] = 0x1E6E2000,
112
+ [ASPEED_XDMA] = 0x1E6E7000,
113
[ASPEED_ADC] = 0x1E6E9000,
114
[ASPEED_SRAM] = 0x1E720000,
115
[ASPEED_GPIO] = 0x1E780000,
116
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2500_memmap[] = {
117
[ASPEED_VIC] = 0x1E6C0000,
118
[ASPEED_SDMC] = 0x1E6E0000,
119
[ASPEED_SCU] = 0x1E6E2000,
120
+ [ASPEED_XDMA] = 0x1E6E7000,
121
[ASPEED_ADC] = 0x1E6E9000,
122
[ASPEED_SRAM] = 0x1E720000,
123
[ASPEED_GPIO] = 0x1E780000,
124
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2400_irqmap[] = {
125
[ASPEED_I2C] = 12,
126
[ASPEED_ETH1] = 2,
127
[ASPEED_ETH2] = 3,
128
+ [ASPEED_XDMA] = 6,
129
};
130
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
}
34
}
140
35
+
141
static void aspeed_soc_realize(DeviceState *dev, Error **errp)
36
+static struct {
142
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
37
+ int nregs;
143
sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0,
38
+ int interleave;
144
aspeed_soc_get_irq(s, ASPEED_ETH1 + i));
39
+ int spacing;
145
}
40
+} const neon_ls_element_type[11] = {
146
+
41
+ {1, 4, 1},
147
+ /* XDMA */
42
+ {1, 4, 2},
148
+ object_property_set_bool(OBJECT(&s->xdma), true, "realized", &err);
43
+ {4, 1, 1},
149
+ if (err) {
44
+ {2, 2, 2},
150
+ error_propagate(errp, err);
45
+ {1, 3, 1},
151
+ return;
46
+ {1, 3, 2},
152
+ }
47
+ {3, 1, 1},
153
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->xdma), 0,
48
+ {1, 1, 1},
154
+ sc->info->memmap[ASPEED_XDMA]);
49
+ {1, 2, 1},
155
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0,
50
+ {1, 2, 2},
156
+ aspeed_soc_get_irq(s, ASPEED_XDMA));
51
+ {2, 1, 1}
157
}
52
+};
158
static Property aspeed_soc_properties[] = {
53
+
159
DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0),
54
+static void gen_neon_ldst_base_update(DisasContext *s, int rm, int rn,
160
diff --git a/hw/misc/aspeed_xdma.c b/hw/misc/aspeed_xdma.c
55
+ int stride)
161
new file mode 100644
162
index XXXXXXX..XXXXXXX
163
--- /dev/null
164
+++ b/hw/misc/aspeed_xdma.c
165
@@ -XXX,XX +XXX,XX @@
166
+/*
167
+ * ASPEED XDMA Controller
168
+ * Eddie James <eajames@linux.ibm.com>
169
+ *
170
+ * Copyright (C) 2019 IBM Corp
171
+ * SPDX-License-Identifer: GPL-2.0-or-later
172
+ */
173
+
174
+#include "qemu/osdep.h"
175
+#include "qemu/log.h"
176
+#include "qemu/error-report.h"
177
+#include "hw/misc/aspeed_xdma.h"
178
+#include "qapi/error.h"
179
+
180
+#include "trace.h"
181
+
182
+#define XDMA_BMC_CMDQ_ADDR 0x10
183
+#define XDMA_BMC_CMDQ_ENDP 0x14
184
+#define XDMA_BMC_CMDQ_WRP 0x18
185
+#define XDMA_BMC_CMDQ_W_MASK 0x0003FFFF
186
+#define XDMA_BMC_CMDQ_RDP 0x1C
187
+#define XDMA_BMC_CMDQ_RDP_MAGIC 0xEE882266
188
+#define XDMA_IRQ_ENG_CTRL 0x20
189
+#define XDMA_IRQ_ENG_CTRL_US_COMP BIT(4)
190
+#define XDMA_IRQ_ENG_CTRL_DS_COMP BIT(5)
191
+#define XDMA_IRQ_ENG_CTRL_W_MASK 0xBFEFF07F
192
+#define XDMA_IRQ_ENG_STAT 0x24
193
+#define XDMA_IRQ_ENG_STAT_US_COMP BIT(4)
194
+#define XDMA_IRQ_ENG_STAT_DS_COMP BIT(5)
195
+#define XDMA_IRQ_ENG_STAT_RESET 0xF8000000
196
+#define XDMA_MEM_SIZE 0x1000
197
+
198
+#define TO_REG(addr) ((addr) / sizeof(uint32_t))
199
+
200
+static uint64_t aspeed_xdma_read(void *opaque, hwaddr addr, unsigned int size)
201
+{
56
+{
202
+ uint32_t val = 0;
57
+ if (rm != 15) {
203
+ AspeedXDMAState *xdma = opaque;
58
+ TCGv_i32 base;
204
+
59
+
205
+ if (addr < ASPEED_XDMA_REG_SIZE) {
60
+ base = load_reg(s, rn);
206
+ val = xdma->regs[TO_REG(addr)];
61
+ if (rm == 13) {
207
+ }
62
+ tcg_gen_addi_i32(base, base, stride);
208
+
63
+ } else {
209
+ return (uint64_t)val;
64
+ TCGv_i32 index;
65
+ index = load_reg(s, rm);
66
+ tcg_gen_add_i32(base, base, index);
67
+ tcg_temp_free_i32(index);
68
+ }
69
+ store_reg(s, rn, base);
70
+ }
210
+}
71
+}
211
+
72
+
212
+static void aspeed_xdma_write(void *opaque, hwaddr addr, uint64_t val,
73
+static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a)
213
+ unsigned int size)
214
+{
74
+{
215
+ unsigned int idx;
75
+ /* Neon load/store multiple structures */
216
+ uint32_t val32 = (uint32_t)val;
76
+ int nregs, interleave, spacing, reg, n;
217
+ AspeedXDMAState *xdma = opaque;
77
+ MemOp endian = s->be_data;
218
+
78
+ int mmu_idx = get_mem_index(s);
219
+ if (addr >= ASPEED_XDMA_REG_SIZE) {
79
+ int size = a->size;
220
+ return;
80
+ TCGv_i64 tmp64;
221
+ }
81
+ TCGv_i32 addr, tmp;
222
+
82
+
223
+ switch (addr) {
83
+ if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
224
+ case XDMA_BMC_CMDQ_ENDP:
84
+ return false;
225
+ xdma->regs[TO_REG(addr)] = val32 & XDMA_BMC_CMDQ_W_MASK;
85
+ }
86
+
87
+ /* UNDEF accesses to D16-D31 if they don't exist */
88
+ if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) {
89
+ return false;
90
+ }
91
+ if (a->itype > 10) {
92
+ return false;
93
+ }
94
+ /* Catch UNDEF cases for bad values of align field */
95
+ switch (a->itype & 0xc) {
96
+ case 4:
97
+ if (a->align >= 2) {
98
+ return false;
99
+ }
226
+ break;
100
+ break;
227
+ case XDMA_BMC_CMDQ_WRP:
101
+ case 8:
228
+ idx = TO_REG(addr);
102
+ if (a->align == 3) {
229
+ xdma->regs[idx] = val32 & XDMA_BMC_CMDQ_W_MASK;
103
+ return false;
230
+ xdma->regs[TO_REG(XDMA_BMC_CMDQ_RDP)] = xdma->regs[idx];
231
+
232
+ trace_aspeed_xdma_write(addr, val);
233
+
234
+ if (xdma->bmc_cmdq_readp_set) {
235
+ xdma->bmc_cmdq_readp_set = 0;
236
+ } else {
237
+ xdma->regs[TO_REG(XDMA_IRQ_ENG_STAT)] |=
238
+ XDMA_IRQ_ENG_STAT_US_COMP | XDMA_IRQ_ENG_STAT_DS_COMP;
239
+
240
+ if (xdma->regs[TO_REG(XDMA_IRQ_ENG_CTRL)] &
241
+ (XDMA_IRQ_ENG_CTRL_US_COMP | XDMA_IRQ_ENG_CTRL_DS_COMP))
242
+ qemu_irq_raise(xdma->irq);
243
+ }
244
+ break;
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
+ }
104
+ }
264
+ break;
105
+ break;
265
+ default:
106
+ default:
266
+ xdma->regs[TO_REG(addr)] = val32;
267
+ break;
107
+ break;
268
+ }
108
+ }
109
+ nregs = neon_ls_element_type[a->itype].nregs;
110
+ interleave = neon_ls_element_type[a->itype].interleave;
111
+ spacing = neon_ls_element_type[a->itype].spacing;
112
+ if (size == 3 && (interleave | spacing) != 1) {
113
+ return false;
114
+ }
115
+
116
+ if (!vfp_access_check(s)) {
117
+ return true;
118
+ }
119
+
120
+ /* For our purposes, bytes are always little-endian. */
121
+ if (size == 0) {
122
+ endian = MO_LE;
123
+ }
124
+ /*
125
+ * Consecutive little-endian elements from a single register
126
+ * can be promoted to a larger little-endian operation.
127
+ */
128
+ if (interleave == 1 && endian == MO_LE) {
129
+ size = 3;
130
+ }
131
+ tmp64 = tcg_temp_new_i64();
132
+ addr = tcg_temp_new_i32();
133
+ tmp = tcg_const_i32(1 << size);
134
+ load_reg_var(s, addr, a->rn);
135
+ for (reg = 0; reg < nregs; reg++) {
136
+ for (n = 0; n < 8 >> size; n++) {
137
+ int xs;
138
+ for (xs = 0; xs < interleave; xs++) {
139
+ int tt = a->vd + reg + spacing * xs;
140
+
141
+ if (a->l) {
142
+ gen_aa32_ld_i64(s, tmp64, addr, mmu_idx, endian | size);
143
+ neon_store_element64(tt, n, size, tmp64);
144
+ } else {
145
+ neon_load_element64(tmp64, tt, n, size);
146
+ gen_aa32_st_i64(s, tmp64, addr, mmu_idx, endian | size);
147
+ }
148
+ tcg_gen_add_i32(addr, addr, tmp);
149
+ }
150
+ }
151
+ }
152
+ tcg_temp_free_i32(addr);
153
+ tcg_temp_free_i32(tmp);
154
+ tcg_temp_free_i64(tmp64);
155
+
156
+ gen_neon_ldst_base_update(s, a->rm, a->rn, nregs * interleave * 8);
157
+ return true;
269
+}
158
+}
270
+
159
diff --git a/target/arm/translate.c b/target/arm/translate.c
271
+static const MemoryRegionOps aspeed_xdma_ops = {
272
+ .read = aspeed_xdma_read,
273
+ .write = aspeed_xdma_write,
274
+ .endianness = DEVICE_NATIVE_ENDIAN,
275
+ .valid.min_access_size = 4,
276
+ .valid.max_access_size = 4,
277
+};
278
+
279
+static void aspeed_xdma_realize(DeviceState *dev, Error **errp)
280
+{
281
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
282
+ AspeedXDMAState *xdma = ASPEED_XDMA(dev);
283
+
284
+ sysbus_init_irq(sbd, &xdma->irq);
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
+ },
308
+};
309
+
310
+static void aspeed_xdma_class_init(ObjectClass *classp, void *data)
311
+{
312
+ DeviceClass *dc = DEVICE_CLASS(classp);
313
+
314
+ dc->realize = aspeed_xdma_realize;
315
+ dc->reset = aspeed_xdma_reset;
316
+ dc->vmsd = &aspeed_xdma_vmstate;
317
+}
318
+
319
+static const TypeInfo aspeed_xdma_info = {
320
+ .name = TYPE_ASPEED_XDMA,
321
+ .parent = TYPE_SYS_BUS_DEVICE,
322
+ .instance_size = sizeof(AspeedXDMAState),
323
+ .class_init = aspeed_xdma_class_init,
324
+};
325
+
326
+static void aspeed_xdma_register_type(void)
327
+{
328
+ type_register_static(&aspeed_xdma_info);
329
+}
330
+type_init(aspeed_xdma_register_type);
331
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
332
index XXXXXXX..XXXXXXX 100644
160
index XXXXXXX..XXXXXXX 100644
333
--- a/hw/misc/trace-events
161
--- a/target/arm/translate.c
334
+++ b/hw/misc/trace-events
162
+++ b/target/arm/translate.c
335
@@ -XXX,XX +XXX,XX @@ armsse_cpuid_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 CPU_I
163
@@ -XXX,XX +XXX,XX @@ static void gen_neon_trn_u16(TCGv_i32 t0, TCGv_i32 t1)
336
# armsse-mhu.c
164
}
337
armsse_mhu_read(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
165
338
armsse_mhu_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
166
339
+
167
-static struct {
340
+# aspeed_xdma.c
168
- int nregs;
341
+aspeed_xdma_write(uint64_t offset, uint64_t data) "XDMA write: offset 0x%" PRIx64 " data 0x%" PRIx64
169
- int interleave;
170
- int spacing;
171
-} const neon_ls_element_type[11] = {
172
- {1, 4, 1},
173
- {1, 4, 2},
174
- {4, 1, 1},
175
- {2, 2, 2},
176
- {1, 3, 1},
177
- {1, 3, 2},
178
- {3, 1, 1},
179
- {1, 1, 1},
180
- {1, 2, 1},
181
- {1, 2, 2},
182
- {2, 1, 1}
183
-};
184
-
185
/* Translate a NEON load/store element instruction. Return nonzero if the
186
instruction is invalid. */
187
static int disas_neon_ls_insn(DisasContext *s, uint32_t insn)
188
{
189
int rd, rn, rm;
190
- int op;
191
int nregs;
192
- int interleave;
193
- int spacing;
194
int stride;
195
int size;
196
int reg;
197
int load;
198
- int n;
199
int vec_size;
200
- int mmu_idx;
201
- MemOp endian;
202
TCGv_i32 addr;
203
TCGv_i32 tmp;
204
- TCGv_i32 tmp2;
205
- TCGv_i64 tmp64;
206
207
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
208
return 1;
209
@@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn)
210
rn = (insn >> 16) & 0xf;
211
rm = insn & 0xf;
212
load = (insn & (1 << 21)) != 0;
213
- endian = s->be_data;
214
- mmu_idx = get_mem_index(s);
215
if ((insn & (1 << 23)) == 0) {
216
- /* Load store all elements. */
217
- op = (insn >> 8) & 0xf;
218
- size = (insn >> 6) & 3;
219
- if (op > 10)
220
- return 1;
221
- /* Catch UNDEF cases for bad values of align field */
222
- switch (op & 0xc) {
223
- case 4:
224
- if (((insn >> 5) & 1) == 1) {
225
- return 1;
226
- }
227
- break;
228
- case 8:
229
- if (((insn >> 4) & 3) == 3) {
230
- return 1;
231
- }
232
- break;
233
- default:
234
- break;
235
- }
236
- nregs = neon_ls_element_type[op].nregs;
237
- interleave = neon_ls_element_type[op].interleave;
238
- spacing = neon_ls_element_type[op].spacing;
239
- if (size == 3 && (interleave | spacing) != 1) {
240
- return 1;
241
- }
242
- /* For our purposes, bytes are always little-endian. */
243
- if (size == 0) {
244
- endian = MO_LE;
245
- }
246
- /* Consecutive little-endian elements from a single register
247
- * can be promoted to a larger little-endian operation.
248
- */
249
- if (interleave == 1 && endian == MO_LE) {
250
- size = 3;
251
- }
252
- tmp64 = tcg_temp_new_i64();
253
- addr = tcg_temp_new_i32();
254
- tmp2 = tcg_const_i32(1 << size);
255
- load_reg_var(s, addr, rn);
256
- for (reg = 0; reg < nregs; reg++) {
257
- for (n = 0; n < 8 >> size; n++) {
258
- int xs;
259
- for (xs = 0; xs < interleave; xs++) {
260
- int tt = rd + reg + spacing * xs;
261
-
262
- if (load) {
263
- gen_aa32_ld_i64(s, tmp64, addr, mmu_idx, endian | size);
264
- neon_store_element64(tt, n, size, tmp64);
265
- } else {
266
- neon_load_element64(tmp64, tt, n, size);
267
- gen_aa32_st_i64(s, tmp64, addr, mmu_idx, endian | size);
268
- }
269
- tcg_gen_add_i32(addr, addr, tmp2);
270
- }
271
- }
272
- }
273
- tcg_temp_free_i32(addr);
274
- tcg_temp_free_i32(tmp2);
275
- tcg_temp_free_i64(tmp64);
276
- stride = nregs * interleave * 8;
277
+ /* Load store all elements -- handled already by decodetree */
278
+ return 1;
279
} else {
280
size = (insn >> 10) & 3;
281
if (size == 3) {
342
--
282
--
343
2.20.1
283
2.20.1
344
284
345
285
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Convert the Neon "load single structure to all lanes" insns to
2
decodetree.
2
3
3
The vfp_set_fpscr() helper contains code specific to the host
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
floating point implementation (here the SoftFloat library).
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Extract this code to vfp_set_fpscr_to_host().
6
Message-id: 20200430181003.21682-13-peter.maydell@linaro.org
7
---
8
target/arm/neon-ls.decode | 5 +++
9
target/arm/translate-neon.inc.c | 73 +++++++++++++++++++++++++++++++++
10
target/arm/translate.c | 55 +------------------------
11
3 files changed, 80 insertions(+), 53 deletions(-)
6
12
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
diff --git a/target/arm/neon-ls.decode b/target/arm/neon-ls.decode
8
Message-id: 20190701132516.26392-16-philmd@redhat.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/vfp_helper.c | 127 +++++++++++++++++++++-------------------
13
1 file changed, 66 insertions(+), 61 deletions(-)
14
15
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
16
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/vfp_helper.c
15
--- a/target/arm/neon-ls.decode
18
+++ b/target/arm/vfp_helper.c
16
+++ b/target/arm/neon-ls.decode
19
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits)
17
@@ -XXX,XX +XXX,XX @@
20
return host_bits;
18
19
VLDST_multiple 1111 0100 0 . l:1 0 rn:4 .... itype:4 size:2 align:2 rm:4 \
20
vd=%vd_dp
21
+
22
+# Neon load single element to all lanes
23
+
24
+VLD_all_lanes 1111 0100 1 . 1 0 rn:4 .... 11 n:2 size:2 t:1 a:1 rm:4 \
25
+ vd=%vd_dp
26
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
27
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/translate-neon.inc.c
29
+++ b/target/arm/translate-neon.inc.c
30
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a)
31
gen_neon_ldst_base_update(s, a->rm, a->rn, nregs * interleave * 8);
32
return true;
21
}
33
}
22
34
+
23
-uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
35
+static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a)
24
-{
25
- uint32_t i, fpscr;
26
-
27
- fpscr = env->vfp.xregs[ARM_VFP_FPSCR]
28
- | (env->vfp.vec_len << 16)
29
- | (env->vfp.vec_stride << 20);
30
-
31
- i = get_float_exception_flags(&env->vfp.fp_status);
32
- i |= get_float_exception_flags(&env->vfp.standard_fp_status);
33
- /* FZ16 does not generate an input denormal exception. */
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
+{
36
+{
98
+ uint32_t i, fpscr;
37
+ /* Neon load single structure to all lanes */
38
+ int reg, stride, vec_size;
39
+ int vd = a->vd;
40
+ int size = a->size;
41
+ int nregs = a->n + 1;
42
+ TCGv_i32 addr, tmp;
99
+
43
+
100
+ fpscr = env->vfp.xregs[ARM_VFP_FPSCR]
44
+ if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
101
+ | (env->vfp.vec_len << 16)
45
+ return false;
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
+ }
46
+ }
128
+
47
+
129
+ if (arm_feature(env, ARM_FEATURE_M)) {
48
+ /* UNDEF accesses to D16-D31 if they don't exist */
130
+ /*
49
+ if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) {
131
+ * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits
50
+ return false;
132
+ * and also for the trapped-exception-handling bits IxE.
51
+ }
133
+ */
52
+
134
+ val &= 0xf7c0009f;
53
+ if (size == 3) {
54
+ if (nregs != 4 || a->a == 0) {
55
+ return false;
56
+ }
57
+ /* For VLD4 size == 3 a == 1 means 32 bits at 16 byte alignment */
58
+ size = 2;
59
+ }
60
+ if (nregs == 1 && a->a == 1 && size == 0) {
61
+ return false;
62
+ }
63
+ if (nregs == 3 && a->a == 1) {
64
+ return false;
65
+ }
66
+
67
+ if (!vfp_access_check(s)) {
68
+ return true;
135
+ }
69
+ }
136
+
70
+
137
+ /*
71
+ /*
138
+ * We don't implement trapped exception handling, so the
72
+ * VLD1 to all lanes: T bit indicates how many Dregs to write.
139
+ * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!)
73
+ * VLD2/3/4 to all lanes: T bit indicates register stride.
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
+ */
74
+ */
145
+ env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000;
75
+ stride = a->t ? 2 : 1;
146
+ env->vfp.vec_len = (val >> 16) & 7;
76
+ vec_size = nregs == 1 ? stride * 8 : 8;
147
+ env->vfp.vec_stride = (val >> 20) & 3;
148
+
77
+
149
+ /*
78
+ tmp = tcg_temp_new_i32();
150
+ * The bit we set within fpscr_q is arbitrary; the register as a
79
+ addr = tcg_temp_new_i32();
151
+ * whole being zero/non-zero is what counts.
80
+ load_reg_var(s, addr, a->rn);
152
+ */
81
+ for (reg = 0; reg < nregs; reg++) {
153
+ env->vfp.qc[0] = val & FPCR_QC;
82
+ gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s),
154
+ env->vfp.qc[1] = 0;
83
+ s->be_data | size);
155
+ env->vfp.qc[2] = 0;
84
+ if ((vd & 1) && vec_size == 16) {
156
+ env->vfp.qc[3] = 0;
85
+ /*
86
+ * We cannot write 16 bytes at once because the
87
+ * destination is unaligned.
88
+ */
89
+ tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0),
90
+ 8, 8, tmp);
91
+ tcg_gen_gvec_mov(0, neon_reg_offset(vd + 1, 0),
92
+ neon_reg_offset(vd, 0), 8, 8);
93
+ } else {
94
+ tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0),
95
+ vec_size, vec_size, tmp);
96
+ }
97
+ tcg_gen_addi_i32(addr, addr, 1 << size);
98
+ vd += stride;
99
+ }
100
+ tcg_temp_free_i32(tmp);
101
+ tcg_temp_free_i32(addr);
157
+
102
+
158
+ vfp_set_fpscr_to_host(env, val);
103
+ gen_neon_ldst_base_update(s, a->rm, a->rn, (1 << size) * nregs);
104
+
105
+ return true;
159
+}
106
+}
160
+
107
diff --git a/target/arm/translate.c b/target/arm/translate.c
161
void vfp_set_fpscr(CPUARMState *env, uint32_t val)
108
index XXXXXXX..XXXXXXX 100644
162
{
109
--- a/target/arm/translate.c
163
HELPER(vfp_set_fpscr)(env, val);
110
+++ b/target/arm/translate.c
111
@@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn)
112
int size;
113
int reg;
114
int load;
115
- int vec_size;
116
TCGv_i32 addr;
117
TCGv_i32 tmp;
118
119
@@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn)
120
} else {
121
size = (insn >> 10) & 3;
122
if (size == 3) {
123
- /* Load single element to all lanes. */
124
- int a = (insn >> 4) & 1;
125
- if (!load) {
126
- return 1;
127
- }
128
- size = (insn >> 6) & 3;
129
- nregs = ((insn >> 8) & 3) + 1;
130
-
131
- if (size == 3) {
132
- if (nregs != 4 || a == 0) {
133
- return 1;
134
- }
135
- /* For VLD4 size==3 a == 1 means 32 bits at 16 byte alignment */
136
- size = 2;
137
- }
138
- if (nregs == 1 && a == 1 && size == 0) {
139
- return 1;
140
- }
141
- if (nregs == 3 && a == 1) {
142
- return 1;
143
- }
144
- addr = tcg_temp_new_i32();
145
- load_reg_var(s, addr, rn);
146
-
147
- /* VLD1 to all lanes: bit 5 indicates how many Dregs to write.
148
- * VLD2/3/4 to all lanes: bit 5 indicates register stride.
149
- */
150
- stride = (insn & (1 << 5)) ? 2 : 1;
151
- vec_size = nregs == 1 ? stride * 8 : 8;
152
-
153
- tmp = tcg_temp_new_i32();
154
- for (reg = 0; reg < nregs; reg++) {
155
- gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s),
156
- s->be_data | size);
157
- if ((rd & 1) && vec_size == 16) {
158
- /* We cannot write 16 bytes at once because the
159
- * destination is unaligned.
160
- */
161
- tcg_gen_gvec_dup_i32(size, neon_reg_offset(rd, 0),
162
- 8, 8, tmp);
163
- tcg_gen_gvec_mov(0, neon_reg_offset(rd + 1, 0),
164
- neon_reg_offset(rd, 0), 8, 8);
165
- } else {
166
- tcg_gen_gvec_dup_i32(size, neon_reg_offset(rd, 0),
167
- vec_size, vec_size, tmp);
168
- }
169
- tcg_gen_addi_i32(addr, addr, 1 << size);
170
- rd += stride;
171
- }
172
- tcg_temp_free_i32(tmp);
173
- tcg_temp_free_i32(addr);
174
- stride = (1 << size) * nregs;
175
+ /* Load single element to all lanes -- handled by decodetree */
176
+ return 1;
177
} else {
178
/* Single element. */
179
int idx = (insn >> 4) & 0xf;
164
--
180
--
165
2.20.1
181
2.20.1
166
182
167
183
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Convert the Neon "load/store single structure to one lane" insns to
2
2
decodetree.
3
In few commits we will split the M-profile functions from this
3
4
file, and this function will also be called in the new file.
4
As this is the last set of insns in the neon load/store group,
5
Declare it in the "internals.h" header.
5
we can remove the whole disas_neon_ls_insn() function.
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.
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>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20200430181003.21682-14-peter.maydell@linaro.org
13
---
10
---
14
target/arm/internals.h | 2 ++
11
target/arm/neon-ls.decode | 11 +++
15
target/arm/helper.c | 76 +++++++++++++++++++++---------------------
12
target/arm/translate-neon.inc.c | 89 +++++++++++++++++++
16
2 files changed, 40 insertions(+), 38 deletions(-)
13
target/arm/translate.c | 147 --------------------------------
17
14
3 files changed, 100 insertions(+), 147 deletions(-)
18
diff --git a/target/arm/internals.h b/target/arm/internals.h
15
16
diff --git a/target/arm/neon-ls.decode b/target/arm/neon-ls.decode
19
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/internals.h
18
--- a/target/arm/neon-ls.decode
21
+++ b/target/arm/internals.h
19
+++ b/target/arm/neon-ls.decode
22
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
20
@@ -XXX,XX +XXX,XX @@ VLDST_multiple 1111 0100 0 . l:1 0 rn:4 .... itype:4 size:2 align:2 rm:4 \
23
target_ulong *page_size,
21
24
ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs);
22
VLD_all_lanes 1111 0100 1 . 1 0 rn:4 .... 11 n:2 size:2 t:1 a:1 rm:4 \
25
23
vd=%vd_dp
26
+void arm_log_exception(int idx);
24
+
27
+
25
+# Neon load/store single structure to one lane
28
#endif /* !CONFIG_USER_ONLY */
26
+%imm1_5_p1 5:1 !function=plus1
29
27
+%imm1_6_p1 6:1 !function=plus1
30
#endif
28
+
31
diff --git a/target/arm/helper.c b/target/arm/helper.c
29
+VLDST_single 1111 0100 1 . l:1 0 rn:4 .... 00 n:2 reg_idx:3 align:1 rm:4 \
30
+ vd=%vd_dp size=0 stride=1
31
+VLDST_single 1111 0100 1 . l:1 0 rn:4 .... 01 n:2 reg_idx:2 align:2 rm:4 \
32
+ vd=%vd_dp size=1 stride=%imm1_5_p1
33
+VLDST_single 1111 0100 1 . l:1 0 rn:4 .... 10 n:2 reg_idx:1 align:3 rm:4 \
34
+ vd=%vd_dp size=2 stride=%imm1_6_p1
35
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
32
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
33
--- a/target/arm/helper.c
37
--- a/target/arm/translate-neon.inc.c
34
+++ b/target/arm/helper.c
38
+++ b/target/arm/translate-neon.inc.c
35
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
39
@@ -XXX,XX +XXX,XX @@
36
return target_el;
40
* It might be possible to convert it to a standalone .c file eventually.
37
}
41
*/
38
42
39
+void arm_log_exception(int idx)
43
+static inline int plus1(DisasContext *s, int x)
40
+{
44
+{
41
+ if (qemu_loglevel_mask(CPU_LOG_INT)) {
45
+ return x + 1;
42
+ const char *exc = NULL;
43
+ static const char * const excnames[] = {
44
+ [EXCP_UDEF] = "Undefined Instruction",
45
+ [EXCP_SWI] = "SVC",
46
+ [EXCP_PREFETCH_ABORT] = "Prefetch Abort",
47
+ [EXCP_DATA_ABORT] = "Data Abort",
48
+ [EXCP_IRQ] = "IRQ",
49
+ [EXCP_FIQ] = "FIQ",
50
+ [EXCP_BKPT] = "Breakpoint",
51
+ [EXCP_EXCEPTION_EXIT] = "QEMU v7M exception exit",
52
+ [EXCP_KERNEL_TRAP] = "QEMU intercept of kernel commpage",
53
+ [EXCP_HVC] = "Hypervisor Call",
54
+ [EXCP_HYP_TRAP] = "Hypervisor Trap",
55
+ [EXCP_SMC] = "Secure Monitor Call",
56
+ [EXCP_VIRQ] = "Virtual IRQ",
57
+ [EXCP_VFIQ] = "Virtual FIQ",
58
+ [EXCP_SEMIHOST] = "Semihosting call",
59
+ [EXCP_NOCP] = "v7M NOCP UsageFault",
60
+ [EXCP_INVSTATE] = "v7M INVSTATE UsageFault",
61
+ [EXCP_STKOF] = "v8M STKOF UsageFault",
62
+ [EXCP_LAZYFP] = "v7M exception during lazy FP stacking",
63
+ [EXCP_LSERR] = "v8M LSERR UsageFault",
64
+ [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault",
65
+ };
66
+
67
+ if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
68
+ exc = excnames[idx];
69
+ }
70
+ if (!exc) {
71
+ exc = "unknown";
72
+ }
73
+ qemu_log_mask(CPU_LOG_INT, "Taking exception %d [%s]\n", idx, exc);
74
+ }
75
+}
46
+}
76
+
47
+
77
/*
48
/* Include the generated Neon decoder */
78
* Return true if the v7M CPACR permits access to the FPU for the specified
49
#include "decode-neon-dp.inc.c"
79
* security state and privilege level.
50
#include "decode-neon-ls.inc.c"
80
@@ -XXX,XX +XXX,XX @@ static bool do_v7m_function_return(ARMCPU *cpu)
51
@@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a)
52
81
return true;
53
return true;
82
}
54
}
83
55
+
84
-static void arm_log_exception(int idx)
56
+static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a)
57
+{
58
+ /* Neon load/store single structure to one lane */
59
+ int reg;
60
+ int nregs = a->n + 1;
61
+ int vd = a->vd;
62
+ TCGv_i32 addr, tmp;
63
+
64
+ if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
65
+ return false;
66
+ }
67
+
68
+ /* UNDEF accesses to D16-D31 if they don't exist */
69
+ if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) {
70
+ return false;
71
+ }
72
+
73
+ /* Catch the UNDEF cases. This is unavoidably a bit messy. */
74
+ switch (nregs) {
75
+ case 1:
76
+ if (((a->align & (1 << a->size)) != 0) ||
77
+ (a->size == 2 && ((a->align & 3) == 1 || (a->align & 3) == 2))) {
78
+ return false;
79
+ }
80
+ break;
81
+ case 3:
82
+ if ((a->align & 1) != 0) {
83
+ return false;
84
+ }
85
+ /* fall through */
86
+ case 2:
87
+ if (a->size == 2 && (a->align & 2) != 0) {
88
+ return false;
89
+ }
90
+ break;
91
+ case 4:
92
+ if ((a->size == 2) && ((a->align & 3) == 3)) {
93
+ return false;
94
+ }
95
+ break;
96
+ default:
97
+ abort();
98
+ }
99
+ if ((vd + a->stride * (nregs - 1)) > 31) {
100
+ /*
101
+ * Attempts to write off the end of the register file are
102
+ * UNPREDICTABLE; we choose to UNDEF because otherwise we would
103
+ * access off the end of the array that holds the register data.
104
+ */
105
+ return false;
106
+ }
107
+
108
+ if (!vfp_access_check(s)) {
109
+ return true;
110
+ }
111
+
112
+ tmp = tcg_temp_new_i32();
113
+ addr = tcg_temp_new_i32();
114
+ load_reg_var(s, addr, a->rn);
115
+ /*
116
+ * TODO: if we implemented alignment exceptions, we should check
117
+ * addr against the alignment encoded in a->align here.
118
+ */
119
+ for (reg = 0; reg < nregs; reg++) {
120
+ if (a->l) {
121
+ gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s),
122
+ s->be_data | a->size);
123
+ neon_store_element(vd, a->reg_idx, a->size, tmp);
124
+ } else { /* Store */
125
+ neon_load_element(tmp, vd, a->reg_idx, a->size);
126
+ gen_aa32_st_i32(s, tmp, addr, get_mem_index(s),
127
+ s->be_data | a->size);
128
+ }
129
+ vd += a->stride;
130
+ tcg_gen_addi_i32(addr, addr, 1 << a->size);
131
+ }
132
+ tcg_temp_free_i32(addr);
133
+ tcg_temp_free_i32(tmp);
134
+
135
+ gen_neon_ldst_base_update(s, a->rm, a->rn, (1 << a->size) * nregs);
136
+
137
+ return true;
138
+}
139
diff --git a/target/arm/translate.c b/target/arm/translate.c
140
index XXXXXXX..XXXXXXX 100644
141
--- a/target/arm/translate.c
142
+++ b/target/arm/translate.c
143
@@ -XXX,XX +XXX,XX @@ static void gen_neon_trn_u16(TCGv_i32 t0, TCGv_i32 t1)
144
tcg_temp_free_i32(rd);
145
}
146
147
-
148
-/* Translate a NEON load/store element instruction. Return nonzero if the
149
- instruction is invalid. */
150
-static int disas_neon_ls_insn(DisasContext *s, uint32_t insn)
85
-{
151
-{
86
- if (qemu_loglevel_mask(CPU_LOG_INT)) {
152
- int rd, rn, rm;
87
- const char *exc = NULL;
153
- int nregs;
88
- static const char * const excnames[] = {
154
- int stride;
89
- [EXCP_UDEF] = "Undefined Instruction",
155
- int size;
90
- [EXCP_SWI] = "SVC",
156
- int reg;
91
- [EXCP_PREFETCH_ABORT] = "Prefetch Abort",
157
- int load;
92
- [EXCP_DATA_ABORT] = "Data Abort",
158
- TCGv_i32 addr;
93
- [EXCP_IRQ] = "IRQ",
159
- TCGv_i32 tmp;
94
- [EXCP_FIQ] = "FIQ",
160
-
95
- [EXCP_BKPT] = "Breakpoint",
161
- if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
96
- [EXCP_EXCEPTION_EXIT] = "QEMU v7M exception exit",
162
- return 1;
97
- [EXCP_KERNEL_TRAP] = "QEMU intercept of kernel commpage",
163
- }
98
- [EXCP_HVC] = "Hypervisor Call",
164
-
99
- [EXCP_HYP_TRAP] = "Hypervisor Trap",
165
- /* FIXME: this access check should not take precedence over UNDEF
100
- [EXCP_SMC] = "Secure Monitor Call",
166
- * for invalid encodings; we will generate incorrect syndrome information
101
- [EXCP_VIRQ] = "Virtual IRQ",
167
- * for attempts to execute invalid vfp/neon encodings with FP disabled.
102
- [EXCP_VFIQ] = "Virtual FIQ",
168
- */
103
- [EXCP_SEMIHOST] = "Semihosting call",
169
- if (s->fp_excp_el) {
104
- [EXCP_NOCP] = "v7M NOCP UsageFault",
170
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
105
- [EXCP_INVSTATE] = "v7M INVSTATE UsageFault",
171
- syn_simd_access_trap(1, 0xe, false), s->fp_excp_el);
106
- [EXCP_STKOF] = "v8M STKOF UsageFault",
172
- return 0;
107
- [EXCP_LAZYFP] = "v7M exception during lazy FP stacking",
173
- }
108
- [EXCP_LSERR] = "v8M LSERR UsageFault",
174
-
109
- [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault",
175
- if (!s->vfp_enabled)
110
- };
176
- return 1;
111
-
177
- VFP_DREG_D(rd, insn);
112
- if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
178
- rn = (insn >> 16) & 0xf;
113
- exc = excnames[idx];
179
- rm = insn & 0xf;
180
- load = (insn & (1 << 21)) != 0;
181
- if ((insn & (1 << 23)) == 0) {
182
- /* Load store all elements -- handled already by decodetree */
183
- return 1;
184
- } else {
185
- size = (insn >> 10) & 3;
186
- if (size == 3) {
187
- /* Load single element to all lanes -- handled by decodetree */
188
- return 1;
189
- } else {
190
- /* Single element. */
191
- int idx = (insn >> 4) & 0xf;
192
- int reg_idx;
193
- switch (size) {
194
- case 0:
195
- reg_idx = (insn >> 5) & 7;
196
- stride = 1;
197
- break;
198
- case 1:
199
- reg_idx = (insn >> 6) & 3;
200
- stride = (insn & (1 << 5)) ? 2 : 1;
201
- break;
202
- case 2:
203
- reg_idx = (insn >> 7) & 1;
204
- stride = (insn & (1 << 6)) ? 2 : 1;
205
- break;
206
- default:
207
- abort();
208
- }
209
- nregs = ((insn >> 8) & 3) + 1;
210
- /* Catch the UNDEF cases. This is unavoidably a bit messy. */
211
- switch (nregs) {
212
- case 1:
213
- if (((idx & (1 << size)) != 0) ||
214
- (size == 2 && ((idx & 3) == 1 || (idx & 3) == 2))) {
215
- return 1;
216
- }
217
- break;
218
- case 3:
219
- if ((idx & 1) != 0) {
220
- return 1;
221
- }
222
- /* fall through */
223
- case 2:
224
- if (size == 2 && (idx & 2) != 0) {
225
- return 1;
226
- }
227
- break;
228
- case 4:
229
- if ((size == 2) && ((idx & 3) == 3)) {
230
- return 1;
231
- }
232
- break;
233
- default:
234
- abort();
235
- }
236
- if ((rd + stride * (nregs - 1)) > 31) {
237
- /* Attempts to write off the end of the register file
238
- * are UNPREDICTABLE; we choose to UNDEF because otherwise
239
- * the neon_load_reg() would write off the end of the array.
240
- */
241
- return 1;
242
- }
243
- tmp = tcg_temp_new_i32();
244
- addr = tcg_temp_new_i32();
245
- load_reg_var(s, addr, rn);
246
- for (reg = 0; reg < nregs; reg++) {
247
- if (load) {
248
- gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s),
249
- s->be_data | size);
250
- neon_store_element(rd, reg_idx, size, tmp);
251
- } else { /* Store */
252
- neon_load_element(tmp, rd, reg_idx, size);
253
- gen_aa32_st_i32(s, tmp, addr, get_mem_index(s),
254
- s->be_data | size);
255
- }
256
- rd += stride;
257
- tcg_gen_addi_i32(addr, addr, 1 << size);
258
- }
259
- tcg_temp_free_i32(addr);
260
- tcg_temp_free_i32(tmp);
261
- stride = nregs * (1 << size);
114
- }
262
- }
115
- if (!exc) {
263
- }
116
- exc = "unknown";
264
- if (rm != 15) {
265
- TCGv_i32 base;
266
-
267
- base = load_reg(s, rn);
268
- if (rm == 13) {
269
- tcg_gen_addi_i32(base, base, stride);
270
- } else {
271
- TCGv_i32 index;
272
- index = load_reg(s, rm);
273
- tcg_gen_add_i32(base, base, index);
274
- tcg_temp_free_i32(index);
117
- }
275
- }
118
- qemu_log_mask(CPU_LOG_INT, "Taking exception %d [%s]\n", idx, exc);
276
- store_reg(s, rn, base);
119
- }
277
- }
278
- return 0;
120
-}
279
-}
121
-
280
-
122
static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx,
281
static inline void gen_neon_narrow(int size, TCGv_i32 dest, TCGv_i64 src)
123
uint32_t addr, uint16_t *insn)
124
{
282
{
283
switch (size) {
284
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
285
}
286
return;
287
}
288
- if ((insn & 0x0f100000) == 0x04000000) {
289
- /* NEON load/store. */
290
- if (disas_neon_ls_insn(s, insn)) {
291
- goto illegal_op;
292
- }
293
- return;
294
- }
295
if ((insn & 0x0e000f00) == 0x0c000100) {
296
if (arm_dc_feature(s, ARM_FEATURE_IWMMXT)) {
297
/* iWMMXt register transfer. */
298
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
299
}
300
break;
301
case 12:
302
- if ((insn & 0x01100000) == 0x01000000) {
303
- if (disas_neon_ls_insn(s, insn)) {
304
- goto illegal_op;
305
- }
306
- break;
307
- }
308
goto illegal_op;
309
default:
310
illegal_op:
125
--
311
--
126
2.20.1
312
2.20.1
127
313
128
314
diff view generated by jsdifflib
1
From: Hongbo Zhang <hongbo.zhang@linaro.org>
1
Convert the Neon 3-reg-same VADD and VSUB insns to decodetree.
2
2
3
For AArch64, the existing "virt" machine is primarily meant to
3
Note that we don't need the neon_3r_sizes[op] check here because all
4
run on KVM and execute virtualization workloads, but we need an
4
size values are OK for VADD and VSUB; we'll add this when we convert
5
environment as faithful as possible to physical hardware, for supporting
5
the first insn that has size restrictions.
6
firmware and OS development for physical Aarch64 machines.
7
6
8
This patch introduces new machine type 'sbsa-ref' with main features:
7
For this we need one of the GVecGen*Fn typedefs currently in
9
- Based on 'virt' machine type.
8
translate-a64.h; move them all to translate.h as a block so they
10
- A new memory map.
9
are visible to the 32-bit decoder.
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
10
24
Arm Trusted Firmware and UEFI porting to this are done accordingly,
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
and the firmware should supply ACPI tables to the guest OS. The
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
26
minimal device tree nodes supplied by QEMU for this platform are only
13
Message-id: 20200430181003.21682-15-peter.maydell@linaro.org
27
to pass the dynamic info reflecting command line input to firmware,
14
---
28
not for loading the guest OS.
15
target/arm/translate-a64.h | 9 --------
16
target/arm/translate.h | 9 ++++++++
17
target/arm/neon-dp.decode | 17 +++++++++++++++
18
target/arm/translate-neon.inc.c | 38 +++++++++++++++++++++++++++++++++
19
target/arm/translate.c | 14 ++++--------
20
5 files changed, 68 insertions(+), 19 deletions(-)
29
21
30
To make the review easier, this task is split into two patches, the
22
diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h
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>
41
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
42
---
43
hw/arm/Makefile.objs | 1 +
44
hw/arm/sbsa-ref.c | 271 ++++++++++++++++++++++++++++
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
51
diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
52
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
53
--- a/hw/arm/Makefile.objs
24
--- a/target/arm/translate-a64.h
54
+++ b/hw/arm/Makefile.objs
25
+++ b/target/arm/translate-a64.h
55
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_SPITZ) += spitz.o
26
@@ -XXX,XX +XXX,XX @@ static inline int vec_full_reg_size(DisasContext *s)
56
obj-$(CONFIG_TOSA) += tosa.o
27
57
obj-$(CONFIG_Z2) += z2.o
28
bool disas_sve(DisasContext *, uint32_t);
58
obj-$(CONFIG_REALVIEW) += realview.o
29
59
+obj-$(CONFIG_SBSA_REF) += sbsa-ref.o
30
-/* Note that the gvec expanders operate on offsets + sizes. */
60
obj-$(CONFIG_STELLARIS) += stellaris.o
31
-typedef void GVecGen2Fn(unsigned, uint32_t, uint32_t, uint32_t, uint32_t);
61
obj-$(CONFIG_COLLIE) += collie.o
32
-typedef void GVecGen2iFn(unsigned, uint32_t, uint32_t, int64_t,
62
obj-$(CONFIG_VERSATILE) += versatilepb.o
33
- uint32_t, uint32_t);
63
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
34
-typedef void GVecGen3Fn(unsigned, uint32_t, uint32_t,
64
new file mode 100644
35
- uint32_t, uint32_t, uint32_t);
65
index XXXXXXX..XXXXXXX
36
-typedef void GVecGen4Fn(unsigned, uint32_t, uint32_t, uint32_t,
66
--- /dev/null
37
- uint32_t, uint32_t, uint32_t);
67
+++ b/hw/arm/sbsa-ref.c
38
-
39
#endif /* TARGET_ARM_TRANSLATE_A64_H */
40
diff --git a/target/arm/translate.h b/target/arm/translate.h
41
index XXXXXXX..XXXXXXX 100644
42
--- a/target/arm/translate.h
43
+++ b/target/arm/translate.h
44
@@ -XXX,XX +XXX,XX @@ void gen_sshl_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b);
45
#define dc_isar_feature(name, ctx) \
46
({ DisasContext *ctx_ = (ctx); isar_feature_##name(ctx_->isar); })
47
48
+/* Note that the gvec expanders operate on offsets + sizes. */
49
+typedef void GVecGen2Fn(unsigned, uint32_t, uint32_t, uint32_t, uint32_t);
50
+typedef void GVecGen2iFn(unsigned, uint32_t, uint32_t, int64_t,
51
+ uint32_t, uint32_t);
52
+typedef void GVecGen3Fn(unsigned, uint32_t, uint32_t,
53
+ uint32_t, uint32_t, uint32_t);
54
+typedef void GVecGen4Fn(unsigned, uint32_t, uint32_t, uint32_t,
55
+ uint32_t, uint32_t, uint32_t);
56
+
57
#endif /* TARGET_ARM_TRANSLATE_H */
58
diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode
59
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/neon-dp.decode
61
+++ b/target/arm/neon-dp.decode
68
@@ -XXX,XX +XXX,XX @@
62
@@ -XXX,XX +XXX,XX @@
69
+/*
63
#
70
+ * ARM SBSA Reference Platform emulation
64
# This file is processed by scripts/decodetree.py
71
+ *
65
#
72
+ * Copyright (c) 2018 Linaro Limited
66
+# VFP/Neon register fields; same as vfp.decode
73
+ * Written by Hongbo Zhang <hongbo.zhang@linaro.org>
67
+%vm_dp 5:1 0:4
74
+ *
68
+%vn_dp 7:1 16:4
75
+ * This program is free software; you can redistribute it and/or modify it
69
+%vd_dp 22:1 12:4
76
+ * under the terms and conditions of the GNU General Public License,
70
77
+ * version 2 or later, as published by the Free Software Foundation.
71
# Encodings for Neon data processing instructions where the T32 encoding
78
+ *
72
# is a simple transformation of the A32 encoding.
79
+ * This program is distributed in the hope it will be useful, but WITHOUT
73
@@ -XXX,XX +XXX,XX @@
80
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74
# 0b111p_1111_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq
81
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
75
# This file works on the A32 encoding only; calling code for T32 has to
82
+ * more details.
76
# transform the insn into the A32 version first.
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
+
77
+
88
+#include "qemu/osdep.h"
78
+######################################################################
89
+#include "qapi/error.h"
79
+# 3-reg-same grouping:
90
+#include "qemu/error-report.h"
80
+# 1111 001 U 0 D sz:2 Vn:4 Vd:4 opc:4 N Q M op Vm:4
91
+#include "qemu/units.h"
81
+######################################################################
92
+#include "sysemu/numa.h"
93
+#include "sysemu/sysemu.h"
94
+#include "exec/address-spaces.h"
95
+#include "exec/hwaddr.h"
96
+#include "kvm_arm.h"
97
+#include "hw/arm/boot.h"
98
+#include "hw/boards.h"
99
+#include "hw/intc/arm_gicv3_common.h"
100
+
82
+
101
+#define RAMLIMIT_GB 8192
83
+&3same vm vn vd q size
102
+#define RAMLIMIT_BYTES (RAMLIMIT_GB * GiB)
103
+
84
+
104
+enum {
85
+@3same .... ... . . . size:2 .... .... .... . q:1 . . .... \
105
+ SBSA_FLASH,
86
+ &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp
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
+
87
+
126
+typedef struct MemMapEntry {
88
+VADD_3s 1111 001 0 0 . .. .... .... 1000 . . . 0 .... @3same
127
+ hwaddr base;
89
+VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same
128
+ hwaddr size;
90
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
129
+} MemMapEntry;
91
index XXXXXXX..XXXXXXX 100644
92
--- a/target/arm/translate-neon.inc.c
93
+++ b/target/arm/translate-neon.inc.c
94
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a)
95
96
return true;
97
}
130
+
98
+
131
+typedef struct {
99
+static bool do_3same(DisasContext *s, arg_3same *a, GVecGen3Fn fn)
132
+ MachineState parent;
100
+{
133
+ struct arm_boot_info bootinfo;
101
+ int vec_size = a->q ? 16 : 8;
134
+ int smp_cpus;
102
+ int rd_ofs = neon_reg_offset(a->vd, 0);
135
+ void *fdt;
103
+ int rn_ofs = neon_reg_offset(a->vn, 0);
136
+ int fdt_size;
104
+ int rm_ofs = neon_reg_offset(a->vm, 0);
137
+ int psci_conduit;
138
+} SBSAMachineState;
139
+
105
+
140
+#define TYPE_SBSA_MACHINE MACHINE_TYPE_NAME("sbsa-ref")
106
+ if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
141
+#define SBSA_MACHINE(obj) \
107
+ return false;
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
+{
175
+ SBSAMachineState *sms = SBSA_MACHINE(machine);
176
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
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
+ }
108
+ }
188
+
109
+
189
+ if (kvm_enabled()) {
110
+ /* UNDEF accesses to D16-D31 if they don't exist. */
190
+ error_report("sbsa-ref: KVM is not supported for this machine");
111
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
191
+ exit(1);
112
+ ((a->vd | a->vn | a->vm) & 0x10)) {
113
+ return false;
192
+ }
114
+ }
193
+
115
+
194
+ /*
116
+ if ((a->vn | a->vm | a->vd) & a->q) {
195
+ * This machine has EL3 enabled, external firmware should supply PSCI
117
+ return false;
196
+ * implementation, so the QEMU's internal PSCI is disabled.
197
+ */
198
+ sms->psci_conduit = QEMU_PSCI_CONDUIT_DISABLED;
199
+
200
+ sbsa_max_cpus = sbsa_ref_memmap[SBSA_GIC_REDIST].size / GICV3_REDIST_SIZE;
201
+
202
+ if (max_cpus > sbsa_max_cpus) {
203
+ error_report("Number of SMP CPUs requested (%d) exceeds max CPUs "
204
+ "supported by machine 'sbsa-ref' (%d)",
205
+ max_cpus, sbsa_max_cpus);
206
+ exit(1);
207
+ }
118
+ }
208
+
119
+
209
+ sms->smp_cpus = smp_cpus;
120
+ if (!vfp_access_check(s)) {
210
+
121
+ return true;
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
+ }
122
+ }
215
+
123
+
216
+ possible_cpus = mc->possible_cpu_arch_ids(machine);
124
+ fn(a->size, rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size);
217
+ for (n = 0; n < possible_cpus->len; n++) {
125
+ return true;
218
+ Object *cpuobj;
126
+}
219
+ CPUState *cs;
220
+
127
+
221
+ if (n >= smp_cpus) {
128
+#define DO_3SAME(INSN, FUNC) \
222
+ break;
129
+ static bool trans_##INSN##_3s(DisasContext *s, arg_3same *a) \
223
+ }
130
+ { \
224
+
131
+ return do_3same(s, a, FUNC); \
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
+ }
132
+ }
250
+
133
+
251
+ memory_region_allocate_system_memory(ram, NULL, "sbsa-ref.ram",
134
+DO_3SAME(VADD, tcg_gen_gvec_add)
252
+ machine->ram_size);
135
+DO_3SAME(VSUB, tcg_gen_gvec_sub)
253
+ memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ram);
136
diff --git a/target/arm/translate.c b/target/arm/translate.c
137
index XXXXXXX..XXXXXXX 100644
138
--- a/target/arm/translate.c
139
+++ b/target/arm/translate.c
140
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
141
}
142
return 0;
143
144
- case NEON_3R_VADD_VSUB:
145
- if (u) {
146
- tcg_gen_gvec_sub(size, rd_ofs, rn_ofs, rm_ofs,
147
- vec_size, vec_size);
148
- } else {
149
- tcg_gen_gvec_add(size, rd_ofs, rn_ofs, rm_ofs,
150
- vec_size, vec_size);
151
- }
152
- return 0;
153
-
154
case NEON_3R_VQADD:
155
tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc),
156
rn_ofs, rm_ofs, vec_size, vec_size,
157
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
158
tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, vec_size, vec_size,
159
u ? &ushl_op[size] : &sshl_op[size]);
160
return 0;
254
+
161
+
255
+ sms->bootinfo.ram_size = machine->ram_size;
162
+ case NEON_3R_VADD_VSUB:
256
+ sms->bootinfo.kernel_filename = machine->kernel_filename;
163
+ /* Already handled by decodetree */
257
+ sms->bootinfo.nb_cpus = smp_cpus;
164
+ return 1;
258
+ sms->bootinfo.board_id = -1;
165
}
259
+ sms->bootinfo.loader_start = sbsa_ref_memmap[SBSA_MEM].base;
166
260
+ arm_load_kernel(ARM_CPU(first_cpu), &sms->bootinfo);
167
if (size == 3) {
261
+}
262
+
263
+static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx)
264
+{
265
+ uint8_t clustersz = ARM_DEFAULT_CPUS_PER_CLUSTER;
266
+ return arm_cpu_mp_affinity(idx, clustersz);
267
+}
268
+
269
+static const CPUArchIdList *sbsa_ref_possible_cpu_arch_ids(MachineState *ms)
270
+{
271
+ SBSAMachineState *sms = SBSA_MACHINE(ms);
272
+ int n;
273
+
274
+ if (ms->possible_cpus) {
275
+ assert(ms->possible_cpus->len == max_cpus);
276
+ return ms->possible_cpus;
277
+ }
278
+
279
+ ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) +
280
+ sizeof(CPUArchId) * max_cpus);
281
+ ms->possible_cpus->len = max_cpus;
282
+ for (n = 0; n < ms->possible_cpus->len; n++) {
283
+ ms->possible_cpus->cpus[n].type = ms->cpu_type;
284
+ ms->possible_cpus->cpus[n].arch_id =
285
+ sbsa_ref_cpu_mp_affinity(sms, n);
286
+ ms->possible_cpus->cpus[n].props.has_thread_id = true;
287
+ ms->possible_cpus->cpus[n].props.thread_id = n;
288
+ }
289
+ return ms->possible_cpus;
290
+}
291
+
292
+static CpuInstanceProperties
293
+sbsa_ref_cpu_index_to_props(MachineState *ms, unsigned cpu_index)
294
+{
295
+ MachineClass *mc = MACHINE_GET_CLASS(ms);
296
+ const CPUArchIdList *possible_cpus = mc->possible_cpu_arch_ids(ms);
297
+
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
--
168
--
394
2.20.1
169
2.20.1
395
170
396
171
diff view generated by jsdifflib
1
From: Jan Kiszka <jan.kiszka@siemens.com>
1
Convert the Neon logic ops in the 3-reg-same grouping to decodetree.
2
Note that for the logic ops the 'size' field forms part of their
3
decode and the actual operations are always bitwise.
2
4
3
Allow cortex-a7 to be used with the virt board; it supports
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
the v7VE features and there is no reason to deny this type.
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20200430181003.21682-16-peter.maydell@linaro.org
8
---
9
target/arm/neon-dp.decode | 12 +++++++++++
10
target/arm/translate-neon.inc.c | 19 +++++++++++++++++
11
target/arm/translate.c | 38 +--------------------------------
12
3 files changed, 32 insertions(+), 37 deletions(-)
5
13
6
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
14
diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Message-id: fc5404f7-4d1d-c28f-6e48-d8799c82acc0@web.de
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/arm/virt.c | 1 +
13
1 file changed, 1 insertion(+)
14
15
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/virt.c
16
--- a/target/arm/neon-dp.decode
18
+++ b/hw/arm/virt.c
17
+++ b/target/arm/neon-dp.decode
19
@@ -XXX,XX +XXX,XX @@ static const int a15irqmap[] = {
18
@@ -XXX,XX +XXX,XX @@
20
};
19
@3same .... ... . . . size:2 .... .... .... . q:1 . . .... \
21
20
&3same vm=%vm_dp vn=%vn_dp vd=%vd_dp
22
static const char *valid_cpus[] = {
21
23
+ ARM_CPU_TYPE_NAME("cortex-a7"),
22
+@3same_logic .... ... . . . .. .... .... .... . q:1 .. .... \
24
ARM_CPU_TYPE_NAME("cortex-a15"),
23
+ &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp size=0
25
ARM_CPU_TYPE_NAME("cortex-a53"),
24
+
26
ARM_CPU_TYPE_NAME("cortex-a57"),
25
+VAND_3s 1111 001 0 0 . 00 .... .... 0001 ... 1 .... @3same_logic
26
+VBIC_3s 1111 001 0 0 . 01 .... .... 0001 ... 1 .... @3same_logic
27
+VORR_3s 1111 001 0 0 . 10 .... .... 0001 ... 1 .... @3same_logic
28
+VORN_3s 1111 001 0 0 . 11 .... .... 0001 ... 1 .... @3same_logic
29
+VEOR_3s 1111 001 1 0 . 00 .... .... 0001 ... 1 .... @3same_logic
30
+VBSL_3s 1111 001 1 0 . 01 .... .... 0001 ... 1 .... @3same_logic
31
+VBIT_3s 1111 001 1 0 . 10 .... .... 0001 ... 1 .... @3same_logic
32
+VBIF_3s 1111 001 1 0 . 11 .... .... 0001 ... 1 .... @3same_logic
33
+
34
VADD_3s 1111 001 0 0 . .. .... .... 1000 . . . 0 .... @3same
35
VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same
36
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/translate-neon.inc.c
39
+++ b/target/arm/translate-neon.inc.c
40
@@ -XXX,XX +XXX,XX @@ static bool do_3same(DisasContext *s, arg_3same *a, GVecGen3Fn fn)
41
42
DO_3SAME(VADD, tcg_gen_gvec_add)
43
DO_3SAME(VSUB, tcg_gen_gvec_sub)
44
+DO_3SAME(VAND, tcg_gen_gvec_and)
45
+DO_3SAME(VBIC, tcg_gen_gvec_andc)
46
+DO_3SAME(VORR, tcg_gen_gvec_or)
47
+DO_3SAME(VORN, tcg_gen_gvec_orc)
48
+DO_3SAME(VEOR, tcg_gen_gvec_xor)
49
+
50
+/* These insns are all gvec_bitsel but with the inputs in various orders. */
51
+#define DO_3SAME_BITSEL(INSN, O1, O2, O3) \
52
+ static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \
53
+ uint32_t rn_ofs, uint32_t rm_ofs, \
54
+ uint32_t oprsz, uint32_t maxsz) \
55
+ { \
56
+ tcg_gen_gvec_bitsel(vece, rd_ofs, O1, O2, O3, oprsz, maxsz); \
57
+ } \
58
+ DO_3SAME(INSN, gen_##INSN##_3s)
59
+
60
+DO_3SAME_BITSEL(VBSL, rd_ofs, rn_ofs, rm_ofs)
61
+DO_3SAME_BITSEL(VBIT, rm_ofs, rn_ofs, rd_ofs)
62
+DO_3SAME_BITSEL(VBIF, rm_ofs, rd_ofs, rn_ofs)
63
diff --git a/target/arm/translate.c b/target/arm/translate.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/target/arm/translate.c
66
+++ b/target/arm/translate.c
67
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
68
}
69
return 1;
70
71
- case NEON_3R_LOGIC: /* Logic ops. */
72
- switch ((u << 2) | size) {
73
- case 0: /* VAND */
74
- tcg_gen_gvec_and(0, rd_ofs, rn_ofs, rm_ofs,
75
- vec_size, vec_size);
76
- break;
77
- case 1: /* VBIC */
78
- tcg_gen_gvec_andc(0, rd_ofs, rn_ofs, rm_ofs,
79
- vec_size, vec_size);
80
- break;
81
- case 2: /* VORR */
82
- tcg_gen_gvec_or(0, rd_ofs, rn_ofs, rm_ofs,
83
- vec_size, vec_size);
84
- break;
85
- case 3: /* VORN */
86
- tcg_gen_gvec_orc(0, rd_ofs, rn_ofs, rm_ofs,
87
- vec_size, vec_size);
88
- break;
89
- case 4: /* VEOR */
90
- tcg_gen_gvec_xor(0, rd_ofs, rn_ofs, rm_ofs,
91
- vec_size, vec_size);
92
- break;
93
- case 5: /* VBSL */
94
- tcg_gen_gvec_bitsel(MO_8, rd_ofs, rd_ofs, rn_ofs, rm_ofs,
95
- vec_size, vec_size);
96
- break;
97
- case 6: /* VBIT */
98
- tcg_gen_gvec_bitsel(MO_8, rd_ofs, rm_ofs, rn_ofs, rd_ofs,
99
- vec_size, vec_size);
100
- break;
101
- case 7: /* VBIF */
102
- tcg_gen_gvec_bitsel(MO_8, rd_ofs, rm_ofs, rd_ofs, rn_ofs,
103
- vec_size, vec_size);
104
- break;
105
- }
106
- return 0;
107
-
108
case NEON_3R_VQADD:
109
tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc),
110
rn_ofs, rm_ofs, vec_size, vec_size,
111
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
112
return 0;
113
114
case NEON_3R_VADD_VSUB:
115
+ case NEON_3R_LOGIC:
116
/* Already handled by decodetree */
117
return 1;
118
}
27
--
119
--
28
2.20.1
120
2.20.1
29
121
30
122
diff view generated by jsdifflib
Deleted patch
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
2
1
3
Instantiate no-op APBH DMA module. Needed to boot latest Linux kernel.
4
5
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
6
Cc: Peter Maydell <peter.maydell@linaro.org>
7
Cc: Michael S. Tsirkin <mst@redhat.com>
8
Cc: qemu-devel@nongnu.org
9
Cc: qemu-arm@nongnu.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
include/hw/arm/fsl-imx7.h | 3 +++
14
hw/arm/fsl-imx7.c | 6 ++++++
15
2 files changed, 9 insertions(+)
16
17
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/arm/fsl-imx7.h
20
+++ b/include/hw/arm/fsl-imx7.h
21
@@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap {
22
FSL_IMX7_PCIE_REG_SIZE = 16 * 1024,
23
24
FSL_IMX7_GPR_ADDR = 0x30340000,
25
+
26
+ FSL_IMX7_DMA_APBH_ADDR = 0x33000000,
27
+ FSL_IMX7_DMA_APBH_SIZE = 0x2000,
28
};
29
30
enum FslIMX7IRQs {
31
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/arm/fsl-imx7.c
34
+++ b/hw/arm/fsl-imx7.c
35
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
36
*/
37
create_unimplemented_device("lcdif", FSL_IMX7_LCDIF_ADDR,
38
FSL_IMX7_LCDIF_SIZE);
39
+
40
+ /*
41
+ * DMA APBH
42
+ */
43
+ create_unimplemented_device("dma-apbh", FSL_IMX7_DMA_APBH_ADDR,
44
+ FSL_IMX7_DMA_APBH_SIZE);
45
}
46
47
static void fsl_imx7_class_init(ObjectClass *oc, void *data)
48
--
49
2.20.1
50
51
diff view generated by jsdifflib
Deleted patch
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
2
1
3
Add no-op/unimplemented PCIE PHY IP block. Needed by new kernels to
4
use PCIE.
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
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
include/hw/arm/fsl-imx7.h | 3 +++
15
hw/arm/fsl-imx7.c | 5 +++++
16
2 files changed, 8 insertions(+)
17
18
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/arm/fsl-imx7.h
21
+++ b/include/hw/arm/fsl-imx7.h
22
@@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap {
23
FSL_IMX7_ADC2_ADDR = 0x30620000,
24
FSL_IMX7_ADCn_SIZE = 0x1000,
25
26
+ FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000,
27
+ FSL_IMX7_PCIE_PHY_SIZE = 0x10000,
28
+
29
FSL_IMX7_GPC_ADDR = 0x303A0000,
30
31
FSL_IMX7_I2C1_ADDR = 0x30A20000,
32
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/arm/fsl-imx7.c
35
+++ b/hw/arm/fsl-imx7.c
36
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
37
*/
38
create_unimplemented_device("dma-apbh", FSL_IMX7_DMA_APBH_ADDR,
39
FSL_IMX7_DMA_APBH_SIZE);
40
+ /*
41
+ * PCIe PHY
42
+ */
43
+ create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR,
44
+ FSL_IMX7_PCIE_PHY_SIZE);
45
}
46
47
static void fsl_imx7_class_init(ObjectClass *oc, void *data)
48
--
49
2.20.1
50
51
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
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
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: 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
1
From: Joel Stanley <joel@jms.id.au>
1
Convert the Neon 3-reg-same VMAX and VMIN insns to decodetree.
2
2
3
The ast2500 uses the watchdog to reset the SDRAM controller. This
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
operation is usually performed by u-boot's memory training procedure,
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
and it is enabled by setting a bit in the SCU and then causing the
5
Message-id: 20200430181003.21682-17-peter.maydell@linaro.org
6
watchdog to expire. Therefore, we need the watchdog to be able to
6
---
7
access the SCU's register space.
7
target/arm/neon-dp.decode | 5 +++++
8
target/arm/translate-neon.inc.c | 14 ++++++++++++++
9
target/arm/translate.c | 21 ++-------------------
10
3 files changed, 21 insertions(+), 19 deletions(-)
8
11
9
This causes the watchdog to not perform a system reset when the bit is
12
diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode
10
set. In the future it could perform a reset of the SDMC model.
11
12
Signed-off-by: Joel Stanley <joel@jms.id.au>
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
13
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/watchdog/wdt_aspeed.h
14
--- a/target/arm/neon-dp.decode
27
+++ b/include/hw/watchdog/wdt_aspeed.h
15
+++ b/target/arm/neon-dp.decode
28
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedWDTState {
16
@@ -XXX,XX +XXX,XX @@ VBSL_3s 1111 001 1 0 . 01 .... .... 0001 ... 1 .... @3same_logic
29
MemoryRegion iomem;
17
VBIT_3s 1111 001 1 0 . 10 .... .... 0001 ... 1 .... @3same_logic
30
uint32_t regs[ASPEED_WDT_REGS_MAX];
18
VBIF_3s 1111 001 1 0 . 11 .... .... 0001 ... 1 .... @3same_logic
31
19
32
+ AspeedSCUState *scu;
20
+VMAX_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 0 .... @3same
33
uint32_t pclk_freq;
21
+VMAX_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 0 .... @3same
34
uint32_t silicon_rev;
22
+VMIN_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 1 .... @3same
35
uint32_t ext_pulse_width_mask;
23
+VMIN_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 1 .... @3same
36
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
24
+
25
VADD_3s 1111 001 0 0 . .. .... .... 1000 . . . 0 .... @3same
26
VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same
27
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
37
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
38
--- a/hw/arm/aspeed_soc.c
29
--- a/target/arm/translate-neon.inc.c
39
+++ b/hw/arm/aspeed_soc.c
30
+++ b/target/arm/translate-neon.inc.c
40
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
31
@@ -XXX,XX +XXX,XX @@ DO_3SAME(VEOR, tcg_gen_gvec_xor)
41
sizeof(s->wdt[i]), TYPE_ASPEED_WDT);
32
DO_3SAME_BITSEL(VBSL, rd_ofs, rn_ofs, rm_ofs)
42
qdev_prop_set_uint32(DEVICE(&s->wdt[i]), "silicon-rev",
33
DO_3SAME_BITSEL(VBIT, rm_ofs, rn_ofs, rd_ofs)
43
sc->info->silicon_rev);
34
DO_3SAME_BITSEL(VBIF, rm_ofs, rd_ofs, rn_ofs)
44
+ object_property_add_const_link(OBJECT(&s->wdt[i]), "scu",
45
+ OBJECT(&s->scu), &error_abort);
46
}
47
48
for (i = 0; i < ASPEED_MACS_NUM; i++) {
49
diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c
50
index XXXXXXX..XXXXXXX 100644
51
--- a/hw/watchdog/wdt_aspeed.c
52
+++ b/hw/watchdog/wdt_aspeed.c
53
@@ -XXX,XX +XXX,XX @@
54
55
#define WDT_RESTART_MAGIC 0x4755
56
57
+#define SCU_RESET_CONTROL1 (0x04 / 4)
58
+#define SCU_RESET_SDRAM BIT(0)
59
+
35
+
60
static bool aspeed_wdt_is_enabled(const AspeedWDTState *s)
36
+#define DO_3SAME_NO_SZ_3(INSN, FUNC) \
61
{
37
+ static bool trans_##INSN##_3s(DisasContext *s, arg_3same *a) \
62
return s->regs[WDT_CTRL] & WDT_CTRL_ENABLE;
38
+ { \
63
@@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_timer_expired(void *dev)
39
+ if (a->size == 3) { \
64
{
40
+ return false; \
65
AspeedWDTState *s = ASPEED_WDT(dev);
41
+ } \
66
42
+ return do_3same(s, a, FUNC); \
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
+ }
43
+ }
73
+
44
+
74
qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n");
45
+DO_3SAME_NO_SZ_3(VMAX_S, tcg_gen_gvec_smax)
75
watchdog_perform_action();
46
+DO_3SAME_NO_SZ_3(VMAX_U, tcg_gen_gvec_umax)
76
timer_del(s->timer);
47
+DO_3SAME_NO_SZ_3(VMIN_S, tcg_gen_gvec_smin)
77
@@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp)
48
+DO_3SAME_NO_SZ_3(VMIN_U, tcg_gen_gvec_umin)
78
{
49
diff --git a/target/arm/translate.c b/target/arm/translate.c
79
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
50
index XXXXXXX..XXXXXXX 100644
80
AspeedWDTState *s = ASPEED_WDT(dev);
51
--- a/target/arm/translate.c
81
+ Error *err = NULL;
52
+++ b/target/arm/translate.c
82
+ Object *obj;
53
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
83
+
54
rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size);
84
+ obj = object_property_get_link(OBJECT(dev), "scu", &err);
55
return 0;
85
+ if (!obj) {
56
86
+ error_propagate(errp, err);
57
- case NEON_3R_VMAX:
87
+ error_prepend(errp, "required link 'scu' not found: ");
58
- if (u) {
88
+ return;
59
- tcg_gen_gvec_umax(size, rd_ofs, rn_ofs, rm_ofs,
89
+ }
60
- vec_size, vec_size);
90
+ s->scu = ASPEED_SCU(obj);
61
- } else {
91
62
- tcg_gen_gvec_smax(size, rd_ofs, rn_ofs, rm_ofs,
92
if (!is_supported_silicon_rev(s->silicon_rev)) {
63
- vec_size, vec_size);
93
error_setg(errp, "Unknown silicon revision: 0x%" PRIx32,
64
- }
65
- return 0;
66
- case NEON_3R_VMIN:
67
- if (u) {
68
- tcg_gen_gvec_umin(size, rd_ofs, rn_ofs, rm_ofs,
69
- vec_size, vec_size);
70
- } else {
71
- tcg_gen_gvec_smin(size, rd_ofs, rn_ofs, rm_ofs,
72
- vec_size, vec_size);
73
- }
74
- return 0;
75
-
76
case NEON_3R_VSHL:
77
/* Note the operation is vshl vd,vm,vn */
78
tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, vec_size, vec_size,
79
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
80
81
case NEON_3R_VADD_VSUB:
82
case NEON_3R_LOGIC:
83
+ case NEON_3R_VMAX:
84
+ case NEON_3R_VMIN:
85
/* Already handled by decodetree */
86
return 1;
87
}
94
--
88
--
95
2.20.1
89
2.20.1
96
90
97
91
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
Convert the Neon comparison ops in the 3-reg-same grouping
2
to decodetree.
2
3
3
The RAM memory region is defined after the SoC is realized when the
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
SDMC controller has checked that the defined RAM size for the machine
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
is correct. This is problematic for controller models requiring a link
6
Message-id: 20200430181003.21682-18-peter.maydell@linaro.org
6
on the RAM region, for DMA support in the SMC controller for instance.
7
---
8
target/arm/neon-dp.decode | 8 ++++++++
9
target/arm/translate-neon.inc.c | 22 ++++++++++++++++++++++
10
target/arm/translate.c | 23 +++--------------------
11
3 files changed, 33 insertions(+), 20 deletions(-)
7
12
8
Introduce a container memory region for the RAM that we can link into
13
diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode
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
14
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/aspeed.c
15
--- a/target/arm/neon-dp.decode
23
+++ b/hw/arm/aspeed.c
16
+++ b/target/arm/neon-dp.decode
24
@@ -XXX,XX +XXX,XX @@ static struct arm_boot_info aspeed_board_binfo = {
17
@@ -XXX,XX +XXX,XX @@ VBSL_3s 1111 001 1 0 . 01 .... .... 0001 ... 1 .... @3same_logic
25
18
VBIT_3s 1111 001 1 0 . 10 .... .... 0001 ... 1 .... @3same_logic
26
struct AspeedBoardState {
19
VBIF_3s 1111 001 1 0 . 11 .... .... 0001 ... 1 .... @3same_logic
27
AspeedSoCState soc;
20
28
+ MemoryRegion ram_container;
21
+VCGT_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 0 .... @3same
29
MemoryRegion ram;
22
+VCGT_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 0 .... @3same
30
MemoryRegion max_ram;
23
+VCGE_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 1 .... @3same
31
};
24
+VCGE_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 1 .... @3same
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
+
25
+
37
+ memory_region_init(&bmc->ram_container, NULL, "aspeed-ram-container",
26
VMAX_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 0 .... @3same
38
+ UINT32_MAX);
27
VMAX_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 0 .... @3same
28
VMIN_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 1 .... @3same
29
@@ -XXX,XX +XXX,XX @@ VMIN_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 1 .... @3same
30
31
VADD_3s 1111 001 0 0 . .. .... .... 1000 . . . 0 .... @3same
32
VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same
39
+
33
+
40
object_initialize_child(OBJECT(machine), "soc", &bmc->soc,
34
+VTST_3s 1111 001 0 0 . .. .... .... 1000 . . . 1 .... @3same
41
(sizeof(bmc->soc)), cfg->soc_name, &error_abort,
35
+VCEQ_3s 1111 001 1 0 . .. .... .... 1000 . . . 1 .... @3same
42
NULL);
36
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
43
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
37
index XXXXXXX..XXXXXXX 100644
44
&error_abort);
38
--- a/target/arm/translate-neon.inc.c
45
39
+++ b/target/arm/translate-neon.inc.c
46
memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size);
40
@@ -XXX,XX +XXX,XX @@ DO_3SAME_NO_SZ_3(VMAX_S, tcg_gen_gvec_smax)
47
+ memory_region_add_subregion(&bmc->ram_container, 0, &bmc->ram);
41
DO_3SAME_NO_SZ_3(VMAX_U, tcg_gen_gvec_umax)
48
memory_region_add_subregion(get_system_memory(),
42
DO_3SAME_NO_SZ_3(VMIN_S, tcg_gen_gvec_smin)
49
- sc->info->memmap[ASPEED_SDRAM], &bmc->ram);
43
DO_3SAME_NO_SZ_3(VMIN_U, tcg_gen_gvec_umin)
50
+ sc->info->memmap[ASPEED_SDRAM],
44
+
51
+ &bmc->ram_container);
45
+#define DO_3SAME_CMP(INSN, COND) \
52
46
+ static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \
53
max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size",
47
+ uint32_t rn_ofs, uint32_t rm_ofs, \
54
&error_abort);
48
+ uint32_t oprsz, uint32_t maxsz) \
55
memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL,
49
+ { \
56
"max_ram", max_ram_size - ram_size);
50
+ tcg_gen_gvec_cmp(COND, vece, rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz); \
57
- memory_region_add_subregion(get_system_memory(),
51
+ } \
58
- sc->info->memmap[ASPEED_SDRAM] + ram_size,
52
+ DO_3SAME_NO_SZ_3(INSN, gen_##INSN##_3s)
59
- &bmc->max_ram);
53
+
60
+ memory_region_add_subregion(&bmc->ram_container, ram_size, &bmc->max_ram);
54
+DO_3SAME_CMP(VCGT_S, TCG_COND_GT)
61
55
+DO_3SAME_CMP(VCGT_U, TCG_COND_GTU)
62
aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort);
56
+DO_3SAME_CMP(VCGE_S, TCG_COND_GE)
63
aspeed_board_init_flashes(&bmc->soc.spi[0], cfg->spi_model, &error_abort);
57
+DO_3SAME_CMP(VCGE_U, TCG_COND_GEU)
58
+DO_3SAME_CMP(VCEQ, TCG_COND_EQ)
59
+
60
+static void gen_VTST_3s(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
61
+ uint32_t rm_ofs, uint32_t oprsz, uint32_t maxsz)
62
+{
63
+ tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz, &cmtst_op[vece]);
64
+}
65
+DO_3SAME_NO_SZ_3(VTST, gen_VTST_3s)
66
diff --git a/target/arm/translate.c b/target/arm/translate.c
67
index XXXXXXX..XXXXXXX 100644
68
--- a/target/arm/translate.c
69
+++ b/target/arm/translate.c
70
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
71
u ? &mls_op[size] : &mla_op[size]);
72
return 0;
73
74
- case NEON_3R_VTST_VCEQ:
75
- if (u) { /* VCEQ */
76
- tcg_gen_gvec_cmp(TCG_COND_EQ, size, rd_ofs, rn_ofs, rm_ofs,
77
- vec_size, vec_size);
78
- } else { /* VTST */
79
- tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs,
80
- vec_size, vec_size, &cmtst_op[size]);
81
- }
82
- return 0;
83
-
84
- case NEON_3R_VCGT:
85
- tcg_gen_gvec_cmp(u ? TCG_COND_GTU : TCG_COND_GT, size,
86
- rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size);
87
- return 0;
88
-
89
- case NEON_3R_VCGE:
90
- tcg_gen_gvec_cmp(u ? TCG_COND_GEU : TCG_COND_GE, size,
91
- rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size);
92
- return 0;
93
-
94
case NEON_3R_VSHL:
95
/* Note the operation is vshl vd,vm,vn */
96
tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, vec_size, vec_size,
97
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
98
case NEON_3R_LOGIC:
99
case NEON_3R_VMAX:
100
case NEON_3R_VMIN:
101
+ case NEON_3R_VTST_VCEQ:
102
+ case NEON_3R_VCGT:
103
+ case NEON_3R_VCGE:
104
/* Already handled by decodetree */
105
return 1;
106
}
64
--
107
--
65
2.20.1
108
2.20.1
66
109
67
110
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
Convert the Neon VQADD/VQSUB insns in the 3-reg-same grouping
2
to decodetree.
2
3
3
It has never been used as far as I can tell from the git history.
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20200430181003.21682-19-peter.maydell@linaro.org
7
---
8
target/arm/neon-dp.decode | 6 ++++++
9
target/arm/translate-neon.inc.c | 15 +++++++++++++++
10
target/arm/translate.c | 14 ++------------
11
3 files changed, 23 insertions(+), 12 deletions(-)
4
12
5
Signed-off-by: Cédric Le Goater <clg@kaod.org>
13
diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode
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
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/aspeed.c
15
--- a/target/arm/neon-dp.decode
16
+++ b/hw/arm/aspeed.c
16
+++ b/target/arm/neon-dp.decode
17
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
17
@@ -XXX,XX +XXX,XX @@
18
memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size);
18
@3same .... ... . . . size:2 .... .... .... . q:1 . . .... \
19
memory_region_add_subregion(get_system_memory(),
19
&3same vm=%vm_dp vn=%vn_dp vd=%vd_dp
20
sc->info->memmap[ASPEED_SDRAM], &bmc->ram);
20
21
- object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram),
21
+VQADD_S_3s 1111 001 0 0 . .. .... .... 0000 . . . 1 .... @3same
22
- &error_abort);
22
+VQADD_U_3s 1111 001 1 0 . .. .... .... 0000 . . . 1 .... @3same
23
23
+
24
max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size",
24
@3same_logic .... ... . . . .. .... .... .... . q:1 .. .... \
25
&error_abort);
25
&3same vm=%vm_dp vn=%vn_dp vd=%vd_dp size=0
26
27
@@ -XXX,XX +XXX,XX @@ VBSL_3s 1111 001 1 0 . 01 .... .... 0001 ... 1 .... @3same_logic
28
VBIT_3s 1111 001 1 0 . 10 .... .... 0001 ... 1 .... @3same_logic
29
VBIF_3s 1111 001 1 0 . 11 .... .... 0001 ... 1 .... @3same_logic
30
31
+VQSUB_S_3s 1111 001 0 0 . .. .... .... 0010 . . . 1 .... @3same
32
+VQSUB_U_3s 1111 001 1 0 . .. .... .... 0010 . . . 1 .... @3same
33
+
34
VCGT_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 0 .... @3same
35
VCGT_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 0 .... @3same
36
VCGE_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 1 .... @3same
37
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/target/arm/translate-neon.inc.c
40
+++ b/target/arm/translate-neon.inc.c
41
@@ -XXX,XX +XXX,XX @@ static void gen_VTST_3s(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
42
tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz, &cmtst_op[vece]);
43
}
44
DO_3SAME_NO_SZ_3(VTST, gen_VTST_3s)
45
+
46
+#define DO_3SAME_GVEC4(INSN, OPARRAY) \
47
+ static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \
48
+ uint32_t rn_ofs, uint32_t rm_ofs, \
49
+ uint32_t oprsz, uint32_t maxsz) \
50
+ { \
51
+ tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc), \
52
+ rn_ofs, rm_ofs, oprsz, maxsz, &OPARRAY[vece]); \
53
+ } \
54
+ DO_3SAME(INSN, gen_##INSN##_3s)
55
+
56
+DO_3SAME_GVEC4(VQADD_S, sqadd_op)
57
+DO_3SAME_GVEC4(VQADD_U, uqadd_op)
58
+DO_3SAME_GVEC4(VQSUB_S, sqsub_op)
59
+DO_3SAME_GVEC4(VQSUB_U, uqsub_op)
60
diff --git a/target/arm/translate.c b/target/arm/translate.c
61
index XXXXXXX..XXXXXXX 100644
62
--- a/target/arm/translate.c
63
+++ b/target/arm/translate.c
64
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
65
}
66
return 1;
67
68
- case NEON_3R_VQADD:
69
- tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc),
70
- rn_ofs, rm_ofs, vec_size, vec_size,
71
- (u ? uqadd_op : sqadd_op) + size);
72
- return 0;
73
-
74
- case NEON_3R_VQSUB:
75
- tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc),
76
- rn_ofs, rm_ofs, vec_size, vec_size,
77
- (u ? uqsub_op : sqsub_op) + size);
78
- return 0;
79
-
80
case NEON_3R_VMUL: /* VMUL */
81
if (u) {
82
/* Polynomial case allows only P8. */
83
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
84
case NEON_3R_VTST_VCEQ:
85
case NEON_3R_VCGT:
86
case NEON_3R_VCGE:
87
+ case NEON_3R_VQADD:
88
+ case NEON_3R_VQSUB:
89
/* Already handled by decodetree */
90
return 1;
91
}
26
--
92
--
27
2.20.1
93
2.20.1
28
94
29
95
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Convert the Neon VMUL, VMLA, VMLS and VSHL insns in the
2
3-reg-same grouping to decodetree.
2
3
3
To ease the review of the next commit,
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
move the vfp_exceptbits_to_host() function directly after
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
vfp_exceptbits_from_host(). Amusingly the diff shows we
6
Message-id: 20200430181003.21682-20-peter.maydell@linaro.org
6
are moving vfp_get_fpscr().
7
---
8
target/arm/neon-dp.decode | 9 +++++++
9
target/arm/translate-neon.inc.c | 44 +++++++++++++++++++++++++++++++++
10
target/arm/translate.c | 28 +++------------------
11
3 files changed, 56 insertions(+), 25 deletions(-)
7
12
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode
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/target/arm/neon-dp.decode
19
+++ b/target/arm/vfp_helper.c
16
+++ b/target/arm/neon-dp.decode
20
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_from_host(int host_bits)
17
@@ -XXX,XX +XXX,XX @@ VCGT_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 0 .... @3same
21
return target_bits;
18
VCGE_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 1 .... @3same
22
}
19
VCGE_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 1 .... @3same
23
20
24
-uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
21
+VSHL_S_3s 1111 001 0 0 . .. .... .... 0100 . . . 0 .... @3same
25
-{
22
+VSHL_U_3s 1111 001 1 0 . .. .... .... 0100 . . . 0 .... @3same
26
- uint32_t i, fpscr;
23
+
27
-
24
VMAX_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 0 .... @3same
28
- fpscr = env->vfp.xregs[ARM_VFP_FPSCR]
25
VMAX_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 0 .... @3same
29
- | (env->vfp.vec_len << 16)
26
VMIN_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 1 .... @3same
30
- | (env->vfp.vec_stride << 20);
27
@@ -XXX,XX +XXX,XX @@ VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same
31
-
28
32
- i = get_float_exception_flags(&env->vfp.fp_status);
29
VTST_3s 1111 001 0 0 . .. .... .... 1000 . . . 1 .... @3same
33
- i |= get_float_exception_flags(&env->vfp.standard_fp_status);
30
VCEQ_3s 1111 001 1 0 . .. .... .... 1000 . . . 1 .... @3same
34
- /* FZ16 does not generate an input denormal exception. */
31
+
35
- i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
32
+VMLA_3s 1111 001 0 0 . .. .... .... 1001 . . . 0 .... @3same
36
- & ~float_flag_input_denormal);
33
+VMLS_3s 1111 001 1 0 . .. .... .... 1001 . . . 0 .... @3same
37
- fpscr |= vfp_exceptbits_from_host(i);
34
+
38
-
35
+VMUL_3s 1111 001 0 0 . .. .... .... 1001 . . . 1 .... @3same
39
- i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3];
36
+VMUL_p_3s 1111 001 1 0 . .. .... .... 1001 . . . 1 .... @3same
40
- fpscr |= i ? FPCR_QC : 0;
37
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
41
-
38
index XXXXXXX..XXXXXXX 100644
42
- return fpscr;
39
--- a/target/arm/translate-neon.inc.c
43
-}
40
+++ b/target/arm/translate-neon.inc.c
44
-
41
@@ -XXX,XX +XXX,XX @@ DO_3SAME_NO_SZ_3(VMAX_S, tcg_gen_gvec_smax)
45
-uint32_t vfp_get_fpscr(CPUARMState *env)
42
DO_3SAME_NO_SZ_3(VMAX_U, tcg_gen_gvec_umax)
46
-{
43
DO_3SAME_NO_SZ_3(VMIN_S, tcg_gen_gvec_smin)
47
- return HELPER(vfp_get_fpscr)(env);
44
DO_3SAME_NO_SZ_3(VMIN_U, tcg_gen_gvec_umin)
48
-}
45
+DO_3SAME_NO_SZ_3(VMUL, tcg_gen_gvec_mul)
49
-
46
50
/* Convert vfp exception flags to target form. */
47
#define DO_3SAME_CMP(INSN, COND) \
51
static inline int vfp_exceptbits_to_host(int target_bits)
48
static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \
52
{
49
@@ -XXX,XX +XXX,XX @@ DO_3SAME_GVEC4(VQADD_S, sqadd_op)
53
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits)
50
DO_3SAME_GVEC4(VQADD_U, uqadd_op)
54
return host_bits;
51
DO_3SAME_GVEC4(VQSUB_S, sqsub_op)
55
}
52
DO_3SAME_GVEC4(VQSUB_U, uqsub_op)
56
53
+
57
+uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
54
+static void gen_VMUL_p_3s(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
55
+ uint32_t rm_ofs, uint32_t oprsz, uint32_t maxsz)
58
+{
56
+{
59
+ uint32_t i, fpscr;
57
+ tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz,
60
+
58
+ 0, gen_helper_gvec_pmul_b);
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
+}
59
+}
77
+
60
+
78
+uint32_t vfp_get_fpscr(CPUARMState *env)
61
+static bool trans_VMUL_p_3s(DisasContext *s, arg_3same *a)
79
+{
62
+{
80
+ return HELPER(vfp_get_fpscr)(env);
63
+ if (a->size != 0) {
64
+ return false;
65
+ }
66
+ return do_3same(s, a, gen_VMUL_p_3s);
81
+}
67
+}
82
+
68
+
83
void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
69
+#define DO_3SAME_GVEC3_NO_SZ_3(INSN, OPARRAY) \
84
{
70
+ static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \
85
int i;
71
+ uint32_t rn_ofs, uint32_t rm_ofs, \
72
+ uint32_t oprsz, uint32_t maxsz) \
73
+ { \
74
+ tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, \
75
+ oprsz, maxsz, &OPARRAY[vece]); \
76
+ } \
77
+ DO_3SAME_NO_SZ_3(INSN, gen_##INSN##_3s)
78
+
79
+
80
+DO_3SAME_GVEC3_NO_SZ_3(VMLA, mla_op)
81
+DO_3SAME_GVEC3_NO_SZ_3(VMLS, mls_op)
82
+
83
+#define DO_3SAME_GVEC3_SHIFT(INSN, OPARRAY) \
84
+ static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \
85
+ uint32_t rn_ofs, uint32_t rm_ofs, \
86
+ uint32_t oprsz, uint32_t maxsz) \
87
+ { \
88
+ /* Note the operation is vshl vd,vm,vn */ \
89
+ tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, \
90
+ oprsz, maxsz, &OPARRAY[vece]); \
91
+ } \
92
+ DO_3SAME(INSN, gen_##INSN##_3s)
93
+
94
+DO_3SAME_GVEC3_SHIFT(VSHL_S, sshl_op)
95
+DO_3SAME_GVEC3_SHIFT(VSHL_U, ushl_op)
96
diff --git a/target/arm/translate.c b/target/arm/translate.c
97
index XXXXXXX..XXXXXXX 100644
98
--- a/target/arm/translate.c
99
+++ b/target/arm/translate.c
100
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
101
}
102
return 1;
103
104
- case NEON_3R_VMUL: /* VMUL */
105
- if (u) {
106
- /* Polynomial case allows only P8. */
107
- if (size != 0) {
108
- return 1;
109
- }
110
- tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size,
111
- 0, gen_helper_gvec_pmul_b);
112
- } else {
113
- tcg_gen_gvec_mul(size, rd_ofs, rn_ofs, rm_ofs,
114
- vec_size, vec_size);
115
- }
116
- return 0;
117
-
118
- case NEON_3R_VML: /* VMLA, VMLS */
119
- tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size,
120
- u ? &mls_op[size] : &mla_op[size]);
121
- return 0;
122
-
123
- case NEON_3R_VSHL:
124
- /* Note the operation is vshl vd,vm,vn */
125
- tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, vec_size, vec_size,
126
- u ? &ushl_op[size] : &sshl_op[size]);
127
- return 0;
128
-
129
case NEON_3R_VADD_VSUB:
130
case NEON_3R_LOGIC:
131
case NEON_3R_VMAX:
132
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
133
case NEON_3R_VCGE:
134
case NEON_3R_VQADD:
135
case NEON_3R_VQSUB:
136
+ case NEON_3R_VMUL:
137
+ case NEON_3R_VML:
138
+ case NEON_3R_VSHL:
139
/* Already handled by decodetree */
140
return 1;
141
}
86
--
142
--
87
2.20.1
143
2.20.1
88
144
89
145
diff view generated by jsdifflib
1
From: Christian Svensson <bluecmd@google.com>
1
We're going to want at least some of the NeonGen* typedefs
2
for the refactored 32-bit Neon decoder, so move them all
3
to translate.h since it makes more sense to keep them in
4
one group.
2
5
3
If the host decrements the counter register that results in a negative
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
delta. This is then passed to muldiv64 which only handles unsigned
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
numbers resulting in bogus results.
8
Message-id: 20200430181003.21682-23-peter.maydell@linaro.org
9
---
10
target/arm/translate.h | 17 +++++++++++++++++
11
target/arm/translate-a64.c | 17 -----------------
12
2 files changed, 17 insertions(+), 17 deletions(-)
6
13
7
This fix ensures the delta being operated on is positive.
14
diff --git a/target/arm/translate.h b/target/arm/translate.h
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
15
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/timer/aspeed_timer.c
16
--- a/target/arm/translate.h
26
+++ b/hw/timer/aspeed_timer.c
17
+++ b/target/arm/translate.h
27
@@ -XXX,XX +XXX,XX @@ static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg,
18
@@ -XXX,XX +XXX,XX @@ typedef void GVecGen3Fn(unsigned, uint32_t, uint32_t,
28
int64_t delta = (int64_t) value - (int64_t) calculate_ticks(t, now);
19
typedef void GVecGen4Fn(unsigned, uint32_t, uint32_t, uint32_t,
29
uint32_t rate = calculate_rate(t);
20
uint32_t, uint32_t, uint32_t);
30
21
31
- t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate);
22
+/* Function prototype for gen_ functions for calling Neon helpers */
32
+ if (delta >= 0) {
23
+typedef void NeonGenOneOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32);
33
+ t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate);
24
+typedef void NeonGenTwoOpFn(TCGv_i32, TCGv_i32, TCGv_i32);
34
+ } else {
25
+typedef void NeonGenTwoOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32);
35
+ t->start -= muldiv64(-delta, NANOSECONDS_PER_SECOND, rate);
26
+typedef void NeonGenTwo64OpFn(TCGv_i64, TCGv_i64, TCGv_i64);
36
+ }
27
+typedef void NeonGenTwo64OpEnvFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i64);
37
aspeed_timer_mod(t);
28
+typedef void NeonGenNarrowFn(TCGv_i32, TCGv_i64);
38
}
29
+typedef void NeonGenNarrowEnvFn(TCGv_i32, TCGv_ptr, TCGv_i64);
39
break;
30
+typedef void NeonGenWidenFn(TCGv_i64, TCGv_i32);
31
+typedef void NeonGenTwoSingleOPFn(TCGv_i32, TCGv_i32, TCGv_i32, TCGv_ptr);
32
+typedef void NeonGenTwoDoubleOPFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_ptr);
33
+typedef void NeonGenOneOpFn(TCGv_i64, TCGv_i64);
34
+typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr);
35
+typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32);
36
+typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr);
37
+typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp);
38
+
39
#endif /* TARGET_ARM_TRANSLATE_H */
40
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/target/arm/translate-a64.c
43
+++ b/target/arm/translate-a64.c
44
@@ -XXX,XX +XXX,XX @@ typedef struct AArch64DecodeTable {
45
AArch64DecodeFn *disas_fn;
46
} AArch64DecodeTable;
47
48
-/* Function prototype for gen_ functions for calling Neon helpers */
49
-typedef void NeonGenOneOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32);
50
-typedef void NeonGenTwoOpFn(TCGv_i32, TCGv_i32, TCGv_i32);
51
-typedef void NeonGenTwoOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32);
52
-typedef void NeonGenTwo64OpFn(TCGv_i64, TCGv_i64, TCGv_i64);
53
-typedef void NeonGenTwo64OpEnvFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i64);
54
-typedef void NeonGenNarrowFn(TCGv_i32, TCGv_i64);
55
-typedef void NeonGenNarrowEnvFn(TCGv_i32, TCGv_ptr, TCGv_i64);
56
-typedef void NeonGenWidenFn(TCGv_i64, TCGv_i32);
57
-typedef void NeonGenTwoSingleOPFn(TCGv_i32, TCGv_i32, TCGv_i32, TCGv_ptr);
58
-typedef void NeonGenTwoDoubleOPFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_ptr);
59
-typedef void NeonGenOneOpFn(TCGv_i64, TCGv_i64);
60
-typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr);
61
-typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32);
62
-typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr);
63
-typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp);
64
-
65
/* initialize TCG globals. */
66
void a64_translate_init(void)
67
{
40
--
68
--
41
2.20.1
69
2.20.1
42
70
43
71
diff view generated by jsdifflib