1 | target-arm queue for softfreeze: this is quite big as I | 1 | First pullreq for 6.0: mostly my v8.1M work, plus some other |
---|---|---|---|
2 | was on holiday last week, so this is all just sneaking in | 2 | bits and pieces. (I still have a lot of stuff in my to-review |
3 | under the wire. I particularly wanted to get Philippe's | 3 | folder, which I may or may not get to before the Christmas break...) |
4 | patches in before freeze as that sort of code-movement | ||
5 | patchset is painful to have to rebase. | ||
6 | 4 | ||
7 | thanks | 5 | thanks |
8 | -- PMM | 6 | -- PMM |
9 | 7 | ||
10 | The following changes since commit ae9108f8f0746ce64d02afb1a216153a50926132: | 8 | The following changes since commit 5e7b204dbfae9a562fc73684986f936b97f63877: |
11 | 9 | ||
12 | Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-4.1-pull-request' into staging (2019-07-01 15:55:40 +0100) | 10 | Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2020-12-09 20:08:54 +0000) |
13 | 11 | ||
14 | are available in the Git repository at: | 12 | are available in the Git repository at: |
15 | 13 | ||
16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190701 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201210 |
17 | 15 | ||
18 | for you to fetch changes up to 787a7e76c2e93a48c47b324fea592c9910a70483: | 16 | for you to fetch changes up to 71f916be1c7e9ede0e37d9cabc781b5a9e8638ff: |
19 | 17 | ||
20 | target/arm: Declare some M-profile functions publicly (2019-07-01 17:29:01 +0100) | 18 | hw/arm/armv7m: Correct typo in QOM object name (2020-12-10 11:44:56 +0000) |
21 | 19 | ||
22 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
23 | target-arm queue: | 21 | target-arm queue: |
24 | * hw/arm/boot: fix direct kernel boot with initrd | 22 | * hw/arm/smmuv3: Fix up L1STD_SPAN decoding |
25 | * hw/arm/msf2-som: Exit when the cpu is not the expected one | 23 | * xlnx-zynqmp: Support Xilinx ZynqMP CAN controllers |
26 | * i.mx7: fix bugs in PCI controller needed to boot recent kernels | 24 | * sbsa-ref: allow to use Cortex-A53/57/72 cpus |
27 | * aspeed: add RTC device | 25 | * Various minor code cleanups |
28 | * aspeed: fix some timer device bugs | 26 | * hw/intc/armv7m_nvic: Make all of system PPB range be RAZWI/BusFault |
29 | * aspeed: add swift-bmc board | 27 | * Implement more pieces of ARMv8.1M support |
30 | * aspeed: vic: Add support for legacy register interface | ||
31 | * aspeed: add aspeed-xdma device | ||
32 | * Add new sbsa-ref board for aarch64 | ||
33 | * target/arm: code refactoring in preparation for support of | ||
34 | compilation with TCG disabled | ||
35 | 28 | ||
36 | ---------------------------------------------------------------- | 29 | ---------------------------------------------------------------- |
37 | Adriana Kobylak (1): | 30 | Alex Chen (4): |
38 | aspeed: Add support for the swift-bmc board | 31 | i.MX25: Fix bad printf format specifiers |
32 | i.MX31: Fix bad printf format specifiers | ||
33 | i.MX6: Fix bad printf format specifiers | ||
34 | i.MX6ul: Fix bad printf format specifiers | ||
39 | 35 | ||
40 | Andrew Jeffery (3): | 36 | Havard Skinnemoen (1): |
41 | aspeed/timer: Status register contains reload for stopped timer | 37 | tests/qtest/npcm7xx_rng-test: dump random data on failure |
42 | aspeed/timer: Fix match calculations | ||
43 | aspeed: vic: Add support for legacy register interface | ||
44 | 38 | ||
45 | Andrew Jones (1): | 39 | Kunkun Jiang (1): |
46 | hw/arm/boot: fix direct kernel boot with initrd | 40 | hw/arm/smmuv3: Fix up L1STD_SPAN decoding |
47 | 41 | ||
48 | Andrey Smirnov (5): | 42 | Marcin Juszkiewicz (1): |
49 | i.mx7d: Add no-op/unimplemented APBH DMA module | 43 | sbsa-ref: allow to use Cortex-A53/57/72 cpus |
50 | i.mx7d: Add no-op/unimplemented PCIE PHY IP block | ||
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 | 44 | ||
55 | Christian Svensson (1): | 45 | Peter Maydell (25): |
56 | aspeed/timer: Ensure positive muldiv delta | 46 | hw/intc/armv7m_nvic: Make all of system PPB range be RAZWI/BusFault |
47 | target/arm: Implement v8.1M PXN extension | ||
48 | target/arm: Don't clobber ID_PFR1.Security on M-profile cores | ||
49 | target/arm: Implement VSCCLRM insn | ||
50 | target/arm: Implement CLRM instruction | ||
51 | target/arm: Enforce M-profile VMRS/VMSR register restrictions | ||
52 | target/arm: Refactor M-profile VMSR/VMRS handling | ||
53 | target/arm: Move general-use constant expanders up in translate.c | ||
54 | target/arm: Implement VLDR/VSTR system register | ||
55 | target/arm: Implement M-profile FPSCR_nzcvqc | ||
56 | target/arm: Use new FPCR_NZCV_MASK constant | ||
57 | target/arm: Factor out preserve-fp-state from full_vfp_access_check() | ||
58 | target/arm: Implement FPCXT_S fp system register | ||
59 | hw/intc/armv7m_nvic: Update FPDSCR masking for v8.1M | ||
60 | target/arm: For v8.1M, always clear R0-R3, R12, APSR, EPSR on exception entry | ||
61 | target/arm: In v8.1M, don't set HFSR.FORCED on vector table fetch failures | ||
62 | target/arm: Implement v8.1M REVIDR register | ||
63 | target/arm: Implement new v8.1M NOCP check for exception return | ||
64 | target/arm: Implement new v8.1M VLLDM and VLSTM encodings | ||
65 | hw/intc/armv7m_nvic: Support v8.1M CCR.TRD bit | ||
66 | target/arm: Implement CCR_S.TRD behaviour for SG insns | ||
67 | hw/intc/armv7m_nvic: Fix "return from inactive handler" check | ||
68 | target/arm: Implement M-profile "minimal RAS implementation" | ||
69 | hw/intc/armv7m_nvic: Implement read/write for RAS register block | ||
70 | hw/arm/armv7m: Correct typo in QOM object name | ||
57 | 71 | ||
58 | Cédric Le Goater (7): | 72 | Vikram Garhwal (4): |
59 | aspeed: add a per SoC mapping for the interrupt space | 73 | hw/net/can: Introduce Xilinx ZynqMP CAN controller |
60 | aspeed: add a per SoC mapping for the memory space | 74 | xlnx-zynqmp: Connect Xilinx ZynqMP CAN controllers |
61 | aspeed: introduce a configurable number of CPU per machine | 75 | tests/qtest: Introduce tests for Xilinx ZynqMP CAN controller |
62 | aspeed: add support for multiple NICs | 76 | MAINTAINERS: Add maintainer entry for Xilinx ZynqMP CAN controller |
63 | aspeed: remove the "ram" link | ||
64 | aspeed: add a RAM memory region container | ||
65 | aspeed/smc: add a 'sdram_base' property | ||
66 | 77 | ||
67 | Eddie James (1): | 78 | meson.build | 1 + |
68 | hw/misc/aspeed_xdma: New device | 79 | hw/arm/smmuv3-internal.h | 2 +- |
80 | hw/net/can/trace.h | 1 + | ||
81 | include/hw/arm/xlnx-zynqmp.h | 8 + | ||
82 | include/hw/intc/armv7m_nvic.h | 2 + | ||
83 | include/hw/net/xlnx-zynqmp-can.h | 78 +++ | ||
84 | target/arm/cpu.h | 46 ++ | ||
85 | target/arm/m-nocp.decode | 10 +- | ||
86 | target/arm/t32.decode | 10 +- | ||
87 | target/arm/vfp.decode | 14 + | ||
88 | hw/arm/armv7m.c | 4 +- | ||
89 | hw/arm/sbsa-ref.c | 23 +- | ||
90 | hw/arm/xlnx-zcu102.c | 20 + | ||
91 | hw/arm/xlnx-zynqmp.c | 34 ++ | ||
92 | hw/intc/armv7m_nvic.c | 246 ++++++-- | ||
93 | hw/misc/imx25_ccm.c | 12 +- | ||
94 | hw/misc/imx31_ccm.c | 14 +- | ||
95 | hw/misc/imx6_ccm.c | 20 +- | ||
96 | hw/misc/imx6_src.c | 2 +- | ||
97 | hw/misc/imx6ul_ccm.c | 4 +- | ||
98 | hw/misc/imx_ccm.c | 4 +- | ||
99 | hw/net/can/xlnx-zynqmp-can.c | 1161 ++++++++++++++++++++++++++++++++++++++ | ||
100 | target/arm/cpu.c | 5 +- | ||
101 | target/arm/helper.c | 7 +- | ||
102 | target/arm/m_helper.c | 130 ++++- | ||
103 | target/arm/translate.c | 105 +++- | ||
104 | tests/qtest/npcm7xx_rng-test.c | 12 + | ||
105 | tests/qtest/xlnx-can-test.c | 360 ++++++++++++ | ||
106 | MAINTAINERS | 8 + | ||
107 | hw/Kconfig | 1 + | ||
108 | hw/net/can/meson.build | 1 + | ||
109 | hw/net/can/trace-events | 9 + | ||
110 | target/arm/translate-vfp.c.inc | 511 ++++++++++++++++- | ||
111 | tests/qtest/meson.build | 1 + | ||
112 | 34 files changed, 2713 insertions(+), 153 deletions(-) | ||
113 | create mode 100644 hw/net/can/trace.h | ||
114 | create mode 100644 include/hw/net/xlnx-zynqmp-can.h | ||
115 | create mode 100644 hw/net/can/xlnx-zynqmp-can.c | ||
116 | create mode 100644 tests/qtest/xlnx-can-test.c | ||
117 | create mode 100644 hw/net/can/trace-events | ||
69 | 118 | ||
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: Kunkun Jiang <jiangkunkun@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | This code is specific to the SoftFloat floating-point | 3 | Accroding to the SMMUv3 spec, the SPAN field of Level1 Stream Table |
4 | implementation, which is only used by TCG. | 4 | Descriptor is 5 bits([4:0]). |
5 | 5 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 6 | Fixes: 9bde7f0674f(hw/arm/smmuv3: Implement translate callback) |
7 | Message-id: 20190701132516.26392-18-philmd@redhat.com | 7 | Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com> |
8 | Message-id: 20201124023711.1184-1-jiangkunkun@huawei.com | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Acked-by: Eric Auger <eric.auger@redhat.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/vfp_helper.c | 26 +++++++++++++++++++++++--- | 13 | hw/arm/smmuv3-internal.h | 2 +- |
12 | 1 file changed, 23 insertions(+), 3 deletions(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 15 | ||
14 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | 16 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/vfp_helper.c | 18 | --- a/hw/arm/smmuv3-internal.h |
17 | +++ b/target/arm/vfp_helper.c | 19 | +++ b/hw/arm/smmuv3-internal.h |
18 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t l1std_l2ptr(STEDesc *desc) |
19 | */ | 21 | return hi << 32 | lo; |
20 | |||
21 | #include "qemu/osdep.h" | ||
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 | + | ||
39 | /* Convert host exception flags to vfp form. */ | ||
40 | static inline int vfp_exceptbits_from_host(int host_bits) | ||
41 | { | ||
42 | @@ -XXX,XX +XXX,XX @@ static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val) | ||
43 | set_float_exception_flags(0, &env->vfp.standard_fp_status); | ||
44 | } | 22 | } |
45 | 23 | ||
46 | +#else | 24 | -#define L1STD_SPAN(stm) (extract32((stm)->word[0], 0, 4)) |
47 | + | 25 | +#define L1STD_SPAN(stm) (extract32((stm)->word[0], 0, 5)) |
48 | +static uint32_t vfp_get_fpscr_from_host(CPUARMState *env) | 26 | |
49 | +{ | 27 | #endif |
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 | } | ||
75 | + | ||
76 | +#endif | ||
77 | -- | 28 | -- |
78 | 2.20.1 | 29 | 2.20.1 |
79 | 30 | ||
80 | 31 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Vikram Garhwal <fnu.vikram@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | The RTC is modeled to provide time and date functionality. It is | 3 | The Xilinx ZynqMP CAN controller is developed based on SocketCAN, QEMU CAN bus |
4 | initialised at zero to match the hardware. | 4 | implementation. Bus connection and socketCAN connection for each CAN module |
5 | can be set through command lines. | ||
5 | 6 | ||
6 | There is no modelling of the alarm functionality, which includes the IRQ | 7 | Example for using single CAN: |
7 | line. As there is no guest code to exercise this function that is | 8 | -object can-bus,id=canbus0 \ |
8 | acceptable for now. | 9 | -machine xlnx-zcu102.canbus0=canbus0 \ |
10 | -object can-host-socketcan,id=socketcan0,if=vcan0,canbus=canbus0 | ||
9 | 11 | ||
10 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 12 | Example for connecting both CAN to same virtual CAN on host machine: |
13 | -object can-bus,id=canbus0 -object can-bus,id=canbus1 \ | ||
14 | -machine xlnx-zcu102.canbus0=canbus0 \ | ||
15 | -machine xlnx-zcu102.canbus1=canbus1 \ | ||
16 | -object can-host-socketcan,id=socketcan0,if=vcan0,canbus=canbus0 \ | ||
17 | -object can-host-socketcan,id=socketcan1,if=vcan0,canbus=canbus1 | ||
18 | |||
19 | To create virtual CAN on the host machine, please check the QEMU CAN docs: | ||
20 | https://github.com/qemu/qemu/blob/master/docs/can.txt | ||
21 | |||
22 | Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com> | ||
23 | Message-id: 1605728926-352690-2-git-send-email-fnu.vikram@xilinx.com | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 24 | 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> | 25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 26 | --- |
15 | hw/timer/Makefile.objs | 2 +- | 27 | meson.build | 1 + |
16 | include/hw/timer/aspeed_rtc.h | 31 ++++++ | 28 | hw/net/can/trace.h | 1 + |
17 | hw/timer/aspeed_rtc.c | 180 ++++++++++++++++++++++++++++++++++ | 29 | include/hw/net/xlnx-zynqmp-can.h | 78 ++ |
18 | hw/timer/trace-events | 4 + | 30 | hw/net/can/xlnx-zynqmp-can.c | 1161 ++++++++++++++++++++++++++++++ |
19 | 4 files changed, 216 insertions(+), 1 deletion(-) | 31 | hw/Kconfig | 1 + |
20 | create mode 100644 include/hw/timer/aspeed_rtc.h | 32 | hw/net/can/meson.build | 1 + |
21 | create mode 100644 hw/timer/aspeed_rtc.c | 33 | hw/net/can/trace-events | 9 + |
34 | 7 files changed, 1252 insertions(+) | ||
35 | create mode 100644 hw/net/can/trace.h | ||
36 | create mode 100644 include/hw/net/xlnx-zynqmp-can.h | ||
37 | create mode 100644 hw/net/can/xlnx-zynqmp-can.c | ||
38 | create mode 100644 hw/net/can/trace-events | ||
22 | 39 | ||
23 | diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs | 40 | diff --git a/meson.build b/meson.build |
24 | index XXXXXXX..XXXXXXX 100644 | 41 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/timer/Makefile.objs | 42 | --- a/meson.build |
26 | +++ b/hw/timer/Makefile.objs | 43 | +++ b/meson.build |
27 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MC146818RTC) += mc146818rtc.o | 44 | @@ -XXX,XX +XXX,XX @@ if have_system |
28 | obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o | 45 | 'hw/misc', |
29 | 46 | 'hw/misc/macio', | |
30 | common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o | 47 | 'hw/net', |
31 | -common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o | 48 | + 'hw/net/can', |
32 | +common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o | 49 | 'hw/nvram', |
33 | 50 | 'hw/pci', | |
34 | common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o | 51 | 'hw/pci-host', |
35 | common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o | 52 | diff --git a/hw/net/can/trace.h b/hw/net/can/trace.h |
36 | diff --git a/include/hw/timer/aspeed_rtc.h b/include/hw/timer/aspeed_rtc.h | ||
37 | new file mode 100644 | 53 | new file mode 100644 |
38 | index XXXXXXX..XXXXXXX | 54 | index XXXXXXX..XXXXXXX |
39 | --- /dev/null | 55 | --- /dev/null |
40 | +++ b/include/hw/timer/aspeed_rtc.h | 56 | +++ b/hw/net/can/trace.h |
41 | @@ -XXX,XX +XXX,XX @@ | 57 | @@ -0,0 +1 @@ |
42 | +/* | 58 | +#include "trace/trace-hw_net_can.h" |
43 | + * ASPEED Real Time Clock | 59 | diff --git a/include/hw/net/xlnx-zynqmp-can.h b/include/hw/net/xlnx-zynqmp-can.h |
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 | 60 | new file mode 100644 |
75 | index XXXXXXX..XXXXXXX | 61 | index XXXXXXX..XXXXXXX |
76 | --- /dev/null | 62 | --- /dev/null |
77 | +++ b/hw/timer/aspeed_rtc.c | 63 | +++ b/include/hw/net/xlnx-zynqmp-can.h |
78 | @@ -XXX,XX +XXX,XX @@ | 64 | @@ -XXX,XX +XXX,XX @@ |
79 | +/* | 65 | +/* |
80 | + * ASPEED Real Time Clock | 66 | + * QEMU model of the Xilinx ZynqMP CAN controller. |
81 | + * Joel Stanley <joel@jms.id.au> | ||
82 | + * | 67 | + * |
83 | + * Copyright 2019 IBM Corp | 68 | + * Copyright (c) 2020 Xilinx Inc. |
84 | + * SPDX-License-Identifier: GPL-2.0-or-later | 69 | + * |
70 | + * Written-by: Vikram Garhwal<fnu.vikram@xilinx.com> | ||
71 | + * | ||
72 | + * Based on QEMU CAN Device emulation implemented by Jin Yang, Deniz Eren and | ||
73 | + * Pavel Pisa. | ||
74 | + * | ||
75 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
76 | + * of this software and associated documentation files (the "Software"), to deal | ||
77 | + * in the Software without restriction, including without limitation the rights | ||
78 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
79 | + * copies of the Software, and to permit persons to whom the Software is | ||
80 | + * furnished to do so, subject to the following conditions: | ||
81 | + * | ||
82 | + * The above copyright notice and this permission notice shall be included in | ||
83 | + * all copies or substantial portions of the Software. | ||
84 | + * | ||
85 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
86 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
87 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
88 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
89 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
90 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
91 | + * THE SOFTWARE. | ||
85 | + */ | 92 | + */ |
86 | + | 93 | + |
94 | +#ifndef XLNX_ZYNQMP_CAN_H | ||
95 | +#define XLNX_ZYNQMP_CAN_H | ||
96 | + | ||
97 | +#include "hw/register.h" | ||
98 | +#include "net/can_emu.h" | ||
99 | +#include "net/can_host.h" | ||
100 | +#include "qemu/fifo32.h" | ||
101 | +#include "hw/ptimer.h" | ||
102 | +#include "hw/qdev-clock.h" | ||
103 | + | ||
104 | +#define TYPE_XLNX_ZYNQMP_CAN "xlnx.zynqmp-can" | ||
105 | + | ||
106 | +#define XLNX_ZYNQMP_CAN(obj) \ | ||
107 | + OBJECT_CHECK(XlnxZynqMPCANState, (obj), TYPE_XLNX_ZYNQMP_CAN) | ||
108 | + | ||
109 | +#define MAX_CAN_CTRLS 2 | ||
110 | +#define XLNX_ZYNQMP_CAN_R_MAX (0x84 / 4) | ||
111 | +#define MAILBOX_CAPACITY 64 | ||
112 | +#define CAN_TIMER_MAX 0XFFFFUL | ||
113 | +#define CAN_DEFAULT_CLOCK (24 * 1000 * 1000) | ||
114 | + | ||
115 | +/* Each CAN_FRAME will have 4 * 32bit size. */ | ||
116 | +#define CAN_FRAME_SIZE 4 | ||
117 | +#define RXFIFO_SIZE (MAILBOX_CAPACITY * CAN_FRAME_SIZE) | ||
118 | + | ||
119 | +typedef struct XlnxZynqMPCANState { | ||
120 | + SysBusDevice parent_obj; | ||
121 | + MemoryRegion iomem; | ||
122 | + | ||
123 | + qemu_irq irq; | ||
124 | + | ||
125 | + CanBusClientState bus_client; | ||
126 | + CanBusState *canbus; | ||
127 | + | ||
128 | + struct { | ||
129 | + uint32_t ext_clk_freq; | ||
130 | + } cfg; | ||
131 | + | ||
132 | + RegisterInfo reg_info[XLNX_ZYNQMP_CAN_R_MAX]; | ||
133 | + uint32_t regs[XLNX_ZYNQMP_CAN_R_MAX]; | ||
134 | + | ||
135 | + Fifo32 rx_fifo; | ||
136 | + Fifo32 tx_fifo; | ||
137 | + Fifo32 txhpb_fifo; | ||
138 | + | ||
139 | + ptimer_state *can_timer; | ||
140 | +} XlnxZynqMPCANState; | ||
141 | + | ||
142 | +#endif | ||
143 | diff --git a/hw/net/can/xlnx-zynqmp-can.c b/hw/net/can/xlnx-zynqmp-can.c | ||
144 | new file mode 100644 | ||
145 | index XXXXXXX..XXXXXXX | ||
146 | --- /dev/null | ||
147 | +++ b/hw/net/can/xlnx-zynqmp-can.c | ||
148 | @@ -XXX,XX +XXX,XX @@ | ||
149 | +/* | ||
150 | + * QEMU model of the Xilinx ZynqMP CAN controller. | ||
151 | + * This implementation is based on the following datasheet: | ||
152 | + * https://www.xilinx.com/support/documentation/user_guides/ug1085-zynq-ultrascale-trm.pdf | ||
153 | + * | ||
154 | + * Copyright (c) 2020 Xilinx Inc. | ||
155 | + * | ||
156 | + * Written-by: Vikram Garhwal<fnu.vikram@xilinx.com> | ||
157 | + * | ||
158 | + * Based on QEMU CAN Device emulation implemented by Jin Yang, Deniz Eren and | ||
159 | + * Pavel Pisa | ||
160 | + * | ||
161 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
162 | + * of this software and associated documentation files (the "Software"), to deal | ||
163 | + * in the Software without restriction, including without limitation the rights | ||
164 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
165 | + * copies of the Software, and to permit persons to whom the Software is | ||
166 | + * furnished to do so, subject to the following conditions: | ||
167 | + * | ||
168 | + * The above copyright notice and this permission notice shall be included in | ||
169 | + * all copies or substantial portions of the Software. | ||
170 | + * | ||
171 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
172 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
173 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
174 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
175 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
176 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
177 | + * THE SOFTWARE. | ||
178 | + */ | ||
179 | + | ||
87 | +#include "qemu/osdep.h" | 180 | +#include "qemu/osdep.h" |
88 | +#include "qemu-common.h" | 181 | +#include "hw/sysbus.h" |
89 | +#include "hw/timer/aspeed_rtc.h" | 182 | +#include "hw/register.h" |
183 | +#include "hw/irq.h" | ||
184 | +#include "qapi/error.h" | ||
185 | +#include "qemu/bitops.h" | ||
90 | +#include "qemu/log.h" | 186 | +#include "qemu/log.h" |
91 | +#include "qemu/timer.h" | 187 | +#include "qemu/cutils.h" |
92 | + | 188 | +#include "sysemu/sysemu.h" |
189 | +#include "migration/vmstate.h" | ||
190 | +#include "hw/qdev-properties.h" | ||
191 | +#include "net/can_emu.h" | ||
192 | +#include "net/can_host.h" | ||
193 | +#include "qemu/event_notifier.h" | ||
194 | +#include "qom/object_interfaces.h" | ||
195 | +#include "hw/net/xlnx-zynqmp-can.h" | ||
93 | +#include "trace.h" | 196 | +#include "trace.h" |
94 | + | 197 | + |
95 | +#define COUNTER1 (0x00 / 4) | 198 | +#ifndef XLNX_ZYNQMP_CAN_ERR_DEBUG |
96 | +#define COUNTER2 (0x04 / 4) | 199 | +#define XLNX_ZYNQMP_CAN_ERR_DEBUG 0 |
97 | +#define ALARM (0x08 / 4) | 200 | +#endif |
98 | +#define CONTROL (0x10 / 4) | 201 | + |
99 | +#define ALARM_STATUS (0x14 / 4) | 202 | +#define MAX_DLC 8 |
100 | + | 203 | +#undef ERROR |
101 | +#define RTC_UNLOCKED BIT(1) | 204 | + |
102 | +#define RTC_ENABLED BIT(0) | 205 | +REG32(SOFTWARE_RESET_REGISTER, 0x0) |
103 | + | 206 | + FIELD(SOFTWARE_RESET_REGISTER, CEN, 1, 1) |
104 | +static void aspeed_rtc_calc_offset(AspeedRtcState *rtc) | 207 | + FIELD(SOFTWARE_RESET_REGISTER, SRST, 0, 1) |
105 | +{ | 208 | +REG32(MODE_SELECT_REGISTER, 0x4) |
106 | + struct tm tm; | 209 | + FIELD(MODE_SELECT_REGISTER, SNOOP, 2, 1) |
107 | + uint32_t year, cent; | 210 | + FIELD(MODE_SELECT_REGISTER, LBACK, 1, 1) |
108 | + uint32_t reg1 = rtc->reg[COUNTER1]; | 211 | + FIELD(MODE_SELECT_REGISTER, SLEEP, 0, 1) |
109 | + uint32_t reg2 = rtc->reg[COUNTER2]; | 212 | +REG32(ARBITRATION_PHASE_BAUD_RATE_PRESCALER_REGISTER, 0x8) |
110 | + | 213 | + FIELD(ARBITRATION_PHASE_BAUD_RATE_PRESCALER_REGISTER, BRP, 0, 8) |
111 | + tm.tm_mday = (reg1 >> 24) & 0x1f; | 214 | +REG32(ARBITRATION_PHASE_BIT_TIMING_REGISTER, 0xc) |
112 | + tm.tm_hour = (reg1 >> 16) & 0x1f; | 215 | + FIELD(ARBITRATION_PHASE_BIT_TIMING_REGISTER, SJW, 7, 2) |
113 | + tm.tm_min = (reg1 >> 8) & 0x3f; | 216 | + FIELD(ARBITRATION_PHASE_BIT_TIMING_REGISTER, TS2, 4, 3) |
114 | + tm.tm_sec = (reg1 >> 0) & 0x3f; | 217 | + FIELD(ARBITRATION_PHASE_BIT_TIMING_REGISTER, TS1, 0, 4) |
115 | + | 218 | +REG32(ERROR_COUNTER_REGISTER, 0x10) |
116 | + cent = (reg2 >> 16) & 0x1f; | 219 | + FIELD(ERROR_COUNTER_REGISTER, REC, 8, 8) |
117 | + year = (reg2 >> 8) & 0x7f; | 220 | + FIELD(ERROR_COUNTER_REGISTER, TEC, 0, 8) |
118 | + tm.tm_mon = ((reg2 >> 0) & 0x0f) - 1; | 221 | +REG32(ERROR_STATUS_REGISTER, 0x14) |
119 | + tm.tm_year = year + (cent * 100) - 1900; | 222 | + FIELD(ERROR_STATUS_REGISTER, ACKER, 4, 1) |
120 | + | 223 | + FIELD(ERROR_STATUS_REGISTER, BERR, 3, 1) |
121 | + rtc->offset = qemu_timedate_diff(&tm); | 224 | + FIELD(ERROR_STATUS_REGISTER, STER, 2, 1) |
122 | +} | 225 | + FIELD(ERROR_STATUS_REGISTER, FMER, 1, 1) |
123 | + | 226 | + FIELD(ERROR_STATUS_REGISTER, CRCER, 0, 1) |
124 | +static uint32_t aspeed_rtc_get_counter(AspeedRtcState *rtc, int r) | 227 | +REG32(STATUS_REGISTER, 0x18) |
125 | +{ | 228 | + FIELD(STATUS_REGISTER, SNOOP, 12, 1) |
126 | + uint32_t year, cent; | 229 | + FIELD(STATUS_REGISTER, ACFBSY, 11, 1) |
127 | + struct tm now; | 230 | + FIELD(STATUS_REGISTER, TXFLL, 10, 1) |
128 | + | 231 | + FIELD(STATUS_REGISTER, TXBFLL, 9, 1) |
129 | + qemu_get_timedate(&now, rtc->offset); | 232 | + FIELD(STATUS_REGISTER, ESTAT, 7, 2) |
130 | + | 233 | + FIELD(STATUS_REGISTER, ERRWRN, 6, 1) |
131 | + switch (r) { | 234 | + FIELD(STATUS_REGISTER, BBSY, 5, 1) |
132 | + case COUNTER1: | 235 | + FIELD(STATUS_REGISTER, BIDLE, 4, 1) |
133 | + return (now.tm_mday << 24) | (now.tm_hour << 16) | | 236 | + FIELD(STATUS_REGISTER, NORMAL, 3, 1) |
134 | + (now.tm_min << 8) | now.tm_sec; | 237 | + FIELD(STATUS_REGISTER, SLEEP, 2, 1) |
135 | + case COUNTER2: | 238 | + FIELD(STATUS_REGISTER, LBACK, 1, 1) |
136 | + cent = (now.tm_year + 1900) / 100; | 239 | + FIELD(STATUS_REGISTER, CONFIG, 0, 1) |
137 | + year = now.tm_year % 100; | 240 | +REG32(INTERRUPT_STATUS_REGISTER, 0x1c) |
138 | + return ((cent & 0x1f) << 16) | ((year & 0x7f) << 8) | | 241 | + FIELD(INTERRUPT_STATUS_REGISTER, TXFEMP, 14, 1) |
139 | + ((now.tm_mon + 1) & 0xf); | 242 | + FIELD(INTERRUPT_STATUS_REGISTER, TXFWMEMP, 13, 1) |
140 | + default: | 243 | + FIELD(INTERRUPT_STATUS_REGISTER, RXFWMFLL, 12, 1) |
141 | + g_assert_not_reached(); | 244 | + FIELD(INTERRUPT_STATUS_REGISTER, WKUP, 11, 1) |
142 | + } | 245 | + FIELD(INTERRUPT_STATUS_REGISTER, SLP, 10, 1) |
143 | +} | 246 | + FIELD(INTERRUPT_STATUS_REGISTER, BSOFF, 9, 1) |
144 | + | 247 | + FIELD(INTERRUPT_STATUS_REGISTER, ERROR, 8, 1) |
145 | +static uint64_t aspeed_rtc_read(void *opaque, hwaddr addr, | 248 | + FIELD(INTERRUPT_STATUS_REGISTER, RXNEMP, 7, 1) |
146 | + unsigned size) | 249 | + FIELD(INTERRUPT_STATUS_REGISTER, RXOFLW, 6, 1) |
147 | +{ | 250 | + FIELD(INTERRUPT_STATUS_REGISTER, RXUFLW, 5, 1) |
148 | + AspeedRtcState *rtc = opaque; | 251 | + FIELD(INTERRUPT_STATUS_REGISTER, RXOK, 4, 1) |
149 | + uint64_t val; | 252 | + FIELD(INTERRUPT_STATUS_REGISTER, TXBFLL, 3, 1) |
150 | + uint32_t r = addr >> 2; | 253 | + FIELD(INTERRUPT_STATUS_REGISTER, TXFLL, 2, 1) |
151 | + | 254 | + FIELD(INTERRUPT_STATUS_REGISTER, TXOK, 1, 1) |
152 | + switch (r) { | 255 | + FIELD(INTERRUPT_STATUS_REGISTER, ARBLST, 0, 1) |
153 | + case COUNTER1: | 256 | +REG32(INTERRUPT_ENABLE_REGISTER, 0x20) |
154 | + case COUNTER2: | 257 | + FIELD(INTERRUPT_ENABLE_REGISTER, ETXFEMP, 14, 1) |
155 | + if (rtc->reg[CONTROL] & RTC_ENABLED) { | 258 | + FIELD(INTERRUPT_ENABLE_REGISTER, ETXFWMEMP, 13, 1) |
156 | + rtc->reg[r] = aspeed_rtc_get_counter(rtc, r); | 259 | + FIELD(INTERRUPT_ENABLE_REGISTER, ERXFWMFLL, 12, 1) |
260 | + FIELD(INTERRUPT_ENABLE_REGISTER, EWKUP, 11, 1) | ||
261 | + FIELD(INTERRUPT_ENABLE_REGISTER, ESLP, 10, 1) | ||
262 | + FIELD(INTERRUPT_ENABLE_REGISTER, EBSOFF, 9, 1) | ||
263 | + FIELD(INTERRUPT_ENABLE_REGISTER, EERROR, 8, 1) | ||
264 | + FIELD(INTERRUPT_ENABLE_REGISTER, ERXNEMP, 7, 1) | ||
265 | + FIELD(INTERRUPT_ENABLE_REGISTER, ERXOFLW, 6, 1) | ||
266 | + FIELD(INTERRUPT_ENABLE_REGISTER, ERXUFLW, 5, 1) | ||
267 | + FIELD(INTERRUPT_ENABLE_REGISTER, ERXOK, 4, 1) | ||
268 | + FIELD(INTERRUPT_ENABLE_REGISTER, ETXBFLL, 3, 1) | ||
269 | + FIELD(INTERRUPT_ENABLE_REGISTER, ETXFLL, 2, 1) | ||
270 | + FIELD(INTERRUPT_ENABLE_REGISTER, ETXOK, 1, 1) | ||
271 | + FIELD(INTERRUPT_ENABLE_REGISTER, EARBLST, 0, 1) | ||
272 | +REG32(INTERRUPT_CLEAR_REGISTER, 0x24) | ||
273 | + FIELD(INTERRUPT_CLEAR_REGISTER, CTXFEMP, 14, 1) | ||
274 | + FIELD(INTERRUPT_CLEAR_REGISTER, CTXFWMEMP, 13, 1) | ||
275 | + FIELD(INTERRUPT_CLEAR_REGISTER, CRXFWMFLL, 12, 1) | ||
276 | + FIELD(INTERRUPT_CLEAR_REGISTER, CWKUP, 11, 1) | ||
277 | + FIELD(INTERRUPT_CLEAR_REGISTER, CSLP, 10, 1) | ||
278 | + FIELD(INTERRUPT_CLEAR_REGISTER, CBSOFF, 9, 1) | ||
279 | + FIELD(INTERRUPT_CLEAR_REGISTER, CERROR, 8, 1) | ||
280 | + FIELD(INTERRUPT_CLEAR_REGISTER, CRXNEMP, 7, 1) | ||
281 | + FIELD(INTERRUPT_CLEAR_REGISTER, CRXOFLW, 6, 1) | ||
282 | + FIELD(INTERRUPT_CLEAR_REGISTER, CRXUFLW, 5, 1) | ||
283 | + FIELD(INTERRUPT_CLEAR_REGISTER, CRXOK, 4, 1) | ||
284 | + FIELD(INTERRUPT_CLEAR_REGISTER, CTXBFLL, 3, 1) | ||
285 | + FIELD(INTERRUPT_CLEAR_REGISTER, CTXFLL, 2, 1) | ||
286 | + FIELD(INTERRUPT_CLEAR_REGISTER, CTXOK, 1, 1) | ||
287 | + FIELD(INTERRUPT_CLEAR_REGISTER, CARBLST, 0, 1) | ||
288 | +REG32(TIMESTAMP_REGISTER, 0x28) | ||
289 | + FIELD(TIMESTAMP_REGISTER, CTS, 0, 1) | ||
290 | +REG32(WIR, 0x2c) | ||
291 | + FIELD(WIR, EW, 8, 8) | ||
292 | + FIELD(WIR, FW, 0, 8) | ||
293 | +REG32(TXFIFO_ID, 0x30) | ||
294 | + FIELD(TXFIFO_ID, IDH, 21, 11) | ||
295 | + FIELD(TXFIFO_ID, SRRRTR, 20, 1) | ||
296 | + FIELD(TXFIFO_ID, IDE, 19, 1) | ||
297 | + FIELD(TXFIFO_ID, IDL, 1, 18) | ||
298 | + FIELD(TXFIFO_ID, RTR, 0, 1) | ||
299 | +REG32(TXFIFO_DLC, 0x34) | ||
300 | + FIELD(TXFIFO_DLC, DLC, 28, 4) | ||
301 | +REG32(TXFIFO_DATA1, 0x38) | ||
302 | + FIELD(TXFIFO_DATA1, DB0, 24, 8) | ||
303 | + FIELD(TXFIFO_DATA1, DB1, 16, 8) | ||
304 | + FIELD(TXFIFO_DATA1, DB2, 8, 8) | ||
305 | + FIELD(TXFIFO_DATA1, DB3, 0, 8) | ||
306 | +REG32(TXFIFO_DATA2, 0x3c) | ||
307 | + FIELD(TXFIFO_DATA2, DB4, 24, 8) | ||
308 | + FIELD(TXFIFO_DATA2, DB5, 16, 8) | ||
309 | + FIELD(TXFIFO_DATA2, DB6, 8, 8) | ||
310 | + FIELD(TXFIFO_DATA2, DB7, 0, 8) | ||
311 | +REG32(TXHPB_ID, 0x40) | ||
312 | + FIELD(TXHPB_ID, IDH, 21, 11) | ||
313 | + FIELD(TXHPB_ID, SRRRTR, 20, 1) | ||
314 | + FIELD(TXHPB_ID, IDE, 19, 1) | ||
315 | + FIELD(TXHPB_ID, IDL, 1, 18) | ||
316 | + FIELD(TXHPB_ID, RTR, 0, 1) | ||
317 | +REG32(TXHPB_DLC, 0x44) | ||
318 | + FIELD(TXHPB_DLC, DLC, 28, 4) | ||
319 | +REG32(TXHPB_DATA1, 0x48) | ||
320 | + FIELD(TXHPB_DATA1, DB0, 24, 8) | ||
321 | + FIELD(TXHPB_DATA1, DB1, 16, 8) | ||
322 | + FIELD(TXHPB_DATA1, DB2, 8, 8) | ||
323 | + FIELD(TXHPB_DATA1, DB3, 0, 8) | ||
324 | +REG32(TXHPB_DATA2, 0x4c) | ||
325 | + FIELD(TXHPB_DATA2, DB4, 24, 8) | ||
326 | + FIELD(TXHPB_DATA2, DB5, 16, 8) | ||
327 | + FIELD(TXHPB_DATA2, DB6, 8, 8) | ||
328 | + FIELD(TXHPB_DATA2, DB7, 0, 8) | ||
329 | +REG32(RXFIFO_ID, 0x50) | ||
330 | + FIELD(RXFIFO_ID, IDH, 21, 11) | ||
331 | + FIELD(RXFIFO_ID, SRRRTR, 20, 1) | ||
332 | + FIELD(RXFIFO_ID, IDE, 19, 1) | ||
333 | + FIELD(RXFIFO_ID, IDL, 1, 18) | ||
334 | + FIELD(RXFIFO_ID, RTR, 0, 1) | ||
335 | +REG32(RXFIFO_DLC, 0x54) | ||
336 | + FIELD(RXFIFO_DLC, DLC, 28, 4) | ||
337 | + FIELD(RXFIFO_DLC, RXT, 0, 16) | ||
338 | +REG32(RXFIFO_DATA1, 0x58) | ||
339 | + FIELD(RXFIFO_DATA1, DB0, 24, 8) | ||
340 | + FIELD(RXFIFO_DATA1, DB1, 16, 8) | ||
341 | + FIELD(RXFIFO_DATA1, DB2, 8, 8) | ||
342 | + FIELD(RXFIFO_DATA1, DB3, 0, 8) | ||
343 | +REG32(RXFIFO_DATA2, 0x5c) | ||
344 | + FIELD(RXFIFO_DATA2, DB4, 24, 8) | ||
345 | + FIELD(RXFIFO_DATA2, DB5, 16, 8) | ||
346 | + FIELD(RXFIFO_DATA2, DB6, 8, 8) | ||
347 | + FIELD(RXFIFO_DATA2, DB7, 0, 8) | ||
348 | +REG32(AFR, 0x60) | ||
349 | + FIELD(AFR, UAF4, 3, 1) | ||
350 | + FIELD(AFR, UAF3, 2, 1) | ||
351 | + FIELD(AFR, UAF2, 1, 1) | ||
352 | + FIELD(AFR, UAF1, 0, 1) | ||
353 | +REG32(AFMR1, 0x64) | ||
354 | + FIELD(AFMR1, AMIDH, 21, 11) | ||
355 | + FIELD(AFMR1, AMSRR, 20, 1) | ||
356 | + FIELD(AFMR1, AMIDE, 19, 1) | ||
357 | + FIELD(AFMR1, AMIDL, 1, 18) | ||
358 | + FIELD(AFMR1, AMRTR, 0, 1) | ||
359 | +REG32(AFIR1, 0x68) | ||
360 | + FIELD(AFIR1, AIIDH, 21, 11) | ||
361 | + FIELD(AFIR1, AISRR, 20, 1) | ||
362 | + FIELD(AFIR1, AIIDE, 19, 1) | ||
363 | + FIELD(AFIR1, AIIDL, 1, 18) | ||
364 | + FIELD(AFIR1, AIRTR, 0, 1) | ||
365 | +REG32(AFMR2, 0x6c) | ||
366 | + FIELD(AFMR2, AMIDH, 21, 11) | ||
367 | + FIELD(AFMR2, AMSRR, 20, 1) | ||
368 | + FIELD(AFMR2, AMIDE, 19, 1) | ||
369 | + FIELD(AFMR2, AMIDL, 1, 18) | ||
370 | + FIELD(AFMR2, AMRTR, 0, 1) | ||
371 | +REG32(AFIR2, 0x70) | ||
372 | + FIELD(AFIR2, AIIDH, 21, 11) | ||
373 | + FIELD(AFIR2, AISRR, 20, 1) | ||
374 | + FIELD(AFIR2, AIIDE, 19, 1) | ||
375 | + FIELD(AFIR2, AIIDL, 1, 18) | ||
376 | + FIELD(AFIR2, AIRTR, 0, 1) | ||
377 | +REG32(AFMR3, 0x74) | ||
378 | + FIELD(AFMR3, AMIDH, 21, 11) | ||
379 | + FIELD(AFMR3, AMSRR, 20, 1) | ||
380 | + FIELD(AFMR3, AMIDE, 19, 1) | ||
381 | + FIELD(AFMR3, AMIDL, 1, 18) | ||
382 | + FIELD(AFMR3, AMRTR, 0, 1) | ||
383 | +REG32(AFIR3, 0x78) | ||
384 | + FIELD(AFIR3, AIIDH, 21, 11) | ||
385 | + FIELD(AFIR3, AISRR, 20, 1) | ||
386 | + FIELD(AFIR3, AIIDE, 19, 1) | ||
387 | + FIELD(AFIR3, AIIDL, 1, 18) | ||
388 | + FIELD(AFIR3, AIRTR, 0, 1) | ||
389 | +REG32(AFMR4, 0x7c) | ||
390 | + FIELD(AFMR4, AMIDH, 21, 11) | ||
391 | + FIELD(AFMR4, AMSRR, 20, 1) | ||
392 | + FIELD(AFMR4, AMIDE, 19, 1) | ||
393 | + FIELD(AFMR4, AMIDL, 1, 18) | ||
394 | + FIELD(AFMR4, AMRTR, 0, 1) | ||
395 | +REG32(AFIR4, 0x80) | ||
396 | + FIELD(AFIR4, AIIDH, 21, 11) | ||
397 | + FIELD(AFIR4, AISRR, 20, 1) | ||
398 | + FIELD(AFIR4, AIIDE, 19, 1) | ||
399 | + FIELD(AFIR4, AIIDL, 1, 18) | ||
400 | + FIELD(AFIR4, AIRTR, 0, 1) | ||
401 | + | ||
402 | +static void can_update_irq(XlnxZynqMPCANState *s) | ||
403 | +{ | ||
404 | + uint32_t irq; | ||
405 | + | ||
406 | + /* Watermark register interrupts. */ | ||
407 | + if ((fifo32_num_free(&s->tx_fifo) / CAN_FRAME_SIZE) > | ||
408 | + ARRAY_FIELD_EX32(s->regs, WIR, EW)) { | ||
409 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, TXFWMEMP, 1); | ||
410 | + } | ||
411 | + | ||
412 | + if ((fifo32_num_used(&s->rx_fifo) / CAN_FRAME_SIZE) > | ||
413 | + ARRAY_FIELD_EX32(s->regs, WIR, FW)) { | ||
414 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXFWMFLL, 1); | ||
415 | + } | ||
416 | + | ||
417 | + /* RX Interrupts. */ | ||
418 | + if (fifo32_num_used(&s->rx_fifo) >= CAN_FRAME_SIZE) { | ||
419 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXNEMP, 1); | ||
420 | + } | ||
421 | + | ||
422 | + /* TX interrupts. */ | ||
423 | + if (fifo32_is_empty(&s->tx_fifo)) { | ||
424 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, TXFEMP, 1); | ||
425 | + } | ||
426 | + | ||
427 | + if (fifo32_is_full(&s->tx_fifo)) { | ||
428 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, TXFLL, 1); | ||
429 | + } | ||
430 | + | ||
431 | + if (fifo32_is_full(&s->txhpb_fifo)) { | ||
432 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, TXBFLL, 1); | ||
433 | + } | ||
434 | + | ||
435 | + irq = s->regs[R_INTERRUPT_STATUS_REGISTER]; | ||
436 | + irq &= s->regs[R_INTERRUPT_ENABLE_REGISTER]; | ||
437 | + | ||
438 | + trace_xlnx_can_update_irq(s->regs[R_INTERRUPT_STATUS_REGISTER], | ||
439 | + s->regs[R_INTERRUPT_ENABLE_REGISTER], irq); | ||
440 | + qemu_set_irq(s->irq, irq); | ||
441 | +} | ||
442 | + | ||
443 | +static void can_ier_post_write(RegisterInfo *reg, uint64_t val) | ||
444 | +{ | ||
445 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
446 | + | ||
447 | + can_update_irq(s); | ||
448 | +} | ||
449 | + | ||
450 | +static uint64_t can_icr_pre_write(RegisterInfo *reg, uint64_t val) | ||
451 | +{ | ||
452 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
453 | + | ||
454 | + s->regs[R_INTERRUPT_STATUS_REGISTER] &= ~val; | ||
455 | + can_update_irq(s); | ||
456 | + | ||
457 | + return 0; | ||
458 | +} | ||
459 | + | ||
460 | +static void can_config_reset(XlnxZynqMPCANState *s) | ||
461 | +{ | ||
462 | + /* Reset all the configuration registers. */ | ||
463 | + register_reset(&s->reg_info[R_SOFTWARE_RESET_REGISTER]); | ||
464 | + register_reset(&s->reg_info[R_MODE_SELECT_REGISTER]); | ||
465 | + register_reset( | ||
466 | + &s->reg_info[R_ARBITRATION_PHASE_BAUD_RATE_PRESCALER_REGISTER]); | ||
467 | + register_reset(&s->reg_info[R_ARBITRATION_PHASE_BIT_TIMING_REGISTER]); | ||
468 | + register_reset(&s->reg_info[R_STATUS_REGISTER]); | ||
469 | + register_reset(&s->reg_info[R_INTERRUPT_STATUS_REGISTER]); | ||
470 | + register_reset(&s->reg_info[R_INTERRUPT_ENABLE_REGISTER]); | ||
471 | + register_reset(&s->reg_info[R_INTERRUPT_CLEAR_REGISTER]); | ||
472 | + register_reset(&s->reg_info[R_WIR]); | ||
473 | +} | ||
474 | + | ||
475 | +static void can_config_mode(XlnxZynqMPCANState *s) | ||
476 | +{ | ||
477 | + register_reset(&s->reg_info[R_ERROR_COUNTER_REGISTER]); | ||
478 | + register_reset(&s->reg_info[R_ERROR_STATUS_REGISTER]); | ||
479 | + | ||
480 | + /* Put XlnxZynqMPCAN in configuration mode. */ | ||
481 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, CONFIG, 1); | ||
482 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, WKUP, 0); | ||
483 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, SLP, 0); | ||
484 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, BSOFF, 0); | ||
485 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, ERROR, 0); | ||
486 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOFLW, 0); | ||
487 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOK, 0); | ||
488 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, TXOK, 0); | ||
489 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, ARBLST, 0); | ||
490 | + | ||
491 | + can_update_irq(s); | ||
492 | +} | ||
493 | + | ||
494 | +static void update_status_register_mode_bits(XlnxZynqMPCANState *s) | ||
495 | +{ | ||
496 | + bool sleep_status = ARRAY_FIELD_EX32(s->regs, STATUS_REGISTER, SLEEP); | ||
497 | + bool sleep_mode = ARRAY_FIELD_EX32(s->regs, MODE_SELECT_REGISTER, SLEEP); | ||
498 | + /* Wake up interrupt bit. */ | ||
499 | + bool wakeup_irq_val = sleep_status && (sleep_mode == 0); | ||
500 | + /* Sleep interrupt bit. */ | ||
501 | + bool sleep_irq_val = sleep_mode && (sleep_status == 0); | ||
502 | + | ||
503 | + /* Clear previous core mode status bits. */ | ||
504 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, LBACK, 0); | ||
505 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, SLEEP, 0); | ||
506 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, SNOOP, 0); | ||
507 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, NORMAL, 0); | ||
508 | + | ||
509 | + /* set current mode bit and generate irqs accordingly. */ | ||
510 | + if (ARRAY_FIELD_EX32(s->regs, MODE_SELECT_REGISTER, LBACK)) { | ||
511 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, LBACK, 1); | ||
512 | + } else if (ARRAY_FIELD_EX32(s->regs, MODE_SELECT_REGISTER, SLEEP)) { | ||
513 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, SLEEP, 1); | ||
514 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, SLP, | ||
515 | + sleep_irq_val); | ||
516 | + } else if (ARRAY_FIELD_EX32(s->regs, MODE_SELECT_REGISTER, SNOOP)) { | ||
517 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, SNOOP, 1); | ||
518 | + } else { | ||
519 | + /* | ||
520 | + * If all bits are zero then XlnxZynqMPCAN is set in normal mode. | ||
521 | + */ | ||
522 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, NORMAL, 1); | ||
523 | + /* Set wakeup interrupt bit. */ | ||
524 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, WKUP, | ||
525 | + wakeup_irq_val); | ||
526 | + } | ||
527 | + | ||
528 | + can_update_irq(s); | ||
529 | +} | ||
530 | + | ||
531 | +static void can_exit_sleep_mode(XlnxZynqMPCANState *s) | ||
532 | +{ | ||
533 | + ARRAY_FIELD_DP32(s->regs, MODE_SELECT_REGISTER, SLEEP, 0); | ||
534 | + update_status_register_mode_bits(s); | ||
535 | +} | ||
536 | + | ||
537 | +static void generate_frame(qemu_can_frame *frame, uint32_t *data) | ||
538 | +{ | ||
539 | + frame->can_id = data[0]; | ||
540 | + frame->can_dlc = FIELD_EX32(data[1], TXFIFO_DLC, DLC); | ||
541 | + | ||
542 | + frame->data[0] = FIELD_EX32(data[2], TXFIFO_DATA1, DB3); | ||
543 | + frame->data[1] = FIELD_EX32(data[2], TXFIFO_DATA1, DB2); | ||
544 | + frame->data[2] = FIELD_EX32(data[2], TXFIFO_DATA1, DB1); | ||
545 | + frame->data[3] = FIELD_EX32(data[2], TXFIFO_DATA1, DB0); | ||
546 | + | ||
547 | + frame->data[4] = FIELD_EX32(data[3], TXFIFO_DATA2, DB7); | ||
548 | + frame->data[5] = FIELD_EX32(data[3], TXFIFO_DATA2, DB6); | ||
549 | + frame->data[6] = FIELD_EX32(data[3], TXFIFO_DATA2, DB5); | ||
550 | + frame->data[7] = FIELD_EX32(data[3], TXFIFO_DATA2, DB4); | ||
551 | +} | ||
552 | + | ||
553 | +static bool tx_ready_check(XlnxZynqMPCANState *s) | ||
554 | +{ | ||
555 | + if (ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, SRST)) { | ||
556 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
557 | + | ||
558 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Attempting to transfer data while" | ||
559 | + " data while controller is in reset mode.\n", | ||
560 | + path); | ||
561 | + return false; | ||
562 | + } | ||
563 | + | ||
564 | + if (ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, CEN) == 0) { | ||
565 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
566 | + | ||
567 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Attempting to transfer" | ||
568 | + " data while controller is in configuration mode. Reset" | ||
569 | + " the core so operations can start fresh.\n", | ||
570 | + path); | ||
571 | + return false; | ||
572 | + } | ||
573 | + | ||
574 | + if (ARRAY_FIELD_EX32(s->regs, STATUS_REGISTER, SNOOP)) { | ||
575 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
576 | + | ||
577 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Attempting to transfer" | ||
578 | + " data while controller is in SNOOP MODE.\n", | ||
579 | + path); | ||
580 | + return false; | ||
581 | + } | ||
582 | + | ||
583 | + return true; | ||
584 | +} | ||
585 | + | ||
586 | +static void transfer_fifo(XlnxZynqMPCANState *s, Fifo32 *fifo) | ||
587 | +{ | ||
588 | + qemu_can_frame frame; | ||
589 | + uint32_t data[CAN_FRAME_SIZE]; | ||
590 | + int i; | ||
591 | + bool can_tx = tx_ready_check(s); | ||
592 | + | ||
593 | + if (!can_tx) { | ||
594 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
595 | + | ||
596 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Controller is not enabled for data" | ||
597 | + " transfer.\n", path); | ||
598 | + can_update_irq(s); | ||
599 | + return; | ||
600 | + } | ||
601 | + | ||
602 | + while (!fifo32_is_empty(fifo)) { | ||
603 | + for (i = 0; i < CAN_FRAME_SIZE; i++) { | ||
604 | + data[i] = fifo32_pop(fifo); | ||
157 | + } | 605 | + } |
158 | + /* fall through */ | 606 | + |
159 | + case CONTROL: | 607 | + if (ARRAY_FIELD_EX32(s->regs, STATUS_REGISTER, LBACK)) { |
160 | + val = rtc->reg[r]; | 608 | + /* |
161 | + break; | 609 | + * Controller is in loopback. In Loopback mode, the CAN core |
162 | + case ALARM: | 610 | + * transmits a recessive bitstream on to the XlnxZynqMPCAN Bus. |
163 | + case ALARM_STATUS: | 611 | + * Any message transmitted is looped back to the RX line and |
164 | + default: | 612 | + * acknowledged. The XlnxZynqMPCAN core receives any message |
165 | + qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx "\n", __func__, addr); | 613 | + * that it transmits. |
614 | + */ | ||
615 | + if (fifo32_is_full(&s->rx_fifo)) { | ||
616 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOFLW, 1); | ||
617 | + } else { | ||
618 | + for (i = 0; i < CAN_FRAME_SIZE; i++) { | ||
619 | + fifo32_push(&s->rx_fifo, data[i]); | ||
620 | + } | ||
621 | + | ||
622 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOK, 1); | ||
623 | + } | ||
624 | + } else { | ||
625 | + /* Normal mode Tx. */ | ||
626 | + generate_frame(&frame, data); | ||
627 | + | ||
628 | + trace_xlnx_can_tx_data(frame.can_id, frame.can_dlc, | ||
629 | + frame.data[0], frame.data[1], | ||
630 | + frame.data[2], frame.data[3], | ||
631 | + frame.data[4], frame.data[5], | ||
632 | + frame.data[6], frame.data[7]); | ||
633 | + can_bus_client_send(&s->bus_client, &frame, 1); | ||
634 | + } | ||
635 | + } | ||
636 | + | ||
637 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, TXOK, 1); | ||
638 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, TXBFLL, 0); | ||
639 | + | ||
640 | + if (ARRAY_FIELD_EX32(s->regs, STATUS_REGISTER, SLEEP)) { | ||
641 | + can_exit_sleep_mode(s); | ||
642 | + } | ||
643 | + | ||
644 | + can_update_irq(s); | ||
645 | +} | ||
646 | + | ||
647 | +static uint64_t can_srr_pre_write(RegisterInfo *reg, uint64_t val) | ||
648 | +{ | ||
649 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
650 | + | ||
651 | + ARRAY_FIELD_DP32(s->regs, SOFTWARE_RESET_REGISTER, CEN, | ||
652 | + FIELD_EX32(val, SOFTWARE_RESET_REGISTER, CEN)); | ||
653 | + | ||
654 | + if (FIELD_EX32(val, SOFTWARE_RESET_REGISTER, SRST)) { | ||
655 | + trace_xlnx_can_reset(val); | ||
656 | + | ||
657 | + /* First, core will do software reset then will enter in config mode. */ | ||
658 | + can_config_reset(s); | ||
659 | + } | ||
660 | + | ||
661 | + if (ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, CEN) == 0) { | ||
662 | + can_config_mode(s); | ||
663 | + } else { | ||
664 | + /* | ||
665 | + * Leave config mode. Now XlnxZynqMPCAN core will enter normal, | ||
666 | + * sleep, snoop or loopback mode depending upon LBACK, SLEEP, SNOOP | ||
667 | + * register states. | ||
668 | + */ | ||
669 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, CONFIG, 0); | ||
670 | + | ||
671 | + ptimer_transaction_begin(s->can_timer); | ||
672 | + ptimer_set_count(s->can_timer, 0); | ||
673 | + ptimer_transaction_commit(s->can_timer); | ||
674 | + | ||
675 | + /* XlnxZynqMPCAN is out of config mode. It will send pending data. */ | ||
676 | + transfer_fifo(s, &s->txhpb_fifo); | ||
677 | + transfer_fifo(s, &s->tx_fifo); | ||
678 | + } | ||
679 | + | ||
680 | + update_status_register_mode_bits(s); | ||
681 | + | ||
682 | + return s->regs[R_SOFTWARE_RESET_REGISTER]; | ||
683 | +} | ||
684 | + | ||
685 | +static uint64_t can_msr_pre_write(RegisterInfo *reg, uint64_t val) | ||
686 | +{ | ||
687 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
688 | + uint8_t multi_mode; | ||
689 | + | ||
690 | + /* | ||
691 | + * Multiple mode set check. This is done to make sure user doesn't set | ||
692 | + * multiple modes. | ||
693 | + */ | ||
694 | + multi_mode = FIELD_EX32(val, MODE_SELECT_REGISTER, LBACK) + | ||
695 | + FIELD_EX32(val, MODE_SELECT_REGISTER, SLEEP) + | ||
696 | + FIELD_EX32(val, MODE_SELECT_REGISTER, SNOOP); | ||
697 | + | ||
698 | + if (multi_mode > 1) { | ||
699 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
700 | + | ||
701 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Attempting to config" | ||
702 | + " several modes simultaneously. One mode will be selected" | ||
703 | + " according to their priority: LBACK > SLEEP > SNOOP.\n", | ||
704 | + path); | ||
705 | + } | ||
706 | + | ||
707 | + if (ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, CEN) == 0) { | ||
708 | + /* We are in configuration mode, any mode can be selected. */ | ||
709 | + s->regs[R_MODE_SELECT_REGISTER] = val; | ||
710 | + } else { | ||
711 | + bool sleep_mode_bit = FIELD_EX32(val, MODE_SELECT_REGISTER, SLEEP); | ||
712 | + | ||
713 | + ARRAY_FIELD_DP32(s->regs, MODE_SELECT_REGISTER, SLEEP, sleep_mode_bit); | ||
714 | + | ||
715 | + if (FIELD_EX32(val, MODE_SELECT_REGISTER, LBACK)) { | ||
716 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
717 | + | ||
718 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Attempting to set" | ||
719 | + " LBACK mode without setting CEN bit as 0.\n", | ||
720 | + path); | ||
721 | + } else if (FIELD_EX32(val, MODE_SELECT_REGISTER, SNOOP)) { | ||
722 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
723 | + | ||
724 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Attempting to set" | ||
725 | + " SNOOP mode without setting CEN bit as 0.\n", | ||
726 | + path); | ||
727 | + } | ||
728 | + | ||
729 | + update_status_register_mode_bits(s); | ||
730 | + } | ||
731 | + | ||
732 | + return s->regs[R_MODE_SELECT_REGISTER]; | ||
733 | +} | ||
734 | + | ||
735 | +static uint64_t can_brpr_pre_write(RegisterInfo *reg, uint64_t val) | ||
736 | +{ | ||
737 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
738 | + | ||
739 | + /* Only allow writes when in config mode. */ | ||
740 | + if (ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, CEN)) { | ||
741 | + return s->regs[R_ARBITRATION_PHASE_BAUD_RATE_PRESCALER_REGISTER]; | ||
742 | + } | ||
743 | + | ||
744 | + return val; | ||
745 | +} | ||
746 | + | ||
747 | +static uint64_t can_btr_pre_write(RegisterInfo *reg, uint64_t val) | ||
748 | +{ | ||
749 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
750 | + | ||
751 | + /* Only allow writes when in config mode. */ | ||
752 | + if (ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, CEN)) { | ||
753 | + return s->regs[R_ARBITRATION_PHASE_BIT_TIMING_REGISTER]; | ||
754 | + } | ||
755 | + | ||
756 | + return val; | ||
757 | +} | ||
758 | + | ||
759 | +static uint64_t can_tcr_pre_write(RegisterInfo *reg, uint64_t val) | ||
760 | +{ | ||
761 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
762 | + | ||
763 | + if (FIELD_EX32(val, TIMESTAMP_REGISTER, CTS)) { | ||
764 | + ptimer_transaction_begin(s->can_timer); | ||
765 | + ptimer_set_count(s->can_timer, 0); | ||
766 | + ptimer_transaction_commit(s->can_timer); | ||
767 | + } | ||
768 | + | ||
769 | + return 0; | ||
770 | +} | ||
771 | + | ||
772 | +static void update_rx_fifo(XlnxZynqMPCANState *s, const qemu_can_frame *frame) | ||
773 | +{ | ||
774 | + bool filter_pass = false; | ||
775 | + uint16_t timestamp = 0; | ||
776 | + | ||
777 | + /* If no filter is enabled. Message will be stored in FIFO. */ | ||
778 | + if (!((ARRAY_FIELD_EX32(s->regs, AFR, UAF1)) | | ||
779 | + (ARRAY_FIELD_EX32(s->regs, AFR, UAF2)) | | ||
780 | + (ARRAY_FIELD_EX32(s->regs, AFR, UAF3)) | | ||
781 | + (ARRAY_FIELD_EX32(s->regs, AFR, UAF4)))) { | ||
782 | + filter_pass = true; | ||
783 | + } | ||
784 | + | ||
785 | + /* | ||
786 | + * Messages that pass any of the acceptance filters will be stored in | ||
787 | + * the RX FIFO. | ||
788 | + */ | ||
789 | + if (ARRAY_FIELD_EX32(s->regs, AFR, UAF1)) { | ||
790 | + uint32_t id_masked = s->regs[R_AFMR1] & frame->can_id; | ||
791 | + uint32_t filter_id_masked = s->regs[R_AFMR1] & s->regs[R_AFIR1]; | ||
792 | + | ||
793 | + if (filter_id_masked == id_masked) { | ||
794 | + filter_pass = true; | ||
795 | + } | ||
796 | + } | ||
797 | + | ||
798 | + if (ARRAY_FIELD_EX32(s->regs, AFR, UAF2)) { | ||
799 | + uint32_t id_masked = s->regs[R_AFMR2] & frame->can_id; | ||
800 | + uint32_t filter_id_masked = s->regs[R_AFMR2] & s->regs[R_AFIR2]; | ||
801 | + | ||
802 | + if (filter_id_masked == id_masked) { | ||
803 | + filter_pass = true; | ||
804 | + } | ||
805 | + } | ||
806 | + | ||
807 | + if (ARRAY_FIELD_EX32(s->regs, AFR, UAF3)) { | ||
808 | + uint32_t id_masked = s->regs[R_AFMR3] & frame->can_id; | ||
809 | + uint32_t filter_id_masked = s->regs[R_AFMR3] & s->regs[R_AFIR3]; | ||
810 | + | ||
811 | + if (filter_id_masked == id_masked) { | ||
812 | + filter_pass = true; | ||
813 | + } | ||
814 | + } | ||
815 | + | ||
816 | + if (ARRAY_FIELD_EX32(s->regs, AFR, UAF4)) { | ||
817 | + uint32_t id_masked = s->regs[R_AFMR4] & frame->can_id; | ||
818 | + uint32_t filter_id_masked = s->regs[R_AFMR4] & s->regs[R_AFIR4]; | ||
819 | + | ||
820 | + if (filter_id_masked == id_masked) { | ||
821 | + filter_pass = true; | ||
822 | + } | ||
823 | + } | ||
824 | + | ||
825 | + if (!filter_pass) { | ||
826 | + trace_xlnx_can_rx_fifo_filter_reject(frame->can_id, frame->can_dlc); | ||
827 | + return; | ||
828 | + } | ||
829 | + | ||
830 | + /* Store the message in fifo if it passed through any of the filters. */ | ||
831 | + if (filter_pass && frame->can_dlc <= MAX_DLC) { | ||
832 | + | ||
833 | + if (fifo32_is_full(&s->rx_fifo)) { | ||
834 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOFLW, 1); | ||
835 | + } else { | ||
836 | + timestamp = CAN_TIMER_MAX - ptimer_get_count(s->can_timer); | ||
837 | + | ||
838 | + fifo32_push(&s->rx_fifo, frame->can_id); | ||
839 | + | ||
840 | + fifo32_push(&s->rx_fifo, deposit32(0, R_RXFIFO_DLC_DLC_SHIFT, | ||
841 | + R_RXFIFO_DLC_DLC_LENGTH, | ||
842 | + frame->can_dlc) | | ||
843 | + deposit32(0, R_RXFIFO_DLC_RXT_SHIFT, | ||
844 | + R_RXFIFO_DLC_RXT_LENGTH, | ||
845 | + timestamp)); | ||
846 | + | ||
847 | + /* First 32 bit of the data. */ | ||
848 | + fifo32_push(&s->rx_fifo, deposit32(0, R_TXFIFO_DATA1_DB3_SHIFT, | ||
849 | + R_TXFIFO_DATA1_DB3_LENGTH, | ||
850 | + frame->data[0]) | | ||
851 | + deposit32(0, R_TXFIFO_DATA1_DB2_SHIFT, | ||
852 | + R_TXFIFO_DATA1_DB2_LENGTH, | ||
853 | + frame->data[1]) | | ||
854 | + deposit32(0, R_TXFIFO_DATA1_DB1_SHIFT, | ||
855 | + R_TXFIFO_DATA1_DB1_LENGTH, | ||
856 | + frame->data[2]) | | ||
857 | + deposit32(0, R_TXFIFO_DATA1_DB0_SHIFT, | ||
858 | + R_TXFIFO_DATA1_DB0_LENGTH, | ||
859 | + frame->data[3])); | ||
860 | + /* Last 32 bit of the data. */ | ||
861 | + fifo32_push(&s->rx_fifo, deposit32(0, R_TXFIFO_DATA2_DB7_SHIFT, | ||
862 | + R_TXFIFO_DATA2_DB7_LENGTH, | ||
863 | + frame->data[4]) | | ||
864 | + deposit32(0, R_TXFIFO_DATA2_DB6_SHIFT, | ||
865 | + R_TXFIFO_DATA2_DB6_LENGTH, | ||
866 | + frame->data[5]) | | ||
867 | + deposit32(0, R_TXFIFO_DATA2_DB5_SHIFT, | ||
868 | + R_TXFIFO_DATA2_DB5_LENGTH, | ||
869 | + frame->data[6]) | | ||
870 | + deposit32(0, R_TXFIFO_DATA2_DB4_SHIFT, | ||
871 | + R_TXFIFO_DATA2_DB4_LENGTH, | ||
872 | + frame->data[7])); | ||
873 | + | ||
874 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOK, 1); | ||
875 | + trace_xlnx_can_rx_data(frame->can_id, frame->can_dlc, | ||
876 | + frame->data[0], frame->data[1], | ||
877 | + frame->data[2], frame->data[3], | ||
878 | + frame->data[4], frame->data[5], | ||
879 | + frame->data[6], frame->data[7]); | ||
880 | + } | ||
881 | + | ||
882 | + can_update_irq(s); | ||
883 | + } | ||
884 | +} | ||
885 | + | ||
886 | +static uint64_t can_rxfifo_pre_read(RegisterInfo *reg, uint64_t val) | ||
887 | +{ | ||
888 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
889 | + | ||
890 | + if (!fifo32_is_empty(&s->rx_fifo)) { | ||
891 | + val = fifo32_pop(&s->rx_fifo); | ||
892 | + } else { | ||
893 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXUFLW, 1); | ||
894 | + } | ||
895 | + | ||
896 | + can_update_irq(s); | ||
897 | + return val; | ||
898 | +} | ||
899 | + | ||
900 | +static void can_filter_enable_post_write(RegisterInfo *reg, uint64_t val) | ||
901 | +{ | ||
902 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
903 | + | ||
904 | + if (ARRAY_FIELD_EX32(s->regs, AFR, UAF1) && | ||
905 | + ARRAY_FIELD_EX32(s->regs, AFR, UAF2) && | ||
906 | + ARRAY_FIELD_EX32(s->regs, AFR, UAF3) && | ||
907 | + ARRAY_FIELD_EX32(s->regs, AFR, UAF4)) { | ||
908 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, ACFBSY, 1); | ||
909 | + } else { | ||
910 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, ACFBSY, 0); | ||
911 | + } | ||
912 | +} | ||
913 | + | ||
914 | +static uint64_t can_filter_mask_pre_write(RegisterInfo *reg, uint64_t val) | ||
915 | +{ | ||
916 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
917 | + uint32_t reg_idx = (reg->access->addr) / 4; | ||
918 | + uint32_t filter_number = (reg_idx - R_AFMR1) / 2; | ||
919 | + | ||
920 | + /* modify an acceptance filter, the corresponding UAF bit should be '0'. */ | ||
921 | + if (!(s->regs[R_AFR] & (1 << filter_number))) { | ||
922 | + s->regs[reg_idx] = val; | ||
923 | + | ||
924 | + trace_xlnx_can_filter_mask_pre_write(filter_number, s->regs[reg_idx]); | ||
925 | + } else { | ||
926 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
927 | + | ||
928 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Acceptance filter %d" | ||
929 | + " mask is not set as corresponding UAF bit is not 0.\n", | ||
930 | + path, filter_number + 1); | ||
931 | + } | ||
932 | + | ||
933 | + return s->regs[reg_idx]; | ||
934 | +} | ||
935 | + | ||
936 | +static uint64_t can_filter_id_pre_write(RegisterInfo *reg, uint64_t val) | ||
937 | +{ | ||
938 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
939 | + uint32_t reg_idx = (reg->access->addr) / 4; | ||
940 | + uint32_t filter_number = (reg_idx - R_AFIR1) / 2; | ||
941 | + | ||
942 | + if (!(s->regs[R_AFR] & (1 << filter_number))) { | ||
943 | + s->regs[reg_idx] = val; | ||
944 | + | ||
945 | + trace_xlnx_can_filter_id_pre_write(filter_number, s->regs[reg_idx]); | ||
946 | + } else { | ||
947 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
948 | + | ||
949 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Acceptance filter %d" | ||
950 | + " id is not set as corresponding UAF bit is not 0.\n", | ||
951 | + path, filter_number + 1); | ||
952 | + } | ||
953 | + | ||
954 | + return s->regs[reg_idx]; | ||
955 | +} | ||
956 | + | ||
957 | +static void can_tx_post_write(RegisterInfo *reg, uint64_t val) | ||
958 | +{ | ||
959 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
960 | + | ||
961 | + bool is_txhpb = reg->access->addr > A_TXFIFO_DATA2; | ||
962 | + | ||
963 | + bool initiate_transfer = (reg->access->addr == A_TXFIFO_DATA2) || | ||
964 | + (reg->access->addr == A_TXHPB_DATA2); | ||
965 | + | ||
966 | + Fifo32 *f = is_txhpb ? &s->txhpb_fifo : &s->tx_fifo; | ||
967 | + | ||
968 | + if (!fifo32_is_full(f)) { | ||
969 | + fifo32_push(f, val); | ||
970 | + } else { | ||
971 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
972 | + | ||
973 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: TX FIFO is full.\n", path); | ||
974 | + } | ||
975 | + | ||
976 | + /* Initiate the message send if TX register is written. */ | ||
977 | + if (initiate_transfer && | ||
978 | + ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, CEN)) { | ||
979 | + transfer_fifo(s, f); | ||
980 | + } | ||
981 | + | ||
982 | + can_update_irq(s); | ||
983 | +} | ||
984 | + | ||
985 | +static const RegisterAccessInfo can_regs_info[] = { | ||
986 | + { .name = "SOFTWARE_RESET_REGISTER", | ||
987 | + .addr = A_SOFTWARE_RESET_REGISTER, | ||
988 | + .rsvd = 0xfffffffc, | ||
989 | + .pre_write = can_srr_pre_write, | ||
990 | + },{ .name = "MODE_SELECT_REGISTER", | ||
991 | + .addr = A_MODE_SELECT_REGISTER, | ||
992 | + .rsvd = 0xfffffff8, | ||
993 | + .pre_write = can_msr_pre_write, | ||
994 | + },{ .name = "ARBITRATION_PHASE_BAUD_RATE_PRESCALER_REGISTER", | ||
995 | + .addr = A_ARBITRATION_PHASE_BAUD_RATE_PRESCALER_REGISTER, | ||
996 | + .rsvd = 0xffffff00, | ||
997 | + .pre_write = can_brpr_pre_write, | ||
998 | + },{ .name = "ARBITRATION_PHASE_BIT_TIMING_REGISTER", | ||
999 | + .addr = A_ARBITRATION_PHASE_BIT_TIMING_REGISTER, | ||
1000 | + .rsvd = 0xfffffe00, | ||
1001 | + .pre_write = can_btr_pre_write, | ||
1002 | + },{ .name = "ERROR_COUNTER_REGISTER", | ||
1003 | + .addr = A_ERROR_COUNTER_REGISTER, | ||
1004 | + .rsvd = 0xffff0000, | ||
1005 | + .ro = 0xffffffff, | ||
1006 | + },{ .name = "ERROR_STATUS_REGISTER", | ||
1007 | + .addr = A_ERROR_STATUS_REGISTER, | ||
1008 | + .rsvd = 0xffffffe0, | ||
1009 | + .w1c = 0x1f, | ||
1010 | + },{ .name = "STATUS_REGISTER", .addr = A_STATUS_REGISTER, | ||
1011 | + .reset = 0x1, | ||
1012 | + .rsvd = 0xffffe000, | ||
1013 | + .ro = 0x1fff, | ||
1014 | + },{ .name = "INTERRUPT_STATUS_REGISTER", | ||
1015 | + .addr = A_INTERRUPT_STATUS_REGISTER, | ||
1016 | + .reset = 0x6000, | ||
1017 | + .rsvd = 0xffff8000, | ||
1018 | + .ro = 0x7fff, | ||
1019 | + },{ .name = "INTERRUPT_ENABLE_REGISTER", | ||
1020 | + .addr = A_INTERRUPT_ENABLE_REGISTER, | ||
1021 | + .rsvd = 0xffff8000, | ||
1022 | + .post_write = can_ier_post_write, | ||
1023 | + },{ .name = "INTERRUPT_CLEAR_REGISTER", | ||
1024 | + .addr = A_INTERRUPT_CLEAR_REGISTER, | ||
1025 | + .rsvd = 0xffff8000, | ||
1026 | + .pre_write = can_icr_pre_write, | ||
1027 | + },{ .name = "TIMESTAMP_REGISTER", | ||
1028 | + .addr = A_TIMESTAMP_REGISTER, | ||
1029 | + .rsvd = 0xfffffffe, | ||
1030 | + .pre_write = can_tcr_pre_write, | ||
1031 | + },{ .name = "WIR", .addr = A_WIR, | ||
1032 | + .reset = 0x3f3f, | ||
1033 | + .rsvd = 0xffff0000, | ||
1034 | + },{ .name = "TXFIFO_ID", .addr = A_TXFIFO_ID, | ||
1035 | + .post_write = can_tx_post_write, | ||
1036 | + },{ .name = "TXFIFO_DLC", .addr = A_TXFIFO_DLC, | ||
1037 | + .rsvd = 0xfffffff, | ||
1038 | + .post_write = can_tx_post_write, | ||
1039 | + },{ .name = "TXFIFO_DATA1", .addr = A_TXFIFO_DATA1, | ||
1040 | + .post_write = can_tx_post_write, | ||
1041 | + },{ .name = "TXFIFO_DATA2", .addr = A_TXFIFO_DATA2, | ||
1042 | + .post_write = can_tx_post_write, | ||
1043 | + },{ .name = "TXHPB_ID", .addr = A_TXHPB_ID, | ||
1044 | + .post_write = can_tx_post_write, | ||
1045 | + },{ .name = "TXHPB_DLC", .addr = A_TXHPB_DLC, | ||
1046 | + .rsvd = 0xfffffff, | ||
1047 | + .post_write = can_tx_post_write, | ||
1048 | + },{ .name = "TXHPB_DATA1", .addr = A_TXHPB_DATA1, | ||
1049 | + .post_write = can_tx_post_write, | ||
1050 | + },{ .name = "TXHPB_DATA2", .addr = A_TXHPB_DATA2, | ||
1051 | + .post_write = can_tx_post_write, | ||
1052 | + },{ .name = "RXFIFO_ID", .addr = A_RXFIFO_ID, | ||
1053 | + .ro = 0xffffffff, | ||
1054 | + .post_read = can_rxfifo_pre_read, | ||
1055 | + },{ .name = "RXFIFO_DLC", .addr = A_RXFIFO_DLC, | ||
1056 | + .rsvd = 0xfff0000, | ||
1057 | + .post_read = can_rxfifo_pre_read, | ||
1058 | + },{ .name = "RXFIFO_DATA1", .addr = A_RXFIFO_DATA1, | ||
1059 | + .post_read = can_rxfifo_pre_read, | ||
1060 | + },{ .name = "RXFIFO_DATA2", .addr = A_RXFIFO_DATA2, | ||
1061 | + .post_read = can_rxfifo_pre_read, | ||
1062 | + },{ .name = "AFR", .addr = A_AFR, | ||
1063 | + .rsvd = 0xfffffff0, | ||
1064 | + .post_write = can_filter_enable_post_write, | ||
1065 | + },{ .name = "AFMR1", .addr = A_AFMR1, | ||
1066 | + .pre_write = can_filter_mask_pre_write, | ||
1067 | + },{ .name = "AFIR1", .addr = A_AFIR1, | ||
1068 | + .pre_write = can_filter_id_pre_write, | ||
1069 | + },{ .name = "AFMR2", .addr = A_AFMR2, | ||
1070 | + .pre_write = can_filter_mask_pre_write, | ||
1071 | + },{ .name = "AFIR2", .addr = A_AFIR2, | ||
1072 | + .pre_write = can_filter_id_pre_write, | ||
1073 | + },{ .name = "AFMR3", .addr = A_AFMR3, | ||
1074 | + .pre_write = can_filter_mask_pre_write, | ||
1075 | + },{ .name = "AFIR3", .addr = A_AFIR3, | ||
1076 | + .pre_write = can_filter_id_pre_write, | ||
1077 | + },{ .name = "AFMR4", .addr = A_AFMR4, | ||
1078 | + .pre_write = can_filter_mask_pre_write, | ||
1079 | + },{ .name = "AFIR4", .addr = A_AFIR4, | ||
1080 | + .pre_write = can_filter_id_pre_write, | ||
1081 | + } | ||
1082 | +}; | ||
1083 | + | ||
1084 | +static void xlnx_zynqmp_can_ptimer_cb(void *opaque) | ||
1085 | +{ | ||
1086 | + /* No action required on the timer rollover. */ | ||
1087 | +} | ||
1088 | + | ||
1089 | +static const MemoryRegionOps can_ops = { | ||
1090 | + .read = register_read_memory, | ||
1091 | + .write = register_write_memory, | ||
1092 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
1093 | + .valid = { | ||
1094 | + .min_access_size = 4, | ||
1095 | + .max_access_size = 4, | ||
1096 | + }, | ||
1097 | +}; | ||
1098 | + | ||
1099 | +static void xlnx_zynqmp_can_reset_init(Object *obj, ResetType type) | ||
1100 | +{ | ||
1101 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(obj); | ||
1102 | + unsigned int i; | ||
1103 | + | ||
1104 | + for (i = R_RXFIFO_ID; i < ARRAY_SIZE(s->reg_info); ++i) { | ||
1105 | + register_reset(&s->reg_info[i]); | ||
1106 | + } | ||
1107 | + | ||
1108 | + ptimer_transaction_begin(s->can_timer); | ||
1109 | + ptimer_set_count(s->can_timer, 0); | ||
1110 | + ptimer_transaction_commit(s->can_timer); | ||
1111 | +} | ||
1112 | + | ||
1113 | +static void xlnx_zynqmp_can_reset_hold(Object *obj) | ||
1114 | +{ | ||
1115 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(obj); | ||
1116 | + unsigned int i; | ||
1117 | + | ||
1118 | + for (i = 0; i < R_RXFIFO_ID; ++i) { | ||
1119 | + register_reset(&s->reg_info[i]); | ||
1120 | + } | ||
1121 | + | ||
1122 | + /* | ||
1123 | + * Reset FIFOs when CAN model is reset. This will clear the fifo writes | ||
1124 | + * done by post_write which gets called from register_reset function, | ||
1125 | + * post_write handle will not be able to trigger tx because CAN will be | ||
1126 | + * disabled when software_reset_register is cleared first. | ||
1127 | + */ | ||
1128 | + fifo32_reset(&s->rx_fifo); | ||
1129 | + fifo32_reset(&s->tx_fifo); | ||
1130 | + fifo32_reset(&s->txhpb_fifo); | ||
1131 | +} | ||
1132 | + | ||
1133 | +static bool xlnx_zynqmp_can_can_receive(CanBusClientState *client) | ||
1134 | +{ | ||
1135 | + XlnxZynqMPCANState *s = container_of(client, XlnxZynqMPCANState, | ||
1136 | + bus_client); | ||
1137 | + | ||
1138 | + if (ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, SRST)) { | ||
1139 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
1140 | + | ||
1141 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Controller is in reset state.\n", | ||
1142 | + path); | ||
1143 | + return false; | ||
1144 | + } | ||
1145 | + | ||
1146 | + if ((ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, CEN)) == 0) { | ||
1147 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
1148 | + | ||
1149 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Controller is disabled. Incoming" | ||
1150 | + " messages will be discarded.\n", path); | ||
1151 | + return false; | ||
1152 | + } | ||
1153 | + | ||
1154 | + return true; | ||
1155 | +} | ||
1156 | + | ||
1157 | +static ssize_t xlnx_zynqmp_can_receive(CanBusClientState *client, | ||
1158 | + const qemu_can_frame *buf, size_t buf_size) { | ||
1159 | + XlnxZynqMPCANState *s = container_of(client, XlnxZynqMPCANState, | ||
1160 | + bus_client); | ||
1161 | + const qemu_can_frame *frame = buf; | ||
1162 | + | ||
1163 | + if (buf_size <= 0) { | ||
1164 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
1165 | + | ||
1166 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Error in the data received.\n", | ||
1167 | + path); | ||
166 | + return 0; | 1168 | + return 0; |
167 | + } | 1169 | + } |
168 | + | 1170 | + |
169 | + trace_aspeed_rtc_read(addr, val); | 1171 | + if (ARRAY_FIELD_EX32(s->regs, STATUS_REGISTER, SNOOP)) { |
170 | + | 1172 | + /* Snoop Mode: Just keep the data. no response back. */ |
171 | + return val; | 1173 | + update_rx_fifo(s, frame); |
172 | +} | 1174 | + } else if ((ARRAY_FIELD_EX32(s->regs, STATUS_REGISTER, SLEEP))) { |
173 | + | 1175 | + /* |
174 | +static void aspeed_rtc_write(void *opaque, hwaddr addr, | 1176 | + * XlnxZynqMPCAN is in sleep mode. Any data on bus will bring it to wake |
175 | + uint64_t val, unsigned size) | 1177 | + * up state. |
176 | +{ | 1178 | + */ |
177 | + AspeedRtcState *rtc = opaque; | 1179 | + can_exit_sleep_mode(s); |
178 | + uint32_t r = addr >> 2; | 1180 | + update_rx_fifo(s, frame); |
179 | + | 1181 | + } else if ((ARRAY_FIELD_EX32(s->regs, STATUS_REGISTER, SLEEP)) == 0) { |
180 | + switch (r) { | 1182 | + update_rx_fifo(s, frame); |
181 | + case COUNTER1: | 1183 | + } else { |
182 | + case COUNTER2: | 1184 | + /* |
183 | + if (!(rtc->reg[CONTROL] & RTC_UNLOCKED)) { | 1185 | + * XlnxZynqMPCAN will not participate in normal bus communication |
184 | + break; | 1186 | + * and will not receive any messages transmitted by other CAN nodes. |
1187 | + */ | ||
1188 | + trace_xlnx_can_rx_discard(s->regs[R_STATUS_REGISTER]); | ||
1189 | + } | ||
1190 | + | ||
1191 | + return 1; | ||
1192 | +} | ||
1193 | + | ||
1194 | +static CanBusClientInfo can_xilinx_bus_client_info = { | ||
1195 | + .can_receive = xlnx_zynqmp_can_can_receive, | ||
1196 | + .receive = xlnx_zynqmp_can_receive, | ||
1197 | +}; | ||
1198 | + | ||
1199 | +static int xlnx_zynqmp_can_connect_to_bus(XlnxZynqMPCANState *s, | ||
1200 | + CanBusState *bus) | ||
1201 | +{ | ||
1202 | + s->bus_client.info = &can_xilinx_bus_client_info; | ||
1203 | + | ||
1204 | + if (can_bus_insert_client(bus, &s->bus_client) < 0) { | ||
1205 | + return -1; | ||
1206 | + } | ||
1207 | + return 0; | ||
1208 | +} | ||
1209 | + | ||
1210 | +static void xlnx_zynqmp_can_realize(DeviceState *dev, Error **errp) | ||
1211 | +{ | ||
1212 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(dev); | ||
1213 | + | ||
1214 | + if (s->canbus) { | ||
1215 | + if (xlnx_zynqmp_can_connect_to_bus(s, s->canbus) < 0) { | ||
1216 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
1217 | + | ||
1218 | + error_setg(errp, "%s: xlnx_zynqmp_can_connect_to_bus" | ||
1219 | + " failed.", path); | ||
1220 | + return; | ||
185 | + } | 1221 | + } |
186 | + /* fall through */ | 1222 | + } |
187 | + case CONTROL: | 1223 | + |
188 | + rtc->reg[r] = val; | 1224 | + /* Create RX FIFO, TXFIFO, TXHPB storage. */ |
189 | + aspeed_rtc_calc_offset(rtc); | 1225 | + fifo32_create(&s->rx_fifo, RXFIFO_SIZE); |
190 | + break; | 1226 | + fifo32_create(&s->tx_fifo, RXFIFO_SIZE); |
191 | + case ALARM: | 1227 | + fifo32_create(&s->txhpb_fifo, CAN_FRAME_SIZE); |
192 | + case ALARM_STATUS: | 1228 | + |
193 | + default: | 1229 | + /* Allocate a new timer. */ |
194 | + qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx "\n", __func__, addr); | 1230 | + s->can_timer = ptimer_init(xlnx_zynqmp_can_ptimer_cb, s, |
195 | + break; | 1231 | + PTIMER_POLICY_DEFAULT); |
196 | + } | 1232 | + |
197 | + trace_aspeed_rtc_write(addr, val); | 1233 | + ptimer_transaction_begin(s->can_timer); |
198 | +} | 1234 | + |
199 | + | 1235 | + ptimer_set_freq(s->can_timer, s->cfg.ext_clk_freq); |
200 | +static void aspeed_rtc_reset(DeviceState *d) | 1236 | + ptimer_set_limit(s->can_timer, CAN_TIMER_MAX, 1); |
201 | +{ | 1237 | + ptimer_run(s->can_timer, 0); |
202 | + AspeedRtcState *rtc = ASPEED_RTC(d); | 1238 | + ptimer_transaction_commit(s->can_timer); |
203 | + | 1239 | +} |
204 | + rtc->offset = 0; | 1240 | + |
205 | + memset(rtc->reg, 0, sizeof(rtc->reg)); | 1241 | +static void xlnx_zynqmp_can_init(Object *obj) |
206 | +} | 1242 | +{ |
207 | + | 1243 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(obj); |
208 | +static const MemoryRegionOps aspeed_rtc_ops = { | 1244 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
209 | + .read = aspeed_rtc_read, | 1245 | + |
210 | + .write = aspeed_rtc_write, | 1246 | + RegisterInfoArray *reg_array; |
211 | + .endianness = DEVICE_NATIVE_ENDIAN, | 1247 | + |
1248 | + memory_region_init(&s->iomem, obj, TYPE_XLNX_ZYNQMP_CAN, | ||
1249 | + XLNX_ZYNQMP_CAN_R_MAX * 4); | ||
1250 | + reg_array = register_init_block32(DEVICE(obj), can_regs_info, | ||
1251 | + ARRAY_SIZE(can_regs_info), | ||
1252 | + s->reg_info, s->regs, | ||
1253 | + &can_ops, | ||
1254 | + XLNX_ZYNQMP_CAN_ERR_DEBUG, | ||
1255 | + XLNX_ZYNQMP_CAN_R_MAX * 4); | ||
1256 | + | ||
1257 | + memory_region_add_subregion(&s->iomem, 0x00, ®_array->mem); | ||
1258 | + sysbus_init_mmio(sbd, &s->iomem); | ||
1259 | + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq); | ||
1260 | +} | ||
1261 | + | ||
1262 | +static const VMStateDescription vmstate_can = { | ||
1263 | + .name = TYPE_XLNX_ZYNQMP_CAN, | ||
1264 | + .version_id = 1, | ||
1265 | + .minimum_version_id = 1, | ||
1266 | + .fields = (VMStateField[]) { | ||
1267 | + VMSTATE_FIFO32(rx_fifo, XlnxZynqMPCANState), | ||
1268 | + VMSTATE_FIFO32(tx_fifo, XlnxZynqMPCANState), | ||
1269 | + VMSTATE_FIFO32(txhpb_fifo, XlnxZynqMPCANState), | ||
1270 | + VMSTATE_UINT32_ARRAY(regs, XlnxZynqMPCANState, XLNX_ZYNQMP_CAN_R_MAX), | ||
1271 | + VMSTATE_PTIMER(can_timer, XlnxZynqMPCANState), | ||
1272 | + VMSTATE_END_OF_LIST(), | ||
1273 | + } | ||
212 | +}; | 1274 | +}; |
213 | + | 1275 | + |
214 | +static const VMStateDescription vmstate_aspeed_rtc = { | 1276 | +static Property xlnx_zynqmp_can_properties[] = { |
215 | + .name = TYPE_ASPEED_RTC, | 1277 | + DEFINE_PROP_UINT32("ext_clk_freq", XlnxZynqMPCANState, cfg.ext_clk_freq, |
216 | + .version_id = 1, | 1278 | + CAN_DEFAULT_CLOCK), |
217 | + .fields = (VMStateField[]) { | 1279 | + DEFINE_PROP_LINK("canbus", XlnxZynqMPCANState, canbus, TYPE_CAN_BUS, |
218 | + VMSTATE_UINT32_ARRAY(reg, AspeedRtcState, 0x18), | 1280 | + CanBusState *), |
219 | + VMSTATE_INT32(offset, AspeedRtcState), | 1281 | + DEFINE_PROP_END_OF_LIST(), |
220 | + VMSTATE_INT32(offset, AspeedRtcState), | ||
221 | + VMSTATE_END_OF_LIST() | ||
222 | + } | ||
223 | +}; | 1282 | +}; |
224 | + | 1283 | + |
225 | +static void aspeed_rtc_realize(DeviceState *dev, Error **errp) | 1284 | +static void xlnx_zynqmp_can_class_init(ObjectClass *klass, void *data) |
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 | +{ | 1285 | +{ |
239 | + DeviceClass *dc = DEVICE_CLASS(klass); | 1286 | + DeviceClass *dc = DEVICE_CLASS(klass); |
240 | + | 1287 | + ResettableClass *rc = RESETTABLE_CLASS(klass); |
241 | + dc->realize = aspeed_rtc_realize; | 1288 | + |
242 | + dc->vmsd = &vmstate_aspeed_rtc; | 1289 | + rc->phases.enter = xlnx_zynqmp_can_reset_init; |
243 | + dc->reset = aspeed_rtc_reset; | 1290 | + rc->phases.hold = xlnx_zynqmp_can_reset_hold; |
244 | +} | 1291 | + dc->realize = xlnx_zynqmp_can_realize; |
245 | + | 1292 | + device_class_set_props(dc, xlnx_zynqmp_can_properties); |
246 | +static const TypeInfo aspeed_rtc_info = { | 1293 | + dc->vmsd = &vmstate_can; |
247 | + .name = TYPE_ASPEED_RTC, | 1294 | +} |
1295 | + | ||
1296 | +static const TypeInfo can_info = { | ||
1297 | + .name = TYPE_XLNX_ZYNQMP_CAN, | ||
248 | + .parent = TYPE_SYS_BUS_DEVICE, | 1298 | + .parent = TYPE_SYS_BUS_DEVICE, |
249 | + .instance_size = sizeof(AspeedRtcState), | 1299 | + .instance_size = sizeof(XlnxZynqMPCANState), |
250 | + .class_init = aspeed_rtc_class_init, | 1300 | + .class_init = xlnx_zynqmp_can_class_init, |
1301 | + .instance_init = xlnx_zynqmp_can_init, | ||
251 | +}; | 1302 | +}; |
252 | + | 1303 | + |
253 | +static void aspeed_rtc_register_types(void) | 1304 | +static void can_register_types(void) |
254 | +{ | 1305 | +{ |
255 | + type_register_static(&aspeed_rtc_info); | 1306 | + type_register_static(&can_info); |
256 | +} | 1307 | +} |
257 | + | 1308 | + |
258 | +type_init(aspeed_rtc_register_types) | 1309 | +type_init(can_register_types) |
259 | diff --git a/hw/timer/trace-events b/hw/timer/trace-events | 1310 | diff --git a/hw/Kconfig b/hw/Kconfig |
260 | index XXXXXXX..XXXXXXX 100644 | 1311 | index XXXXXXX..XXXXXXX 100644 |
261 | --- a/hw/timer/trace-events | 1312 | --- a/hw/Kconfig |
262 | +++ b/hw/timer/trace-events | 1313 | +++ b/hw/Kconfig |
263 | @@ -XXX,XX +XXX,XX @@ cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK A | 1314 | @@ -XXX,XX +XXX,XX @@ config XILINX_AXI |
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" | 1315 | config XLNX_ZYNQMP |
265 | cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset" | 1316 | bool |
266 | 1317 | select REGISTER | |
267 | +# hw/timer/aspeed-rtc.c | 1318 | + select CAN_BUS |
268 | +aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64 | 1319 | diff --git a/hw/net/can/meson.build b/hw/net/can/meson.build |
269 | +aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64 | 1320 | index XXXXXXX..XXXXXXX 100644 |
270 | + | 1321 | --- a/hw/net/can/meson.build |
271 | # sun4v-rtc.c | 1322 | +++ b/hw/net/can/meson.build |
272 | sun4v_rtc_read(uint64_t addr, uint64_t value) "read: addr 0x%" PRIx64 " value 0x%" PRIx64 | 1323 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_CAN_PCI', if_true: files('can_pcm3680_pci.c')) |
273 | sun4v_rtc_write(uint64_t addr, uint64_t value) "write: addr 0x%" PRIx64 " value 0x%" PRIx64 | 1324 | softmmu_ss.add(when: 'CONFIG_CAN_PCI', if_true: files('can_mioe3680_pci.c')) |
1325 | softmmu_ss.add(when: 'CONFIG_CAN_CTUCANFD', if_true: files('ctucan_core.c')) | ||
1326 | softmmu_ss.add(when: 'CONFIG_CAN_CTUCANFD_PCI', if_true: files('ctucan_pci.c')) | ||
1327 | +softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP', if_true: files('xlnx-zynqmp-can.c')) | ||
1328 | diff --git a/hw/net/can/trace-events b/hw/net/can/trace-events | ||
1329 | new file mode 100644 | ||
1330 | index XXXXXXX..XXXXXXX | ||
1331 | --- /dev/null | ||
1332 | +++ b/hw/net/can/trace-events | ||
1333 | @@ -XXX,XX +XXX,XX @@ | ||
1334 | +# xlnx-zynqmp-can.c | ||
1335 | +xlnx_can_update_irq(uint32_t isr, uint32_t ier, uint32_t irq) "ISR: 0x%08x IER: 0x%08x IRQ: 0x%08x" | ||
1336 | +xlnx_can_reset(uint32_t val) "Resetting controller with value = 0x%08x" | ||
1337 | +xlnx_can_rx_fifo_filter_reject(uint32_t id, uint8_t dlc) "Frame: ID: 0x%08x DLC: 0x%02x" | ||
1338 | +xlnx_can_filter_id_pre_write(uint8_t filter_num, uint32_t value) "Filter%d ID: 0x%08x" | ||
1339 | +xlnx_can_filter_mask_pre_write(uint8_t filter_num, uint32_t value) "Filter%d MASK: 0x%08x" | ||
1340 | +xlnx_can_tx_data(uint32_t id, uint8_t dlc, uint8_t db0, uint8_t db1, uint8_t db2, uint8_t db3, uint8_t db4, uint8_t db5, uint8_t db6, uint8_t db7) "Frame: ID: 0x%08x DLC: 0x%02x DATA: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" | ||
1341 | +xlnx_can_rx_data(uint32_t id, uint32_t dlc, uint8_t db0, uint8_t db1, uint8_t db2, uint8_t db3, uint8_t db4, uint8_t db5, uint8_t db6, uint8_t db7) "Frame: ID: 0x%08x DLC: 0x%02x DATA: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" | ||
1342 | +xlnx_can_rx_discard(uint32_t status) "Controller is not enabled for bus communication. Status Register: 0x%08x" | ||
274 | -- | 1343 | -- |
275 | 2.20.1 | 1344 | 2.20.1 |
276 | 1345 | ||
277 | 1346 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Vikram Garhwal <fnu.vikram@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | The current models of the Aspeed SoCs only have one CPU but future | 3 | Connect CAN0 and CAN1 on the ZynqMP. |
4 | ones will support SMP. Introduce a new num_cpus field at the SoC class | ||
5 | level to define the number of available CPUs per SoC and also | ||
6 | introduce a 'num-cpus' property to activate the CPUs configured for | ||
7 | the machine. | ||
8 | 4 | ||
9 | The max_cpus limit of the machine should depend on the SoC definition | 5 | Reviewed-by: Francisco Iglesias <francisco.iglesias@xilinx.com> |
10 | but, unfortunately, these values are not available when the machine | 6 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
11 | class is initialized. This is the reason why we add a check on | 7 | Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com> |
12 | num_cpus in the AspeedSoC realize handler. | 8 | Message-id: 1605728926-352690-3-git-send-email-fnu.vikram@xilinx.com |
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> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | --- | 10 | --- |
21 | include/hw/arm/aspeed_soc.h | 5 ++++- | 11 | include/hw/arm/xlnx-zynqmp.h | 8 ++++++++ |
22 | hw/arm/aspeed.c | 7 +++++-- | 12 | hw/arm/xlnx-zcu102.c | 20 ++++++++++++++++++++ |
23 | hw/arm/aspeed_soc.c | 33 +++++++++++++++++++++++++++------ | 13 | hw/arm/xlnx-zynqmp.c | 34 ++++++++++++++++++++++++++++++++++ |
24 | 3 files changed, 36 insertions(+), 9 deletions(-) | 14 | 3 files changed, 62 insertions(+) |
25 | 15 | ||
26 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | 16 | diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h |
27 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/include/hw/arm/aspeed_soc.h | 18 | --- a/include/hw/arm/xlnx-zynqmp.h |
29 | +++ b/include/hw/arm/aspeed_soc.h | 19 | +++ b/include/hw/arm/xlnx-zynqmp.h |
30 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ |
31 | 21 | #include "hw/intc/arm_gic.h" | |
32 | #define ASPEED_SPIS_NUM 2 | 22 | #include "hw/net/cadence_gem.h" |
33 | #define ASPEED_WDTS_NUM 3 | 23 | #include "hw/char/cadence_uart.h" |
34 | +#define ASPEED_CPUS_NUM 2 | 24 | +#include "hw/net/xlnx-zynqmp-can.h" |
35 | 25 | #include "hw/ide/ahci.h" | |
36 | typedef struct AspeedSoCState { | 26 | #include "hw/sd/sdhci.h" |
37 | /*< private >*/ | 27 | #include "hw/ssi/xilinx_spips.h" |
38 | DeviceState parent; | 28 | @@ -XXX,XX +XXX,XX @@ |
39 | 29 | #include "hw/cpu/cluster.h" | |
40 | /*< public >*/ | 30 | #include "target/arm/cpu.h" |
41 | - ARMCPU cpu; | 31 | #include "qom/object.h" |
42 | + ARMCPU cpu[ASPEED_CPUS_NUM]; | 32 | +#include "net/can_emu.h" |
43 | + uint32_t num_cpus; | 33 | |
44 | MemoryRegion sram; | 34 | #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp" |
45 | AspeedVICState vic; | 35 | OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) |
46 | AspeedRtcState rtc; | 36 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) |
47 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { | 37 | #define XLNX_ZYNQMP_NUM_RPU_CPUS 2 |
48 | int wdts_num; | 38 | #define XLNX_ZYNQMP_NUM_GEMS 4 |
49 | const int *irqmap; | 39 | #define XLNX_ZYNQMP_NUM_UARTS 2 |
50 | const hwaddr *memmap; | 40 | +#define XLNX_ZYNQMP_NUM_CAN 2 |
51 | + uint32_t num_cpus; | 41 | +#define XLNX_ZYNQMP_CAN_REF_CLK (24 * 1000 * 1000) |
52 | } AspeedSoCInfo; | 42 | #define XLNX_ZYNQMP_NUM_SDHCI 2 |
53 | 43 | #define XLNX_ZYNQMP_NUM_SPIS 2 | |
54 | typedef struct AspeedSoCClass { | 44 | #define XLNX_ZYNQMP_NUM_GDMA_CH 8 |
55 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 45 | @@ -XXX,XX +XXX,XX @@ struct XlnxZynqMPState { |
46 | |||
47 | CadenceGEMState gem[XLNX_ZYNQMP_NUM_GEMS]; | ||
48 | CadenceUARTState uart[XLNX_ZYNQMP_NUM_UARTS]; | ||
49 | + XlnxZynqMPCANState can[XLNX_ZYNQMP_NUM_CAN]; | ||
50 | SysbusAHCIState sata; | ||
51 | SDHCIState sdhci[XLNX_ZYNQMP_NUM_SDHCI]; | ||
52 | XilinxSPIPS spi[XLNX_ZYNQMP_NUM_SPIS]; | ||
53 | @@ -XXX,XX +XXX,XX @@ struct XlnxZynqMPState { | ||
54 | bool virt; | ||
55 | /* Has the RPU subsystem? */ | ||
56 | bool has_rpu; | ||
57 | + | ||
58 | + /* CAN bus. */ | ||
59 | + CanBusState *canbus[XLNX_ZYNQMP_NUM_CAN]; | ||
60 | }; | ||
61 | |||
62 | #endif | ||
63 | diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | 64 | index XXXXXXX..XXXXXXX 100644 |
57 | --- a/hw/arm/aspeed.c | 65 | --- a/hw/arm/xlnx-zcu102.c |
58 | +++ b/hw/arm/aspeed.c | 66 | +++ b/hw/arm/xlnx-zcu102.c |
59 | @@ -XXX,XX +XXX,XX @@ | 67 | @@ -XXX,XX +XXX,XX @@ |
60 | #include "hw/misc/tmp105.h" | 68 | #include "sysemu/qtest.h" |
61 | #include "qemu/log.h" | 69 | #include "sysemu/device_tree.h" |
62 | #include "sysemu/block-backend.h" | 70 | #include "qom/object.h" |
63 | +#include "sysemu/sysemu.h" | 71 | +#include "net/can_emu.h" |
64 | #include "hw/loader.h" | 72 | |
65 | #include "qemu/error-report.h" | 73 | struct XlnxZCU102 { |
66 | #include "qemu/units.h" | 74 | MachineState parent_obj; |
67 | 75 | @@ -XXX,XX +XXX,XX @@ struct XlnxZCU102 { | |
68 | static struct arm_boot_info aspeed_board_binfo = { | 76 | bool secure; |
69 | .board_id = -1, /* device-tree-only board */ | 77 | bool virt; |
70 | - .nb_cpus = 1, | 78 | |
79 | + CanBusState *canbus[XLNX_ZYNQMP_NUM_CAN]; | ||
80 | + | ||
81 | struct arm_boot_info binfo; | ||
71 | }; | 82 | }; |
72 | 83 | ||
73 | struct AspeedBoardState { | 84 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_init(MachineState *machine) |
74 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | 85 | object_property_set_bool(OBJECT(&s->soc), "virtualization", s->virt, |
75 | &error_abort); | 86 | &error_fatal); |
76 | object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs", | 87 | |
77 | &error_abort); | 88 | + for (i = 0; i < XLNX_ZYNQMP_NUM_CAN; i++) { |
78 | + object_property_set_int(OBJECT(&bmc->soc), smp_cpus, "num-cpus", | 89 | + gchar *bus_name = g_strdup_printf("canbus%d", i); |
79 | + &error_abort); | 90 | + |
80 | if (machine->kernel_filename) { | 91 | + object_property_set_link(OBJECT(&s->soc), bus_name, |
81 | /* | 92 | + OBJECT(s->canbus[i]), &error_fatal); |
82 | * When booting with a -kernel command line there is no u-boot | 93 | + g_free(bus_name); |
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 | + } | 94 | + } |
167 | + | 95 | + |
168 | /* CPU */ | 96 | qdev_realize(DEVICE(&s->soc), NULL, &error_fatal); |
169 | - object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); | 97 | |
170 | - if (err) { | 98 | /* Create and plug in the SD cards */ |
171 | - error_propagate(errp, err); | 99 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_machine_instance_init(Object *obj) |
172 | - return; | 100 | s->secure = false; |
173 | + for (i = 0; i < s->num_cpus; i++) { | 101 | /* Default to virt (EL2) being disabled */ |
174 | + object_property_set_bool(OBJECT(&s->cpu[i]), true, "realized", &err); | 102 | s->virt = false; |
103 | + object_property_add_link(obj, "xlnx-zcu102.canbus0", TYPE_CAN_BUS, | ||
104 | + (Object **)&s->canbus[0], | ||
105 | + object_property_allow_set_link, | ||
106 | + 0); | ||
107 | + | ||
108 | + object_property_add_link(obj, "xlnx-zcu102.canbus1", TYPE_CAN_BUS, | ||
109 | + (Object **)&s->canbus[1], | ||
110 | + object_property_allow_set_link, | ||
111 | + 0); | ||
112 | } | ||
113 | |||
114 | static void xlnx_zcu102_machine_class_init(ObjectClass *oc, void *data) | ||
115 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c | ||
116 | index XXXXXXX..XXXXXXX 100644 | ||
117 | --- a/hw/arm/xlnx-zynqmp.c | ||
118 | +++ b/hw/arm/xlnx-zynqmp.c | ||
119 | @@ -XXX,XX +XXX,XX @@ static const int uart_intr[XLNX_ZYNQMP_NUM_UARTS] = { | ||
120 | 21, 22, | ||
121 | }; | ||
122 | |||
123 | +static const uint64_t can_addr[XLNX_ZYNQMP_NUM_CAN] = { | ||
124 | + 0xFF060000, 0xFF070000, | ||
125 | +}; | ||
126 | + | ||
127 | +static const int can_intr[XLNX_ZYNQMP_NUM_CAN] = { | ||
128 | + 23, 24, | ||
129 | +}; | ||
130 | + | ||
131 | static const uint64_t sdhci_addr[XLNX_ZYNQMP_NUM_SDHCI] = { | ||
132 | 0xFF160000, 0xFF170000, | ||
133 | }; | ||
134 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_init(Object *obj) | ||
135 | TYPE_CADENCE_UART); | ||
136 | } | ||
137 | |||
138 | + for (i = 0; i < XLNX_ZYNQMP_NUM_CAN; i++) { | ||
139 | + object_initialize_child(obj, "can[*]", &s->can[i], | ||
140 | + TYPE_XLNX_ZYNQMP_CAN); | ||
141 | + } | ||
142 | + | ||
143 | object_initialize_child(obj, "sata", &s->sata, TYPE_SYSBUS_AHCI); | ||
144 | |||
145 | for (i = 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) { | ||
146 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | ||
147 | gic_spi[uart_intr[i]]); | ||
148 | } | ||
149 | |||
150 | + for (i = 0; i < XLNX_ZYNQMP_NUM_CAN; i++) { | ||
151 | + object_property_set_int(OBJECT(&s->can[i]), "ext_clk_freq", | ||
152 | + XLNX_ZYNQMP_CAN_REF_CLK, &error_abort); | ||
153 | + | ||
154 | + object_property_set_link(OBJECT(&s->can[i]), "canbus", | ||
155 | + OBJECT(s->canbus[i]), &error_fatal); | ||
156 | + | ||
157 | + sysbus_realize(SYS_BUS_DEVICE(&s->can[i]), &err); | ||
175 | + if (err) { | 158 | + if (err) { |
176 | + error_propagate(errp, err); | 159 | + error_propagate(errp, err); |
177 | + return; | 160 | + return; |
178 | + } | 161 | + } |
179 | } | 162 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->can[i]), 0, can_addr[i]); |
180 | 163 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->can[i]), 0, | |
181 | /* SRAM */ | 164 | + gic_spi[can_intr[i]]); |
182 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 165 | + } |
183 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, | 166 | + |
184 | aspeed_soc_get_irq(s, ASPEED_ETH1)); | 167 | object_property_set_int(OBJECT(&s->sata), "num-ports", SATA_NUM_PORTS, |
185 | } | 168 | &error_abort); |
186 | +static Property aspeed_soc_properties[] = { | 169 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->sata), errp)) { |
187 | + DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), | 170 | @@ -XXX,XX +XXX,XX @@ static Property xlnx_zynqmp_props[] = { |
188 | + DEFINE_PROP_END_OF_LIST(), | 171 | DEFINE_PROP_BOOL("has_rpu", XlnxZynqMPState, has_rpu, false), |
189 | +}; | 172 | DEFINE_PROP_LINK("ddr-ram", XlnxZynqMPState, ddr_ram, TYPE_MEMORY_REGION, |
190 | 173 | MemoryRegion *), | |
191 | static void aspeed_soc_class_init(ObjectClass *oc, void *data) | 174 | + DEFINE_PROP_LINK("canbus0", XlnxZynqMPState, canbus[0], TYPE_CAN_BUS, |
192 | { | 175 | + CanBusState *), |
193 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_class_init(ObjectClass *oc, void *data) | 176 | + DEFINE_PROP_LINK("canbus1", XlnxZynqMPState, canbus[1], TYPE_CAN_BUS, |
194 | dc->realize = aspeed_soc_realize; | 177 | + CanBusState *), |
195 | /* Reason: Uses serial_hds and nd_table in realize() directly */ | 178 | DEFINE_PROP_END_OF_LIST() |
196 | dc->user_creatable = false; | 179 | }; |
197 | + dc->props = aspeed_soc_properties; | 180 | |
198 | } | ||
199 | |||
200 | static const TypeInfo aspeed_soc_type_info = { | ||
201 | -- | 181 | -- |
202 | 2.20.1 | 182 | 2.20.1 |
203 | 183 | ||
204 | 184 | diff view generated by jsdifflib |
1 | From: Hongbo Zhang <hongbo.zhang@linaro.org> | 1 | From: Vikram Garhwal <fnu.vikram@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | For AArch64, the existing "virt" machine is primarily meant to | 3 | The QTests perform five tests on the Xilinx ZynqMP CAN controller: |
4 | run on KVM and execute virtualization workloads, but we need an | 4 | Tests the CAN controller in loopback, sleep and snoop mode. |
5 | environment as faithful as possible to physical hardware, for supporting | 5 | Tests filtering of incoming CAN messages. |
6 | firmware and OS development for physical Aarch64 machines. | 6 | |
7 | 7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | |
8 | This patch introduces new machine type 'sbsa-ref' with main features: | 8 | Reviewed-by: Francisco Iglesias <francisco.iglesias@xilinx.com> |
9 | - Based on 'virt' machine type. | 9 | Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com> |
10 | - A new memory map. | 10 | Message-id: 1605728926-352690-4-git-send-email-fnu.vikram@xilinx.com |
11 | - CPU type cortex-a57. | ||
12 | - EL2 and EL3 are enabled. | ||
13 | - GIC version 3. | ||
14 | - System bus AHCI controller. | ||
15 | - System bus EHCI controller. | ||
16 | - CDROM and hard disc on AHCI bus. | ||
17 | - E1000E ethernet card on PCIE bus. | ||
18 | - VGA display adaptor on PCIE bus. | ||
19 | - No virtio devices. | ||
20 | - No fw_cfg device. | ||
21 | - No ACPI table supplied. | ||
22 | - Only minimal device tree nodes. | ||
23 | |||
24 | Arm Trusted Firmware and UEFI porting to this are done accordingly, | ||
25 | and the firmware should supply ACPI tables to the guest OS. The | ||
26 | minimal device tree nodes supplied by QEMU for this platform are only | ||
27 | to pass the dynamic info reflecting command line input to firmware, | ||
28 | not for loading the guest OS. | ||
29 | |||
30 | To make the review easier, this task is split into two patches, the | ||
31 | fundamental skeleton part and the peripheral devices part; this patch is | ||
32 | the first part. | ||
33 | |||
34 | Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org> | ||
35 | Message-id: 1561890034-15921-2-git-send-email-hongbo.zhang@linaro.org | ||
36 | [PMM: commit message tweaks; moved some bits between patch 1 and 2 | ||
37 | to ensure patch 1 builds cleanly; removed unneeded lines from | ||
38 | Kconfig stanza; only provide board for qemu-system-aarch64, not | ||
39 | qemu-system-arm; added MAINTAINERS entry] | ||
40 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
41 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
42 | --- | 12 | --- |
43 | hw/arm/Makefile.objs | 1 + | 13 | tests/qtest/xlnx-can-test.c | 360 ++++++++++++++++++++++++++++++++++++ |
44 | hw/arm/sbsa-ref.c | 271 ++++++++++++++++++++++++++++ | 14 | tests/qtest/meson.build | 1 + |
45 | MAINTAINERS | 8 + | 15 | 2 files changed, 361 insertions(+) |
46 | default-configs/aarch64-softmmu.mak | 1 + | 16 | create mode 100644 tests/qtest/xlnx-can-test.c |
47 | hw/arm/Kconfig | 14 ++ | 17 | |
48 | 5 files changed, 295 insertions(+) | 18 | diff --git a/tests/qtest/xlnx-can-test.c b/tests/qtest/xlnx-can-test.c |
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 | ||
53 | --- a/hw/arm/Makefile.objs | ||
54 | +++ b/hw/arm/Makefile.objs | ||
55 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_SPITZ) += spitz.o | ||
56 | obj-$(CONFIG_TOSA) += tosa.o | ||
57 | obj-$(CONFIG_Z2) += z2.o | ||
58 | obj-$(CONFIG_REALVIEW) += realview.o | ||
59 | +obj-$(CONFIG_SBSA_REF) += sbsa-ref.o | ||
60 | obj-$(CONFIG_STELLARIS) += stellaris.o | ||
61 | obj-$(CONFIG_COLLIE) += collie.o | ||
62 | obj-$(CONFIG_VERSATILE) += versatilepb.o | ||
63 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | ||
64 | new file mode 100644 | 19 | new file mode 100644 |
65 | index XXXXXXX..XXXXXXX | 20 | index XXXXXXX..XXXXXXX |
66 | --- /dev/null | 21 | --- /dev/null |
67 | +++ b/hw/arm/sbsa-ref.c | 22 | +++ b/tests/qtest/xlnx-can-test.c |
68 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ |
69 | +/* | 24 | +/* |
70 | + * ARM SBSA Reference Platform emulation | 25 | + * QTests for the Xilinx ZynqMP CAN controller. |
71 | + * | 26 | + * |
72 | + * Copyright (c) 2018 Linaro Limited | 27 | + * Copyright (c) 2020 Xilinx Inc. |
73 | + * Written by Hongbo Zhang <hongbo.zhang@linaro.org> | 28 | + * |
74 | + * | 29 | + * Written-by: Vikram Garhwal<fnu.vikram@xilinx.com> |
75 | + * This program is free software; you can redistribute it and/or modify it | 30 | + * |
76 | + * under the terms and conditions of the GNU General Public License, | 31 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
77 | + * version 2 or later, as published by the Free Software Foundation. | 32 | + * of this software and associated documentation files (the "Software"), to deal |
78 | + * | 33 | + * in the Software without restriction, including without limitation the rights |
79 | + * This program is distributed in the hope it will be useful, but WITHOUT | 34 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
80 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 35 | + * copies of the Software, and to permit persons to whom the Software is |
81 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 36 | + * furnished to do so, subject to the following conditions: |
82 | + * more details. | 37 | + * |
83 | + * | 38 | + * The above copyright notice and this permission notice shall be included in |
84 | + * You should have received a copy of the GNU General Public License along with | 39 | + * all copies or substantial portions of the Software. |
85 | + * this program. If not, see <http://www.gnu.org/licenses/>. | 40 | + * |
41 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
42 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
43 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
44 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
45 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
46 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
47 | + * THE SOFTWARE. | ||
86 | + */ | 48 | + */ |
87 | + | 49 | + |
88 | +#include "qemu/osdep.h" | 50 | +#include "qemu/osdep.h" |
89 | +#include "qapi/error.h" | 51 | +#include "libqos/libqtest.h" |
90 | +#include "qemu/error-report.h" | 52 | + |
91 | +#include "qemu/units.h" | 53 | +/* Base address. */ |
92 | +#include "sysemu/numa.h" | 54 | +#define CAN0_BASE_ADDR 0xFF060000 |
93 | +#include "sysemu/sysemu.h" | 55 | +#define CAN1_BASE_ADDR 0xFF070000 |
94 | +#include "exec/address-spaces.h" | 56 | + |
95 | +#include "exec/hwaddr.h" | 57 | +/* Register addresses. */ |
96 | +#include "kvm_arm.h" | 58 | +#define R_SRR_OFFSET 0x00 |
97 | +#include "hw/arm/boot.h" | 59 | +#define R_MSR_OFFSET 0x04 |
98 | +#include "hw/boards.h" | 60 | +#define R_SR_OFFSET 0x18 |
99 | +#include "hw/intc/arm_gicv3_common.h" | 61 | +#define R_ISR_OFFSET 0x1C |
100 | + | 62 | +#define R_ICR_OFFSET 0x24 |
101 | +#define RAMLIMIT_GB 8192 | 63 | +#define R_TXID_OFFSET 0x30 |
102 | +#define RAMLIMIT_BYTES (RAMLIMIT_GB * GiB) | 64 | +#define R_TXDLC_OFFSET 0x34 |
103 | + | 65 | +#define R_TXDATA1_OFFSET 0x38 |
104 | +enum { | 66 | +#define R_TXDATA2_OFFSET 0x3C |
105 | + SBSA_FLASH, | 67 | +#define R_RXID_OFFSET 0x50 |
106 | + SBSA_MEM, | 68 | +#define R_RXDLC_OFFSET 0x54 |
107 | + SBSA_CPUPERIPHS, | 69 | +#define R_RXDATA1_OFFSET 0x58 |
108 | + SBSA_GIC_DIST, | 70 | +#define R_RXDATA2_OFFSET 0x5C |
109 | + SBSA_GIC_REDIST, | 71 | +#define R_AFR 0x60 |
110 | + SBSA_SMMU, | 72 | +#define R_AFMR1 0x64 |
111 | + SBSA_UART, | 73 | +#define R_AFIR1 0x68 |
112 | + SBSA_RTC, | 74 | +#define R_AFMR2 0x6C |
113 | + SBSA_PCIE, | 75 | +#define R_AFIR2 0x70 |
114 | + SBSA_PCIE_MMIO, | 76 | +#define R_AFMR3 0x74 |
115 | + SBSA_PCIE_MMIO_HIGH, | 77 | +#define R_AFIR3 0x78 |
116 | + SBSA_PCIE_PIO, | 78 | +#define R_AFMR4 0x7C |
117 | + SBSA_PCIE_ECAM, | 79 | +#define R_AFIR4 0x80 |
118 | + SBSA_GPIO, | 80 | + |
119 | + SBSA_SECURE_UART, | 81 | +/* CAN modes. */ |
120 | + SBSA_SECURE_UART_MM, | 82 | +#define CONFIG_MODE 0x00 |
121 | + SBSA_SECURE_MEM, | 83 | +#define NORMAL_MODE 0x00 |
122 | + SBSA_AHCI, | 84 | +#define LOOPBACK_MODE 0x02 |
123 | + SBSA_EHCI, | 85 | +#define SNOOP_MODE 0x04 |
124 | +}; | 86 | +#define SLEEP_MODE 0x01 |
125 | + | 87 | +#define ENABLE_CAN (1 << 1) |
126 | +typedef struct MemMapEntry { | 88 | +#define STATUS_NORMAL_MODE (1 << 3) |
127 | + hwaddr base; | 89 | +#define STATUS_LOOPBACK_MODE (1 << 1) |
128 | + hwaddr size; | 90 | +#define STATUS_SNOOP_MODE (1 << 12) |
129 | +} MemMapEntry; | 91 | +#define STATUS_SLEEP_MODE (1 << 2) |
130 | + | 92 | +#define ISR_TXOK (1 << 1) |
131 | +typedef struct { | 93 | +#define ISR_RXOK (1 << 4) |
132 | + MachineState parent; | 94 | + |
133 | + struct arm_boot_info bootinfo; | 95 | +static void match_rx_tx_data(const uint32_t *buf_tx, const uint32_t *buf_rx, |
134 | + int smp_cpus; | 96 | + uint8_t can_timestamp) |
135 | + void *fdt; | 97 | +{ |
136 | + int fdt_size; | 98 | + uint16_t size = 0; |
137 | + int psci_conduit; | 99 | + uint8_t len = 4; |
138 | +} SBSAMachineState; | 100 | + |
139 | + | 101 | + while (size < len) { |
140 | +#define TYPE_SBSA_MACHINE MACHINE_TYPE_NAME("sbsa-ref") | 102 | + if (R_RXID_OFFSET + 4 * size == R_RXDLC_OFFSET) { |
141 | +#define SBSA_MACHINE(obj) \ | 103 | + g_assert_cmpint(buf_rx[size], ==, buf_tx[size] + can_timestamp); |
142 | + OBJECT_CHECK(SBSAMachineState, (obj), TYPE_SBSA_MACHINE) | 104 | + } else { |
143 | + | 105 | + g_assert_cmpint(buf_rx[size], ==, buf_tx[size]); |
144 | +static const MemMapEntry sbsa_ref_memmap[] = { | 106 | + } |
145 | + /* 512M boot ROM */ | 107 | + |
146 | + [SBSA_FLASH] = { 0, 0x20000000 }, | 108 | + size++; |
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 | + } | 109 | + } |
188 | + | 110 | +} |
189 | + if (kvm_enabled()) { | 111 | + |
190 | + error_report("sbsa-ref: KVM is not supported for this machine"); | 112 | +static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx) |
191 | + exit(1); | 113 | +{ |
192 | + } | 114 | + uint32_t int_status; |
115 | + | ||
116 | + /* Read the interrupt on CAN rx. */ | ||
117 | + int_status = qtest_readl(qts, can_base_addr + R_ISR_OFFSET) & ISR_RXOK; | ||
118 | + | ||
119 | + g_assert_cmpint(int_status, ==, ISR_RXOK); | ||
120 | + | ||
121 | + /* Read the RX register data for CAN. */ | ||
122 | + buf_rx[0] = qtest_readl(qts, can_base_addr + R_RXID_OFFSET); | ||
123 | + buf_rx[1] = qtest_readl(qts, can_base_addr + R_RXDLC_OFFSET); | ||
124 | + buf_rx[2] = qtest_readl(qts, can_base_addr + R_RXDATA1_OFFSET); | ||
125 | + buf_rx[3] = qtest_readl(qts, can_base_addr + R_RXDATA2_OFFSET); | ||
126 | + | ||
127 | + /* Clear the RX interrupt. */ | ||
128 | + qtest_writel(qts, CAN1_BASE_ADDR + R_ICR_OFFSET, ISR_RXOK); | ||
129 | +} | ||
130 | + | ||
131 | +static void send_data(QTestState *qts, uint64_t can_base_addr, | ||
132 | + const uint32_t *buf_tx) | ||
133 | +{ | ||
134 | + uint32_t int_status; | ||
135 | + | ||
136 | + /* Write the TX register data for CAN. */ | ||
137 | + qtest_writel(qts, can_base_addr + R_TXID_OFFSET, buf_tx[0]); | ||
138 | + qtest_writel(qts, can_base_addr + R_TXDLC_OFFSET, buf_tx[1]); | ||
139 | + qtest_writel(qts, can_base_addr + R_TXDATA1_OFFSET, buf_tx[2]); | ||
140 | + qtest_writel(qts, can_base_addr + R_TXDATA2_OFFSET, buf_tx[3]); | ||
141 | + | ||
142 | + /* Read the interrupt on CAN for tx. */ | ||
143 | + int_status = qtest_readl(qts, can_base_addr + R_ISR_OFFSET) & ISR_TXOK; | ||
144 | + | ||
145 | + g_assert_cmpint(int_status, ==, ISR_TXOK); | ||
146 | + | ||
147 | + /* Clear the interrupt for tx. */ | ||
148 | + qtest_writel(qts, CAN0_BASE_ADDR + R_ICR_OFFSET, ISR_TXOK); | ||
149 | +} | ||
150 | + | ||
151 | +/* | ||
152 | + * This test will be transferring data from CAN0 and CAN1 through canbus. CAN0 | ||
153 | + * initiate the data transfer to can-bus, CAN1 receives the data. Test compares | ||
154 | + * the data sent from CAN0 with received on CAN1. | ||
155 | + */ | ||
156 | +static void test_can_bus(void) | ||
157 | +{ | ||
158 | + const uint32_t buf_tx[4] = { 0xFF, 0x80000000, 0x12345678, 0x87654321 }; | ||
159 | + uint32_t buf_rx[4] = { 0x00, 0x00, 0x00, 0x00 }; | ||
160 | + uint32_t status = 0; | ||
161 | + uint8_t can_timestamp = 1; | ||
162 | + | ||
163 | + QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
164 | + " -object can-bus,id=canbus0" | ||
165 | + " -machine xlnx-zcu102.canbus0=canbus0" | ||
166 | + " -machine xlnx-zcu102.canbus1=canbus0" | ||
167 | + ); | ||
168 | + | ||
169 | + /* Configure the CAN0 and CAN1. */ | ||
170 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
171 | + qtest_writel(qts, CAN0_BASE_ADDR + R_MSR_OFFSET, NORMAL_MODE); | ||
172 | + qtest_writel(qts, CAN1_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
173 | + qtest_writel(qts, CAN1_BASE_ADDR + R_MSR_OFFSET, NORMAL_MODE); | ||
174 | + | ||
175 | + /* Check here if CAN0 and CAN1 are in normal mode. */ | ||
176 | + status = qtest_readl(qts, CAN0_BASE_ADDR + R_SR_OFFSET); | ||
177 | + g_assert_cmpint(status, ==, STATUS_NORMAL_MODE); | ||
178 | + | ||
179 | + status = qtest_readl(qts, CAN1_BASE_ADDR + R_SR_OFFSET); | ||
180 | + g_assert_cmpint(status, ==, STATUS_NORMAL_MODE); | ||
181 | + | ||
182 | + send_data(qts, CAN0_BASE_ADDR, buf_tx); | ||
183 | + | ||
184 | + read_data(qts, CAN1_BASE_ADDR, buf_rx); | ||
185 | + match_rx_tx_data(buf_tx, buf_rx, can_timestamp); | ||
186 | + | ||
187 | + qtest_quit(qts); | ||
188 | +} | ||
189 | + | ||
190 | +/* | ||
191 | + * This test is performing loopback mode on CAN0 and CAN1. Data sent from TX of | ||
192 | + * each CAN0 and CAN1 are compared with RX register data for respective CAN. | ||
193 | + */ | ||
194 | +static void test_can_loopback(void) | ||
195 | +{ | ||
196 | + uint32_t buf_tx[4] = { 0xFF, 0x80000000, 0x12345678, 0x87654321 }; | ||
197 | + uint32_t buf_rx[4] = { 0x00, 0x00, 0x00, 0x00 }; | ||
198 | + uint32_t status = 0; | ||
199 | + | ||
200 | + QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
201 | + " -object can-bus,id=canbus0" | ||
202 | + " -machine xlnx-zcu102.canbus0=canbus0" | ||
203 | + " -machine xlnx-zcu102.canbus1=canbus0" | ||
204 | + ); | ||
205 | + | ||
206 | + /* Configure the CAN0 in loopback mode. */ | ||
207 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, CONFIG_MODE); | ||
208 | + qtest_writel(qts, CAN0_BASE_ADDR + R_MSR_OFFSET, LOOPBACK_MODE); | ||
209 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
210 | + | ||
211 | + /* Check here if CAN0 is set in loopback mode. */ | ||
212 | + status = qtest_readl(qts, CAN0_BASE_ADDR + R_SR_OFFSET); | ||
213 | + | ||
214 | + g_assert_cmpint(status, ==, STATUS_LOOPBACK_MODE); | ||
215 | + | ||
216 | + send_data(qts, CAN0_BASE_ADDR, buf_tx); | ||
217 | + read_data(qts, CAN0_BASE_ADDR, buf_rx); | ||
218 | + match_rx_tx_data(buf_tx, buf_rx, 0); | ||
219 | + | ||
220 | + /* Configure the CAN1 in loopback mode. */ | ||
221 | + qtest_writel(qts, CAN1_BASE_ADDR + R_SRR_OFFSET, CONFIG_MODE); | ||
222 | + qtest_writel(qts, CAN1_BASE_ADDR + R_MSR_OFFSET, LOOPBACK_MODE); | ||
223 | + qtest_writel(qts, CAN1_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
224 | + | ||
225 | + /* Check here if CAN1 is set in loopback mode. */ | ||
226 | + status = qtest_readl(qts, CAN1_BASE_ADDR + R_SR_OFFSET); | ||
227 | + | ||
228 | + g_assert_cmpint(status, ==, STATUS_LOOPBACK_MODE); | ||
229 | + | ||
230 | + send_data(qts, CAN1_BASE_ADDR, buf_tx); | ||
231 | + read_data(qts, CAN1_BASE_ADDR, buf_rx); | ||
232 | + match_rx_tx_data(buf_tx, buf_rx, 0); | ||
233 | + | ||
234 | + qtest_quit(qts); | ||
235 | +} | ||
236 | + | ||
237 | +/* | ||
238 | + * Enable filters for CAN1. This will filter incoming messages with ID. In this | ||
239 | + * test message will pass through filter 2. | ||
240 | + */ | ||
241 | +static void test_can_filter(void) | ||
242 | +{ | ||
243 | + uint32_t buf_tx[4] = { 0x14, 0x80000000, 0x12345678, 0x87654321 }; | ||
244 | + uint32_t buf_rx[4] = { 0x00, 0x00, 0x00, 0x00 }; | ||
245 | + uint32_t status = 0; | ||
246 | + uint8_t can_timestamp = 1; | ||
247 | + | ||
248 | + QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
249 | + " -object can-bus,id=canbus0" | ||
250 | + " -machine xlnx-zcu102.canbus0=canbus0" | ||
251 | + " -machine xlnx-zcu102.canbus1=canbus0" | ||
252 | + ); | ||
253 | + | ||
254 | + /* Configure the CAN0 and CAN1. */ | ||
255 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
256 | + qtest_writel(qts, CAN0_BASE_ADDR + R_MSR_OFFSET, NORMAL_MODE); | ||
257 | + qtest_writel(qts, CAN1_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
258 | + qtest_writel(qts, CAN1_BASE_ADDR + R_MSR_OFFSET, NORMAL_MODE); | ||
259 | + | ||
260 | + /* Check here if CAN0 and CAN1 are in normal mode. */ | ||
261 | + status = qtest_readl(qts, CAN0_BASE_ADDR + R_SR_OFFSET); | ||
262 | + g_assert_cmpint(status, ==, STATUS_NORMAL_MODE); | ||
263 | + | ||
264 | + status = qtest_readl(qts, CAN1_BASE_ADDR + R_SR_OFFSET); | ||
265 | + g_assert_cmpint(status, ==, STATUS_NORMAL_MODE); | ||
266 | + | ||
267 | + /* Set filter for CAN1 for incoming messages. */ | ||
268 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFR, 0x0); | ||
269 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFMR1, 0xF7); | ||
270 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFIR1, 0x121F); | ||
271 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFMR2, 0x5431); | ||
272 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFIR2, 0x14); | ||
273 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFMR3, 0x1234); | ||
274 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFIR3, 0x5431); | ||
275 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFMR4, 0xFFF); | ||
276 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFIR4, 0x1234); | ||
277 | + | ||
278 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFR, 0xF); | ||
279 | + | ||
280 | + send_data(qts, CAN0_BASE_ADDR, buf_tx); | ||
281 | + | ||
282 | + read_data(qts, CAN1_BASE_ADDR, buf_rx); | ||
283 | + match_rx_tx_data(buf_tx, buf_rx, can_timestamp); | ||
284 | + | ||
285 | + qtest_quit(qts); | ||
286 | +} | ||
287 | + | ||
288 | +/* Testing sleep mode on CAN0 while CAN1 is in normal mode. */ | ||
289 | +static void test_can_sleepmode(void) | ||
290 | +{ | ||
291 | + uint32_t buf_tx[4] = { 0x14, 0x80000000, 0x12345678, 0x87654321 }; | ||
292 | + uint32_t buf_rx[4] = { 0x00, 0x00, 0x00, 0x00 }; | ||
293 | + uint32_t status = 0; | ||
294 | + uint8_t can_timestamp = 1; | ||
295 | + | ||
296 | + QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
297 | + " -object can-bus,id=canbus0" | ||
298 | + " -machine xlnx-zcu102.canbus0=canbus0" | ||
299 | + " -machine xlnx-zcu102.canbus1=canbus0" | ||
300 | + ); | ||
301 | + | ||
302 | + /* Configure the CAN0. */ | ||
303 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, CONFIG_MODE); | ||
304 | + qtest_writel(qts, CAN0_BASE_ADDR + R_MSR_OFFSET, SLEEP_MODE); | ||
305 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
306 | + | ||
307 | + qtest_writel(qts, CAN1_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
308 | + qtest_writel(qts, CAN1_BASE_ADDR + R_MSR_OFFSET, NORMAL_MODE); | ||
309 | + | ||
310 | + /* Check here if CAN0 is in SLEEP mode and CAN1 in normal mode. */ | ||
311 | + status = qtest_readl(qts, CAN0_BASE_ADDR + R_SR_OFFSET); | ||
312 | + g_assert_cmpint(status, ==, STATUS_SLEEP_MODE); | ||
313 | + | ||
314 | + status = qtest_readl(qts, CAN1_BASE_ADDR + R_SR_OFFSET); | ||
315 | + g_assert_cmpint(status, ==, STATUS_NORMAL_MODE); | ||
316 | + | ||
317 | + send_data(qts, CAN1_BASE_ADDR, buf_tx); | ||
193 | + | 318 | + |
194 | + /* | 319 | + /* |
195 | + * This machine has EL3 enabled, external firmware should supply PSCI | 320 | + * Once CAN1 sends data on can-bus. CAN0 should exit sleep mode. |
196 | + * implementation, so the QEMU's internal PSCI is disabled. | 321 | + * Check the CAN0 status now. It should exit the sleep mode and receive the |
322 | + * incoming data. | ||
197 | + */ | 323 | + */ |
198 | + sms->psci_conduit = QEMU_PSCI_CONDUIT_DISABLED; | 324 | + status = qtest_readl(qts, CAN0_BASE_ADDR + R_SR_OFFSET); |
199 | + | 325 | + g_assert_cmpint(status, ==, STATUS_NORMAL_MODE); |
200 | + sbsa_max_cpus = sbsa_ref_memmap[SBSA_GIC_REDIST].size / GICV3_REDIST_SIZE; | 326 | + |
201 | + | 327 | + read_data(qts, CAN0_BASE_ADDR, buf_rx); |
202 | + if (max_cpus > sbsa_max_cpus) { | 328 | + |
203 | + error_report("Number of SMP CPUs requested (%d) exceeds max CPUs " | 329 | + match_rx_tx_data(buf_tx, buf_rx, can_timestamp); |
204 | + "supported by machine 'sbsa-ref' (%d)", | 330 | + |
205 | + max_cpus, sbsa_max_cpus); | 331 | + qtest_quit(qts); |
206 | + exit(1); | 332 | +} |
207 | + } | 333 | + |
208 | + | 334 | +/* Testing Snoop mode on CAN0 while CAN1 is in normal mode. */ |
209 | + sms->smp_cpus = smp_cpus; | 335 | +static void test_can_snoopmode(void) |
210 | + | 336 | +{ |
211 | + if (machine->ram_size > sbsa_ref_memmap[SBSA_MEM].size) { | 337 | + uint32_t buf_tx[4] = { 0x14, 0x80000000, 0x12345678, 0x87654321 }; |
212 | + error_report("sbsa-ref: cannot model more than %dGB RAM", RAMLIMIT_GB); | 338 | + uint32_t buf_rx[4] = { 0x00, 0x00, 0x00, 0x00 }; |
213 | + exit(1); | 339 | + uint32_t status = 0; |
214 | + } | 340 | + uint8_t can_timestamp = 1; |
215 | + | 341 | + |
216 | + possible_cpus = mc->possible_cpu_arch_ids(machine); | 342 | + QTestState *qts = qtest_init("-machine xlnx-zcu102" |
217 | + for (n = 0; n < possible_cpus->len; n++) { | 343 | + " -object can-bus,id=canbus0" |
218 | + Object *cpuobj; | 344 | + " -machine xlnx-zcu102.canbus0=canbus0" |
219 | + CPUState *cs; | 345 | + " -machine xlnx-zcu102.canbus1=canbus0" |
220 | + | 346 | + ); |
221 | + if (n >= smp_cpus) { | 347 | + |
222 | + break; | 348 | + /* Configure the CAN0. */ |
223 | + } | 349 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, CONFIG_MODE); |
224 | + | 350 | + qtest_writel(qts, CAN0_BASE_ADDR + R_MSR_OFFSET, SNOOP_MODE); |
225 | + cpuobj = object_new(possible_cpus->cpus[n].type); | 351 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); |
226 | + object_property_set_int(cpuobj, possible_cpus->cpus[n].arch_id, | 352 | + |
227 | + "mp-affinity", NULL); | 353 | + qtest_writel(qts, CAN1_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); |
228 | + | 354 | + qtest_writel(qts, CAN1_BASE_ADDR + R_MSR_OFFSET, NORMAL_MODE); |
229 | + cs = CPU(cpuobj); | 355 | + |
230 | + cs->cpu_index = n; | 356 | + /* Check here if CAN0 is in SNOOP mode and CAN1 in normal mode. */ |
231 | + | 357 | + status = qtest_readl(qts, CAN0_BASE_ADDR + R_SR_OFFSET); |
232 | + numa_cpu_pre_plug(&possible_cpus->cpus[cs->cpu_index], DEVICE(cpuobj), | 358 | + g_assert_cmpint(status, ==, STATUS_SNOOP_MODE); |
233 | + &error_fatal); | 359 | + |
234 | + | 360 | + status = qtest_readl(qts, CAN1_BASE_ADDR + R_SR_OFFSET); |
235 | + if (object_property_find(cpuobj, "reset-cbar", NULL)) { | 361 | + g_assert_cmpint(status, ==, STATUS_NORMAL_MODE); |
236 | + object_property_set_int(cpuobj, | 362 | + |
237 | + sbsa_ref_memmap[SBSA_CPUPERIPHS].base, | 363 | + send_data(qts, CAN1_BASE_ADDR, buf_tx); |
238 | + "reset-cbar", &error_abort); | 364 | + |
239 | + } | 365 | + read_data(qts, CAN0_BASE_ADDR, buf_rx); |
240 | + | 366 | + |
241 | + object_property_set_link(cpuobj, OBJECT(sysmem), "memory", | 367 | + match_rx_tx_data(buf_tx, buf_rx, can_timestamp); |
242 | + &error_abort); | 368 | + |
243 | + | 369 | + qtest_quit(qts); |
244 | + object_property_set_link(cpuobj, OBJECT(secure_sysmem), | 370 | +} |
245 | + "secure-memory", &error_abort); | 371 | + |
246 | + | 372 | +int main(int argc, char **argv) |
247 | + object_property_set_bool(cpuobj, true, "realized", &error_fatal); | 373 | +{ |
248 | + object_unref(cpuobj); | 374 | + g_test_init(&argc, &argv, NULL); |
249 | + } | 375 | + |
250 | + | 376 | + qtest_add_func("/net/can/can_bus", test_can_bus); |
251 | + memory_region_allocate_system_memory(ram, NULL, "sbsa-ref.ram", | 377 | + qtest_add_func("/net/can/can_loopback", test_can_loopback); |
252 | + machine->ram_size); | 378 | + qtest_add_func("/net/can/can_filter", test_can_filter); |
253 | + memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ram); | 379 | + qtest_add_func("/net/can/can_test_snoopmode", test_can_snoopmode); |
254 | + | 380 | + qtest_add_func("/net/can/can_test_sleepmode", test_can_sleepmode); |
255 | + sms->bootinfo.ram_size = machine->ram_size; | 381 | + |
256 | + sms->bootinfo.kernel_filename = machine->kernel_filename; | 382 | + return g_test_run(); |
257 | + sms->bootinfo.nb_cpus = smp_cpus; | 383 | +} |
258 | + sms->bootinfo.board_id = -1; | 384 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build |
259 | + sms->bootinfo.loader_start = sbsa_ref_memmap[SBSA_MEM].base; | ||
260 | + arm_load_kernel(ARM_CPU(first_cpu), &sms->bootinfo); | ||
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 | 385 | index XXXXXXX..XXXXXXX 100644 |
342 | --- a/MAINTAINERS | 386 | --- a/tests/qtest/meson.build |
343 | +++ b/MAINTAINERS | 387 | +++ b/tests/qtest/meson.build |
344 | @@ -XXX,XX +XXX,XX @@ F: include/hw/arm/fsl-imx6.h | 388 | @@ -XXX,XX +XXX,XX @@ qtests_aarch64 = \ |
345 | F: include/hw/misc/imx6_*.h | 389 | ['arm-cpu-features', |
346 | F: include/hw/ssi/imx_spi.h | 390 | 'numa-test', |
347 | 391 | 'boot-serial-test', | |
348 | +SBSA-REF | 392 | + 'xlnx-can-test', |
349 | +M: Radoslaw Biernacki <radoslaw.biernacki@linaro.org> | 393 | 'migration-test'] |
350 | +M: Peter Maydell <peter.maydell@linaro.org> | 394 | |
351 | +R: Leif Lindholm <leif.lindholm@linaro.org> | 395 | qtests_s390x = \ |
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 | -- | 396 | -- |
394 | 2.20.1 | 397 | 2.20.1 |
395 | 398 | ||
396 | 399 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Vikram Garhwal <fnu.vikram@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | The vfp_set_fpscr() helper contains code specific to the host | 3 | Reviewed-by: Francisco Iglesias <francisco.iglesias@xilinx.com> |
4 | floating point implementation (here the SoftFloat library). | 4 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
5 | Extract this code to vfp_set_fpscr_from_host(). | 5 | Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com> |
6 | 6 | Message-id: 1605728926-352690-5-git-send-email-fnu.vikram@xilinx.com | |
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190701132516.26392-17-philmd@redhat.com | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 8 | --- |
12 | target/arm/vfp_helper.c | 19 +++++++++++++------ | 9 | MAINTAINERS | 8 ++++++++ |
13 | 1 file changed, 13 insertions(+), 6 deletions(-) | 10 | 1 file changed, 8 insertions(+) |
14 | 11 | ||
15 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | 12 | diff --git a/MAINTAINERS b/MAINTAINERS |
16 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/vfp_helper.c | 14 | --- a/MAINTAINERS |
18 | +++ b/target/arm/vfp_helper.c | 15 | +++ b/MAINTAINERS |
19 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits) | 16 | @@ -XXX,XX +XXX,XX @@ F: hw/net/opencores_eth.c |
20 | return host_bits; | 17 | |
21 | } | 18 | Devices |
22 | 19 | ------- | |
23 | +static uint32_t vfp_get_fpscr_from_host(CPUARMState *env) | 20 | +Xilinx CAN |
24 | +{ | 21 | +M: Vikram Garhwal <fnu.vikram@xilinx.com> |
25 | + uint32_t i; | 22 | +M: Francisco Iglesias <francisco.iglesias@xilinx.com> |
23 | +S: Maintained | ||
24 | +F: hw/net/can/xlnx-* | ||
25 | +F: include/hw/net/xlnx-* | ||
26 | +F: tests/qtest/xlnx-can-test* | ||
26 | + | 27 | + |
27 | + i = get_float_exception_flags(&env->vfp.fp_status); | 28 | EDU |
28 | + i |= get_float_exception_flags(&env->vfp.standard_fp_status); | 29 | M: Jiri Slaby <jslaby@suse.cz> |
29 | + /* FZ16 does not generate an input denormal exception. */ | 30 | S: Maintained |
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 | -- | 31 | -- |
53 | 2.20.1 | 32 | 2.20.1 |
54 | 33 | ||
55 | 34 | diff view generated by jsdifflib |
1 | From: Hongbo Zhang <hongbo.zhang@linaro.org> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Following the previous patch, this patch adds peripheral devices to the | 3 | Trusted Firmware now supports A72 on sbsa-ref by default [1] so enable |
4 | newly introduced SBSA-ref machine. | 4 | it for QEMU as well. A53 was already enabled there. |
5 | 5 | ||
6 | Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org> | 6 | 1. https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/7117 |
7 | Message-id: 1561890034-15921-3-git-send-email-hongbo.zhang@linaro.org | 7 | |
8 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20201120141705.246690-1-marcin.juszkiewicz@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 13 | --- |
11 | hw/arm/sbsa-ref.c | 535 ++++++++++++++++++++++++++++++++++++++++++++++ | 14 | hw/arm/sbsa-ref.c | 23 ++++++++++++++++++++--- |
12 | 1 file changed, 535 insertions(+) | 15 | 1 file changed, 20 insertions(+), 3 deletions(-) |
13 | 16 | ||
14 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | 17 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/sbsa-ref.c | 19 | --- a/hw/arm/sbsa-ref.c |
17 | +++ b/hw/arm/sbsa-ref.c | 20 | +++ b/hw/arm/sbsa-ref.c |
18 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { |
19 | */ | 22 | [SBSA_GWDT] = 16, |
20 | |||
21 | #include "qemu/osdep.h" | ||
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 | + | ||
50 | +#define VIRTUAL_PMU_IRQ 7 | ||
51 | +#define ARCH_GIC_MAINT_IRQ 9 | ||
52 | +#define ARCH_TIMER_VIRT_IRQ 11 | ||
53 | +#define ARCH_TIMER_S_EL1_IRQ 13 | ||
54 | +#define ARCH_TIMER_NS_EL1_IRQ 14 | ||
55 | +#define ARCH_TIMER_NS_EL2_IRQ 10 | ||
56 | + | ||
57 | enum { | ||
58 | SBSA_FLASH, | ||
59 | SBSA_MEM, | ||
60 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
61 | void *fdt; | ||
62 | int fdt_size; | ||
63 | int psci_conduit; | ||
64 | + PFlashCFI01 *flash[2]; | ||
65 | } SBSAMachineState; | ||
66 | |||
67 | #define TYPE_SBSA_MACHINE MACHINE_TYPE_NAME("sbsa-ref") | ||
68 | @@ -XXX,XX +XXX,XX @@ static const MemMapEntry sbsa_ref_memmap[] = { | ||
69 | [SBSA_MEM] = { 0x10000000000ULL, RAMLIMIT_BYTES }, | ||
70 | }; | 23 | }; |
71 | 24 | ||
72 | +static const int sbsa_ref_irqmap[] = { | 25 | +static const char * const valid_cpus[] = { |
73 | + [SBSA_UART] = 1, | 26 | + ARM_CPU_TYPE_NAME("cortex-a53"), |
74 | + [SBSA_RTC] = 2, | 27 | + ARM_CPU_TYPE_NAME("cortex-a57"), |
75 | + [SBSA_PCIE] = 3, /* ... to 6 */ | 28 | + ARM_CPU_TYPE_NAME("cortex-a72"), |
76 | + [SBSA_GPIO] = 7, | ||
77 | + [SBSA_SECURE_UART] = 8, | ||
78 | + [SBSA_SECURE_UART_MM] = 9, | ||
79 | + [SBSA_AHCI] = 10, | ||
80 | + [SBSA_EHCI] = 11, | ||
81 | +}; | 29 | +}; |
82 | + | 30 | + |
83 | +/* | 31 | +static bool cpu_type_valid(const char *cpu) |
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 | +{ | 32 | +{ |
91 | + void *fdt = create_device_tree(&sms->fdt_size); | 33 | + int i; |
92 | + const MachineState *ms = MACHINE(sms); | ||
93 | + int cpu; | ||
94 | + | 34 | + |
95 | + if (!fdt) { | 35 | + for (i = 0; i < ARRAY_SIZE(valid_cpus); i++) { |
96 | + error_report("create_device_tree() failed"); | 36 | + if (strcmp(cpu, valid_cpus[i]) == 0) { |
97 | + exit(1); | 37 | + return true; |
38 | + } | ||
98 | + } | 39 | + } |
99 | + | 40 | + return false; |
100 | + sms->fdt = fdt; | ||
101 | + | ||
102 | + qemu_fdt_setprop_string(fdt, "/", "compatible", "linux,sbsa-ref"); | ||
103 | + qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2); | ||
104 | + qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 0x2); | ||
105 | + | ||
106 | + if (have_numa_distance) { | ||
107 | + int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t); | ||
108 | + uint32_t *matrix = g_malloc0(size); | ||
109 | + int idx, i, j; | ||
110 | + | ||
111 | + for (i = 0; i < nb_numa_nodes; i++) { | ||
112 | + for (j = 0; j < nb_numa_nodes; j++) { | ||
113 | + idx = (i * nb_numa_nodes + j) * 3; | ||
114 | + matrix[idx + 0] = cpu_to_be32(i); | ||
115 | + matrix[idx + 1] = cpu_to_be32(j); | ||
116 | + matrix[idx + 2] = cpu_to_be32(numa_info[i].distance[j]); | ||
117 | + } | ||
118 | + } | ||
119 | + | ||
120 | + qemu_fdt_add_subnode(fdt, "/distance-map"); | ||
121 | + qemu_fdt_setprop(fdt, "/distance-map", "distance-matrix", | ||
122 | + matrix, size); | ||
123 | + g_free(matrix); | ||
124 | + } | ||
125 | + | ||
126 | + qemu_fdt_add_subnode(sms->fdt, "/cpus"); | ||
127 | + | ||
128 | + for (cpu = sms->smp_cpus - 1; cpu >= 0; cpu--) { | ||
129 | + char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu); | ||
130 | + ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); | ||
131 | + CPUState *cs = CPU(armcpu); | ||
132 | + | ||
133 | + qemu_fdt_add_subnode(sms->fdt, nodename); | ||
134 | + | ||
135 | + if (ms->possible_cpus->cpus[cs->cpu_index].props.has_node_id) { | ||
136 | + qemu_fdt_setprop_cell(sms->fdt, nodename, "numa-node-id", | ||
137 | + ms->possible_cpus->cpus[cs->cpu_index].props.node_id); | ||
138 | + } | ||
139 | + | ||
140 | + g_free(nodename); | ||
141 | + } | ||
142 | +} | 41 | +} |
143 | + | 42 | + |
144 | +#define SBSA_FLASH_SECTOR_SIZE (256 * KiB) | 43 | static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx) |
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 | + } | ||
227 | + | ||
228 | + sbsa_flash_map(sms, sysmem, secure_sysmem); | ||
229 | + | ||
230 | + pflash_blk0 = pflash_cfi01_get_blk(sms->flash[0]); | ||
231 | + | ||
232 | + if (bios_name) { | ||
233 | + char *fname; | ||
234 | + MemoryRegion *mr; | ||
235 | + int image_size; | ||
236 | + | ||
237 | + if (pflash_blk0) { | ||
238 | + error_report("The contents of the first flash device may be " | ||
239 | + "specified with -bios or with -drive if=pflash... " | ||
240 | + "but you cannot use both options at once"); | ||
241 | + exit(1); | ||
242 | + } | ||
243 | + | ||
244 | + /* Fall back to -bios */ | ||
245 | + | ||
246 | + fname = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); | ||
247 | + if (!fname) { | ||
248 | + error_report("Could not find ROM image '%s'", bios_name); | ||
249 | + exit(1); | ||
250 | + } | ||
251 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(sms->flash[0]), 0); | ||
252 | + image_size = load_image_mr(fname, mr); | ||
253 | + g_free(fname); | ||
254 | + if (image_size < 0) { | ||
255 | + error_report("Could not load ROM image '%s'", bios_name); | ||
256 | + exit(1); | ||
257 | + } | ||
258 | + } | ||
259 | + | ||
260 | + return pflash_blk0 || bios_name; | ||
261 | +} | ||
262 | + | ||
263 | +static void create_secure_ram(SBSAMachineState *sms, | ||
264 | + MemoryRegion *secure_sysmem) | ||
265 | +{ | ||
266 | + MemoryRegion *secram = g_new(MemoryRegion, 1); | ||
267 | + hwaddr base = sbsa_ref_memmap[SBSA_SECURE_MEM].base; | ||
268 | + hwaddr size = sbsa_ref_memmap[SBSA_SECURE_MEM].size; | ||
269 | + | ||
270 | + memory_region_init_ram(secram, NULL, "sbsa-ref.secure-ram", size, | ||
271 | + &error_fatal); | ||
272 | + memory_region_add_subregion(secure_sysmem, base, secram); | ||
273 | +} | ||
274 | + | ||
275 | +static void create_gic(SBSAMachineState *sms, qemu_irq *pic) | ||
276 | +{ | ||
277 | + DeviceState *gicdev; | ||
278 | + SysBusDevice *gicbusdev; | ||
279 | + const char *gictype; | ||
280 | + uint32_t redist0_capacity, redist0_count; | ||
281 | + int i; | ||
282 | + | ||
283 | + gictype = gicv3_class_name(); | ||
284 | + | ||
285 | + gicdev = qdev_create(NULL, gictype); | ||
286 | + qdev_prop_set_uint32(gicdev, "revision", 3); | ||
287 | + qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus); | ||
288 | + /* | ||
289 | + * Note that the num-irq property counts both internal and external | ||
290 | + * interrupts; there are always 32 of the former (mandated by GIC spec). | ||
291 | + */ | ||
292 | + qdev_prop_set_uint32(gicdev, "num-irq", NUM_IRQS + 32); | ||
293 | + qdev_prop_set_bit(gicdev, "has-security-extensions", true); | ||
294 | + | ||
295 | + redist0_capacity = | ||
296 | + sbsa_ref_memmap[SBSA_GIC_REDIST].size / GICV3_REDIST_SIZE; | ||
297 | + redist0_count = MIN(smp_cpus, redist0_capacity); | ||
298 | + | ||
299 | + qdev_prop_set_uint32(gicdev, "len-redist-region-count", 1); | ||
300 | + qdev_prop_set_uint32(gicdev, "redist-region-count[0]", redist0_count); | ||
301 | + | ||
302 | + qdev_init_nofail(gicdev); | ||
303 | + gicbusdev = SYS_BUS_DEVICE(gicdev); | ||
304 | + sysbus_mmio_map(gicbusdev, 0, sbsa_ref_memmap[SBSA_GIC_DIST].base); | ||
305 | + sysbus_mmio_map(gicbusdev, 1, sbsa_ref_memmap[SBSA_GIC_REDIST].base); | ||
306 | + | ||
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 | { | 44 | { |
534 | SBSAMachineState *sms = SBSA_MACHINE(machine); | 45 | uint8_t clustersz = ARM_DEFAULT_CPUS_PER_CLUSTER; |
535 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | 46 | @@ -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; | 47 | const CPUArchIdList *possible_cpus; |
541 | int n, sbsa_max_cpus; | 48 | int n, sbsa_max_cpus; |
542 | + qemu_irq pic[NUM_IRQS]; | 49 | |
543 | 50 | - if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a57"))) { | |
544 | if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a57"))) { | 51 | - error_report("sbsa-ref: CPU type other than the built-in " |
545 | error_report("sbsa-ref: CPU type other than the built-in " | 52 | - "cortex-a57 not supported"); |
546 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | 53 | + if (!cpu_type_valid(machine->cpu_type)) { |
54 | + error_report("mach-virt: CPU type %s not supported", machine->cpu_type); | ||
547 | exit(1); | 55 | exit(1); |
548 | } | 56 | } |
549 | 57 | ||
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 | -- | 58 | -- |
632 | 2.20.1 | 59 | 2.20.1 |
633 | 60 | ||
634 | 61 | diff view generated by jsdifflib |
1 | From: Andrew Jeffery <andrew@aj.id.au> | 1 | From: Havard Skinnemoen <hskinnemoen@google.com> |
---|---|---|---|
2 | 2 | ||
3 | If the match value exceeds reload then we don't want to include it in | 3 | Dump the collected random data after a randomness test failure. |
4 | calculations for the next event. | ||
5 | 4 | ||
6 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> | 5 | Note that this relies on the test having called |
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 6 | g_test_set_nonfatal_assertions() so we don't abort immediately on the |
8 | Message-id: 20190618165311.27066-10-clg@kaod.org | 7 | assertion failure. |
8 | |||
9 | Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | [PMM: minor commit message tweak] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 13 | --- |
11 | hw/timer/aspeed_timer.c | 13 ++++++++++--- | 14 | tests/qtest/npcm7xx_rng-test.c | 12 ++++++++++++ |
12 | 1 file changed, 10 insertions(+), 3 deletions(-) | 15 | 1 file changed, 12 insertions(+) |
13 | 16 | ||
14 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c | 17 | diff --git a/tests/qtest/npcm7xx_rng-test.c b/tests/qtest/npcm7xx_rng-test.c |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/timer/aspeed_timer.c | 19 | --- a/tests/qtest/npcm7xx_rng-test.c |
17 | +++ b/hw/timer/aspeed_timer.c | 20 | +++ b/tests/qtest/npcm7xx_rng-test.c |
18 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks) | 21 | @@ -XXX,XX +XXX,XX @@ |
19 | return t->start + delta_ns; | 22 | |
20 | } | 23 | #include "libqtest-single.h" |
21 | 24 | #include "qemu/bitops.h" | |
22 | +static inline uint32_t calculate_match(struct AspeedTimer *t, int i) | 25 | +#include "qemu-common.h" |
26 | |||
27 | #define RNG_BASE_ADDR 0xf000b000 | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ | ||
30 | /* Number of bits to collect for randomness tests. */ | ||
31 | #define TEST_INPUT_BITS (128) | ||
32 | |||
33 | +static void dump_buf_if_failed(const uint8_t *buf, size_t size) | ||
23 | +{ | 34 | +{ |
24 | + return t->match[i] < t->reload ? t->match[i] : 0; | 35 | + if (g_test_failed()) { |
36 | + qemu_hexdump(stderr, "", buf, size); | ||
37 | + } | ||
25 | +} | 38 | +} |
26 | + | 39 | + |
27 | static uint64_t calculate_next(struct AspeedTimer *t) | 40 | static void rng_writeb(unsigned int offset, uint8_t value) |
28 | { | 41 | { |
29 | uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | 42 | writeb(RNG_BASE_ADDR + offset, value); |
30 | @@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t) | 43 | @@ -XXX,XX +XXX,XX @@ static void test_continuous_monobit(void) |
31 | * the timer counts down to zero. | ||
32 | */ | ||
33 | |||
34 | - next = calculate_time(t, MAX(t->match[0], t->match[1])); | ||
35 | + next = calculate_time(t, MAX(calculate_match(t, 0), calculate_match(t, 1))); | ||
36 | if (now < next) { | ||
37 | return next; | ||
38 | } | 44 | } |
39 | 45 | ||
40 | - next = calculate_time(t, MIN(t->match[0], t->match[1])); | 46 | g_assert_cmpfloat(calc_monobit_p(buf, sizeof(buf)), >, 0.01); |
41 | + next = calculate_time(t, MIN(calculate_match(t, 0), calculate_match(t, 1))); | 47 | + dump_buf_if_failed(buf, sizeof(buf)); |
42 | if (now < next) { | 48 | } |
43 | return next; | 49 | |
50 | /* | ||
51 | @@ -XXX,XX +XXX,XX @@ static void test_continuous_runs(void) | ||
44 | } | 52 | } |
45 | @@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t) | 53 | |
46 | qemu_set_irq(t->irq, t->level); | 54 | g_assert_cmpfloat(calc_runs_p(buf.l, sizeof(buf) * BITS_PER_BYTE), >, 0.01); |
55 | + dump_buf_if_failed(buf.c, sizeof(buf)); | ||
56 | } | ||
57 | |||
58 | /* | ||
59 | @@ -XXX,XX +XXX,XX @@ static void test_first_byte_monobit(void) | ||
47 | } | 60 | } |
48 | 61 | ||
49 | + next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0); | 62 | g_assert_cmpfloat(calc_monobit_p(buf, sizeof(buf)), >, 0.01); |
50 | t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | 63 | + dump_buf_if_failed(buf, sizeof(buf)); |
51 | - return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0)); | ||
52 | + | ||
53 | + return calculate_time(t, next); | ||
54 | } | 64 | } |
55 | 65 | ||
56 | static void aspeed_timer_mod(AspeedTimer *t) | 66 | /* |
67 | @@ -XXX,XX +XXX,XX @@ static void test_first_byte_runs(void) | ||
68 | } | ||
69 | |||
70 | g_assert_cmpfloat(calc_runs_p(buf.l, sizeof(buf) * BITS_PER_BYTE), >, 0.01); | ||
71 | + dump_buf_if_failed(buf.c, sizeof(buf)); | ||
72 | } | ||
73 | |||
74 | int main(int argc, char **argv) | ||
57 | -- | 75 | -- |
58 | 2.20.1 | 76 | 2.20.1 |
59 | 77 | ||
60 | 78 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Alex Chen <alex.chen@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | In the next commit we will split the TLB related routines of | 3 | We should use printf format specifier "%u" instead of "%d" for |
4 | this file, and this function will also be called in the new | 4 | argument of type "unsigned int". |
5 | file. Declare it in the "internals.h" header. | ||
6 | 5 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 6 | Reported-by: Euler Robot <euler.robot@huawei.com> |
8 | Message-id: 20190701132516.26392-12-philmd@redhat.com | 7 | Signed-off-by: Alex Chen <alex.chen@huawei.com> |
8 | Message-id: 20201126111109.112238-2-alex.chen@huawei.com | ||
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/internals.h | 16 ++++++++++++++++ | 12 | hw/misc/imx25_ccm.c | 12 ++++++------ |
13 | target/arm/helper.c | 21 +++++---------------- | 13 | 1 file changed, 6 insertions(+), 6 deletions(-) |
14 | 2 files changed, 21 insertions(+), 16 deletions(-) | ||
15 | 14 | ||
16 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 15 | diff --git a/hw/misc/imx25_ccm.c b/hw/misc/imx25_ccm.c |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/internals.h | 17 | --- a/hw/misc/imx25_ccm.c |
19 | +++ b/target/arm/internals.h | 18 | +++ b/hw/misc/imx25_ccm.c |
20 | @@ -XXX,XX +XXX,XX @@ static inline int exception_target_el(CPUARMState *env) | 19 | @@ -XXX,XX +XXX,XX @@ static const char *imx25_ccm_reg_name(uint32_t reg) |
21 | return target_el; | 20 | case IMX25_CCM_LPIMR1_REG: |
21 | return "lpimr1"; | ||
22 | default: | ||
23 | - sprintf(unknown, "[%d ?]", reg); | ||
24 | + sprintf(unknown, "[%u ?]", reg); | ||
25 | return unknown; | ||
26 | } | ||
22 | } | 27 | } |
23 | 28 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx25_ccm_get_mpll_clk(IMXCCMState *dev) | |
24 | +#ifndef CONFIG_USER_ONLY | 29 | freq = imx_ccm_calc_pll(s->reg[IMX25_CCM_MPCTL_REG], CKIH_FREQ); |
25 | + | 30 | } |
26 | +/* Cacheability and shareability attributes for a memory access */ | 31 | |
27 | +typedef struct ARMCacheAttrs { | 32 | - DPRINTF("freq = %d\n", freq); |
28 | + unsigned int attrs:8; /* as in the MAIR register encoding */ | 33 | + DPRINTF("freq = %u\n", freq); |
29 | + unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */ | 34 | |
30 | +} ARMCacheAttrs; | 35 | return freq; |
31 | + | 36 | } |
32 | +bool get_phys_addr(CPUARMState *env, target_ulong address, | 37 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx25_ccm_get_mcu_clk(IMXCCMState *dev) |
33 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | 38 | |
34 | + hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | 39 | freq = freq / (1 + EXTRACT(s->reg[IMX25_CCM_CCTL_REG], ARM_CLK_DIV)); |
35 | + target_ulong *page_size, | 40 | |
36 | + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); | 41 | - DPRINTF("freq = %d\n", freq); |
37 | + | 42 | + DPRINTF("freq = %u\n", freq); |
38 | +#endif /* !CONFIG_USER_ONLY */ | 43 | |
39 | + | 44 | return freq; |
40 | #endif | 45 | } |
41 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 46 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx25_ccm_get_ahb_clk(IMXCCMState *dev) |
42 | index XXXXXXX..XXXXXXX 100644 | 47 | freq = imx25_ccm_get_mcu_clk(dev) |
43 | --- a/target/arm/helper.c | 48 | / (1 + EXTRACT(s->reg[IMX25_CCM_CCTL_REG], AHB_CLK_DIV)); |
44 | +++ b/target/arm/helper.c | 49 | |
45 | @@ -XXX,XX +XXX,XX @@ | 50 | - DPRINTF("freq = %d\n", freq); |
46 | #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ | 51 | + DPRINTF("freq = %u\n", freq); |
47 | 52 | ||
48 | #ifndef CONFIG_USER_ONLY | 53 | return freq; |
49 | -/* Cacheability and shareability attributes for a memory access */ | 54 | } |
50 | -typedef struct ARMCacheAttrs { | 55 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx25_ccm_get_ipg_clk(IMXCCMState *dev) |
51 | - unsigned int attrs:8; /* as in the MAIR register encoding */ | 56 | |
52 | - unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */ | 57 | freq = imx25_ccm_get_ahb_clk(dev) / 2; |
53 | -} ARMCacheAttrs; | 58 | |
54 | - | 59 | - DPRINTF("freq = %d\n", freq); |
55 | -static bool get_phys_addr(CPUARMState *env, target_ulong address, | 60 | + DPRINTF("freq = %u\n", freq); |
56 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | 61 | |
57 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | 62 | return freq; |
58 | - target_ulong *page_size, | 63 | } |
59 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); | 64 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx25_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock) |
60 | 65 | break; | |
61 | static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | 66 | } |
62 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 67 | |
63 | @@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2) | 68 | - DPRINTF("Clock = %d) = %d\n", clock, freq); |
64 | * @fi: set to fault info if the translation fails | 69 | + DPRINTF("Clock = %d) = %u\n", clock, freq); |
65 | * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes | 70 | |
66 | */ | 71 | return freq; |
67 | -static bool get_phys_addr(CPUARMState *env, target_ulong address, | 72 | } |
68 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
69 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
70 | - target_ulong *page_size, | ||
71 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
72 | +bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
73 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
74 | + hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
75 | + target_ulong *page_size, | ||
76 | + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
77 | { | ||
78 | if (mmu_idx == ARMMMUIdx_S12NSE0 || mmu_idx == ARMMMUIdx_S12NSE1) { | ||
79 | /* Call ourselves recursively to do the stage 1 and then stage 2 | ||
80 | -- | 73 | -- |
81 | 2.20.1 | 74 | 2.20.1 |
82 | 75 | ||
83 | 76 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Alex Chen <alex.chen@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Since commit 8c06fbdf36b checkpatch.pl enforce a new multiline | 3 | We should use printf format specifier "%u" instead of "%d" for |
4 | comment syntax. Since we'll move this code around, fix its style | 4 | argument of type "unsigned int". |
5 | first. | ||
6 | 5 | ||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 6 | Reported-by: Euler Robot <euler.robot@huawei.com> |
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Signed-off-by: Alex Chen <alex.chen@huawei.com> |
9 | Message-id: 20190701132516.26392-8-philmd@redhat.com | 8 | Message-id: 20201126111109.112238-3-alex.chen@huawei.com |
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/helper.c | 237 ++++++++++++++++++++++++++-------------- | 12 | hw/misc/imx31_ccm.c | 14 +++++++------- |
13 | target/arm/op_helper.c | 54 ++++++--- | 13 | hw/misc/imx_ccm.c | 4 ++-- |
14 | target/arm/vfp_helper.c | 3 +- | 14 | 2 files changed, 9 insertions(+), 9 deletions(-) |
15 | 3 files changed, 196 insertions(+), 98 deletions(-) | ||
16 | 15 | ||
17 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 16 | diff --git a/hw/misc/imx31_ccm.c b/hw/misc/imx31_ccm.c |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.c | 18 | --- a/hw/misc/imx31_ccm.c |
20 | +++ b/target/arm/helper.c | 19 | +++ b/hw/misc/imx31_ccm.c |
21 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) | 20 | @@ -XXX,XX +XXX,XX @@ static const char *imx31_ccm_reg_name(uint32_t reg) |
22 | 21 | case IMX31_CCM_PDR2_REG: | |
23 | uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | 22 | return "PDR2"; |
24 | { | 23 | default: |
25 | - /* The TT instructions can be used by unprivileged code, but in | 24 | - sprintf(unknown, "[%d ?]", reg); |
26 | + /* | 25 | + sprintf(unknown, "[%u ?]", reg); |
27 | + * The TT instructions can be used by unprivileged code, but in | 26 | return unknown; |
28 | * user-only emulation we don't have the MPU. | ||
29 | * Luckily since we know we are NonSecure unprivileged (and that in | ||
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 | } | 27 | } |
63 | } | 28 | } |
64 | 29 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx31_ccm_get_pll_ref_clk(IMXCCMState *dev) | |
65 | -/* Write to v7M CONTROL.SPSEL bit. This may change the current | 30 | freq = CKIH_FREQ; |
66 | +/* | ||
67 | + * Write to v7M CONTROL.SPSEL bit. This may change the current | ||
68 | * stack pointer between Main and Process stack pointers. | ||
69 | */ | ||
70 | static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel) | ||
71 | @@ -XXX,XX +XXX,XX @@ static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel) | ||
72 | |||
73 | void write_v7m_exception(CPUARMState *env, uint32_t new_exc) | ||
74 | { | ||
75 | - /* Write a new value to v7m.exception, thus transitioning into or out | ||
76 | + /* | ||
77 | + * Write a new value to v7m.exception, thus transitioning into or out | ||
78 | * of Handler mode; this may result in a change of active stack pointer. | ||
79 | */ | ||
80 | bool new_is_psp, old_is_psp = v7m_using_psp(env); | ||
81 | @@ -XXX,XX +XXX,XX @@ static void switch_v7m_security_state(CPUARMState *env, bool new_secstate) | ||
82 | return; | ||
83 | } | 31 | } |
84 | 32 | ||
85 | - /* All the banked state is accessed by looking at env->v7m.secure | 33 | - DPRINTF("freq = %d\n", freq); |
86 | + /* | 34 | + DPRINTF("freq = %u\n", freq); |
87 | + * All the banked state is accessed by looking at env->v7m.secure | 35 | |
88 | * except for the stack pointer; rearrange the SP appropriately. | 36 | return freq; |
89 | */ | 37 | } |
90 | new_ss_msp = env->v7m.other_ss_msp; | 38 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx31_ccm_get_mpll_clk(IMXCCMState *dev) |
91 | @@ -XXX,XX +XXX,XX @@ static void switch_v7m_security_state(CPUARMState *env, bool new_secstate) | 39 | freq = imx_ccm_calc_pll(s->reg[IMX31_CCM_MPCTL_REG], |
92 | 40 | imx31_ccm_get_pll_ref_clk(dev)); | |
93 | void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | 41 | |
94 | { | 42 | - DPRINTF("freq = %d\n", freq); |
95 | - /* Handle v7M BXNS: | 43 | + DPRINTF("freq = %u\n", freq); |
96 | + /* | 44 | |
97 | + * Handle v7M BXNS: | 45 | return freq; |
98 | * - if the return value is a magic value, do exception return (like BX) | 46 | } |
99 | * - otherwise bit 0 of the return value is the target security state | 47 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx31_ccm_get_mcu_main_clk(IMXCCMState *dev) |
100 | */ | 48 | freq = imx31_ccm_get_mpll_clk(dev); |
101 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | ||
102 | } | 49 | } |
103 | 50 | ||
104 | if (dest >= min_magic) { | 51 | - DPRINTF("freq = %d\n", freq); |
105 | - /* This is an exception return magic value; put it where | 52 | + DPRINTF("freq = %u\n", freq); |
106 | + /* | 53 | |
107 | + * This is an exception return magic value; put it where | 54 | return freq; |
108 | * do_v7m_exception_exit() expects and raise EXCEPTION_EXIT. | 55 | } |
109 | * Note that if we ever add gen_ss_advance() singlestep support to | 56 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx31_ccm_get_hclk_clk(IMXCCMState *dev) |
110 | * M profile this should count as an "instruction execution complete" | 57 | freq = imx31_ccm_get_mcu_main_clk(dev) |
111 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | 58 | / (1 + EXTRACT(s->reg[IMX31_CCM_PDR0_REG], MAX)); |
112 | 59 | ||
113 | void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | 60 | - DPRINTF("freq = %d\n", freq); |
114 | { | 61 | + DPRINTF("freq = %u\n", freq); |
115 | - /* Handle v7M BLXNS: | 62 | |
116 | + /* | 63 | return freq; |
117 | + * Handle v7M BLXNS: | 64 | } |
118 | * - bit 0 of the destination address is the target security state | 65 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx31_ccm_get_ipg_clk(IMXCCMState *dev) |
119 | */ | 66 | freq = imx31_ccm_get_hclk_clk(dev) |
120 | 67 | / (1 + EXTRACT(s->reg[IMX31_CCM_PDR0_REG], IPG)); | |
121 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | 68 | |
122 | assert(env->v7m.secure); | 69 | - DPRINTF("freq = %d\n", freq); |
123 | 70 | + DPRINTF("freq = %u\n", freq); | |
124 | if (dest & 1) { | 71 | |
125 | - /* target is Secure, so this is just a normal BLX, | 72 | return freq; |
126 | + /* | 73 | } |
127 | + * Target is Secure, so this is just a normal BLX, | 74 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx31_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock) |
128 | * except that the low bit doesn't indicate Thumb/not. | 75 | break; |
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 | } | 76 | } |
184 | 77 | ||
185 | - /* Write as much of the stack frame as we can. A write failure may | 78 | - DPRINTF("Clock = %d) = %d\n", clock, freq); |
186 | + /* | 79 | + DPRINTF("Clock = %d) = %u\n", clock, freq); |
187 | + * Write as much of the stack frame as we can. A write failure may | 80 | |
188 | * cause us to pend a derived exception. | 81 | return freq; |
189 | */ | 82 | } |
190 | sig = v7m_integrity_sig(env, lr); | 83 | diff --git a/hw/misc/imx_ccm.c b/hw/misc/imx_ccm.c |
191 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 84 | index XXXXXXX..XXXXXXX 100644 |
192 | static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 85 | --- a/hw/misc/imx_ccm.c |
193 | bool ignore_stackfaults) | 86 | +++ b/hw/misc/imx_ccm.c |
194 | { | 87 | @@ -XXX,XX +XXX,XX @@ uint32_t imx_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock) |
195 | - /* Do the "take the exception" parts of exception entry, | 88 | freq = klass->get_clock_frequency(dev, clock); |
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 | } | 89 | } |
250 | 90 | ||
251 | if (push_failed && !ignore_stackfaults) { | 91 | - DPRINTF("(clock = %d) = %d\n", clock, freq); |
252 | - /* Derived exception on callee-saves register stacking: | 92 | + DPRINTF("(clock = %d) = %u\n", clock, freq); |
253 | + /* | 93 | |
254 | + * Derived exception on callee-saves register stacking: | 94 | return freq; |
255 | * we might now want to take a different exception which | ||
256 | * targets a different security state, so try again from the top. | ||
257 | */ | ||
258 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
259 | return; | ||
260 | } | ||
261 | |||
262 | - /* Now we've done everything that might cause a derived exception | ||
263 | + /* | ||
264 | + * Now we've done everything that might cause a derived exception | ||
265 | * we can go ahead and activate whichever exception we're going to | ||
266 | * take (which might now be the derived exception). | ||
267 | */ | ||
268 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) | ||
269 | |||
270 | static bool v7m_push_stack(ARMCPU *cpu) | ||
271 | { | ||
272 | - /* Do the "set up stack frame" part of exception entry, | ||
273 | + /* | ||
274 | + * Do the "set up stack frame" part of exception entry, | ||
275 | * similar to pseudocode PushStack(). | ||
276 | * Return true if we generate a derived exception (and so | ||
277 | * should ignore further stack faults trying to process | ||
278 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
279 | } | ||
280 | } | ||
281 | |||
282 | - /* Write as much of the stack frame as we can. If we fail a stack | ||
283 | + /* | ||
284 | + * Write as much of the stack frame as we can. If we fail a stack | ||
285 | * write this will result in a derived exception being pended | ||
286 | * (which may be taken in preference to the one we started with | ||
287 | * if it has higher priority). | ||
288 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
289 | bool ftype; | ||
290 | bool restore_s16_s31; | ||
291 | |||
292 | - /* If we're not in Handler mode then jumps to magic exception-exit | ||
293 | + /* | ||
294 | + * If we're not in Handler mode then jumps to magic exception-exit | ||
295 | * addresses don't have magic behaviour. However for the v8M | ||
296 | * security extensions the magic secure-function-return has to | ||
297 | * work in thread mode too, so to avoid doing an extra check in | ||
298 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
299 | return; | ||
300 | } | ||
301 | |||
302 | - /* In the spec pseudocode ExceptionReturn() is called directly | ||
303 | + /* | ||
304 | + * In the spec pseudocode ExceptionReturn() is called directly | ||
305 | * from BXWritePC() and gets the full target PC value including | ||
306 | * bit zero. In QEMU's implementation we treat it as a normal | ||
307 | * jump-to-register (which is then caught later on), and so split | ||
308 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
309 | } | ||
310 | |||
311 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
312 | - /* EXC_RETURN.ES validation check (R_SMFL). We must do this before | ||
313 | + /* | ||
314 | + * EXC_RETURN.ES validation check (R_SMFL). We must do this before | ||
315 | * we pick which FAULTMASK to clear. | ||
316 | */ | ||
317 | if (!env->v7m.secure && | ||
318 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
319 | } | ||
320 | |||
321 | if (env->v7m.exception != ARMV7M_EXCP_NMI) { | ||
322 | - /* Auto-clear FAULTMASK on return from other than NMI. | ||
323 | + /* | ||
324 | + * Auto-clear FAULTMASK on return from other than NMI. | ||
325 | * If the security extension is implemented then this only | ||
326 | * happens if the raw execution priority is >= 0; the | ||
327 | * value of the ES bit in the exception return value indicates | ||
328 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
329 | /* still an irq active now */ | ||
330 | break; | ||
331 | case 1: | ||
332 | - /* we returned to base exception level, no nesting. | ||
333 | + /* | ||
334 | + * We returned to base exception level, no nesting. | ||
335 | * (In the pseudocode this is written using "NestedActivation != 1" | ||
336 | * where we have 'rettobase == false'.) | ||
337 | */ | ||
338 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
339 | |||
340 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
341 | if (!arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
342 | - /* UNPREDICTABLE if S == 1 or DCRS == 0 or ES == 1 (R_XLCP); | ||
343 | + /* | ||
344 | + * UNPREDICTABLE if S == 1 or DCRS == 0 or ES == 1 (R_XLCP); | ||
345 | * we choose to take the UsageFault. | ||
346 | */ | ||
347 | if ((excret & R_V7M_EXCRET_S_MASK) || | ||
348 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
349 | break; | ||
350 | case 13: /* Return to Thread using Process stack */ | ||
351 | case 9: /* Return to Thread using Main stack */ | ||
352 | - /* We only need to check NONBASETHRDENA for v7M, because in | ||
353 | + /* | ||
354 | + * We only need to check NONBASETHRDENA for v7M, because in | ||
355 | * v8M this bit does not exist (it is RES1). | ||
356 | */ | ||
357 | if (!rettobase && | ||
358 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
359 | } | ||
360 | |||
361 | if (ufault) { | ||
362 | - /* Bad exception return: instead of popping the exception | ||
363 | + /* | ||
364 | + * Bad exception return: instead of popping the exception | ||
365 | * stack, directly take a usage fault on the current stack. | ||
366 | */ | ||
367 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK; | ||
368 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
369 | switch_v7m_security_state(env, return_to_secure); | ||
370 | |||
371 | { | ||
372 | - /* The stack pointer we should be reading the exception frame from | ||
373 | + /* | ||
374 | + * The stack pointer we should be reading the exception frame from | ||
375 | * depends on bits in the magic exception return type value (and | ||
376 | * for v8M isn't necessarily the stack pointer we will eventually | ||
377 | * end up resuming execution with). Get a pointer to the location | ||
378 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
379 | v7m_stack_read(cpu, &xpsr, frameptr + 0x1c, mmu_idx); | ||
380 | |||
381 | if (!pop_ok) { | ||
382 | - /* v7m_stack_read() pended a fault, so take it (as a tail | ||
383 | + /* | ||
384 | + * v7m_stack_read() pended a fault, so take it (as a tail | ||
385 | * chained exception on the same stack frame) | ||
386 | */ | ||
387 | qemu_log_mask(CPU_LOG_INT, "...derived exception on unstacking\n"); | ||
388 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
389 | return; | ||
390 | } | ||
391 | |||
392 | - /* Returning from an exception with a PC with bit 0 set is defined | ||
393 | + /* | ||
394 | + * Returning from an exception with a PC with bit 0 set is defined | ||
395 | * behaviour on v8M (bit 0 is ignored), but for v7M it was specified | ||
396 | * to be UNPREDICTABLE. In practice actual v7M hardware seems to ignore | ||
397 | * the lsbit, and there are several RTOSes out there which incorrectly | ||
398 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
399 | } | ||
400 | |||
401 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
402 | - /* For v8M we have to check whether the xPSR exception field | ||
403 | + /* | ||
404 | + * For v8M we have to check whether the xPSR exception field | ||
405 | * matches the EXCRET value for return to handler/thread | ||
406 | * before we commit to changing the SP and xPSR. | ||
407 | */ | ||
408 | bool will_be_handler = (xpsr & XPSR_EXCP) != 0; | ||
409 | if (return_to_handler != will_be_handler) { | ||
410 | - /* Take an INVPC UsageFault on the current stack. | ||
411 | + /* | ||
412 | + * Take an INVPC UsageFault on the current stack. | ||
413 | * By this point we will have switched to the security state | ||
414 | * for the background state, so this UsageFault will target | ||
415 | * that state. | ||
416 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
417 | frameptr += 0x40; | ||
418 | } | ||
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 | } | 95 | } |
596 | 96 | @@ -XXX,XX +XXX,XX @@ uint32_t imx_ccm_calc_pll(uint32_t pllreg, uint32_t base_freq) | |
597 | -/* Function used to synchronize QEMU's AArch64 register set with AArch32 | 97 | freq = ((2 * (base_freq >> 10) * (mfi * mfd + mfn)) / |
598 | +/* | 98 | (mfd * pd)) << 10; |
599 | + * Function used to synchronize QEMU's AArch64 register set with AArch32 | 99 | |
600 | * register set. This is necessary when switching between AArch32 and AArch64 | 100 | - DPRINTF("(pllreg = 0x%08x, base_freq = %d) = %d\n", pllreg, base_freq, |
601 | * execution state. | 101 | + DPRINTF("(pllreg = 0x%08x, base_freq = %u) = %d\n", pllreg, base_freq, |
602 | */ | 102 | freq); |
603 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | 103 | |
604 | env->xregs[i] = env->regs[i]; | 104 | return freq; |
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 | -- | 105 | -- |
988 | 2.20.1 | 106 | 2.20.1 |
989 | 107 | ||
990 | 108 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Alex Chen <alex.chen@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | In the next commit we will split the M-profile functions from this | 3 | We should use printf format specifier "%u" instead of "%d" for |
4 | file. Some function will be called out of helper.c. Declare them in | 4 | argument of type "unsigned int". |
5 | the "internals.h" header. | ||
6 | 5 | ||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 6 | Reported-by: Euler Robot <euler.robot@huawei.com> |
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Signed-off-by: Alex Chen <alex.chen@huawei.com> |
9 | Message-id: 20190701132516.26392-22-philmd@redhat.com | 8 | Message-id: 20201126111109.112238-4-alex.chen@huawei.com |
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/internals.h | 42 ++++++++++++++++++++++++++++++++++++++++++ | 12 | hw/misc/imx6_ccm.c | 20 ++++++++++---------- |
13 | target/arm/helper.c | 38 ++------------------------------------ | 13 | hw/misc/imx6_src.c | 2 +- |
14 | 2 files changed, 44 insertions(+), 36 deletions(-) | 14 | 2 files changed, 11 insertions(+), 11 deletions(-) |
15 | 15 | ||
16 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 16 | diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/internals.h | 18 | --- a/hw/misc/imx6_ccm.c |
19 | +++ b/target/arm/internals.h | 19 | +++ b/hw/misc/imx6_ccm.c |
20 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t v7m_sp_limit(CPUARMState *env) | 20 | @@ -XXX,XX +XXX,XX @@ static const char *imx6_ccm_reg_name(uint32_t reg) |
21 | case CCM_CMEOR: | ||
22 | return "CMEOR"; | ||
23 | default: | ||
24 | - sprintf(unknown, "%d ?", reg); | ||
25 | + sprintf(unknown, "%u ?", reg); | ||
26 | return unknown; | ||
21 | } | 27 | } |
22 | } | 28 | } |
23 | 29 | @@ -XXX,XX +XXX,XX @@ static const char *imx6_analog_reg_name(uint32_t reg) | |
24 | +/** | 30 | case USB_ANALOG_DIGPROG: |
25 | + * v7m_cpacr_pass: | 31 | return "USB_ANALOG_DIGPROG"; |
26 | + * Return true if the v7M CPACR permits access to the FPU for the specified | 32 | default: |
27 | + * security state and privilege level. | 33 | - sprintf(unknown, "%d ?", reg); |
28 | + */ | 34 | + sprintf(unknown, "%u ?", reg); |
29 | +static inline bool v7m_cpacr_pass(CPUARMState *env, | 35 | return unknown; |
30 | + bool is_secure, bool is_priv) | ||
31 | +{ | ||
32 | + switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) { | ||
33 | + case 0: | ||
34 | + case 2: /* UNPREDICTABLE: we treat like 0 */ | ||
35 | + return false; | ||
36 | + case 1: | ||
37 | + return is_priv; | ||
38 | + case 3: | ||
39 | + return true; | ||
40 | + default: | ||
41 | + g_assert_not_reached(); | ||
42 | + } | ||
43 | +} | ||
44 | + | ||
45 | /** | ||
46 | * aarch32_mode_name(): Return name of the AArch32 CPU mode | ||
47 | * @psr: Program Status Register indicating CPU mode | ||
48 | @@ -XXX,XX +XXX,XX @@ static inline int exception_target_el(CPUARMState *env) | ||
49 | |||
50 | #ifndef CONFIG_USER_ONLY | ||
51 | |||
52 | +/* Security attributes for an address, as returned by v8m_security_lookup. */ | ||
53 | +typedef struct V8M_SAttributes { | ||
54 | + bool subpage; /* true if these attrs don't cover the whole TARGET_PAGE */ | ||
55 | + bool ns; | ||
56 | + bool nsc; | ||
57 | + uint8_t sregion; | ||
58 | + bool srvalid; | ||
59 | + uint8_t iregion; | ||
60 | + bool irvalid; | ||
61 | +} V8M_SAttributes; | ||
62 | + | ||
63 | +void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
64 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
65 | + V8M_SAttributes *sattrs); | ||
66 | + | ||
67 | +bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
68 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
69 | + hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
70 | + int *prot, bool *is_subpage, | ||
71 | + ARMMMUFaultInfo *fi, uint32_t *mregion); | ||
72 | + | ||
73 | /* Cacheability and shareability attributes for a memory access */ | ||
74 | typedef struct ARMCacheAttrs { | ||
75 | unsigned int attrs:8; /* as in the MAIR register encoding */ | ||
76 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/helper.c | ||
79 | +++ b/target/arm/helper.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
81 | hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | ||
82 | target_ulong *page_size_ptr, | ||
83 | ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); | ||
84 | - | ||
85 | -/* Security attributes for an address, as returned by v8m_security_lookup. */ | ||
86 | -typedef struct V8M_SAttributes { | ||
87 | - bool subpage; /* true if these attrs don't cover the whole TARGET_PAGE */ | ||
88 | - bool ns; | ||
89 | - bool nsc; | ||
90 | - uint8_t sregion; | ||
91 | - bool srvalid; | ||
92 | - uint8_t iregion; | ||
93 | - bool irvalid; | ||
94 | -} V8M_SAttributes; | ||
95 | - | ||
96 | -static void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
97 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
98 | - V8M_SAttributes *sattrs); | ||
99 | #endif | ||
100 | |||
101 | static void switch_mode(CPUARMState *env, int mode); | ||
102 | @@ -XXX,XX +XXX,XX @@ void arm_log_exception(int idx) | ||
103 | } | 36 | } |
104 | } | 37 | } |
105 | 38 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx6_analog_get_pll2_clk(IMX6CCMState *dev) | |
106 | -/* | 39 | freq *= 20; |
107 | - * Return true if the v7M CPACR permits access to the FPU for the specified | 40 | } |
108 | - * security state and privilege level. | 41 | |
109 | - */ | 42 | - DPRINTF("freq = %d\n", (uint32_t)freq); |
110 | -static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv) | 43 | + DPRINTF("freq = %u\n", (uint32_t)freq); |
111 | -{ | 44 | |
112 | - switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) { | 45 | return freq; |
113 | - case 0: | ||
114 | - case 2: /* UNPREDICTABLE: we treat like 0 */ | ||
115 | - return false; | ||
116 | - case 1: | ||
117 | - return is_priv; | ||
118 | - case 3: | ||
119 | - return true; | ||
120 | - default: | ||
121 | - g_assert_not_reached(); | ||
122 | - } | ||
123 | -} | ||
124 | - | ||
125 | /* | ||
126 | * What kind of stack write are we doing? This affects how exceptions | ||
127 | * generated during the stacking are treated. | ||
128 | @@ -XXX,XX +XXX,XX @@ static bool v8m_is_sau_exempt(CPUARMState *env, | ||
129 | (address >= 0xe00ff000 && address <= 0xe00fffff); | ||
130 | } | 46 | } |
131 | 47 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx6_analog_get_pll2_pfd0_clk(IMX6CCMState *dev) | |
132 | -static void v8m_security_lookup(CPUARMState *env, uint32_t address, | 48 | freq = imx6_analog_get_pll2_clk(dev) * 18 |
133 | +void v8m_security_lookup(CPUARMState *env, uint32_t address, | 49 | / EXTRACT(dev->analog[CCM_ANALOG_PFD_528], PFD0_FRAC); |
134 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 50 | |
135 | V8M_SAttributes *sattrs) | 51 | - DPRINTF("freq = %d\n", (uint32_t)freq); |
136 | { | 52 | + DPRINTF("freq = %u\n", (uint32_t)freq); |
137 | @@ -XXX,XX +XXX,XX @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address, | 53 | |
54 | return freq; | ||
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx6_analog_get_pll2_pfd2_clk(IMX6CCMState *dev) | ||
57 | freq = imx6_analog_get_pll2_clk(dev) * 18 | ||
58 | / EXTRACT(dev->analog[CCM_ANALOG_PFD_528], PFD2_FRAC); | ||
59 | |||
60 | - DPRINTF("freq = %d\n", (uint32_t)freq); | ||
61 | + DPRINTF("freq = %u\n", (uint32_t)freq); | ||
62 | |||
63 | return freq; | ||
64 | } | ||
65 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx6_analog_get_periph_clk(IMX6CCMState *dev) | ||
66 | break; | ||
67 | } | ||
68 | |||
69 | - DPRINTF("freq = %d\n", (uint32_t)freq); | ||
70 | + DPRINTF("freq = %u\n", (uint32_t)freq); | ||
71 | |||
72 | return freq; | ||
73 | } | ||
74 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx6_ccm_get_ahb_clk(IMX6CCMState *dev) | ||
75 | freq = imx6_analog_get_periph_clk(dev) | ||
76 | / (1 + EXTRACT(dev->ccm[CCM_CBCDR], AHB_PODF)); | ||
77 | |||
78 | - DPRINTF("freq = %d\n", (uint32_t)freq); | ||
79 | + DPRINTF("freq = %u\n", (uint32_t)freq); | ||
80 | |||
81 | return freq; | ||
82 | } | ||
83 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx6_ccm_get_ipg_clk(IMX6CCMState *dev) | ||
84 | freq = imx6_ccm_get_ahb_clk(dev) | ||
85 | / (1 + EXTRACT(dev->ccm[CCM_CBCDR], IPG_PODF)); | ||
86 | |||
87 | - DPRINTF("freq = %d\n", (uint32_t)freq); | ||
88 | + DPRINTF("freq = %u\n", (uint32_t)freq); | ||
89 | |||
90 | return freq; | ||
91 | } | ||
92 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx6_ccm_get_per_clk(IMX6CCMState *dev) | ||
93 | freq = imx6_ccm_get_ipg_clk(dev) | ||
94 | / (1 + EXTRACT(dev->ccm[CCM_CSCMR1], PERCLK_PODF)); | ||
95 | |||
96 | - DPRINTF("freq = %d\n", (uint32_t)freq); | ||
97 | + DPRINTF("freq = %u\n", (uint32_t)freq); | ||
98 | |||
99 | return freq; | ||
100 | } | ||
101 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx6_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock) | ||
102 | break; | ||
103 | } | ||
104 | |||
105 | - DPRINTF("Clock = %d) = %d\n", clock, freq); | ||
106 | + DPRINTF("Clock = %d) = %u\n", clock, freq); | ||
107 | |||
108 | return freq; | ||
109 | } | ||
110 | diff --git a/hw/misc/imx6_src.c b/hw/misc/imx6_src.c | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/hw/misc/imx6_src.c | ||
113 | +++ b/hw/misc/imx6_src.c | ||
114 | @@ -XXX,XX +XXX,XX @@ static const char *imx6_src_reg_name(uint32_t reg) | ||
115 | case SRC_GPR10: | ||
116 | return "SRC_GPR10"; | ||
117 | default: | ||
118 | - sprintf(unknown, "%d ?", reg); | ||
119 | + sprintf(unknown, "%u ?", reg); | ||
120 | return unknown; | ||
138 | } | 121 | } |
139 | } | 122 | } |
140 | |||
141 | -static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
142 | +bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
143 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
144 | hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
145 | int *prot, bool *is_subpage, | ||
146 | -- | 123 | -- |
147 | 2.20.1 | 124 | 2.20.1 |
148 | 125 | ||
149 | 126 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Alex Chen <alex.chen@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 3 | We should use printf format specifier "%u" instead of "%d" for |
4 | Message-id: 20190701132516.26392-7-philmd@redhat.com | 4 | argument of type "unsigned int". |
5 | |||
6 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
7 | Signed-off-by: Alex Chen <alex.chen@huawei.com> | ||
8 | Message-id: 20201126111109.112238-5-alex.chen@huawei.com | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 11 | --- |
8 | target/arm/helper.c | 2 -- | 12 | hw/misc/imx6ul_ccm.c | 4 ++-- |
9 | 1 file changed, 2 deletions(-) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
10 | 14 | ||
11 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 15 | diff --git a/hw/misc/imx6ul_ccm.c b/hw/misc/imx6ul_ccm.c |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/helper.c | 17 | --- a/hw/misc/imx6ul_ccm.c |
14 | +++ b/target/arm/helper.c | 18 | +++ b/hw/misc/imx6ul_ccm.c |
15 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static const char *imx6ul_ccm_reg_name(uint32_t reg) |
16 | #include "exec/gdbstub.h" | 20 | case CCM_CMEOR: |
17 | #include "exec/helper-proto.h" | 21 | return "CMEOR"; |
18 | #include "qemu/host-utils.h" | 22 | default: |
19 | -#include "sysemu/arch_init.h" | 23 | - sprintf(unknown, "%d ?", reg); |
20 | #include "sysemu/sysemu.h" | 24 | + sprintf(unknown, "%u ?", reg); |
21 | #include "qemu/bitops.h" | 25 | return unknown; |
22 | #include "qemu/crc32c.h" | 26 | } |
23 | @@ -XXX,XX +XXX,XX @@ | 27 | } |
24 | #include "hw/semihosting/semihost.h" | 28 | @@ -XXX,XX +XXX,XX @@ static const char *imx6ul_analog_reg_name(uint32_t reg) |
25 | #include "sysemu/cpus.h" | 29 | case USB_ANALOG_DIGPROG: |
26 | #include "sysemu/kvm.h" | 30 | return "USB_ANALOG_DIGPROG"; |
27 | -#include "fpu/softfloat.h" | 31 | default: |
28 | #include "qemu/range.h" | 32 | - sprintf(unknown, "%d ?", reg); |
29 | #include "qapi/qapi-commands-target.h" | 33 | + sprintf(unknown, "%u ?", reg); |
30 | #include "qapi/error.h" | 34 | return unknown; |
35 | } | ||
36 | } | ||
31 | -- | 37 | -- |
32 | 2.20.1 | 38 | 2.20.1 |
33 | 39 | ||
34 | 40 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | For M-profile CPUs, the range from 0xe0000000 to 0xe00fffff is the |
---|---|---|---|
2 | Private Peripheral Bus range, which includes all of the memory mapped | ||
3 | devices and registers that are part of the CPU itself, including the | ||
4 | NVIC, systick timer, and debug and trace components like the Data | ||
5 | Watchpoint and Trace unit (DWT). Within this large region, the range | ||
6 | 0xe000e000 to 0xe000efff is the System Control Space (NVIC, system | ||
7 | registers, systick) and 0xe002e000 to 0exe002efff is its Non-secure | ||
8 | alias. | ||
2 | 9 | ||
3 | This will simplify the definition of new SoCs, like the AST2600 which | 10 | The architecture is clear that within the SCS unimplemented registers |
4 | should use a different CPU and a different IRQ number layout. | 11 | should be RES0 for privileged accesses and generate BusFault for |
12 | unprivileged accesses, and we currently implement this. | ||
5 | 13 | ||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 14 | It is less clear about how to handle accesses to unimplemented |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 15 | regions of the wider PPB. Unprivileged accesses should definitely |
8 | Reviewed-by: Joel Stanley <joel@jms.id.au> | 16 | cause BusFaults (R_DQQS), but the behaviour of privileged accesses is |
9 | Message-id: 20190618165311.27066-2-clg@kaod.org | 17 | not given as a general rule. However, the register definitions of |
18 | individual registers for components like the DWT all state that they | ||
19 | are RES0 if the relevant component is not implemented, so the | ||
20 | simplest way to provide that is to provide RAZ/WI for the whole range | ||
21 | for privileged accesses. (The v7M Arm ARM does say that reserved | ||
22 | registers should be UNK/SBZP.) | ||
23 | |||
24 | Expand the container MemoryRegion that the NVIC exposes so that | ||
25 | it covers the whole PPB space. This means: | ||
26 | * moving the address that the ARMV7M device maps it to down by | ||
27 | 0xe000 bytes | ||
28 | * moving the off and the offsets within the container of all the | ||
29 | subregions forward by 0xe000 bytes | ||
30 | * adding a new default MemoryRegion that covers the whole container | ||
31 | at a lower priority than anything else and which provides the | ||
32 | RAZWI/BusFault behaviour | ||
33 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 34 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
35 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
36 | Message-id: 20201119215617.29887-2-peter.maydell@linaro.org | ||
11 | --- | 37 | --- |
12 | include/hw/arm/aspeed_soc.h | 36 +++++++++++++++++++++++ | 38 | include/hw/intc/armv7m_nvic.h | 1 + |
13 | hw/arm/aspeed_soc.c | 57 +++++++++++++++++++++++++++++++------ | 39 | hw/arm/armv7m.c | 2 +- |
14 | 2 files changed, 85 insertions(+), 8 deletions(-) | 40 | hw/intc/armv7m_nvic.c | 78 ++++++++++++++++++++++++++++++----- |
41 | 3 files changed, 69 insertions(+), 12 deletions(-) | ||
15 | 42 | ||
16 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | 43 | diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h |
17 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/arm/aspeed_soc.h | 45 | --- a/include/hw/intc/armv7m_nvic.h |
19 | +++ b/include/hw/arm/aspeed_soc.h | 46 | +++ b/include/hw/intc/armv7m_nvic.h |
20 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { | 47 | @@ -XXX,XX +XXX,XX @@ struct NVICState { |
21 | const char *fmc_typename; | 48 | MemoryRegion systickmem; |
22 | const char **spi_typename; | 49 | MemoryRegion systick_ns_mem; |
23 | int wdts_num; | 50 | MemoryRegion container; |
24 | + const int *irqmap; | 51 | + MemoryRegion defaultmem; |
25 | } AspeedSoCInfo; | 52 | |
26 | 53 | uint32_t num_irq; | |
27 | typedef struct AspeedSoCClass { | 54 | qemu_irq excpout; |
28 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCClass { | 55 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c |
29 | #define ASPEED_SOC_GET_CLASS(obj) \ | 56 | index XXXXXXX..XXXXXXX 100644 |
30 | OBJECT_GET_CLASS(AspeedSoCClass, (obj), TYPE_ASPEED_SOC) | 57 | --- a/hw/arm/armv7m.c |
31 | 58 | +++ b/hw/arm/armv7m.c | |
32 | +enum { | 59 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) |
33 | + ASPEED_IOMEM, | 60 | sysbus_connect_irq(sbd, 0, |
34 | + ASPEED_UART1, | 61 | qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ)); |
35 | + ASPEED_UART2, | 62 | |
36 | + ASPEED_UART3, | 63 | - memory_region_add_subregion(&s->container, 0xe000e000, |
37 | + ASPEED_UART4, | 64 | + memory_region_add_subregion(&s->container, 0xe0000000, |
38 | + ASPEED_UART5, | 65 | sysbus_mmio_get_region(sbd, 0)); |
39 | + ASPEED_VUART, | 66 | |
40 | + ASPEED_FMC, | 67 | for (i = 0; i < ARRAY_SIZE(s->bitband); i++) { |
41 | + ASPEED_SPI1, | 68 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
42 | + ASPEED_SPI2, | 69 | index XXXXXXX..XXXXXXX 100644 |
43 | + ASPEED_VIC, | 70 | --- a/hw/intc/armv7m_nvic.c |
44 | + ASPEED_SDMC, | 71 | +++ b/hw/intc/armv7m_nvic.c |
45 | + ASPEED_SCU, | 72 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps nvic_systick_ops = { |
46 | + ASPEED_ADC, | 73 | .endianness = DEVICE_NATIVE_ENDIAN, |
47 | + ASPEED_SRAM, | 74 | }; |
48 | + ASPEED_GPIO, | 75 | |
49 | + ASPEED_RTC, | 76 | +/* |
50 | + ASPEED_TIMER1, | 77 | + * Unassigned portions of the PPB space are RAZ/WI for privileged |
51 | + ASPEED_TIMER2, | 78 | + * accesses, and fault for non-privileged accesses. |
52 | + ASPEED_TIMER3, | 79 | + */ |
53 | + ASPEED_TIMER4, | 80 | +static MemTxResult ppb_default_read(void *opaque, hwaddr addr, |
54 | + ASPEED_TIMER5, | 81 | + uint64_t *data, unsigned size, |
55 | + ASPEED_TIMER6, | 82 | + MemTxAttrs attrs) |
56 | + ASPEED_TIMER7, | 83 | +{ |
57 | + ASPEED_TIMER8, | 84 | + qemu_log_mask(LOG_UNIMP, "Read of unassigned area of PPB: offset 0x%x\n", |
58 | + ASPEED_WDT, | 85 | + (uint32_t)addr); |
59 | + ASPEED_PWM, | 86 | + if (attrs.user) { |
60 | + ASPEED_LPC, | 87 | + return MEMTX_ERROR; |
61 | + ASPEED_IBT, | 88 | + } |
62 | + ASPEED_I2C, | 89 | + *data = 0; |
63 | + ASPEED_ETH1, | 90 | + return MEMTX_OK; |
64 | + ASPEED_ETH2, | 91 | +} |
92 | + | ||
93 | +static MemTxResult ppb_default_write(void *opaque, hwaddr addr, | ||
94 | + uint64_t value, unsigned size, | ||
95 | + MemTxAttrs attrs) | ||
96 | +{ | ||
97 | + qemu_log_mask(LOG_UNIMP, "Write of unassigned area of PPB: offset 0x%x\n", | ||
98 | + (uint32_t)addr); | ||
99 | + if (attrs.user) { | ||
100 | + return MEMTX_ERROR; | ||
101 | + } | ||
102 | + return MEMTX_OK; | ||
103 | +} | ||
104 | + | ||
105 | +static const MemoryRegionOps ppb_default_ops = { | ||
106 | + .read_with_attrs = ppb_default_read, | ||
107 | + .write_with_attrs = ppb_default_write, | ||
108 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
109 | + .valid.min_access_size = 1, | ||
110 | + .valid.max_access_size = 8, | ||
65 | +}; | 111 | +}; |
66 | + | 112 | + |
67 | #endif /* ASPEED_SOC_H */ | 113 | static int nvic_post_load(void *opaque, int version_id) |
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 | { | 114 | { |
158 | AspeedSoCState *s = ASPEED_SOC(obj); | 115 | NVICState *s = opaque; |
159 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 116 | @@ -XXX,XX +XXX,XX @@ static void nvic_systick_trigger(void *opaque, int n, int level) |
160 | return; | 117 | static void armv7m_nvic_realize(DeviceState *dev, Error **errp) |
118 | { | ||
119 | NVICState *s = NVIC(dev); | ||
120 | - int regionlen; | ||
121 | |||
122 | /* The armv7m container object will have set our CPU pointer */ | ||
123 | if (!s->cpu || !arm_feature(&s->cpu->env, ARM_FEATURE_M)) { | ||
124 | @@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) | ||
125 | M_REG_S)); | ||
161 | } | 126 | } |
162 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, ASPEED_SOC_TIMER_BASE); | 127 | |
163 | - for (i = 0; i < ARRAY_SIZE(timer_irqs); i++) { | 128 | - /* The NVIC and System Control Space (SCS) starts at 0xe000e000 |
164 | - qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->vic), timer_irqs[i]); | 129 | + /* |
165 | + for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { | 130 | + * This device provides a single sysbus memory region which |
166 | + qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_TIMER1 + i); | 131 | + * represents the whole of the "System PPB" space. This is the |
167 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq); | 132 | + * range from 0xe0000000 to 0xe00fffff and includes the NVIC, |
133 | + * the System Control Space (system registers), the systick timer, | ||
134 | + * and for CPUs with the Security extension an NS banked version | ||
135 | + * of all of these. | ||
136 | + * | ||
137 | + * The default behaviour for unimplemented registers/ranges | ||
138 | + * (for instance the Data Watchpoint and Trace unit at 0xe0001000) | ||
139 | + * is to RAZ/WI for privileged access and BusFault for non-privileged | ||
140 | + * access. | ||
141 | + * | ||
142 | + * The NVIC and System Control Space (SCS) starts at 0xe000e000 | ||
143 | * and looks like this: | ||
144 | * 0x004 - ICTR | ||
145 | * 0x010 - 0xff - systick | ||
146 | @@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) | ||
147 | * generally code determining which banked register to use should | ||
148 | * use attrs.secure; code determining actual behaviour of the system | ||
149 | * should use env->v7m.secure. | ||
150 | + * | ||
151 | + * The container covers the whole PPB space. Within it the priority | ||
152 | + * of overlapping regions is: | ||
153 | + * - default region (for RAZ/WI and BusFault) : -1 | ||
154 | + * - system register regions : 0 | ||
155 | + * - systick : 1 | ||
156 | + * This is because the systick device is a small block of registers | ||
157 | + * in the middle of the other system control registers. | ||
158 | */ | ||
159 | - regionlen = arm_feature(&s->cpu->env, ARM_FEATURE_V8) ? 0x21000 : 0x1000; | ||
160 | - memory_region_init(&s->container, OBJECT(s), "nvic", regionlen); | ||
161 | - /* The system register region goes at the bottom of the priority | ||
162 | - * stack as it covers the whole page. | ||
163 | - */ | ||
164 | + memory_region_init(&s->container, OBJECT(s), "nvic", 0x100000); | ||
165 | + memory_region_init_io(&s->defaultmem, OBJECT(s), &ppb_default_ops, s, | ||
166 | + "nvic-default", 0x100000); | ||
167 | + memory_region_add_subregion_overlap(&s->container, 0, &s->defaultmem, -1); | ||
168 | memory_region_init_io(&s->sysregmem, OBJECT(s), &nvic_sysreg_ops, s, | ||
169 | "nvic_sysregs", 0x1000); | ||
170 | - memory_region_add_subregion(&s->container, 0, &s->sysregmem); | ||
171 | + memory_region_add_subregion(&s->container, 0xe000, &s->sysregmem); | ||
172 | |||
173 | memory_region_init_io(&s->systickmem, OBJECT(s), | ||
174 | &nvic_systick_ops, s, | ||
175 | "nvic_systick", 0xe0); | ||
176 | |||
177 | - memory_region_add_subregion_overlap(&s->container, 0x10, | ||
178 | + memory_region_add_subregion_overlap(&s->container, 0xe010, | ||
179 | &s->systickmem, 1); | ||
180 | |||
181 | if (arm_feature(&s->cpu->env, ARM_FEATURE_V8)) { | ||
182 | memory_region_init_io(&s->sysreg_ns_mem, OBJECT(s), | ||
183 | &nvic_sysreg_ns_ops, &s->sysregmem, | ||
184 | "nvic_sysregs_ns", 0x1000); | ||
185 | - memory_region_add_subregion(&s->container, 0x20000, &s->sysreg_ns_mem); | ||
186 | + memory_region_add_subregion(&s->container, 0x2e000, &s->sysreg_ns_mem); | ||
187 | memory_region_init_io(&s->systick_ns_mem, OBJECT(s), | ||
188 | &nvic_sysreg_ns_ops, &s->systickmem, | ||
189 | "nvic_systick_ns", 0xe0); | ||
190 | - memory_region_add_subregion_overlap(&s->container, 0x20010, | ||
191 | + memory_region_add_subregion_overlap(&s->container, 0x2e010, | ||
192 | &s->systick_ns_mem, 1); | ||
168 | } | 193 | } |
169 | 194 | ||
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 | -- | 195 | -- |
205 | 2.20.1 | 196 | 2.20.1 |
206 | 197 | ||
207 | 198 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | In v8.1M the PXN architecture extension adds a new PXN bit to the |
---|---|---|---|
2 | MPU_RLAR registers, which forbids execution of code in the region | ||
3 | from a privileged mode. | ||
2 | 4 | ||
3 | Reviewed-by: Robert Bradford <robert.bradford@intel.com> | 5 | This is another feature which is just in the generic "in v8.1M" set |
4 | Reviewed-by: Samuel Ortiz <sameo@linux.intel.com> | 6 | and has no ID register field indicating its presence. |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 7 | |
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> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20201119215617.29887-3-peter.maydell@linaro.org | ||
9 | --- | 11 | --- |
10 | target/arm/helper.c | 7 +++++++ | 12 | target/arm/helper.c | 7 ++++++- |
11 | 1 file changed, 7 insertions(+) | 13 | 1 file changed, 6 insertions(+), 1 deletion(-) |
12 | 14 | ||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.c | 17 | --- a/target/arm/helper.c |
16 | +++ b/target/arm/helper.c | 18 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, |
18 | +/* | 20 | } else { |
19 | + * ARM generic helpers. | 21 | uint32_t ap = extract32(env->pmsav8.rbar[secure][matchregion], 1, 2); |
20 | + * | 22 | uint32_t xn = extract32(env->pmsav8.rbar[secure][matchregion], 0, 1); |
21 | + * This code is licensed under the GNU GPL v2 or later. | 23 | + bool pxn = false; |
22 | + * | 24 | + |
23 | + * SPDX-License-Identifier: GPL-2.0-or-later | 25 | + if (arm_feature(env, ARM_FEATURE_V8_1M)) { |
24 | + */ | 26 | + pxn = extract32(env->pmsav8.rlar[secure][matchregion], 4, 1); |
25 | #include "qemu/osdep.h" | 27 | + } |
26 | #include "qemu/units.h" | 28 | |
27 | #include "target/arm/idau.h" | 29 | if (m_is_system_region(env, address)) { |
30 | /* System space is always execute never */ | ||
31 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
32 | } | ||
33 | |||
34 | *prot = simple_ap_to_rw_prot(env, mmu_idx, ap); | ||
35 | - if (*prot && !xn) { | ||
36 | + if (*prot && !xn && !(pxn && !is_user)) { | ||
37 | *prot |= PAGE_EXEC; | ||
38 | } | ||
39 | /* We don't need to look the attribute up in the MAIR0/MAIR1 | ||
28 | -- | 40 | -- |
29 | 2.20.1 | 41 | 2.20.1 |
30 | 42 | ||
31 | 43 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | In arm_cpu_realizefn() we check whether the board code disabled EL3 |
---|---|---|---|
2 | via the has_el3 CPU object property, which we create if the CPU | ||
3 | starts with the ARM_FEATURE_EL3 feature bit. If it is disabled, then | ||
4 | we turn off ARM_FEATURE_EL3 and also zero out the relevant fields in | ||
5 | the ID_PFR1 and ID_AA64PFR0 registers. | ||
2 | 6 | ||
3 | This machine correctly defines its default_cpu_type to cortex-m3 | 7 | This codepath was incorrectly being taken for M-profile CPUs, which |
4 | and report an error if the user requested another cpu_type, | 8 | do not have an EL3 and don't set ARM_FEATURE_EL3, but which may have |
5 | however it does not exit, and this can confuse users trying | 9 | the M-profile Security extension and so should have non-zero values |
6 | to use another core: | 10 | in the ID_PFR1.Security field. |
7 | 11 | ||
8 | $ qemu-system-arm -M emcraft-sf2 -cpu cortex-m4 -kernel test-m4.elf | 12 | Restrict the handling of the feature flag to A/R-profile cores. |
9 | qemu-system-arm: This board can only be used with CPU cortex-m3-arm-cpu | ||
10 | [output related to M3 core ...] | ||
11 | 13 | ||
12 | The CPU is indeed a M3 core: | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20201119215617.29887-4-peter.maydell@linaro.org | ||
17 | --- | ||
18 | target/arm/cpu.c | 2 +- | ||
19 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | 20 | ||
14 | (qemu) info qom-tree | 21 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
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 | 22 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/arm/msf2-som.c | 23 | --- a/target/arm/cpu.c |
35 | +++ b/hw/arm/msf2-som.c | 24 | +++ b/target/arm/cpu.c |
36 | @@ -XXX,XX +XXX,XX @@ static void emcraft_sf2_s2s010_init(MachineState *machine) | 25 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
37 | if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) { | 26 | } |
38 | error_report("This board can only be used with CPU %s", | ||
39 | mc->default_cpu_type); | ||
40 | + exit(1); | ||
41 | } | 27 | } |
42 | 28 | ||
43 | memory_region_init_ram(ddr, NULL, "ddr-ram", DDR_SIZE, | 29 | - if (!cpu->has_el3) { |
30 | + if (!arm_feature(env, ARM_FEATURE_M) && !cpu->has_el3) { | ||
31 | /* If the has_el3 CPU property is disabled then we need to disable the | ||
32 | * feature. | ||
33 | */ | ||
44 | -- | 34 | -- |
45 | 2.20.1 | 35 | 2.20.1 |
46 | 36 | ||
47 | 37 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Jan Kiszka <jan.kiszka@siemens.com> | ||
2 | 1 | ||
3 | Allow cortex-a7 to be used with the virt board; it supports | ||
4 | the v7VE features and there is no reason to deny this type. | ||
5 | |||
6 | Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> | ||
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 | ||
17 | --- a/hw/arm/virt.c | ||
18 | +++ b/hw/arm/virt.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static const int a15irqmap[] = { | ||
20 | }; | ||
21 | |||
22 | static const char *valid_cpus[] = { | ||
23 | + ARM_CPU_TYPE_NAME("cortex-a7"), | ||
24 | ARM_CPU_TYPE_NAME("cortex-a15"), | ||
25 | ARM_CPU_TYPE_NAME("cortex-a53"), | ||
26 | ARM_CPU_TYPE_NAME("cortex-a57"), | ||
27 | -- | ||
28 | 2.20.1 | ||
29 | |||
30 | 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 |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Implement the v8.1M VSCCLRM insn, which zeros floating point |
---|---|---|---|
2 | 2 | registers if there is an active floating point context. | |
3 | To ease the review of the next commit, | 3 | This requires support in write_neon_element32() for the MO_32 |
4 | move the vfp_exceptbits_to_host() function directly after | 4 | element size, so add it. |
5 | vfp_exceptbits_from_host(). Amusingly the diff shows we | 5 | |
6 | are moving vfp_get_fpscr(). | 6 | Because we want to use arm_gen_condlabel(), we need to move |
7 | 7 | the definition of that function up in translate.c so it is | |
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | before the #include of translate-vfp.c.inc. |
9 | Message-id: 20190701132516.26392-15-philmd@redhat.com | 9 | |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | 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: 20201119215617.29887-5-peter.maydell@linaro.org | ||
12 | --- | 13 | --- |
13 | target/arm/vfp_helper.c | 52 ++++++++++++++++++++--------------------- | 14 | target/arm/cpu.h | 9 ++++ |
14 | 1 file changed, 26 insertions(+), 26 deletions(-) | 15 | target/arm/m-nocp.decode | 8 +++- |
15 | 16 | target/arm/translate.c | 21 +++++---- | |
16 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | 17 | target/arm/translate-vfp.c.inc | 84 ++++++++++++++++++++++++++++++++++ |
17 | index XXXXXXX..XXXXXXX 100644 | 18 | 4 files changed, 111 insertions(+), 11 deletions(-) |
18 | --- a/target/arm/vfp_helper.c | 19 | |
19 | +++ b/target/arm/vfp_helper.c | 20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
20 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_from_host(int host_bits) | 21 | index XXXXXXX..XXXXXXX 100644 |
21 | return target_bits; | 22 | --- a/target/arm/cpu.h |
22 | } | 23 | +++ b/target/arm/cpu.h |
23 | 24 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_mprofile(const ARMISARegisters *id) | |
24 | -uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | 25 | return FIELD_EX32(id->id_pfr1, ID_PFR1, MPROGMOD) != 0; |
26 | } | ||
27 | |||
28 | +static inline bool isar_feature_aa32_m_sec_state(const ARMISARegisters *id) | ||
29 | +{ | ||
30 | + /* | ||
31 | + * Return true if M-profile state handling insns | ||
32 | + * (VSCCLRM, CLRM, FPCTX access insns) are implemented | ||
33 | + */ | ||
34 | + return FIELD_EX32(id->id_pfr1, ID_PFR1, SECURITY) >= 3; | ||
35 | +} | ||
36 | + | ||
37 | static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) | ||
38 | { | ||
39 | /* Sadly this is encoded differently for A-profile and M-profile */ | ||
40 | diff --git a/target/arm/m-nocp.decode b/target/arm/m-nocp.decode | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/m-nocp.decode | ||
43 | +++ b/target/arm/m-nocp.decode | ||
44 | @@ -XXX,XX +XXX,XX @@ | ||
45 | # If the coprocessor is not present or disabled then we will generate | ||
46 | # the NOCP exception; otherwise we let the insn through to the main decode. | ||
47 | |||
48 | +%vd_dp 22:1 12:4 | ||
49 | +%vd_sp 12:4 22:1 | ||
50 | + | ||
51 | &nocp cp | ||
52 | |||
53 | { | ||
54 | # Special cases which do not take an early NOCP: VLLDM and VLSTM | ||
55 | VLLDM_VLSTM 1110 1100 001 l:1 rn:4 0000 1010 0000 0000 | ||
56 | - # TODO: VSCCLRM (new in v8.1M) is similar: | ||
57 | - #VSCCLRM 1110 1100 1-01 1111 ---- 1011 ---- ---0 | ||
58 | + # VSCCLRM (new in v8.1M) is similar: | ||
59 | + VSCCLRM 1110 1100 1.01 1111 .... 1011 imm:7 0 vd=%vd_dp size=3 | ||
60 | + VSCCLRM 1110 1100 1.01 1111 .... 1010 imm:8 vd=%vd_sp size=2 | ||
61 | |||
62 | NOCP 111- 1110 ---- ---- ---- cp:4 ---- ---- &nocp | ||
63 | NOCP 111- 110- ---- ---- ---- cp:4 ---- ---- &nocp | ||
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 @@ void arm_translate_init(void) | ||
69 | a64_translate_init(); | ||
70 | } | ||
71 | |||
72 | +/* Generate a label used for skipping this instruction */ | ||
73 | +static void arm_gen_condlabel(DisasContext *s) | ||
74 | +{ | ||
75 | + if (!s->condjmp) { | ||
76 | + s->condlabel = gen_new_label(); | ||
77 | + s->condjmp = 1; | ||
78 | + } | ||
79 | +} | ||
80 | + | ||
81 | /* Flags for the disas_set_da_iss info argument: | ||
82 | * lower bits hold the Rt register number, higher bits are flags. | ||
83 | */ | ||
84 | @@ -XXX,XX +XXX,XX @@ static void write_neon_element64(TCGv_i64 src, int reg, int ele, MemOp memop) | ||
85 | long off = neon_element_offset(reg, ele, memop); | ||
86 | |||
87 | switch (memop) { | ||
88 | + case MO_32: | ||
89 | + tcg_gen_st32_i64(src, cpu_env, off); | ||
90 | + break; | ||
91 | case MO_64: | ||
92 | tcg_gen_st_i64(src, cpu_env, off); | ||
93 | break; | ||
94 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
95 | s->base.is_jmp = DISAS_UPDATE_EXIT; | ||
96 | } | ||
97 | |||
98 | -/* Generate a label used for skipping this instruction */ | ||
99 | -static void arm_gen_condlabel(DisasContext *s) | ||
25 | -{ | 100 | -{ |
26 | - uint32_t i, fpscr; | 101 | - if (!s->condjmp) { |
27 | - | 102 | - s->condlabel = gen_new_label(); |
28 | - fpscr = env->vfp.xregs[ARM_VFP_FPSCR] | 103 | - s->condjmp = 1; |
29 | - | (env->vfp.vec_len << 16) | 104 | - } |
30 | - | (env->vfp.vec_stride << 20); | ||
31 | - | ||
32 | - i = get_float_exception_flags(&env->vfp.fp_status); | ||
33 | - i |= get_float_exception_flags(&env->vfp.standard_fp_status); | ||
34 | - /* FZ16 does not generate an input denormal exception. */ | ||
35 | - i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | ||
36 | - & ~float_flag_input_denormal); | ||
37 | - fpscr |= vfp_exceptbits_from_host(i); | ||
38 | - | ||
39 | - i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; | ||
40 | - fpscr |= i ? FPCR_QC : 0; | ||
41 | - | ||
42 | - return fpscr; | ||
43 | -} | 105 | -} |
44 | - | 106 | - |
45 | -uint32_t vfp_get_fpscr(CPUARMState *env) | 107 | /* Skip this instruction if the ARM condition is false */ |
46 | -{ | 108 | static void arm_skip_unless(DisasContext *s, uint32_t cond) |
47 | - return HELPER(vfp_get_fpscr)(env); | 109 | { |
48 | -} | 110 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
49 | - | 111 | index XXXXXXX..XXXXXXX 100644 |
50 | /* Convert vfp exception flags to target form. */ | 112 | --- a/target/arm/translate-vfp.c.inc |
51 | static inline int vfp_exceptbits_to_host(int target_bits) | 113 | +++ b/target/arm/translate-vfp.c.inc |
52 | { | 114 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLLDM_VLSTM(DisasContext *s, arg_VLLDM_VLSTM *a) |
53 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits) | 115 | return true; |
54 | return host_bits; | 116 | } |
55 | } | 117 | |
56 | 118 | +static bool trans_VSCCLRM(DisasContext *s, arg_VSCCLRM *a) | |
57 | +uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | ||
58 | +{ | 119 | +{ |
59 | + uint32_t i, fpscr; | 120 | + int btmreg, topreg; |
60 | + | 121 | + TCGv_i64 zero; |
61 | + fpscr = env->vfp.xregs[ARM_VFP_FPSCR] | 122 | + TCGv_i32 aspen, sfpa; |
62 | + | (env->vfp.vec_len << 16) | 123 | + |
63 | + | (env->vfp.vec_stride << 20); | 124 | + if (!dc_isar_feature(aa32_m_sec_state, s)) { |
64 | + | 125 | + /* Before v8.1M, fall through in decode to NOCP check */ |
65 | + i = get_float_exception_flags(&env->vfp.fp_status); | 126 | + return false; |
66 | + i |= get_float_exception_flags(&env->vfp.standard_fp_status); | 127 | + } |
67 | + /* FZ16 does not generate an input denormal exception. */ | 128 | + |
68 | + i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | 129 | + /* Explicitly UNDEF because this takes precedence over NOCP */ |
69 | + & ~float_flag_input_denormal); | 130 | + if (!arm_dc_feature(s, ARM_FEATURE_M_MAIN) || !s->v8m_secure) { |
70 | + fpscr |= vfp_exceptbits_from_host(i); | 131 | + unallocated_encoding(s); |
71 | + | 132 | + return true; |
72 | + i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; | 133 | + } |
73 | + fpscr |= i ? FPCR_QC : 0; | 134 | + |
74 | + | 135 | + if (!dc_isar_feature(aa32_vfp_simd, s)) { |
75 | + return fpscr; | 136 | + /* NOP if we have neither FP nor MVE */ |
137 | + return true; | ||
138 | + } | ||
139 | + | ||
140 | + /* | ||
141 | + * If FPCCR.ASPEN != 0 && CONTROL_S.SFPA == 0 then there is no | ||
142 | + * active floating point context so we must NOP (without doing | ||
143 | + * any lazy state preservation or the NOCP check). | ||
144 | + */ | ||
145 | + aspen = load_cpu_field(v7m.fpccr[M_REG_S]); | ||
146 | + sfpa = load_cpu_field(v7m.control[M_REG_S]); | ||
147 | + tcg_gen_andi_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
148 | + tcg_gen_xori_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
149 | + tcg_gen_andi_i32(sfpa, sfpa, R_V7M_CONTROL_SFPA_MASK); | ||
150 | + tcg_gen_or_i32(sfpa, sfpa, aspen); | ||
151 | + arm_gen_condlabel(s); | ||
152 | + tcg_gen_brcondi_i32(TCG_COND_EQ, sfpa, 0, s->condlabel); | ||
153 | + | ||
154 | + if (s->fp_excp_el != 0) { | ||
155 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
156 | + syn_uncategorized(), s->fp_excp_el); | ||
157 | + return true; | ||
158 | + } | ||
159 | + | ||
160 | + topreg = a->vd + a->imm - 1; | ||
161 | + btmreg = a->vd; | ||
162 | + | ||
163 | + /* Convert to Sreg numbers if the insn specified in Dregs */ | ||
164 | + if (a->size == 3) { | ||
165 | + topreg = topreg * 2 + 1; | ||
166 | + btmreg *= 2; | ||
167 | + } | ||
168 | + | ||
169 | + if (topreg > 63 || (topreg > 31 && !(topreg & 1))) { | ||
170 | + /* UNPREDICTABLE: we choose to undef */ | ||
171 | + unallocated_encoding(s); | ||
172 | + return true; | ||
173 | + } | ||
174 | + | ||
175 | + /* Silently ignore requests to clear D16-D31 if they don't exist */ | ||
176 | + if (topreg > 31 && !dc_isar_feature(aa32_simd_r32, s)) { | ||
177 | + topreg = 31; | ||
178 | + } | ||
179 | + | ||
180 | + if (!vfp_access_check(s)) { | ||
181 | + return true; | ||
182 | + } | ||
183 | + | ||
184 | + /* Zero the Sregs from btmreg to topreg inclusive. */ | ||
185 | + zero = tcg_const_i64(0); | ||
186 | + if (btmreg & 1) { | ||
187 | + write_neon_element64(zero, btmreg >> 1, 1, MO_32); | ||
188 | + btmreg++; | ||
189 | + } | ||
190 | + for (; btmreg + 1 <= topreg; btmreg += 2) { | ||
191 | + write_neon_element64(zero, btmreg >> 1, 0, MO_64); | ||
192 | + } | ||
193 | + if (btmreg == topreg) { | ||
194 | + write_neon_element64(zero, btmreg >> 1, 0, MO_32); | ||
195 | + btmreg++; | ||
196 | + } | ||
197 | + assert(btmreg == topreg + 1); | ||
198 | + /* TODO: when MVE is implemented, zero VPR here */ | ||
199 | + return true; | ||
76 | +} | 200 | +} |
77 | + | 201 | + |
78 | +uint32_t vfp_get_fpscr(CPUARMState *env) | 202 | static bool trans_NOCP(DisasContext *s, arg_nocp *a) |
79 | +{ | 203 | { |
80 | + return HELPER(vfp_get_fpscr)(env); | 204 | /* |
81 | +} | ||
82 | + | ||
83 | void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | ||
84 | { | ||
85 | int i; | ||
86 | -- | 205 | -- |
87 | 2.20.1 | 206 | 2.20.1 |
88 | 207 | ||
89 | 208 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | In v8.1M the new CLRM instruction allows zeroing an arbitrary set of |
---|---|---|---|
2 | the general-purpose registers and APSR. Implement this. | ||
2 | 3 | ||
3 | The Linux kernel driver was updated in commit 4451d3f59f2a | 4 | The encoding is a subset of the LDMIA T2 encoding, using what would |
4 | ("clocksource/drivers/fttmr010: Fix set_next_event handler) to fix an | 5 | be Rn=0b1111 (which UNDEFs for LDMIA). |
5 | issue observed on hardware: | ||
6 | 6 | ||
7 | > RELOAD register is loaded into COUNT register when the aspeed timer | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | > is enabled, which means the next event may be delayed because timer | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | > interrupt won't be generated until <0xFFFFFFFF - current_count + | 9 | Message-id: 20201119215617.29887-6-peter.maydell@linaro.org |
10 | > cycles>. | 10 | --- |
11 | target/arm/t32.decode | 6 +++++- | ||
12 | target/arm/translate.c | 38 ++++++++++++++++++++++++++++++++++++++ | ||
13 | 2 files changed, 43 insertions(+), 1 deletion(-) | ||
11 | 14 | ||
12 | When running under Qemu, the system appeared "laggy". The guest is now | 15 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode |
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 | 16 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/timer/aspeed_timer.c | 17 | --- a/target/arm/t32.decode |
39 | +++ b/hw/timer/aspeed_timer.c | 18 | +++ b/target/arm/t32.decode |
40 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks) | 19 | @@ -XXX,XX +XXX,XX @@ UXTAB 1111 1010 0101 .... 1111 .... 10.. .... @rrr_rot |
41 | 20 | ||
42 | static uint64_t calculate_next(struct AspeedTimer *t) | 21 | STM_t32 1110 1000 10.0 .... ................ @ldstm i=1 b=0 |
43 | { | 22 | STM_t32 1110 1001 00.0 .... ................ @ldstm i=0 b=1 |
44 | - uint64_t next = 0; | 23 | -LDM_t32 1110 1000 10.1 .... ................ @ldstm i=1 b=0 |
45 | - uint32_t rate = calculate_rate(t); | 24 | +{ |
46 | + uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | 25 | + # Rn=15 UNDEFs for LDM; M-profile CLRM uses that encoding |
47 | + uint64_t next; | 26 | + CLRM 1110 1000 1001 1111 list:16 |
48 | 27 | + LDM_t32 1110 1000 10.1 .... ................ @ldstm i=1 b=0 | |
49 | - while (!next) { | 28 | +} |
50 | - /* We don't know the relationship between the values in the match | 29 | LDM_t32 1110 1001 00.1 .... ................ @ldstm i=0 b=1 |
51 | - * registers, so sort using MAX/MIN/zero. We sort in that order as the | 30 | |
52 | - * timer counts down to zero. */ | 31 | &rfe !extern rn w pu |
53 | - uint64_t seq[] = { | 32 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
54 | - calculate_time(t, MAX(t->match[0], t->match[1])), | 33 | index XXXXXXX..XXXXXXX 100644 |
55 | - calculate_time(t, MIN(t->match[0], t->match[1])), | 34 | --- a/target/arm/translate.c |
56 | - calculate_time(t, 0), | 35 | +++ b/target/arm/translate.c |
57 | - }; | 36 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDM_t16(DisasContext *s, arg_ldst_block *a) |
58 | - uint64_t reload_ns; | 37 | return do_ldm(s, a, 1); |
59 | - uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | 38 | } |
60 | + /* | 39 | |
61 | + * We don't know the relationship between the values in the match | 40 | +static bool trans_CLRM(DisasContext *s, arg_CLRM *a) |
62 | + * registers, so sort using MAX/MIN/zero. We sort in that order as | 41 | +{ |
63 | + * the timer counts down to zero. | 42 | + int i; |
64 | + */ | 43 | + TCGv_i32 zero; |
65 | 44 | + | |
66 | - if (now < seq[0]) { | 45 | + if (!dc_isar_feature(aa32_m_sec_state, s)) { |
67 | - next = seq[0]; | 46 | + return false; |
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 | + } | 47 | + } |
89 | + | 48 | + |
90 | + next = calculate_time(t, 0); | 49 | + if (extract32(a->list, 13, 1)) { |
91 | + if (now < next) { | 50 | + return false; |
92 | + return next; | ||
93 | + } | 51 | + } |
94 | + | 52 | + |
95 | + /* We've missed all deadlines, fire interrupt and try again */ | 53 | + if (!a->list) { |
96 | + timer_del(&t->timer); | 54 | + /* UNPREDICTABLE; we choose to UNDEF */ |
97 | + | 55 | + return false; |
98 | + if (timer_overflow_interrupt(t)) { | ||
99 | + t->level = !t->level; | ||
100 | + qemu_set_irq(t->irq, t->level); | ||
101 | + } | 56 | + } |
102 | + | 57 | + |
103 | + t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | 58 | + zero = tcg_const_i32(0); |
104 | + return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0)); | 59 | + for (i = 0; i < 15; i++) { |
105 | } | 60 | + if (extract32(a->list, i, 1)) { |
106 | 61 | + /* Clear R[i] */ | |
107 | static void aspeed_timer_mod(AspeedTimer *t) | 62 | + tcg_gen_mov_i32(cpu_R[i], zero); |
63 | + } | ||
64 | + } | ||
65 | + if (extract32(a->list, 15, 1)) { | ||
66 | + /* | ||
67 | + * Clear APSR (by calling the MSR helper with the same argument | ||
68 | + * as for "MSR APSR_nzcvqg, Rn": mask = 0b1100, SYSM=0) | ||
69 | + */ | ||
70 | + TCGv_i32 maskreg = tcg_const_i32(0xc << 8); | ||
71 | + gen_helper_v7m_msr(cpu_env, maskreg, zero); | ||
72 | + tcg_temp_free_i32(maskreg); | ||
73 | + } | ||
74 | + tcg_temp_free_i32(zero); | ||
75 | + return true; | ||
76 | +} | ||
77 | + | ||
78 | /* | ||
79 | * Branch, branch with link | ||
80 | */ | ||
108 | -- | 81 | -- |
109 | 2.20.1 | 82 | 2.20.1 |
110 | 83 | ||
111 | 84 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | For M-profile before v8.1M, the only valid register for VMSR/VMRS is |
---|---|---|---|
2 | the FPSCR. We have a comment that states this, but the actual logic | ||
3 | to forbid accesses for any other register value is missing, so we | ||
4 | would end up with A-profile style behaviour. Add the missing check. | ||
2 | 5 | ||
3 | Group SOFTMMU objects together. | ||
4 | Since PSCI is TCG specific, keep it separate. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190701132516.26392-5-philmd@redhat.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20201119215617.29887-7-peter.maydell@linaro.org | ||
10 | --- | 9 | --- |
11 | target/arm/Makefile.objs | 5 ++++- | 10 | target/arm/translate-vfp.c.inc | 5 ++++- |
12 | 1 file changed, 4 insertions(+), 1 deletion(-) | 11 | 1 file changed, 4 insertions(+), 1 deletion(-) |
13 | 12 | ||
14 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | 13 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/Makefile.objs | 15 | --- a/target/arm/translate-vfp.c.inc |
17 | +++ b/target/arm/Makefile.objs | 16 | +++ b/target/arm/translate-vfp.c.inc |
18 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) |
19 | obj-y += arm-semi.o | 18 | * Accesses to R15 are UNPREDICTABLE; we choose to undef. |
20 | -obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o | 19 | * (FPSCR -> r15 is a special case which writes to the PSR flags.) |
21 | obj-y += helper.o vfp_helper.o | 20 | */ |
22 | obj-y += cpu.o gdbstub.o | 21 | - if (a->rt == 15 && (!a->l || a->reg != ARM_VFP_FPSCR)) { |
23 | obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o | 22 | + if (a->reg != ARM_VFP_FPSCR) { |
24 | + | 23 | + return false; |
25 | +obj-$(CONFIG_SOFTMMU) += machine.o arch_dump.o monitor.o | 24 | + } |
26 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o | 25 | + if (a->rt == 15 && !a->l) { |
27 | 26 | return false; | |
28 | obj-$(CONFIG_KVM) += kvm.o | 27 | } |
29 | @@ -XXX,XX +XXX,XX @@ obj-y += translate.o op_helper.o | 28 | } |
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 | -- | 29 | -- |
39 | 2.20.1 | 30 | 2.20.1 |
40 | 31 | ||
41 | 32 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | Currently M-profile borrows the A-profile code for VMSR and VMRS |
---|---|---|---|
2 | 2 | (access to the FP system registers), because all it needs to support | |
3 | The Aspeed SoCs have two MACs. Extend the Aspeed model to support a | 3 | is the FPSCR. In v8.1M things become significantly more complicated |
4 | second NIC. | 4 | in two ways: |
5 | 5 | ||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 6 | * there are several new FP system registers; some have side effects |
7 | Reviewed-by: Joel Stanley <joel@jms.id.au> | 7 | on read, and one (FPCXT_NS) needs to avoid the usual |
8 | Message-id: 20190618165311.27066-7-clg@kaod.org | 8 | vfp_access_check() and the "only if FPU implemented" check |
9 | |||
10 | * all sysregs are now accessible both by VMRS/VMSR (which | ||
11 | reads/writes a general purpose register) and also by VLDR/VSTR | ||
12 | (which reads/writes them directly to memory) | ||
13 | |||
14 | Refactor the structure of how we handle VMSR/VMRS to cope with this: | ||
15 | |||
16 | * keep the M-profile code entirely separate from the A-profile code | ||
17 | |||
18 | * abstract out the "read or write the general purpose register" part | ||
19 | of the code into a loadfn or storefn function pointer, so we can | ||
20 | reuse it for VLDR/VSTR. | ||
21 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
24 | Message-id: 20201119215617.29887-8-peter.maydell@linaro.org | ||
10 | --- | 25 | --- |
11 | include/hw/arm/aspeed_soc.h | 3 ++- | 26 | target/arm/cpu.h | 3 + |
12 | hw/arm/aspeed_soc.c | 33 +++++++++++++++++++-------------- | 27 | target/arm/translate-vfp.c.inc | 182 ++++++++++++++++++++++++++++++--- |
13 | 2 files changed, 21 insertions(+), 15 deletions(-) | 28 | 2 files changed, 171 insertions(+), 14 deletions(-) |
14 | 29 | ||
15 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | 30 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
16 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/arm/aspeed_soc.h | 32 | --- a/target/arm/cpu.h |
18 | +++ b/include/hw/arm/aspeed_soc.h | 33 | +++ b/target/arm/cpu.h |
19 | @@ -XXX,XX +XXX,XX @@ | 34 | @@ -XXX,XX +XXX,XX @@ enum arm_cpu_mode { |
20 | #define ASPEED_SPIS_NUM 2 | 35 | #define ARM_VFP_FPINST 9 |
21 | #define ASPEED_WDTS_NUM 3 | 36 | #define ARM_VFP_FPINST2 10 |
22 | #define ASPEED_CPUS_NUM 2 | 37 | |
23 | +#define ASPEED_MACS_NUM 2 | 38 | +/* QEMU-internal value meaning "FPSCR, but we care only about NZCV" */ |
24 | 39 | +#define QEMU_VFP_FPSCR_NZCV 0xffff | |
25 | typedef struct AspeedSoCState { | 40 | + |
26 | /*< private >*/ | 41 | /* iwMMXt coprocessor control registers. */ |
27 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { | 42 | #define ARM_IWMMXT_wCID 0 |
28 | AspeedSMCState spi[ASPEED_SPIS_NUM]; | 43 | #define ARM_IWMMXT_wCon 1 |
29 | AspeedSDMCState sdmc; | 44 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
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 | 45 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/arm/aspeed_soc.c | 46 | --- a/target/arm/translate-vfp.c.inc |
39 | +++ b/hw/arm/aspeed_soc.c | 47 | +++ b/target/arm/translate-vfp.c.inc |
40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | 48 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDUP(DisasContext *s, arg_VDUP *a) |
41 | sc->info->silicon_rev); | 49 | return true; |
50 | } | ||
51 | |||
52 | +/* | ||
53 | + * M-profile provides two different sets of instructions that can | ||
54 | + * access floating point system registers: VMSR/VMRS (which move | ||
55 | + * to/from a general purpose register) and VLDR/VSTR sysreg (which | ||
56 | + * move directly to/from memory). In some cases there are also side | ||
57 | + * effects which must happen after any write to memory (which could | ||
58 | + * cause an exception). So we implement the common logic for the | ||
59 | + * sysreg access in gen_M_fp_sysreg_write() and gen_M_fp_sysreg_read(), | ||
60 | + * which take pointers to callback functions which will perform the | ||
61 | + * actual "read/write general purpose register" and "read/write | ||
62 | + * memory" operations. | ||
63 | + */ | ||
64 | + | ||
65 | +/* | ||
66 | + * Emit code to store the sysreg to its final destination; frees the | ||
67 | + * TCG temp 'value' it is passed. | ||
68 | + */ | ||
69 | +typedef void fp_sysreg_storefn(DisasContext *s, void *opaque, TCGv_i32 value); | ||
70 | +/* | ||
71 | + * Emit code to load the value to be copied to the sysreg; returns | ||
72 | + * a new TCG temporary | ||
73 | + */ | ||
74 | +typedef TCGv_i32 fp_sysreg_loadfn(DisasContext *s, void *opaque); | ||
75 | + | ||
76 | +/* Common decode/access checks for fp sysreg read/write */ | ||
77 | +typedef enum FPSysRegCheckResult { | ||
78 | + FPSysRegCheckFailed, /* caller should return false */ | ||
79 | + FPSysRegCheckDone, /* caller should return true */ | ||
80 | + FPSysRegCheckContinue, /* caller should continue generating code */ | ||
81 | +} FPSysRegCheckResult; | ||
82 | + | ||
83 | +static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) | ||
84 | +{ | ||
85 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
86 | + return FPSysRegCheckFailed; | ||
87 | + } | ||
88 | + | ||
89 | + switch (regno) { | ||
90 | + case ARM_VFP_FPSCR: | ||
91 | + case QEMU_VFP_FPSCR_NZCV: | ||
92 | + break; | ||
93 | + default: | ||
94 | + return FPSysRegCheckFailed; | ||
95 | + } | ||
96 | + | ||
97 | + if (!vfp_access_check(s)) { | ||
98 | + return FPSysRegCheckDone; | ||
99 | + } | ||
100 | + | ||
101 | + return FPSysRegCheckContinue; | ||
102 | +} | ||
103 | + | ||
104 | +static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
105 | + | ||
106 | + fp_sysreg_loadfn *loadfn, | ||
107 | + void *opaque) | ||
108 | +{ | ||
109 | + /* Do a write to an M-profile floating point system register */ | ||
110 | + TCGv_i32 tmp; | ||
111 | + | ||
112 | + switch (fp_sysreg_checks(s, regno)) { | ||
113 | + case FPSysRegCheckFailed: | ||
114 | + return false; | ||
115 | + case FPSysRegCheckDone: | ||
116 | + return true; | ||
117 | + case FPSysRegCheckContinue: | ||
118 | + break; | ||
119 | + } | ||
120 | + | ||
121 | + switch (regno) { | ||
122 | + case ARM_VFP_FPSCR: | ||
123 | + tmp = loadfn(s, opaque); | ||
124 | + gen_helper_vfp_set_fpscr(cpu_env, tmp); | ||
125 | + tcg_temp_free_i32(tmp); | ||
126 | + gen_lookup_tb(s); | ||
127 | + break; | ||
128 | + default: | ||
129 | + g_assert_not_reached(); | ||
130 | + } | ||
131 | + return true; | ||
132 | +} | ||
133 | + | ||
134 | +static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
135 | + fp_sysreg_storefn *storefn, | ||
136 | + void *opaque) | ||
137 | +{ | ||
138 | + /* Do a read from an M-profile floating point system register */ | ||
139 | + TCGv_i32 tmp; | ||
140 | + | ||
141 | + switch (fp_sysreg_checks(s, regno)) { | ||
142 | + case FPSysRegCheckFailed: | ||
143 | + return false; | ||
144 | + case FPSysRegCheckDone: | ||
145 | + return true; | ||
146 | + case FPSysRegCheckContinue: | ||
147 | + break; | ||
148 | + } | ||
149 | + | ||
150 | + switch (regno) { | ||
151 | + case ARM_VFP_FPSCR: | ||
152 | + tmp = tcg_temp_new_i32(); | ||
153 | + gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
154 | + storefn(s, opaque, tmp); | ||
155 | + break; | ||
156 | + case QEMU_VFP_FPSCR_NZCV: | ||
157 | + /* | ||
158 | + * Read just NZCV; this is a special case to avoid the | ||
159 | + * helper call for the "VMRS to CPSR.NZCV" insn. | ||
160 | + */ | ||
161 | + tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | ||
162 | + tcg_gen_andi_i32(tmp, tmp, 0xf0000000); | ||
163 | + storefn(s, opaque, tmp); | ||
164 | + break; | ||
165 | + default: | ||
166 | + g_assert_not_reached(); | ||
167 | + } | ||
168 | + return true; | ||
169 | +} | ||
170 | + | ||
171 | +static void fp_sysreg_to_gpr(DisasContext *s, void *opaque, TCGv_i32 value) | ||
172 | +{ | ||
173 | + arg_VMSR_VMRS *a = opaque; | ||
174 | + | ||
175 | + if (a->rt == 15) { | ||
176 | + /* Set the 4 flag bits in the CPSR */ | ||
177 | + gen_set_nzcv(value); | ||
178 | + tcg_temp_free_i32(value); | ||
179 | + } else { | ||
180 | + store_reg(s, a->rt, value); | ||
181 | + } | ||
182 | +} | ||
183 | + | ||
184 | +static TCGv_i32 gpr_to_fp_sysreg(DisasContext *s, void *opaque) | ||
185 | +{ | ||
186 | + arg_VMSR_VMRS *a = opaque; | ||
187 | + | ||
188 | + return load_reg(s, a->rt); | ||
189 | +} | ||
190 | + | ||
191 | +static bool gen_M_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
192 | +{ | ||
193 | + /* | ||
194 | + * Accesses to R15 are UNPREDICTABLE; we choose to undef. | ||
195 | + * FPSCR -> r15 is a special case which writes to the PSR flags; | ||
196 | + * set a->reg to a special value to tell gen_M_fp_sysreg_read() | ||
197 | + * we only care about the top 4 bits of FPSCR there. | ||
198 | + */ | ||
199 | + if (a->rt == 15) { | ||
200 | + if (a->l && a->reg == ARM_VFP_FPSCR) { | ||
201 | + a->reg = QEMU_VFP_FPSCR_NZCV; | ||
202 | + } else { | ||
203 | + return false; | ||
204 | + } | ||
205 | + } | ||
206 | + | ||
207 | + if (a->l) { | ||
208 | + /* VMRS, move FP system register to gp register */ | ||
209 | + return gen_M_fp_sysreg_read(s, a->reg, fp_sysreg_to_gpr, a); | ||
210 | + } else { | ||
211 | + /* VMSR, move gp register to FP system register */ | ||
212 | + return gen_M_fp_sysreg_write(s, a->reg, gpr_to_fp_sysreg, a); | ||
213 | + } | ||
214 | +} | ||
215 | + | ||
216 | static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
217 | { | ||
218 | TCGv_i32 tmp; | ||
219 | bool ignore_vfp_enabled = false; | ||
220 | |||
221 | - if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
222 | - return false; | ||
223 | + if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
224 | + return gen_M_VMSR_VMRS(s, a); | ||
42 | } | 225 | } |
43 | 226 | ||
44 | - sysbus_init_child_obj(obj, "ftgmac100", OBJECT(&s->ftgmac100), | 227 | - if (arm_dc_feature(s, ARM_FEATURE_M)) { |
45 | - sizeof(s->ftgmac100), TYPE_FTGMAC100); | 228 | - /* |
46 | + for (i = 0; i < ASPEED_MACS_NUM; i++) { | 229 | - * The only M-profile VFP vmrs/vmsr sysreg is FPSCR. |
47 | + sysbus_init_child_obj(obj, "ftgmac100[*]", OBJECT(&s->ftgmac100[i]), | 230 | - * Accesses to R15 are UNPREDICTABLE; we choose to undef. |
48 | + sizeof(s->ftgmac100[i]), TYPE_FTGMAC100); | 231 | - * (FPSCR -> r15 is a special case which writes to the PSR flags.) |
49 | + } | 232 | - */ |
50 | } | 233 | - if (a->reg != ARM_VFP_FPSCR) { |
51 | 234 | - return false; | |
52 | static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 235 | - } |
53 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 236 | - if (a->rt == 15 && !a->l) { |
237 | - return false; | ||
238 | - } | ||
239 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
240 | + return false; | ||
54 | } | 241 | } |
55 | 242 | ||
56 | /* Net */ | 243 | switch (a->reg) { |
57 | - qdev_set_nic_properties(DEVICE(&s->ftgmac100), &nd_table[0]); | ||
58 | - object_property_set_bool(OBJECT(&s->ftgmac100), true, "aspeed", &err); | ||
59 | - object_property_set_bool(OBJECT(&s->ftgmac100), true, "realized", | ||
60 | - &local_err); | ||
61 | - error_propagate(&err, local_err); | ||
62 | - if (err) { | ||
63 | - error_propagate(errp, err); | ||
64 | - return; | ||
65 | + for (i = 0; i < nb_nics; i++) { | ||
66 | + qdev_set_nic_properties(DEVICE(&s->ftgmac100[i]), &nd_table[i]); | ||
67 | + object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "aspeed", | ||
68 | + &err); | ||
69 | + object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "realized", | ||
70 | + &local_err); | ||
71 | + error_propagate(&err, local_err); | ||
72 | + if (err) { | ||
73 | + error_propagate(errp, err); | ||
74 | + return; | ||
75 | + } | ||
76 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, | ||
77 | + sc->info->memmap[ASPEED_ETH1 + i]); | ||
78 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, | ||
79 | + aspeed_soc_get_irq(s, ASPEED_ETH1 + i)); | ||
80 | } | ||
81 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, | ||
82 | - sc->info->memmap[ASPEED_ETH1]); | ||
83 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, | ||
84 | - aspeed_soc_get_irq(s, ASPEED_ETH1)); | ||
85 | } | ||
86 | static Property aspeed_soc_properties[] = { | ||
87 | DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), | ||
88 | -- | 244 | -- |
89 | 2.20.1 | 245 | 2.20.1 |
90 | 246 | ||
91 | 247 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | The constant-expander functions like negate, plus_2, etc, are |
---|---|---|---|
2 | generally useful; move them up in translate.c so we can use them in | ||
3 | the VFP/Neon decoders as well as in the A32/T32/T16 decoders. | ||
2 | 4 | ||
3 | Since we'll move this code around, fix its style first. | ||
4 | |||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Message-id: 20190701132516.26392-9-philmd@redhat.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20201119215617.29887-9-peter.maydell@linaro.org | ||
9 | --- | 8 | --- |
10 | target/arm/translate.c | 11 ++++++----- | 9 | target/arm/translate.c | 46 +++++++++++++++++++++++------------------- |
11 | target/arm/vfp_helper.c | 36 ++++++++++++++++++++++++------------ | 10 | 1 file changed, 25 insertions(+), 21 deletions(-) |
12 | 2 files changed, 30 insertions(+), 17 deletions(-) | ||
13 | 11 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 12 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
15 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 14 | --- a/target/arm/translate.c |
17 | +++ b/target/arm/translate.c | 15 | +++ b/target/arm/translate.c |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 16 | @@ -XXX,XX +XXX,XX @@ static void arm_gen_condlabel(DisasContext *s) |
19 | loaded_base = 0; | ||
20 | loaded_var = NULL; | ||
21 | n = 0; | ||
22 | - for(i=0;i<16;i++) { | ||
23 | + for (i = 0; i < 16; i++) { | ||
24 | if (insn & (1 << i)) | ||
25 | n++; | ||
26 | } | ||
27 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
28 | } | ||
29 | } | ||
30 | j = 0; | ||
31 | - for(i=0;i<16;i++) { | ||
32 | + for (i = 0; i < 16; i++) { | ||
33 | if (insn & (1 << i)) { | ||
34 | if (is_load) { | ||
35 | /* load */ | ||
36 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
37 | return; | ||
38 | } | 17 | } |
39 | 18 | } | |
40 | - for(i=0;i<16;i++) { | 19 | |
41 | + for (i = 0; i < 16; i++) { | 20 | +/* |
42 | qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]); | 21 | + * Constant expanders for the decoders. |
43 | - if ((i % 4) == 3) | 22 | + */ |
44 | + if ((i % 4) == 3) { | 23 | + |
45 | qemu_fprintf(f, "\n"); | 24 | +static int negate(DisasContext *s, int x) |
46 | - else | 25 | +{ |
47 | + } else { | 26 | + return -x; |
48 | qemu_fprintf(f, " "); | 27 | +} |
49 | + } | 28 | + |
50 | } | 29 | +static int plus_2(DisasContext *s, int x) |
51 | 30 | +{ | |
52 | if (arm_feature(env, ARM_FEATURE_M)) { | 31 | + return x + 2; |
53 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | 32 | +} |
54 | index XXXXXXX..XXXXXXX 100644 | 33 | + |
55 | --- a/target/arm/vfp_helper.c | 34 | +static int times_2(DisasContext *s, int x) |
56 | +++ b/target/arm/vfp_helper.c | 35 | +{ |
57 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_from_host(int host_bits) | 36 | + return x * 2; |
37 | +} | ||
38 | + | ||
39 | +static int times_4(DisasContext *s, int x) | ||
40 | +{ | ||
41 | + return x * 4; | ||
42 | +} | ||
43 | + | ||
44 | /* Flags for the disas_set_da_iss info argument: | ||
45 | * lower bits hold the Rt register number, higher bits are flags. | ||
46 | */ | ||
47 | @@ -XXX,XX +XXX,XX @@ static void arm_skip_unless(DisasContext *s, uint32_t cond) | ||
48 | |||
49 | |||
50 | /* | ||
51 | - * Constant expanders for the decoders. | ||
52 | + * Constant expanders used by T16/T32 decode | ||
53 | */ | ||
54 | |||
55 | -static int negate(DisasContext *s, int x) | ||
56 | -{ | ||
57 | - return -x; | ||
58 | -} | ||
59 | - | ||
60 | -static int plus_2(DisasContext *s, int x) | ||
61 | -{ | ||
62 | - return x + 2; | ||
63 | -} | ||
64 | - | ||
65 | -static int times_2(DisasContext *s, int x) | ||
66 | -{ | ||
67 | - return x * 2; | ||
68 | -} | ||
69 | - | ||
70 | -static int times_4(DisasContext *s, int x) | ||
71 | -{ | ||
72 | - return x * 4; | ||
73 | -} | ||
74 | - | ||
75 | /* Return only the rotation part of T32ExpandImm. */ | ||
76 | static int t32_expandimm_rot(DisasContext *s, int x) | ||
58 | { | 77 | { |
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 | -- | 78 | -- |
120 | 2.20.1 | 79 | 2.20.1 |
121 | 80 | ||
122 | 81 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Implement the new-in-v8.1M VLDR/VSTR variants which directly |
---|---|---|---|
2 | read or write FP system registers to memory. | ||
2 | 3 | ||
3 | These routines are TCG specific. | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | The arm_deliver_fault() function is only used within the new | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | helper. Make it static. | 6 | Message-id: 20201119215617.29887-10-peter.maydell@linaro.org |
7 | --- | ||
8 | target/arm/vfp.decode | 14 ++++++ | ||
9 | target/arm/translate-vfp.c.inc | 91 ++++++++++++++++++++++++++++++++++ | ||
10 | 2 files changed, 105 insertions(+) | ||
6 | 11 | ||
7 | Suggested-by: Alex Bennée <alex.bennee@linaro.org> | 12 | diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode |
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190701132516.26392-13-philmd@redhat.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/Makefile.objs | 1 + | ||
14 | target/arm/internals.h | 3 - | ||
15 | target/arm/cpu.c | 6 +- | ||
16 | target/arm/helper.c | 53 ----------- | ||
17 | target/arm/op_helper.c | 135 -------------------------- | ||
18 | target/arm/tlb_helper.c | 200 +++++++++++++++++++++++++++++++++++++++ | ||
19 | 6 files changed, 205 insertions(+), 193 deletions(-) | ||
20 | create mode 100644 target/arm/tlb_helper.c | ||
21 | |||
22 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | ||
23 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/Makefile.objs | 14 | --- a/target/arm/vfp.decode |
25 | +++ b/target/arm/Makefile.objs | 15 | +++ b/target/arm/vfp.decode |
26 | @@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c | 16 | @@ -XXX,XX +XXX,XX @@ VLDR_VSTR_hp ---- 1101 u:1 .0 l:1 rn:4 .... 1001 imm:8 vd=%vd_sp |
27 | target/arm/translate.o: target/arm/decode-vfp.inc.c | 17 | VLDR_VSTR_sp ---- 1101 u:1 .0 l:1 rn:4 .... 1010 imm:8 vd=%vd_sp |
28 | target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c | 18 | VLDR_VSTR_dp ---- 1101 u:1 .0 l:1 rn:4 .... 1011 imm:8 vd=%vd_dp |
29 | 19 | ||
30 | +obj-y += tlb_helper.o | 20 | +# M-profile VLDR/VSTR to sysreg |
31 | obj-y += translate.o op_helper.o | 21 | +%vldr_sysreg 22:1 13:3 |
32 | obj-y += crypto_helper.o | 22 | +%imm7_0x4 0:7 !function=times_4 |
33 | obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o | 23 | + |
34 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 24 | +&vldr_sysreg rn reg imm a w p |
25 | +@vldr_sysreg .... ... . a:1 . . . rn:4 ... . ... .. ....... \ | ||
26 | + reg=%vldr_sysreg imm=%imm7_0x4 &vldr_sysreg | ||
27 | + | ||
28 | +# P=0 W=0 is SEE "Related encodings", so split into two patterns | ||
29 | +VLDR_sysreg ---- 110 1 . . w:1 1 .... ... 0 111 11 ....... @vldr_sysreg p=1 | ||
30 | +VLDR_sysreg ---- 110 0 . . 1 1 .... ... 0 111 11 ....... @vldr_sysreg p=0 w=1 | ||
31 | +VSTR_sysreg ---- 110 1 . . w:1 0 .... ... 0 111 11 ....... @vldr_sysreg p=1 | ||
32 | +VSTR_sysreg ---- 110 0 . . 1 0 .... ... 0 111 11 ....... @vldr_sysreg p=0 w=1 | ||
33 | + | ||
34 | # We split the load/store multiple up into two patterns to avoid | ||
35 | # overlap with other insns in the "Advanced SIMD load/store and 64-bit move" | ||
36 | # grouping: | ||
37 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
35 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/arm/internals.h | 39 | --- a/target/arm/translate-vfp.c.inc |
37 | +++ b/target/arm/internals.h | 40 | +++ b/target/arm/translate-vfp.c.inc |
38 | @@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | 41 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) |
39 | MMUAccessType access_type, int mmu_idx, | 42 | return true; |
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 | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/cpu.c | ||
51 | +++ b/target/arm/cpu.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) | ||
53 | cc->gdb_write_register = arm_cpu_gdb_write_register; | ||
54 | #ifndef CONFIG_USER_ONLY | ||
55 | cc->do_interrupt = arm_cpu_do_interrupt; | ||
56 | - cc->do_unaligned_access = arm_cpu_do_unaligned_access; | ||
57 | - cc->do_transaction_failed = arm_cpu_do_transaction_failed; | ||
58 | cc->get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug; | ||
59 | cc->asidx_from_attrs = arm_asidx_from_attrs; | ||
60 | cc->vmsd = &vmstate_arm_cpu; | ||
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 | } | 43 | } |
71 | 44 | ||
72 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 45 | +static void fp_sysreg_to_memory(DisasContext *s, void *opaque, TCGv_i32 value) |
73 | index XXXXXXX..XXXXXXX 100644 | 46 | +{ |
74 | --- a/target/arm/helper.c | 47 | + arg_vldr_sysreg *a = opaque; |
75 | +++ b/target/arm/helper.c | 48 | + uint32_t offset = a->imm; |
76 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | 49 | + TCGv_i32 addr; |
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 | + | 50 | + |
300 | +#if !defined(CONFIG_USER_ONLY) | 51 | + if (!a->a) { |
52 | + offset = - offset; | ||
53 | + } | ||
301 | + | 54 | + |
302 | +static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | 55 | + addr = load_reg(s, a->rn); |
303 | + unsigned int target_el, | 56 | + if (a->p) { |
304 | + bool same_el, bool ea, | 57 | + tcg_gen_addi_i32(addr, addr, offset); |
305 | + bool s1ptw, bool is_write, | 58 | + } |
306 | + int fsc) | ||
307 | +{ | ||
308 | + uint32_t syn; | ||
309 | + | 59 | + |
310 | + /* | 60 | + if (s->v8m_stackcheck && a->rn == 13 && a->w) { |
311 | + * ISV is only set for data aborts routed to EL2 and | 61 | + gen_helper_v8m_stackcheck(cpu_env, addr); |
312 | + * never for stage-1 page table walks faulting on stage 2. | 62 | + } |
313 | + * | 63 | + |
314 | + * Furthermore, ISV is only set for certain kinds of load/stores. | 64 | + gen_aa32_st_i32(s, value, addr, get_mem_index(s), |
315 | + * If the template syndrome does not have ISV set, we should leave | 65 | + MO_UL | MO_ALIGN | s->be_data); |
316 | + * it cleared. | 66 | + tcg_temp_free_i32(value); |
317 | + * | 67 | + |
318 | + * See ARMv8 specs, D7-1974: | 68 | + if (a->w) { |
319 | + * ISS encoding for an exception from a Data Abort, the | 69 | + /* writeback */ |
320 | + * ISV field. | 70 | + if (!a->p) { |
321 | + */ | 71 | + tcg_gen_addi_i32(addr, addr, offset); |
322 | + if (!(template_syn & ARM_EL_ISV) || target_el != 2 || s1ptw) { | 72 | + } |
323 | + syn = syn_data_abort_no_iss(same_el, | 73 | + store_reg(s, a->rn, addr); |
324 | + ea, 0, s1ptw, is_write, fsc); | ||
325 | + } else { | 74 | + } else { |
326 | + /* | 75 | + tcg_temp_free_i32(addr); |
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 | + } | 76 | + } |
338 | + return syn; | ||
339 | +} | 77 | +} |
340 | + | 78 | + |
341 | +static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, | 79 | +static TCGv_i32 memory_to_fp_sysreg(DisasContext *s, void *opaque) |
342 | + MMUAccessType access_type, | ||
343 | + int mmu_idx, ARMMMUFaultInfo *fi) | ||
344 | +{ | 80 | +{ |
345 | + CPUARMState *env = &cpu->env; | 81 | + arg_vldr_sysreg *a = opaque; |
346 | + int target_el; | 82 | + uint32_t offset = a->imm; |
347 | + bool same_el; | 83 | + TCGv_i32 addr; |
348 | + uint32_t syn, exc, fsr, fsc; | 84 | + TCGv_i32 value = tcg_temp_new_i32(); |
349 | + ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx); | ||
350 | + | 85 | + |
351 | + target_el = exception_target_el(env); | 86 | + if (!a->a) { |
352 | + if (fi->stage2) { | 87 | + offset = - offset; |
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 | + } | 88 | + } |
376 | + | 89 | + |
377 | + if (access_type == MMU_INST_FETCH) { | 90 | + addr = load_reg(s, a->rn); |
378 | + syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc); | 91 | + if (a->p) { |
379 | + exc = EXCP_PREFETCH_ABORT; | 92 | + tcg_gen_addi_i32(addr, addr, offset); |
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 | + } | 93 | + } |
391 | + | 94 | + |
392 | + env->exception.vaddress = addr; | 95 | + if (s->v8m_stackcheck && a->rn == 13 && a->w) { |
393 | + env->exception.fsr = fsr; | 96 | + gen_helper_v8m_stackcheck(cpu_env, addr); |
394 | + raise_exception(env, exc, syn, target_el); | 97 | + } |
98 | + | ||
99 | + gen_aa32_ld_i32(s, value, addr, get_mem_index(s), | ||
100 | + MO_UL | MO_ALIGN | s->be_data); | ||
101 | + | ||
102 | + if (a->w) { | ||
103 | + /* writeback */ | ||
104 | + if (!a->p) { | ||
105 | + tcg_gen_addi_i32(addr, addr, offset); | ||
106 | + } | ||
107 | + store_reg(s, a->rn, addr); | ||
108 | + } else { | ||
109 | + tcg_temp_free_i32(addr); | ||
110 | + } | ||
111 | + return value; | ||
395 | +} | 112 | +} |
396 | + | 113 | + |
397 | +/* Raise a data fault alignment exception for the specified virtual address */ | 114 | +static bool trans_VLDR_sysreg(DisasContext *s, arg_vldr_sysreg *a) |
398 | +void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, | ||
399 | + MMUAccessType access_type, | ||
400 | + int mmu_idx, uintptr_t retaddr) | ||
401 | +{ | 115 | +{ |
402 | + ARMCPU *cpu = ARM_CPU(cs); | 116 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
403 | + ARMMMUFaultInfo fi = {}; | 117 | + return false; |
404 | + | 118 | + } |
405 | + /* now we have a real cpu fault */ | 119 | + if (a->rn == 15) { |
406 | + cpu_restore_state(cs, retaddr, true); | 120 | + return false; |
407 | + | 121 | + } |
408 | + fi.type = ARMFault_Alignment; | 122 | + return gen_M_fp_sysreg_write(s, a->reg, memory_to_fp_sysreg, a); |
409 | + arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi); | ||
410 | +} | 123 | +} |
411 | + | 124 | + |
412 | +/* | 125 | +static bool trans_VSTR_sysreg(DisasContext *s, arg_vldr_sysreg *a) |
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 | +{ | 126 | +{ |
423 | + ARMCPU *cpu = ARM_CPU(cs); | 127 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
424 | + ARMMMUFaultInfo fi = {}; | 128 | + return false; |
425 | + | 129 | + } |
426 | + /* now we have a real cpu fault */ | 130 | + if (a->rn == 15) { |
427 | + cpu_restore_state(cs, retaddr, true); | 131 | + return false; |
428 | + | 132 | + } |
429 | + fi.ea = arm_extabort_type(response); | 133 | + return gen_M_fp_sysreg_read(s, a->reg, fp_sysreg_to_memory, a); |
430 | + fi.type = ARMFault_SyncExternal; | ||
431 | + arm_deliver_fault(cpu, addr, access_type, mmu_idx, &fi); | ||
432 | +} | 134 | +} |
433 | + | 135 | + |
434 | +#endif /* !defined(CONFIG_USER_ONLY) */ | 136 | static bool trans_VMOV_half(DisasContext *s, arg_VMOV_single *a) |
435 | + | 137 | { |
436 | +bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | 138 | TCGv_i32 tmp; |
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 | -- | 139 | -- |
489 | 2.20.1 | 140 | 2.20.1 |
490 | 141 | ||
491 | 142 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | v8.1M defines a new FP system register FPSCR_nzcvqc; this behaves |
---|---|---|---|
2 | like the existing FPSCR, except that it reads and writes only bits | ||
3 | [31:27] of the FPSCR (the N, Z, C, V and QC flag bits). (Unlike the | ||
4 | FPSCR, the special case for Rt=15 of writing the CPSR.NZCV is not | ||
5 | permitted.) | ||
2 | 6 | ||
3 | Group KVM rules together. | 7 | Implement the register. Since we don't yet implement MVE, we handle |
8 | the QC bit as RES0, with todo comments for where we will need to add | ||
9 | support later. | ||
4 | 10 | ||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Message-id: 20190701132516.26392-4-philmd@redhat.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20201119215617.29887-11-peter.maydell@linaro.org | ||
9 | --- | 14 | --- |
10 | target/arm/Makefile.objs | 9 +++++---- | 15 | target/arm/cpu.h | 13 +++++++++++++ |
11 | 1 file changed, 5 insertions(+), 4 deletions(-) | 16 | target/arm/translate-vfp.c.inc | 27 +++++++++++++++++++++++++++ |
17 | 2 files changed, 40 insertions(+) | ||
12 | 18 | ||
13 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | 19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
14 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/Makefile.objs | 21 | --- a/target/arm/cpu.h |
16 | +++ b/target/arm/Makefile.objs | 22 | +++ b/target/arm/cpu.h |
17 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ void vfp_set_fpscr(CPUARMState *env, uint32_t val); |
18 | obj-y += arm-semi.o | 24 | #define FPCR_FZ (1 << 24) /* Flush-to-zero enable bit */ |
19 | obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o | 25 | #define FPCR_DN (1 << 25) /* Default NaN enable bit */ |
20 | -obj-$(CONFIG_KVM) += kvm.o | 26 | #define FPCR_QC (1 << 27) /* Cumulative saturation bit */ |
21 | -obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o | 27 | +#define FPCR_V (1 << 28) /* FP overflow flag */ |
22 | -obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o | 28 | +#define FPCR_C (1 << 29) /* FP carry flag */ |
23 | -obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o | 29 | +#define FPCR_Z (1 << 30) /* FP zero flag */ |
24 | obj-y += helper.o vfp_helper.o | 30 | +#define FPCR_N (1 << 31) /* FP negative flag */ |
25 | obj-y += cpu.o gdbstub.o | ||
26 | obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o | ||
27 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o | ||
28 | |||
29 | +obj-$(CONFIG_KVM) += kvm.o | ||
30 | +obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o | ||
31 | +obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o | ||
32 | +obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o | ||
33 | + | 31 | + |
34 | DECODETREE = $(SRC_PATH)/scripts/decodetree.py | 32 | +#define FPCR_NZCV_MASK (FPCR_N | FPCR_Z | FPCR_C | FPCR_V) |
35 | 33 | +#define FPCR_NZCVQC_MASK (FPCR_NZCV_MASK | FPCR_QC) | |
36 | target/arm/decode-sve.inc.c: $(SRC_PATH)/target/arm/sve.decode $(DECODETREE) | 34 | |
35 | static inline uint32_t vfp_get_fpsr(CPUARMState *env) | ||
36 | { | ||
37 | @@ -XXX,XX +XXX,XX @@ enum arm_cpu_mode { | ||
38 | #define ARM_VFP_FPEXC 8 | ||
39 | #define ARM_VFP_FPINST 9 | ||
40 | #define ARM_VFP_FPINST2 10 | ||
41 | +/* These ones are M-profile only */ | ||
42 | +#define ARM_VFP_FPSCR_NZCVQC 2 | ||
43 | +#define ARM_VFP_VPR 12 | ||
44 | +#define ARM_VFP_P0 13 | ||
45 | +#define ARM_VFP_FPCXT_NS 14 | ||
46 | +#define ARM_VFP_FPCXT_S 15 | ||
47 | |||
48 | /* QEMU-internal value meaning "FPSCR, but we care only about NZCV" */ | ||
49 | #define QEMU_VFP_FPSCR_NZCV 0xffff | ||
50 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/translate-vfp.c.inc | ||
53 | +++ b/target/arm/translate-vfp.c.inc | ||
54 | @@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) | ||
55 | case ARM_VFP_FPSCR: | ||
56 | case QEMU_VFP_FPSCR_NZCV: | ||
57 | break; | ||
58 | + case ARM_VFP_FPSCR_NZCVQC: | ||
59 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
60 | + return false; | ||
61 | + } | ||
62 | + break; | ||
63 | default: | ||
64 | return FPSysRegCheckFailed; | ||
65 | } | ||
66 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
67 | tcg_temp_free_i32(tmp); | ||
68 | gen_lookup_tb(s); | ||
69 | break; | ||
70 | + case ARM_VFP_FPSCR_NZCVQC: | ||
71 | + { | ||
72 | + TCGv_i32 fpscr; | ||
73 | + tmp = loadfn(s, opaque); | ||
74 | + /* | ||
75 | + * TODO: when we implement MVE, write the QC bit. | ||
76 | + * For non-MVE, QC is RES0. | ||
77 | + */ | ||
78 | + tcg_gen_andi_i32(tmp, tmp, FPCR_NZCV_MASK); | ||
79 | + fpscr = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | ||
80 | + tcg_gen_andi_i32(fpscr, fpscr, ~FPCR_NZCV_MASK); | ||
81 | + tcg_gen_or_i32(fpscr, fpscr, tmp); | ||
82 | + store_cpu_field(fpscr, vfp.xregs[ARM_VFP_FPSCR]); | ||
83 | + tcg_temp_free_i32(tmp); | ||
84 | + break; | ||
85 | + } | ||
86 | default: | ||
87 | g_assert_not_reached(); | ||
88 | } | ||
89 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
90 | gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
91 | storefn(s, opaque, tmp); | ||
92 | break; | ||
93 | + case ARM_VFP_FPSCR_NZCVQC: | ||
94 | + /* | ||
95 | + * TODO: MVE has a QC bit, which we probably won't store | ||
96 | + * in the xregs[] field. For non-MVE, where QC is RES0, | ||
97 | + * we can just fall through to the FPSCR_NZCV case. | ||
98 | + */ | ||
99 | case QEMU_VFP_FPSCR_NZCV: | ||
100 | /* | ||
101 | * Read just NZCV; this is a special case to avoid the | ||
37 | -- | 102 | -- |
38 | 2.20.1 | 103 | 2.20.1 |
39 | 104 | ||
40 | 105 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | We defined a constant name for the mask of NZCV bits in the FPCR/FPSCR |
---|---|---|---|
2 | in the previous commit; use it in a couple of places in existing code, | ||
3 | where we're masking out everything except NZCV for the "load to Rt=15 | ||
4 | sets CPSR.NZCV" special case. | ||
2 | 5 | ||
3 | Group ARM objects together, TCG related ones at the bottom. | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | This will help when restricting TCG-only objects. | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20201119215617.29887-12-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/translate-vfp.c.inc | 4 ++-- | ||
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
5 | 12 | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 13 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190701132516.26392-3-philmd@redhat.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/Makefile.objs | 10 ++++++---- | ||
12 | 1 file changed, 6 insertions(+), 4 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | ||
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/Makefile.objs | 15 | --- a/target/arm/translate-vfp.c.inc |
17 | +++ b/target/arm/Makefile.objs | 16 | +++ b/target/arm/translate-vfp.c.inc |
18 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_KVM) += kvm.o | 17 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, |
19 | obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o | 18 | * helper call for the "VMRS to CPSR.NZCV" insn. |
20 | obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o | 19 | */ |
21 | obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o | 20 | tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); |
22 | -obj-y += translate.o op_helper.o helper.o cpu.o | 21 | - tcg_gen_andi_i32(tmp, tmp, 0xf0000000); |
23 | -obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o | 22 | + tcg_gen_andi_i32(tmp, tmp, FPCR_NZCV_MASK); |
24 | -obj-y += gdbstub.o | 23 | storefn(s, opaque, tmp); |
25 | +obj-y += helper.o vfp_helper.o | 24 | break; |
26 | +obj-y += cpu.o gdbstub.o | 25 | default: |
27 | obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o | 26 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) |
28 | -obj-y += crypto_helper.o | 27 | case ARM_VFP_FPSCR: |
29 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o | 28 | if (a->rt == 15) { |
30 | 29 | tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | |
31 | DECODETREE = $(SRC_PATH)/scripts/decodetree.py | 30 | - tcg_gen_andi_i32(tmp, tmp, 0xf0000000); |
32 | @@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c | 31 | + tcg_gen_andi_i32(tmp, tmp, FPCR_NZCV_MASK); |
33 | target/arm/translate.o: target/arm/decode-vfp.inc.c | 32 | } else { |
34 | target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c | 33 | tmp = tcg_temp_new_i32(); |
35 | 34 | gen_helper_vfp_get_fpscr(tmp, cpu_env); | |
36 | +obj-y += translate.o op_helper.o | ||
37 | +obj-y += crypto_helper.o | ||
38 | +obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o | ||
39 | + | ||
40 | obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o | ||
41 | obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o | ||
42 | obj-$(TARGET_AARCH64) += pauth_helper.o | ||
43 | -- | 35 | -- |
44 | 2.20.1 | 36 | 2.20.1 |
45 | 37 | ||
46 | 38 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Factor out the code which handles M-profile lazy FP state preservation |
---|---|---|---|
2 | from full_vfp_access_check(); accesses to the FPCXT_NS register are | ||
3 | a special case which need to do just this part (corresponding in the | ||
4 | pseudocode to the PreserveFPState() function), and not the full | ||
5 | set of actions matching the pseudocode ExecuteFPCheck() which | ||
6 | normal FP instructions need to do. | ||
2 | 7 | ||
3 | In few commits we will split the M-profile functions from this | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | file, and this function will also be called in the new file. | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Declare it in the "internals.h" header. | 10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Since it is in the middle of a block of M profile functions, | 11 | Message-id: 20201119215617.29887-13-peter.maydell@linaro.org |
7 | move it previous to this block to ease the later refactor. | 12 | --- |
13 | target/arm/translate-vfp.c.inc | 45 ++++++++++++++++++++-------------- | ||
14 | 1 file changed, 27 insertions(+), 18 deletions(-) | ||
8 | 15 | ||
9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 16 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
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> | ||
13 | --- | ||
14 | target/arm/internals.h | 2 ++ | ||
15 | target/arm/helper.c | 76 +++++++++++++++++++++--------------------- | ||
16 | 2 files changed, 40 insertions(+), 38 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/internals.h | 18 | --- a/target/arm/translate-vfp.c.inc |
21 | +++ b/target/arm/internals.h | 19 | +++ b/target/arm/translate-vfp.c.inc |
22 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | 20 | @@ -XXX,XX +XXX,XX @@ static inline long vfp_f16_offset(unsigned reg, bool top) |
23 | target_ulong *page_size, | 21 | return offs; |
24 | ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); | ||
25 | |||
26 | +void arm_log_exception(int idx); | ||
27 | + | ||
28 | #endif /* !CONFIG_USER_ONLY */ | ||
29 | |||
30 | #endif | ||
31 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/helper.c | ||
34 | +++ b/target/arm/helper.c | ||
35 | @@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, | ||
36 | return target_el; | ||
37 | } | 22 | } |
38 | 23 | ||
39 | +void arm_log_exception(int idx) | 24 | +/* |
25 | + * Generate code for M-profile lazy FP state preservation if needed; | ||
26 | + * this corresponds to the pseudocode PreserveFPState() function. | ||
27 | + */ | ||
28 | +static void gen_preserve_fp_state(DisasContext *s) | ||
40 | +{ | 29 | +{ |
41 | + if (qemu_loglevel_mask(CPU_LOG_INT)) { | 30 | + if (s->v7m_lspact) { |
42 | + const char *exc = NULL; | 31 | + /* |
43 | + static const char * const excnames[] = { | 32 | + * Lazy state saving affects external memory and also the NVIC, |
44 | + [EXCP_UDEF] = "Undefined Instruction", | 33 | + * so we must mark it as an IO operation for icount (and cause |
45 | + [EXCP_SWI] = "SVC", | 34 | + * this to be the last insn in the TB). |
46 | + [EXCP_PREFETCH_ABORT] = "Prefetch Abort", | 35 | + */ |
47 | + [EXCP_DATA_ABORT] = "Data Abort", | 36 | + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { |
48 | + [EXCP_IRQ] = "IRQ", | 37 | + s->base.is_jmp = DISAS_UPDATE_EXIT; |
49 | + [EXCP_FIQ] = "FIQ", | 38 | + gen_io_start(); |
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 | + } | 39 | + } |
70 | + if (!exc) { | 40 | + gen_helper_v7m_preserve_fp_state(cpu_env); |
71 | + exc = "unknown"; | 41 | + /* |
72 | + } | 42 | + * If the preserve_fp_state helper doesn't throw an exception |
73 | + qemu_log_mask(CPU_LOG_INT, "Taking exception %d [%s]\n", idx, exc); | 43 | + * then it will clear LSPACT; we don't need to repeat this for |
44 | + * any further FP insns in this TB. | ||
45 | + */ | ||
46 | + s->v7m_lspact = false; | ||
74 | + } | 47 | + } |
75 | +} | 48 | +} |
76 | + | 49 | + |
77 | /* | 50 | /* |
78 | * Return true if the v7M CPACR permits access to the FPU for the specified | 51 | * Check that VFP access is enabled. If it is, do the necessary |
79 | * security state and privilege level. | 52 | * M-profile lazy-FP handling and then return true. |
80 | @@ -XXX,XX +XXX,XX @@ static bool do_v7m_function_return(ARMCPU *cpu) | 53 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) |
81 | return true; | 54 | /* Handle M-profile lazy FP state mechanics */ |
82 | } | 55 | |
83 | 56 | /* Trigger lazy-state preservation if necessary */ | |
84 | -static void arm_log_exception(int idx) | 57 | - if (s->v7m_lspact) { |
85 | -{ | 58 | - /* |
86 | - if (qemu_loglevel_mask(CPU_LOG_INT)) { | 59 | - * Lazy state saving affects external memory and also the NVIC, |
87 | - const char *exc = NULL; | 60 | - * so we must mark it as an IO operation for icount (and cause |
88 | - static const char * const excnames[] = { | 61 | - * this to be the last insn in the TB). |
89 | - [EXCP_UDEF] = "Undefined Instruction", | 62 | - */ |
90 | - [EXCP_SWI] = "SVC", | 63 | - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { |
91 | - [EXCP_PREFETCH_ABORT] = "Prefetch Abort", | 64 | - s->base.is_jmp = DISAS_UPDATE_EXIT; |
92 | - [EXCP_DATA_ABORT] = "Data Abort", | 65 | - gen_io_start(); |
93 | - [EXCP_IRQ] = "IRQ", | 66 | - } |
94 | - [EXCP_FIQ] = "FIQ", | 67 | - gen_helper_v7m_preserve_fp_state(cpu_env); |
95 | - [EXCP_BKPT] = "Breakpoint", | 68 | - /* |
96 | - [EXCP_EXCEPTION_EXIT] = "QEMU v7M exception exit", | 69 | - * If the preserve_fp_state helper doesn't throw an exception |
97 | - [EXCP_KERNEL_TRAP] = "QEMU intercept of kernel commpage", | 70 | - * then it will clear LSPACT; we don't need to repeat this for |
98 | - [EXCP_HVC] = "Hypervisor Call", | 71 | - * any further FP insns in this TB. |
99 | - [EXCP_HYP_TRAP] = "Hypervisor Trap", | 72 | - */ |
100 | - [EXCP_SMC] = "Secure Monitor Call", | 73 | - s->v7m_lspact = false; |
101 | - [EXCP_VIRQ] = "Virtual IRQ", | ||
102 | - [EXCP_VFIQ] = "Virtual FIQ", | ||
103 | - [EXCP_SEMIHOST] = "Semihosting call", | ||
104 | - [EXCP_NOCP] = "v7M NOCP UsageFault", | ||
105 | - [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | ||
106 | - [EXCP_STKOF] = "v8M STKOF UsageFault", | ||
107 | - [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | ||
108 | - [EXCP_LSERR] = "v8M LSERR UsageFault", | ||
109 | - [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | ||
110 | - }; | ||
111 | - | ||
112 | - if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | ||
113 | - exc = excnames[idx]; | ||
114 | - } | 74 | - } |
115 | - if (!exc) { | 75 | + gen_preserve_fp_state(s); |
116 | - exc = "unknown"; | 76 | |
117 | - } | 77 | /* Update ownership of FP context: set FPCCR.S to match current state */ |
118 | - qemu_log_mask(CPU_LOG_INT, "Taking exception %d [%s]\n", idx, exc); | 78 | if (s->v8m_fpccr_s_wrong) { |
119 | - } | ||
120 | -} | ||
121 | - | ||
122 | static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
123 | uint32_t addr, uint16_t *insn) | ||
124 | { | ||
125 | -- | 79 | -- |
126 | 2.20.1 | 80 | 2.20.1 |
127 | 81 | ||
128 | 82 | diff view generated by jsdifflib |
1 | From: Andrew Jeffery <andrew@aj.id.au> | 1 | Implement the new-in-v8.1M FPCXT_S floating point system register. |
---|---|---|---|
2 | This is for saving and restoring the secure floating point context, | ||
3 | and it reads and writes bits [27:0] from the FPSCR and the | ||
4 | CONTROL.SFPA bit in bit [31]. | ||
2 | 5 | ||
3 | The legacy interface only supported up to 32 IRQs, which became | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | restrictive around the AST2400 generation. QEMU support for the SoCs | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | started with the AST2400 along with an effort to reimplement and | 8 | Message-id: 20201119215617.29887-14-peter.maydell@linaro.org |
6 | upstream drivers for Linux, so up until this point the consumers of the | 9 | --- |
7 | QEMU ASPEED support only required the 64 IRQ register interface. | 10 | target/arm/translate-vfp.c.inc | 58 ++++++++++++++++++++++++++++++++++ |
11 | 1 file changed, 58 insertions(+) | ||
8 | 12 | ||
9 | In an effort to support older BMC firmware, add support for the 32 IRQ | 13 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
10 | interface. | ||
11 | |||
12 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> | ||
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
15 | Message-id: 20190618165311.27066-22-clg@kaod.org | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | hw/intc/aspeed_vic.c | 105 ++++++++++++++++++++++++++----------------- | ||
19 | 1 file changed, 63 insertions(+), 42 deletions(-) | ||
20 | |||
21 | diff --git a/hw/intc/aspeed_vic.c b/hw/intc/aspeed_vic.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/intc/aspeed_vic.c | 15 | --- a/target/arm/translate-vfp.c.inc |
24 | +++ b/hw/intc/aspeed_vic.c | 16 | +++ b/target/arm/translate-vfp.c.inc |
25 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_set_irq(void *opaque, int irq, int level) | 17 | @@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) |
26 | 18 | return false; | |
27 | static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size) | ||
28 | { | ||
29 | - uint64_t val; | ||
30 | - const bool high = !!(offset & 0x4); | ||
31 | - hwaddr n_offset = (offset & ~0x4); | ||
32 | AspeedVICState *s = (AspeedVICState *)opaque; | ||
33 | + hwaddr n_offset; | ||
34 | + uint64_t val; | ||
35 | + bool high; | ||
36 | |||
37 | if (offset < AVIC_NEW_BASE_OFFSET) { | ||
38 | - qemu_log_mask(LOG_UNIMP, "%s: Ignoring read from legacy registers " | ||
39 | - "at 0x%" HWADDR_PRIx "[%u]\n", __func__, offset, size); | ||
40 | - return 0; | ||
41 | + high = false; | ||
42 | + n_offset = offset; | ||
43 | + } else { | ||
44 | + high = !!(offset & 0x4); | ||
45 | + n_offset = (offset & ~0x4); | ||
46 | } | ||
47 | |||
48 | - n_offset -= AVIC_NEW_BASE_OFFSET; | ||
49 | - | ||
50 | switch (n_offset) { | ||
51 | - case 0x0: /* IRQ Status */ | ||
52 | + case 0x80: /* IRQ Status */ | ||
53 | + case 0x00: | ||
54 | val = s->raw & ~s->select & s->enable; | ||
55 | break; | ||
56 | - case 0x08: /* FIQ Status */ | ||
57 | + case 0x88: /* FIQ Status */ | ||
58 | + case 0x04: | ||
59 | val = s->raw & s->select & s->enable; | ||
60 | break; | ||
61 | - case 0x10: /* Raw Interrupt Status */ | ||
62 | + case 0x90: /* Raw Interrupt Status */ | ||
63 | + case 0x08: | ||
64 | val = s->raw; | ||
65 | break; | ||
66 | - case 0x18: /* Interrupt Selection */ | ||
67 | + case 0x98: /* Interrupt Selection */ | ||
68 | + case 0x0c: | ||
69 | val = s->select; | ||
70 | break; | ||
71 | - case 0x20: /* Interrupt Enable */ | ||
72 | + case 0xa0: /* Interrupt Enable */ | ||
73 | + case 0x10: | ||
74 | val = s->enable; | ||
75 | break; | ||
76 | - case 0x30: /* Software Interrupt */ | ||
77 | + case 0xb0: /* Software Interrupt */ | ||
78 | + case 0x18: | ||
79 | val = s->trigger; | ||
80 | break; | ||
81 | - case 0x40: /* Interrupt Sensitivity */ | ||
82 | + case 0xc0: /* Interrupt Sensitivity */ | ||
83 | + case 0x24: | ||
84 | val = s->sense; | ||
85 | break; | ||
86 | - case 0x48: /* Interrupt Both Edge Trigger Control */ | ||
87 | + case 0xc8: /* Interrupt Both Edge Trigger Control */ | ||
88 | + case 0x28: | ||
89 | val = s->dual_edge; | ||
90 | break; | ||
91 | - case 0x50: /* Interrupt Event */ | ||
92 | + case 0xd0: /* Interrupt Event */ | ||
93 | + case 0x2c: | ||
94 | val = s->event; | ||
95 | break; | ||
96 | - case 0x60: /* Edge Triggered Interrupt Status */ | ||
97 | + case 0xe0: /* Edge Triggered Interrupt Status */ | ||
98 | val = s->raw & ~s->sense; | ||
99 | break; | ||
100 | /* Illegal */ | ||
101 | - case 0x28: /* Interrupt Enable Clear */ | ||
102 | - case 0x38: /* Software Interrupt Clear */ | ||
103 | - case 0x58: /* Edge Triggered Interrupt Clear */ | ||
104 | + case 0xa8: /* Interrupt Enable Clear */ | ||
105 | + case 0xb8: /* Software Interrupt Clear */ | ||
106 | + case 0xd8: /* Edge Triggered Interrupt Clear */ | ||
107 | qemu_log_mask(LOG_GUEST_ERROR, | ||
108 | "%s: Read of write-only register with offset 0x%" | ||
109 | HWADDR_PRIx "\n", __func__, offset); | ||
110 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size) | ||
111 | } | ||
112 | if (high) { | ||
113 | val = extract64(val, 32, 19); | ||
114 | + } else { | ||
115 | + val = extract64(val, 0, 32); | ||
116 | } | ||
117 | trace_aspeed_vic_read(offset, size, val); | ||
118 | return val; | ||
119 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size) | ||
120 | static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
121 | unsigned size) | ||
122 | { | ||
123 | - const bool high = !!(offset & 0x4); | ||
124 | - hwaddr n_offset = (offset & ~0x4); | ||
125 | AspeedVICState *s = (AspeedVICState *)opaque; | ||
126 | + hwaddr n_offset; | ||
127 | + bool high; | ||
128 | |||
129 | if (offset < AVIC_NEW_BASE_OFFSET) { | ||
130 | - qemu_log_mask(LOG_UNIMP, | ||
131 | - "%s: Ignoring write to legacy registers at 0x%" | ||
132 | - HWADDR_PRIx "[%u] <- 0x%" PRIx64 "\n", __func__, offset, | ||
133 | - size, data); | ||
134 | - return; | ||
135 | + high = false; | ||
136 | + n_offset = offset; | ||
137 | + } else { | ||
138 | + high = !!(offset & 0x4); | ||
139 | + n_offset = (offset & ~0x4); | ||
140 | } | ||
141 | |||
142 | - n_offset -= AVIC_NEW_BASE_OFFSET; | ||
143 | trace_aspeed_vic_write(offset, size, data); | ||
144 | |||
145 | /* Given we have members using separate enable/clear registers, deposit64() | ||
146 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
147 | } | ||
148 | |||
149 | switch (n_offset) { | ||
150 | - case 0x18: /* Interrupt Selection */ | ||
151 | + case 0x98: /* Interrupt Selection */ | ||
152 | + case 0x0c: | ||
153 | /* Register has deposit64() semantics - overwrite requested 32 bits */ | ||
154 | if (high) { | ||
155 | s->select &= AVIC_L_MASK; | ||
156 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
157 | } | ||
158 | s->select |= data; | ||
159 | break; | ||
160 | - case 0x20: /* Interrupt Enable */ | ||
161 | + case 0xa0: /* Interrupt Enable */ | ||
162 | + case 0x10: | ||
163 | s->enable |= data; | ||
164 | break; | ||
165 | - case 0x28: /* Interrupt Enable Clear */ | ||
166 | + case 0xa8: /* Interrupt Enable Clear */ | ||
167 | + case 0x14: | ||
168 | s->enable &= ~data; | ||
169 | break; | ||
170 | - case 0x30: /* Software Interrupt */ | ||
171 | + case 0xb0: /* Software Interrupt */ | ||
172 | + case 0x18: | ||
173 | qemu_log_mask(LOG_UNIMP, "%s: Software interrupts unavailable. " | ||
174 | "IRQs requested: 0x%016" PRIx64 "\n", __func__, data); | ||
175 | break; | ||
176 | - case 0x38: /* Software Interrupt Clear */ | ||
177 | + case 0xb8: /* Software Interrupt Clear */ | ||
178 | + case 0x1c: | ||
179 | qemu_log_mask(LOG_UNIMP, "%s: Software interrupts unavailable. " | ||
180 | "IRQs to be cleared: 0x%016" PRIx64 "\n", __func__, data); | ||
181 | break; | ||
182 | - case 0x50: /* Interrupt Event */ | ||
183 | + case 0xd0: /* Interrupt Event */ | ||
184 | /* Register has deposit64() semantics - overwrite the top four valid | ||
185 | * IRQ bits, as only the top four IRQs (GPIOs) can change their event | ||
186 | * type */ | ||
187 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
188 | "Ignoring invalid write to interrupt event register"); | ||
189 | } | 19 | } |
190 | break; | 20 | break; |
191 | - case 0x58: /* Edge Triggered Interrupt Clear */ | 21 | + case ARM_VFP_FPCXT_S: |
192 | + case 0xd8: /* Edge Triggered Interrupt Clear */ | 22 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
193 | + case 0x38: | 23 | + return false; |
194 | s->raw &= ~(data & ~s->sense); | 24 | + } |
25 | + if (!s->v8m_secure) { | ||
26 | + return false; | ||
27 | + } | ||
28 | + break; | ||
29 | default: | ||
30 | return FPSysRegCheckFailed; | ||
31 | } | ||
32 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
33 | tcg_temp_free_i32(tmp); | ||
195 | break; | 34 | break; |
196 | - case 0x00: /* IRQ Status */ | 35 | } |
197 | - case 0x08: /* FIQ Status */ | 36 | + case ARM_VFP_FPCXT_S: |
198 | - case 0x10: /* Raw Interrupt Status */ | 37 | + { |
199 | - case 0x40: /* Interrupt Sensitivity */ | 38 | + TCGv_i32 sfpa, control, fpscr; |
200 | - case 0x48: /* Interrupt Both Edge Trigger Control */ | 39 | + /* Set FPSCR[27:0] and CONTROL.SFPA from value */ |
201 | - case 0x60: /* Edge Triggered Interrupt Status */ | 40 | + tmp = loadfn(s, opaque); |
202 | + case 0x80: /* IRQ Status */ | 41 | + sfpa = tcg_temp_new_i32(); |
203 | + case 0x00: | 42 | + tcg_gen_shri_i32(sfpa, tmp, 31); |
204 | + case 0x88: /* FIQ Status */ | 43 | + control = load_cpu_field(v7m.control[M_REG_S]); |
205 | + case 0x04: | 44 | + tcg_gen_deposit_i32(control, control, sfpa, |
206 | + case 0x90: /* Raw Interrupt Status */ | 45 | + R_V7M_CONTROL_SFPA_SHIFT, 1); |
207 | + case 0x08: | 46 | + store_cpu_field(control, v7m.control[M_REG_S]); |
208 | + case 0xc0: /* Interrupt Sensitivity */ | 47 | + fpscr = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); |
209 | + case 0x24: | 48 | + tcg_gen_andi_i32(fpscr, fpscr, FPCR_NZCV_MASK); |
210 | + case 0xc8: /* Interrupt Both Edge Trigger Control */ | 49 | + tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK); |
211 | + case 0x28: | 50 | + tcg_gen_or_i32(fpscr, fpscr, tmp); |
212 | + case 0xe0: /* Edge Triggered Interrupt Status */ | 51 | + store_cpu_field(fpscr, vfp.xregs[ARM_VFP_FPSCR]); |
213 | qemu_log_mask(LOG_GUEST_ERROR, | 52 | + tcg_temp_free_i32(tmp); |
214 | "%s: Write of read-only register with offset 0x%" | 53 | + tcg_temp_free_i32(sfpa); |
215 | HWADDR_PRIx "\n", __func__, offset); | 54 | + break; |
55 | + } | ||
56 | default: | ||
57 | g_assert_not_reached(); | ||
58 | } | ||
59 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
60 | tcg_gen_andi_i32(tmp, tmp, FPCR_NZCV_MASK); | ||
61 | storefn(s, opaque, tmp); | ||
62 | break; | ||
63 | + case ARM_VFP_FPCXT_S: | ||
64 | + { | ||
65 | + TCGv_i32 control, sfpa, fpscr; | ||
66 | + /* Bits [27:0] from FPSCR, bit [31] from CONTROL.SFPA */ | ||
67 | + tmp = tcg_temp_new_i32(); | ||
68 | + sfpa = tcg_temp_new_i32(); | ||
69 | + gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
70 | + tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK); | ||
71 | + control = load_cpu_field(v7m.control[M_REG_S]); | ||
72 | + tcg_gen_andi_i32(sfpa, control, R_V7M_CONTROL_SFPA_MASK); | ||
73 | + tcg_gen_shli_i32(sfpa, sfpa, 31 - R_V7M_CONTROL_SFPA_SHIFT); | ||
74 | + tcg_gen_or_i32(tmp, tmp, sfpa); | ||
75 | + tcg_temp_free_i32(sfpa); | ||
76 | + /* | ||
77 | + * Store result before updating FPSCR etc, in case | ||
78 | + * it is a memory write which causes an exception. | ||
79 | + */ | ||
80 | + storefn(s, opaque, tmp); | ||
81 | + /* | ||
82 | + * Now we must reset FPSCR from FPDSCR_NS, and clear | ||
83 | + * CONTROL.SFPA; so we'll end the TB here. | ||
84 | + */ | ||
85 | + tcg_gen_andi_i32(control, control, ~R_V7M_CONTROL_SFPA_MASK); | ||
86 | + store_cpu_field(control, v7m.control[M_REG_S]); | ||
87 | + fpscr = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
88 | + gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
89 | + tcg_temp_free_i32(fpscr); | ||
90 | + gen_lookup_tb(s); | ||
91 | + break; | ||
92 | + } | ||
93 | default: | ||
94 | g_assert_not_reached(); | ||
95 | } | ||
216 | -- | 96 | -- |
217 | 2.20.1 | 97 | 2.20.1 |
218 | 98 | ||
219 | 99 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | The FPDSCR register has a similar layout to the FPSCR. In v8.1M it |
---|---|---|---|
2 | gains new fields FZ16 (if half-precision floating point is supported) | ||
3 | and LTPSIZE (always reads as 4). Update the reset value and the code | ||
4 | that handles writes to this register accordingly. | ||
2 | 5 | ||
3 | Suggested-by: Samuel Ortiz <sameo@linux.intel.com> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
5 | Message-id: 20190701132516.26392-11-philmd@redhat.com | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20201119215617.29887-16-peter.maydell@linaro.org | ||
8 | --- | 9 | --- |
9 | target/arm/cpu.h | 2 - | 10 | target/arm/cpu.h | 5 +++++ |
10 | target/arm/translate.h | 5 - | 11 | hw/intc/armv7m_nvic.c | 9 ++++++++- |
11 | target/arm/cpu.c | 226 +++++++++++++++++++++++++++++++++++++ | 12 | target/arm/cpu.c | 3 +++ |
12 | target/arm/translate-a64.c | 128 --------------------- | 13 | 3 files changed, 16 insertions(+), 1 deletion(-) |
13 | target/arm/translate.c | 88 --------------- | ||
14 | 5 files changed, 226 insertions(+), 223 deletions(-) | ||
15 | 14 | ||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/cpu.h |
19 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/cpu.h |
20 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cpu); | 19 | @@ -XXX,XX +XXX,XX @@ void vfp_set_fpscr(CPUARMState *env, uint32_t val); |
21 | void arm_v7m_cpu_do_interrupt(CPUState *cpu); | 20 | #define FPCR_IXE (1 << 12) /* Inexact exception trap enable */ |
22 | bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req); | 21 | #define FPCR_IDE (1 << 15) /* Input Denormal exception trap enable */ |
23 | 22 | #define FPCR_FZ16 (1 << 19) /* ARMv8.2+, FP16 flush-to-zero */ | |
24 | -void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags); | 23 | +#define FPCR_RMODE_MASK (3 << 22) /* Rounding mode */ |
25 | - | 24 | #define FPCR_FZ (1 << 24) /* Flush-to-zero enable bit */ |
26 | hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, | 25 | #define FPCR_DN (1 << 25) /* Default NaN enable bit */ |
27 | MemTxAttrs *attrs); | 26 | +#define FPCR_AHP (1 << 26) /* Alternative half-precision */ |
28 | 27 | #define FPCR_QC (1 << 27) /* Cumulative saturation bit */ | |
29 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 28 | #define FPCR_V (1 << 28) /* FP overflow flag */ |
29 | #define FPCR_C (1 << 29) /* FP carry flag */ | ||
30 | #define FPCR_Z (1 << 30) /* FP zero flag */ | ||
31 | #define FPCR_N (1 << 31) /* FP negative flag */ | ||
32 | |||
33 | +#define FPCR_LTPSIZE_SHIFT 16 /* LTPSIZE, M-profile only */ | ||
34 | +#define FPCR_LTPSIZE_MASK (7 << FPCR_LTPSIZE_SHIFT) | ||
35 | + | ||
36 | #define FPCR_NZCV_MASK (FPCR_N | FPCR_Z | FPCR_C | FPCR_V) | ||
37 | #define FPCR_NZCVQC_MASK (FPCR_NZCV_MASK | FPCR_QC) | ||
38 | |||
39 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/target/arm/translate.h | 41 | --- a/hw/intc/armv7m_nvic.c |
32 | +++ b/target/arm/translate.h | 42 | +++ b/hw/intc/armv7m_nvic.c |
33 | @@ -XXX,XX +XXX,XX @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn) | 43 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, |
34 | #ifdef TARGET_AARCH64 | 44 | break; |
35 | void a64_translate_init(void); | 45 | case 0xf3c: /* FPDSCR */ |
36 | void gen_a64_set_pc_im(uint64_t val); | 46 | if (cpu_isar_feature(aa32_vfp_simd, cpu)) { |
37 | -void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags); | 47 | - value &= 0x07c00000; |
38 | extern const TranslatorOps aarch64_translator_ops; | 48 | + uint32_t mask = FPCR_AHP | FPCR_DN | FPCR_FZ | FPCR_RMODE_MASK; |
39 | #else | 49 | + if (cpu_isar_feature(any_fp16, cpu)) { |
40 | static inline void a64_translate_init(void) | 50 | + mask |= FPCR_FZ16; |
41 | @@ -XXX,XX +XXX,XX @@ static inline void a64_translate_init(void) | 51 | + } |
42 | static inline void gen_a64_set_pc_im(uint64_t val) | 52 | + value &= mask; |
43 | { | 53 | + if (cpu_isar_feature(aa32_lob, cpu)) { |
44 | } | 54 | + value |= 4 << FPCR_LTPSIZE_SHIFT; |
45 | - | 55 | + } |
46 | -static inline void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | 56 | cpu->env.v7m.fpdscr[attrs.secure] = value; |
47 | -{ | 57 | } |
48 | -} | 58 | break; |
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 | 59 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
53 | index XXXXXXX..XXXXXXX 100644 | 60 | index XXXXXXX..XXXXXXX 100644 |
54 | --- a/target/arm/cpu.c | 61 | --- a/target/arm/cpu.c |
55 | +++ b/target/arm/cpu.c | 62 | +++ b/target/arm/cpu.c |
56 | @@ -XXX,XX +XXX,XX @@ | 63 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) |
57 | */ | 64 | * always reset to 4. |
58 | 65 | */ | |
59 | #include "qemu/osdep.h" | 66 | env->v7m.ltpsize = 4; |
60 | +#include "qemu/qemu-print.h" | 67 | + /* The LTPSIZE field in FPDSCR is constant and reads as 4. */ |
61 | #include "qemu-common.h" | 68 | + env->v7m.fpdscr[M_REG_NS] = 4 << FPCR_LTPSIZE_SHIFT; |
62 | #include "target/arm/idau.h" | 69 | + env->v7m.fpdscr[M_REG_S] = 4 << FPCR_LTPSIZE_SHIFT; |
63 | #include "qemu/module.h" | 70 | } |
64 | @@ -XXX,XX +XXX,XX @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) | 71 | |
65 | #endif | 72 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { |
66 | } | ||
67 | |||
68 | +#ifdef TARGET_AARCH64 | ||
69 | + | ||
70 | +static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
71 | +{ | ||
72 | + ARMCPU *cpu = ARM_CPU(cs); | ||
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 | + | ||
79 | + qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc); | ||
80 | + for (i = 0; i < 32; i++) { | ||
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 | + } | ||
88 | + | ||
89 | + if (arm_feature(env, ARM_FEATURE_EL3) && el != 3) { | ||
90 | + ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; | ||
91 | + } else { | ||
92 | + ns_status = ""; | ||
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 | + } | ||
216 | + | ||
217 | + for (i = 0; i < 16; i++) { | ||
218 | + qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]); | ||
219 | + if ((i % 4) == 3) { | ||
220 | + qemu_fprintf(f, "\n"); | ||
221 | + } else { | ||
222 | + qemu_fprintf(f, " "); | ||
223 | + } | ||
224 | + } | ||
225 | + | ||
226 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
227 | + uint32_t xpsr = xpsr_read(env); | ||
228 | + const char *mode; | ||
229 | + const char *ns_status = ""; | ||
230 | + | ||
231 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
232 | + ns_status = env->v7m.secure ? "S " : "NS "; | ||
233 | + } | ||
234 | + | ||
235 | + if (xpsr & XPSR_EXCP) { | ||
236 | + mode = "handler"; | ||
237 | + } else { | ||
238 | + if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_NPRIV_MASK) { | ||
239 | + mode = "unpriv-thread"; | ||
240 | + } else { | ||
241 | + mode = "priv-thread"; | ||
242 | + } | ||
243 | + } | ||
244 | + | ||
245 | + qemu_fprintf(f, "XPSR=%08x %c%c%c%c %c %s%s\n", | ||
246 | + xpsr, | ||
247 | + xpsr & XPSR_N ? 'N' : '-', | ||
248 | + xpsr & XPSR_Z ? 'Z' : '-', | ||
249 | + xpsr & XPSR_C ? 'C' : '-', | ||
250 | + xpsr & XPSR_V ? 'V' : '-', | ||
251 | + xpsr & XPSR_T ? 'T' : 'A', | ||
252 | + ns_status, | ||
253 | + mode); | ||
254 | + } else { | ||
255 | + uint32_t psr = cpsr_read(env); | ||
256 | + const char *ns_status = ""; | ||
257 | + | ||
258 | + if (arm_feature(env, ARM_FEATURE_EL3) && | ||
259 | + (psr & CPSR_M) != ARM_CPU_MODE_MON) { | ||
260 | + ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; | ||
261 | + } | ||
262 | + | ||
263 | + qemu_fprintf(f, "PSR=%08x %c%c%c%c %c %s%s%d\n", | ||
264 | + psr, | ||
265 | + psr & CPSR_N ? 'N' : '-', | ||
266 | + psr & CPSR_Z ? 'Z' : '-', | ||
267 | + psr & CPSR_C ? 'C' : '-', | ||
268 | + psr & CPSR_V ? 'V' : '-', | ||
269 | + psr & CPSR_T ? 'T' : 'A', | ||
270 | + ns_status, | ||
271 | + aarch32_mode_name(psr), (psr & 0x10) ? 32 : 26); | ||
272 | + } | ||
273 | + | ||
274 | + if (flags & CPU_DUMP_FPU) { | ||
275 | + int numvfpregs = 0; | ||
276 | + if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
277 | + numvfpregs += 16; | ||
278 | + } | ||
279 | + if (arm_feature(env, ARM_FEATURE_VFP3)) { | ||
280 | + numvfpregs += 16; | ||
281 | + } | ||
282 | + for (i = 0; i < numvfpregs; i++) { | ||
283 | + uint64_t v = *aa32_vfp_dreg(env, i); | ||
284 | + qemu_fprintf(f, "s%02d=%08x s%02d=%08x d%02d=%016" PRIx64 "\n", | ||
285 | + i * 2, (uint32_t)v, | ||
286 | + i * 2 + 1, (uint32_t)(v >> 32), | ||
287 | + i, v); | ||
288 | + } | ||
289 | + qemu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env)); | ||
290 | + } | ||
291 | +} | ||
292 | + | ||
293 | uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) | ||
294 | { | ||
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 | ||
443 | index XXXXXXX..XXXXXXX 100644 | ||
444 | --- a/target/arm/translate.c | ||
445 | +++ b/target/arm/translate.c | ||
446 | @@ -XXX,XX +XXX,XX @@ | ||
447 | #include "tcg-op-gvec.h" | ||
448 | #include "qemu/log.h" | ||
449 | #include "qemu/bitops.h" | ||
450 | -#include "qemu/qemu-print.h" | ||
451 | #include "arm_ldst.h" | ||
452 | #include "hw/semihosting/semihost.h" | ||
453 | |||
454 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns) | ||
455 | translator_loop(ops, &dc.base, cpu, tb, max_insns); | ||
456 | } | ||
457 | |||
458 | -void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
459 | -{ | ||
460 | - ARMCPU *cpu = ARM_CPU(cs); | ||
461 | - CPUARMState *env = &cpu->env; | ||
462 | - int i; | ||
463 | - | ||
464 | - if (is_a64(env)) { | ||
465 | - aarch64_cpu_dump_state(cs, f, flags); | ||
466 | - return; | ||
467 | - } | ||
468 | - | ||
469 | - for (i = 0; i < 16; i++) { | ||
470 | - qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]); | ||
471 | - if ((i % 4) == 3) { | ||
472 | - qemu_fprintf(f, "\n"); | ||
473 | - } else { | ||
474 | - qemu_fprintf(f, " "); | ||
475 | - } | ||
476 | - } | ||
477 | - | ||
478 | - if (arm_feature(env, ARM_FEATURE_M)) { | ||
479 | - uint32_t xpsr = xpsr_read(env); | ||
480 | - const char *mode; | ||
481 | - const char *ns_status = ""; | ||
482 | - | ||
483 | - if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
484 | - ns_status = env->v7m.secure ? "S " : "NS "; | ||
485 | - } | ||
486 | - | ||
487 | - if (xpsr & XPSR_EXCP) { | ||
488 | - mode = "handler"; | ||
489 | - } else { | ||
490 | - if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_NPRIV_MASK) { | ||
491 | - mode = "unpriv-thread"; | ||
492 | - } else { | ||
493 | - mode = "priv-thread"; | ||
494 | - } | ||
495 | - } | ||
496 | - | ||
497 | - qemu_fprintf(f, "XPSR=%08x %c%c%c%c %c %s%s\n", | ||
498 | - xpsr, | ||
499 | - xpsr & XPSR_N ? 'N' : '-', | ||
500 | - xpsr & XPSR_Z ? 'Z' : '-', | ||
501 | - xpsr & XPSR_C ? 'C' : '-', | ||
502 | - xpsr & XPSR_V ? 'V' : '-', | ||
503 | - xpsr & XPSR_T ? 'T' : 'A', | ||
504 | - ns_status, | ||
505 | - mode); | ||
506 | - } else { | ||
507 | - uint32_t psr = cpsr_read(env); | ||
508 | - const char *ns_status = ""; | ||
509 | - | ||
510 | - if (arm_feature(env, ARM_FEATURE_EL3) && | ||
511 | - (psr & CPSR_M) != ARM_CPU_MODE_MON) { | ||
512 | - ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; | ||
513 | - } | ||
514 | - | ||
515 | - qemu_fprintf(f, "PSR=%08x %c%c%c%c %c %s%s%d\n", | ||
516 | - psr, | ||
517 | - psr & CPSR_N ? 'N' : '-', | ||
518 | - psr & CPSR_Z ? 'Z' : '-', | ||
519 | - psr & CPSR_C ? 'C' : '-', | ||
520 | - psr & CPSR_V ? 'V' : '-', | ||
521 | - psr & CPSR_T ? 'T' : 'A', | ||
522 | - ns_status, | ||
523 | - aarch32_mode_name(psr), (psr & 0x10) ? 32 : 26); | ||
524 | - } | ||
525 | - | ||
526 | - if (flags & CPU_DUMP_FPU) { | ||
527 | - int numvfpregs = 0; | ||
528 | - if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
529 | - numvfpregs += 16; | ||
530 | - } | ||
531 | - if (arm_feature(env, ARM_FEATURE_VFP3)) { | ||
532 | - numvfpregs += 16; | ||
533 | - } | ||
534 | - for (i = 0; i < numvfpregs; i++) { | ||
535 | - uint64_t v = *aa32_vfp_dreg(env, i); | ||
536 | - qemu_fprintf(f, "s%02d=%08x s%02d=%08x d%02d=%016" PRIx64 "\n", | ||
537 | - i * 2, (uint32_t)v, | ||
538 | - i * 2 + 1, (uint32_t)(v >> 32), | ||
539 | - i, v); | ||
540 | - } | ||
541 | - qemu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env)); | ||
542 | - } | ||
543 | -} | ||
544 | - | ||
545 | void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb, | ||
546 | target_ulong *data) | ||
547 | { | ||
548 | -- | 73 | -- |
549 | 2.20.1 | 74 | 2.20.1 |
550 | 75 | ||
551 | 76 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | In v8.0M, on exception entry the registers R0-R3, R12, APSR and EPSR |
---|---|---|---|
2 | are zeroed for an exception taken to Non-secure state; for an | ||
3 | exception taken to Secure state they become UNKNOWN, and we chose to | ||
4 | leave them at their previous values. | ||
2 | 5 | ||
3 | Add no-op/unimplemented PCIE PHY IP block. Needed by new kernels to | 6 | In v8.1M the behaviour is specified more tightly and these registers |
4 | use PCIE. | 7 | are always zeroed regardless of the security state that the exception |
8 | targets (see rule R_KPZV). Implement this. | ||
5 | 9 | ||
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> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20201119215617.29887-17-peter.maydell@linaro.org | ||
13 | --- | 13 | --- |
14 | include/hw/arm/fsl-imx7.h | 3 +++ | 14 | target/arm/m_helper.c | 16 ++++++++++++---- |
15 | hw/arm/fsl-imx7.c | 5 +++++ | 15 | 1 file changed, 12 insertions(+), 4 deletions(-) |
16 | 2 files changed, 8 insertions(+) | ||
17 | 16 | ||
18 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | 17 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/arm/fsl-imx7.h | 19 | --- a/target/arm/m_helper.c |
21 | +++ b/include/hw/arm/fsl-imx7.h | 20 | +++ b/target/arm/m_helper.c |
22 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { | 21 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, |
23 | FSL_IMX7_ADC2_ADDR = 0x30620000, | 22 | * Clear registers if necessary to prevent non-secure exception |
24 | FSL_IMX7_ADCn_SIZE = 0x1000, | 23 | * code being able to see register values from secure code. |
25 | 24 | * Where register values become architecturally UNKNOWN we leave | |
26 | + FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000, | 25 | - * them with their previous values. |
27 | + FSL_IMX7_PCIE_PHY_SIZE = 0x10000, | 26 | + * them with their previous values. v8.1M is tighter than v8.0M |
28 | + | 27 | + * here and always zeroes the caller-saved registers regardless |
29 | FSL_IMX7_GPC_ADDR = 0x303A0000, | 28 | + * of the security state the exception is targeting. |
30 | 29 | */ | |
31 | FSL_IMX7_I2C1_ADDR = 0x30A20000, | 30 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { |
32 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | 31 | - if (!targets_secure) { |
33 | index XXXXXXX..XXXXXXX 100644 | 32 | + if (!targets_secure || arm_feature(env, ARM_FEATURE_V8_1M)) { |
34 | --- a/hw/arm/fsl-imx7.c | 33 | /* |
35 | +++ b/hw/arm/fsl-imx7.c | 34 | * Always clear the caller-saved registers (they have been |
36 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | 35 | * pushed to the stack earlier in v7m_push_stack()). |
37 | */ | 36 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, |
38 | create_unimplemented_device("dma-apbh", FSL_IMX7_DMA_APBH_ADDR, | 37 | * v7m_push_callee_stack()). |
39 | FSL_IMX7_DMA_APBH_SIZE); | 38 | */ |
40 | + /* | 39 | int i; |
41 | + * PCIe PHY | 40 | + /* |
42 | + */ | 41 | + * r4..r11 are callee-saves, zero only if background |
43 | + create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR, | 42 | + * state was Secure (EXCRET.S == 1) and exception |
44 | + FSL_IMX7_PCIE_PHY_SIZE); | 43 | + * targets Non-secure state |
45 | } | 44 | + */ |
46 | 45 | + bool zero_callee_saves = !targets_secure && | |
47 | static void fsl_imx7_class_init(ObjectClass *oc, void *data) | 46 | + (lr & R_V7M_EXCRET_S_MASK); |
47 | |||
48 | for (i = 0; i < 13; i++) { | ||
49 | - /* r4..r11 are callee-saves, zero only if EXCRET.S == 1 */ | ||
50 | - if (i < 4 || i > 11 || (lr & R_V7M_EXCRET_S_MASK)) { | ||
51 | + if (i < 4 || i > 11 || zero_callee_saves) { | ||
52 | env->regs[i] = 0; | ||
53 | } | ||
54 | } | ||
48 | -- | 55 | -- |
49 | 2.20.1 | 56 | 2.20.1 |
50 | 57 | ||
51 | 58 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
2 | 1 | ||
3 | Expression to calculate update_msi_mapping in code handling writes to | ||
4 | DESIGNWARE_PCIE_MSI_INTR0_ENABLE is missing an ! operator and should | ||
5 | be: | ||
6 | |||
7 | !!root->msi.intr[0].enable ^ !!val; | ||
8 | |||
9 | so that MSI mapping is updated when enabled transitions from either | ||
10 | "none" -> "any" or "any" -> "none". Since that register shouldn't be | ||
11 | written to very often, change the code to update MSI mapping | ||
12 | unconditionally instead of trying to fix the update_msi_mapping logic. | ||
13 | |||
14 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
15 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Cc: Michael S. Tsirkin <mst@redhat.com> | ||
17 | Cc: qemu-devel@nongnu.org | ||
18 | Cc: qemu-arm@nongnu.org | ||
19 | Acked-by: Michael S. Tsirkin <mst@redhat.com> | ||
20 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | --- | ||
23 | hw/pci-host/designware.c | 10 ++-------- | ||
24 | 1 file changed, 2 insertions(+), 8 deletions(-) | ||
25 | |||
26 | diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/hw/pci-host/designware.c | ||
29 | +++ b/hw/pci-host/designware.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, | ||
31 | root->msi.base |= (uint64_t)val << 32; | ||
32 | break; | ||
33 | |||
34 | - case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: { | ||
35 | - const bool update_msi_mapping = !root->msi.intr[0].enable ^ !!val; | ||
36 | - | ||
37 | + case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: | ||
38 | root->msi.intr[0].enable = val; | ||
39 | - | ||
40 | - if (update_msi_mapping) { | ||
41 | - designware_pcie_root_update_msi_mapping(root); | ||
42 | - } | ||
43 | + designware_pcie_root_update_msi_mapping(root); | ||
44 | break; | ||
45 | - } | ||
46 | |||
47 | case DESIGNWARE_PCIE_MSI_INTR0_MASK: | ||
48 | root->msi.intr[0].mask = val; | ||
49 | -- | ||
50 | 2.20.1 | ||
51 | |||
52 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
2 | 1 | ||
3 | MSI mapping needs to be update when MSI address changes, so add the | ||
4 | code to do so. | ||
5 | |||
6 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
7 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Cc: Michael S. Tsirkin <mst@redhat.com> | ||
9 | Cc: qemu-devel@nongnu.org | ||
10 | Cc: qemu-arm@nongnu.org | ||
11 | Acked-by: Michael S. Tsirkin <mst@redhat.com> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/pci-host/designware.c | 2 ++ | ||
16 | 1 file changed, 2 insertions(+) | ||
17 | |||
18 | diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/pci-host/designware.c | ||
21 | +++ b/hw/pci-host/designware.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, | ||
23 | case DESIGNWARE_PCIE_MSI_ADDR_LO: | ||
24 | root->msi.base &= 0xFFFFFFFF00000000ULL; | ||
25 | root->msi.base |= val; | ||
26 | + designware_pcie_root_update_msi_mapping(root); | ||
27 | break; | ||
28 | |||
29 | case DESIGNWARE_PCIE_MSI_ADDR_HI: | ||
30 | root->msi.base &= 0x00000000FFFFFFFFULL; | ||
31 | root->msi.base |= (uint64_t)val << 32; | ||
32 | + designware_pcie_root_update_msi_mapping(root); | ||
33 | break; | ||
34 | |||
35 | case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: | ||
36 | -- | ||
37 | 2.20.1 | ||
38 | |||
39 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | In v8.1M, vector table fetch failures don't set HFSR.FORCED (see rule |
---|---|---|---|
2 | R_LLRP). (In previous versions of the architecture this was either | ||
3 | required or IMPDEF.) | ||
2 | 4 | ||
3 | Under KVM, the kernel gets the HVC call and handle the PSCI requests. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
6 | Message-id: 20190701132516.26392-20-philmd@redhat.com | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20201119215617.29887-18-peter.maydell@linaro.org | ||
9 | --- | 8 | --- |
10 | target/arm/internals.h | 6 +++++- | 9 | target/arm/m_helper.c | 6 +++++- |
11 | 1 file changed, 5 insertions(+), 1 deletion(-) | 10 | 1 file changed, 5 insertions(+), 1 deletion(-) |
12 | 11 | ||
13 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 12 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/internals.h | 14 | --- a/target/arm/m_helper.c |
16 | +++ b/target/arm/internals.h | 15 | +++ b/target/arm/m_helper.c |
17 | @@ -XXX,XX +XXX,XX @@ vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len); | 16 | @@ -XXX,XX +XXX,XX @@ load_fail: |
18 | /* Callback function for when a watchpoint or breakpoint triggers. */ | 17 | * The HardFault is Secure if BFHFNMINS is 0 (meaning that all HFs are |
19 | void arm_debug_excp_handler(CPUState *cs); | 18 | * secure); otherwise it targets the same security state as the |
20 | 19 | * underlying exception. | |
21 | -#ifdef CONFIG_USER_ONLY | 20 | + * In v8.1M HardFaults from vector table fetch fails don't set FORCED. |
22 | +#if defined(CONFIG_USER_ONLY) || !defined(CONFIG_TCG) | 21 | */ |
23 | static inline bool arm_is_psci_call(ARMCPU *cpu, int excp_type) | 22 | if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { |
24 | { | 23 | exc_secure = true; |
24 | } | ||
25 | - env->v7m.hfsr |= R_V7M_HFSR_VECTTBL_MASK | R_V7M_HFSR_FORCED_MASK; | ||
26 | + env->v7m.hfsr |= R_V7M_HFSR_VECTTBL_MASK; | ||
27 | + if (!arm_feature(env, ARM_FEATURE_V8_1M)) { | ||
28 | + env->v7m.hfsr |= R_V7M_HFSR_FORCED_MASK; | ||
29 | + } | ||
30 | armv7m_nvic_set_pending_derived(env->nvic, ARMV7M_EXCP_HARD, exc_secure); | ||
25 | return false; | 31 | return false; |
26 | } | 32 | } |
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 | -- | 33 | -- |
35 | 2.20.1 | 34 | 2.20.1 |
36 | 35 | ||
37 | 36 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | In v8.1M a REVIDR register is defined, which is at address 0xe00ecfc |
---|---|---|---|
2 | and is a read-only IMPDEF register providing implementation specific | ||
3 | minor revision information, like the v8A REVIDR_EL1. Implement this. | ||
2 | 4 | ||
3 | Group Aarch64 rules together, TCG related ones at the bottom. | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | This will help when restricting TCG-only objects. | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20201119215617.29887-19-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/intc/armv7m_nvic.c | 5 +++++ | ||
10 | 1 file changed, 5 insertions(+) | ||
5 | 11 | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 12 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190701132516.26392-2-philmd@redhat.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/Makefile.objs | 5 +++-- | ||
12 | 1 file changed, 3 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | ||
15 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/Makefile.objs | 14 | --- a/hw/intc/armv7m_nvic.c |
17 | +++ b/target/arm/Makefile.objs | 15 | +++ b/hw/intc/armv7m_nvic.c |
18 | @@ -XXX,XX +XXX,XX @@ obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o | 16 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) |
19 | obj-y += translate.o op_helper.o helper.o cpu.o | 17 | } |
20 | obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o | 18 | return val; |
21 | obj-y += gdbstub.o | 19 | } |
22 | -obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o | 20 | + case 0xcfc: |
23 | -obj-$(TARGET_AARCH64) += pauth_helper.o | 21 | + if (!arm_feature(&cpu->env, ARM_FEATURE_V8_1M)) { |
24 | +obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o | 22 | + goto bad_offset; |
25 | obj-y += crypto_helper.o | 23 | + } |
26 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o | 24 | + return cpu->revidr; |
27 | 25 | case 0xd00: /* CPUID Base. */ | |
28 | @@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c | 26 | return cpu->midr; |
29 | target/arm/translate.o: target/arm/decode-vfp.inc.c | 27 | case 0xd04: /* Interrupt Control State (ICSR) */ |
30 | target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c | ||
31 | |||
32 | +obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o | ||
33 | obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o | ||
34 | +obj-$(TARGET_AARCH64) += pauth_helper.o | ||
35 | -- | 28 | -- |
36 | 2.20.1 | 29 | 2.20.1 |
37 | 30 | ||
38 | 31 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | In v8.1M a new exception return check is added which may cause a NOCP |
---|---|---|---|
2 | UsageFault (see rule R_XLTP): before we clear s0..s15 and the FPSCR | ||
3 | we must check whether access to CP10 from the Security state of the | ||
4 | returning exception is disabled; if it is then we must take a fault. | ||
2 | 5 | ||
3 | The DRAM address of a DMA transaction depends on the DRAM base address | 6 | (Note that for our implementation CPPWR is always RAZ/WI and so can |
4 | of the SoC. Inform the SMC controller model with this value. | 7 | never cause CP10 accesses to fail.) |
5 | 8 | ||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 9 | The other v8.1M change to this register-clearing code is that if MVE |
7 | Reviewed-by: Joel Stanley <joel@jms.id.au> | 10 | is implemented VPR must also be cleared, so add a TODO comment to |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 11 | that effect. |
9 | Message-id: 20190618165311.27066-15-clg@kaod.org | 12 | |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20201119215617.29887-20-peter.maydell@linaro.org | ||
11 | --- | 16 | --- |
12 | include/hw/ssi/aspeed_smc.h | 3 +++ | 17 | target/arm/m_helper.c | 22 +++++++++++++++++++++- |
13 | hw/arm/aspeed_soc.c | 6 ++++++ | 18 | 1 file changed, 21 insertions(+), 1 deletion(-) |
14 | hw/ssi/aspeed_smc.c | 1 + | ||
15 | 3 files changed, 10 insertions(+) | ||
16 | 19 | ||
17 | diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h | 20 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/ssi/aspeed_smc.h | 22 | --- a/target/arm/m_helper.c |
20 | +++ b/include/hw/ssi/aspeed_smc.h | 23 | +++ b/target/arm/m_helper.c |
21 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCState { | 24 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
22 | uint8_t r_timings; | 25 | v7m_exception_taken(cpu, excret, true, false); |
23 | uint8_t conf_enable_w0; | 26 | return; |
24 | 27 | } else { | |
25 | + /* for DMA support */ | 28 | - /* Clear s0..s15 and FPSCR */ |
26 | + uint64_t sdram_base; | 29 | + if (arm_feature(env, ARM_FEATURE_V8_1M)) { |
27 | + | 30 | + /* v8.1M adds this NOCP check */ |
28 | AspeedSMCFlash *flashes; | 31 | + bool nsacr_pass = exc_secure || |
29 | 32 | + extract32(env->v7m.nsacr, 10, 1); | |
30 | uint8_t snoop_index; | 33 | + bool cpacr_pass = v7m_cpacr_pass(env, exc_secure, true); |
31 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | 34 | + if (!nsacr_pass) { |
32 | index XXXXXXX..XXXXXXX 100644 | 35 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, true); |
33 | --- a/hw/arm/aspeed_soc.c | 36 | + env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_NOCP_MASK; |
34 | +++ b/hw/arm/aspeed_soc.c | 37 | + qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " |
35 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 38 | + "stackframe: NSACR prevents clearing FPU registers\n"); |
36 | aspeed_soc_get_irq(s, ASPEED_I2C)); | 39 | + v7m_exception_taken(cpu, excret, true, false); |
37 | 40 | + } else if (!cpacr_pass) { | |
38 | /* FMC, The number of CS is set at the board level */ | 41 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, |
39 | + object_property_set_int(OBJECT(&s->fmc), sc->info->memmap[ASPEED_SDRAM], | 42 | + exc_secure); |
40 | + "sdram-base", &err); | 43 | + env->v7m.cfsr[exc_secure] |= R_V7M_CFSR_NOCP_MASK; |
41 | + if (err) { | 44 | + qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " |
42 | + error_propagate(errp, err); | 45 | + "stackframe: CPACR prevents clearing FPU registers\n"); |
43 | + return; | 46 | + v7m_exception_taken(cpu, excret, true, false); |
44 | + } | 47 | + } |
45 | object_property_set_bool(OBJECT(&s->fmc), true, "realized", &err); | 48 | + } |
46 | if (err) { | 49 | + /* Clear s0..s15 and FPSCR; TODO also VPR when MVE is implemented */ |
47 | error_propagate(errp, err); | 50 | int i; |
48 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | 51 | |
49 | index XXXXXXX..XXXXXXX 100644 | 52 | for (i = 0; i < 16; i += 2) { |
50 | --- a/hw/ssi/aspeed_smc.c | ||
51 | +++ b/hw/ssi/aspeed_smc.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_smc = { | ||
53 | |||
54 | static Property aspeed_smc_properties[] = { | ||
55 | DEFINE_PROP_UINT32("num-cs", AspeedSMCState, num_cs, 1), | ||
56 | + DEFINE_PROP_UINT64("sdram-base", AspeedSMCState, sdram_base, 0), | ||
57 | DEFINE_PROP_END_OF_LIST(), | ||
58 | }; | ||
59 | |||
60 | -- | 53 | -- |
61 | 2.20.1 | 54 | 2.20.1 |
62 | 55 | ||
63 | 56 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | v8.1M adds new encodings of VLLDM and VLSTM (where bit 7 is set). |
---|---|---|---|
2 | The only difference is that: | ||
3 | * the old T1 encodings UNDEF if the implementation implements 32 | ||
4 | Dregs (this is currently architecturally impossible for M-profile) | ||
5 | * the new T2 encodings have the implementation-defined option to | ||
6 | read from memory (discarding the data) or write UNKNOWN values to | ||
7 | memory for the stack slots that would be D16-D31 | ||
2 | 8 | ||
3 | The ast2500 uses the watchdog to reset the SDRAM controller. This | 9 | We choose not to make those accesses, so for us the two |
4 | operation is usually performed by u-boot's memory training procedure, | 10 | instructions behave identically assuming they don't UNDEF. |
5 | and it is enabled by setting a bit in the SCU and then causing the | ||
6 | watchdog to expire. Therefore, we need the watchdog to be able to | ||
7 | access the SCU's register space. | ||
8 | 11 | ||
9 | This causes the watchdog to not perform a system reset when the bit is | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | set. In the future it could perform a reset of the SDMC model. | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Message-id: 20201119215617.29887-21-peter.maydell@linaro.org | ||
15 | --- | ||
16 | target/arm/m-nocp.decode | 2 +- | ||
17 | target/arm/translate-vfp.c.inc | 25 +++++++++++++++++++++++++ | ||
18 | 2 files changed, 26 insertions(+), 1 deletion(-) | ||
11 | 19 | ||
12 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 20 | diff --git a/target/arm/m-nocp.decode b/target/arm/m-nocp.decode |
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 | 21 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/watchdog/wdt_aspeed.h | 22 | --- a/target/arm/m-nocp.decode |
27 | +++ b/include/hw/watchdog/wdt_aspeed.h | 23 | +++ b/target/arm/m-nocp.decode |
28 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedWDTState { | 24 | @@ -XXX,XX +XXX,XX @@ |
29 | MemoryRegion iomem; | 25 | |
30 | uint32_t regs[ASPEED_WDT_REGS_MAX]; | 26 | { |
31 | 27 | # Special cases which do not take an early NOCP: VLLDM and VLSTM | |
32 | + AspeedSCUState *scu; | 28 | - VLLDM_VLSTM 1110 1100 001 l:1 rn:4 0000 1010 0000 0000 |
33 | uint32_t pclk_freq; | 29 | + VLLDM_VLSTM 1110 1100 001 l:1 rn:4 0000 1010 op:1 000 0000 |
34 | uint32_t silicon_rev; | 30 | # VSCCLRM (new in v8.1M) is similar: |
35 | uint32_t ext_pulse_width_mask; | 31 | VSCCLRM 1110 1100 1.01 1111 .... 1011 imm:7 0 vd=%vd_dp size=3 |
36 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | 32 | VSCCLRM 1110 1100 1.01 1111 .... 1010 imm:8 vd=%vd_sp size=2 |
33 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
37 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/arm/aspeed_soc.c | 35 | --- a/target/arm/translate-vfp.c.inc |
39 | +++ b/hw/arm/aspeed_soc.c | 36 | +++ b/target/arm/translate-vfp.c.inc |
40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | 37 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLLDM_VLSTM(DisasContext *s, arg_VLLDM_VLSTM *a) |
41 | sizeof(s->wdt[i]), TYPE_ASPEED_WDT); | 38 | !arm_dc_feature(s, ARM_FEATURE_V8)) { |
42 | qdev_prop_set_uint32(DEVICE(&s->wdt[i]), "silicon-rev", | 39 | return false; |
43 | sc->info->silicon_rev); | ||
44 | + object_property_add_const_link(OBJECT(&s->wdt[i]), "scu", | ||
45 | + OBJECT(&s->scu), &error_abort); | ||
46 | } | 40 | } |
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 | + | 41 | + |
60 | static bool aspeed_wdt_is_enabled(const AspeedWDTState *s) | 42 | + if (a->op) { |
61 | { | 43 | + /* |
62 | return s->regs[WDT_CTRL] & WDT_CTRL_ENABLE; | 44 | + * T2 encoding ({D0-D31} reglist): v8.1M and up. We choose not |
63 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_timer_expired(void *dev) | 45 | + * to take the IMPDEF option to make memory accesses to the stack |
64 | { | 46 | + * slots that correspond to the D16-D31 registers (discarding |
65 | AspeedWDTState *s = ASPEED_WDT(dev); | 47 | + * read data and writing UNKNOWN values), so for us the T2 |
66 | 48 | + * encoding behaves identically to the T1 encoding. | |
67 | + /* Do not reset on SDRAM controller reset */ | 49 | + */ |
68 | + if (s->scu->regs[SCU_RESET_CONTROL1] & SCU_RESET_SDRAM) { | 50 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
69 | + timer_del(s->timer); | 51 | + return false; |
70 | + s->regs[WDT_CTRL] = 0; | 52 | + } |
71 | + return; | 53 | + } else { |
54 | + /* | ||
55 | + * T1 encoding ({D0-D15} reglist); undef if we have 32 Dregs. | ||
56 | + * This is currently architecturally impossible, but we add the | ||
57 | + * check to stay in line with the pseudocode. Note that we must | ||
58 | + * emit code for the UNDEF so it takes precedence over the NOCP. | ||
59 | + */ | ||
60 | + if (dc_isar_feature(aa32_simd_r32, s)) { | ||
61 | + unallocated_encoding(s); | ||
62 | + return true; | ||
63 | + } | ||
72 | + } | 64 | + } |
73 | + | 65 | + |
74 | qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n"); | 66 | /* |
75 | watchdog_perform_action(); | 67 | * If not secure, UNDEF. We must emit code for this |
76 | timer_del(s->timer); | 68 | * rather than returning false so that this takes |
77 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp) | ||
78 | { | ||
79 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
80 | AspeedWDTState *s = ASPEED_WDT(dev); | ||
81 | + Error *err = NULL; | ||
82 | + Object *obj; | ||
83 | + | ||
84 | + obj = object_property_get_link(OBJECT(dev), "scu", &err); | ||
85 | + if (!obj) { | ||
86 | + error_propagate(errp, err); | ||
87 | + error_prepend(errp, "required link 'scu' not found: "); | ||
88 | + return; | ||
89 | + } | ||
90 | + s->scu = ASPEED_SCU(obj); | ||
91 | |||
92 | if (!is_supported_silicon_rev(s->silicon_rev)) { | ||
93 | error_setg(errp, "Unknown silicon revision: 0x%" PRIx32, | ||
94 | -- | 69 | -- |
95 | 2.20.1 | 70 | 2.20.1 |
96 | 71 | ||
97 | 72 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | v8.1M introduces a new TRD flag in the CCR register, which enables |
---|---|---|---|
2 | checking for stack frame integrity signatures on SG instructions. | ||
3 | This bit is not banked, and is always RAZ/WI to Non-secure code. | ||
4 | Adjust the code for handling CCR reads and writes to handle this. | ||
2 | 5 | ||
3 | The RAM memory region is defined after the SoC is realized when the | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | SDMC controller has checked that the defined RAM size for the machine | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | is correct. This is problematic for controller models requiring a link | 8 | Message-id: 20201119215617.29887-23-peter.maydell@linaro.org |
6 | on the RAM region, for DMA support in the SMC controller for instance. | 9 | --- |
10 | target/arm/cpu.h | 2 ++ | ||
11 | hw/intc/armv7m_nvic.c | 26 ++++++++++++++++++-------- | ||
12 | 2 files changed, 20 insertions(+), 8 deletions(-) | ||
7 | 13 | ||
8 | Introduce a container memory region for the RAM that we can link into | 14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
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 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/aspeed.c | 16 | --- a/target/arm/cpu.h |
23 | +++ b/hw/arm/aspeed.c | 17 | +++ b/target/arm/cpu.h |
24 | @@ -XXX,XX +XXX,XX @@ static struct arm_boot_info aspeed_board_binfo = { | 18 | @@ -XXX,XX +XXX,XX @@ FIELD(V7M_CCR, STKOFHFNMIGN, 10, 1) |
25 | 19 | FIELD(V7M_CCR, DC, 16, 1) | |
26 | struct AspeedBoardState { | 20 | FIELD(V7M_CCR, IC, 17, 1) |
27 | AspeedSoCState soc; | 21 | FIELD(V7M_CCR, BP, 18, 1) |
28 | + MemoryRegion ram_container; | 22 | +FIELD(V7M_CCR, LOB, 19, 1) |
29 | MemoryRegion ram; | 23 | +FIELD(V7M_CCR, TRD, 20, 1) |
30 | MemoryRegion max_ram; | 24 | |
31 | }; | 25 | /* V7M SCR bits */ |
32 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | 26 | FIELD(V7M_SCR, SLEEPONEXIT, 1, 1) |
33 | ram_addr_t max_ram_size; | 27 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
34 | 28 | index XXXXXXX..XXXXXXX 100644 | |
35 | bmc = g_new0(AspeedBoardState, 1); | 29 | --- a/hw/intc/armv7m_nvic.c |
30 | +++ b/hw/intc/armv7m_nvic.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
32 | } | ||
33 | return cpu->env.v7m.scr[attrs.secure]; | ||
34 | case 0xd14: /* Configuration Control. */ | ||
35 | - /* The BFHFNMIGN bit is the only non-banked bit; we | ||
36 | - * keep it in the non-secure copy of the register. | ||
37 | + /* | ||
38 | + * Non-banked bits: BFHFNMIGN (stored in the NS copy of the register) | ||
39 | + * and TRD (stored in the S copy of the register) | ||
40 | */ | ||
41 | val = cpu->env.v7m.ccr[attrs.secure]; | ||
42 | val |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK; | ||
43 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
44 | cpu->env.v7m.scr[attrs.secure] = value; | ||
45 | break; | ||
46 | case 0xd14: /* Configuration Control. */ | ||
47 | + { | ||
48 | + uint32_t mask; | ||
36 | + | 49 | + |
37 | + memory_region_init(&bmc->ram_container, NULL, "aspeed-ram-container", | 50 | if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { |
38 | + UINT32_MAX); | 51 | goto bad_offset; |
39 | + | 52 | } |
40 | object_initialize_child(OBJECT(machine), "soc", &bmc->soc, | 53 | |
41 | (sizeof(bmc->soc)), cfg->soc_name, &error_abort, | 54 | /* Enforce RAZ/WI on reserved and must-RAZ/WI bits */ |
42 | NULL); | 55 | - value &= (R_V7M_CCR_STKALIGN_MASK | |
43 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | 56 | - R_V7M_CCR_BFHFNMIGN_MASK | |
44 | &error_abort); | 57 | - R_V7M_CCR_DIV_0_TRP_MASK | |
45 | 58 | - R_V7M_CCR_UNALIGN_TRP_MASK | | |
46 | memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); | 59 | - R_V7M_CCR_USERSETMPEND_MASK | |
47 | + memory_region_add_subregion(&bmc->ram_container, 0, &bmc->ram); | 60 | - R_V7M_CCR_NONBASETHRDENA_MASK); |
48 | memory_region_add_subregion(get_system_memory(), | 61 | + mask = R_V7M_CCR_STKALIGN_MASK | |
49 | - sc->info->memmap[ASPEED_SDRAM], &bmc->ram); | 62 | + R_V7M_CCR_BFHFNMIGN_MASK | |
50 | + sc->info->memmap[ASPEED_SDRAM], | 63 | + R_V7M_CCR_DIV_0_TRP_MASK | |
51 | + &bmc->ram_container); | 64 | + R_V7M_CCR_UNALIGN_TRP_MASK | |
52 | 65 | + R_V7M_CCR_USERSETMPEND_MASK | | |
53 | max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size", | 66 | + R_V7M_CCR_NONBASETHRDENA_MASK; |
54 | &error_abort); | 67 | + if (arm_feature(&cpu->env, ARM_FEATURE_V8_1M) && attrs.secure) { |
55 | memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL, | 68 | + /* TRD is always RAZ/WI from NS */ |
56 | "max_ram", max_ram_size - ram_size); | 69 | + mask |= R_V7M_CCR_TRD_MASK; |
57 | - memory_region_add_subregion(get_system_memory(), | 70 | + } |
58 | - sc->info->memmap[ASPEED_SDRAM] + ram_size, | 71 | + value &= mask; |
59 | - &bmc->max_ram); | 72 | |
60 | + memory_region_add_subregion(&bmc->ram_container, ram_size, &bmc->max_ram); | 73 | if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { |
61 | 74 | /* v8M makes NONBASETHRDENA and STKALIGN be RES1 */ | |
62 | aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort); | 75 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, |
63 | aspeed_board_init_flashes(&bmc->soc.spi[0], cfg->spi_model, &error_abort); | 76 | |
77 | cpu->env.v7m.ccr[attrs.secure] = value; | ||
78 | break; | ||
79 | + } | ||
80 | case 0xd24: /* System Handler Control and State (SHCSR) */ | ||
81 | if (!arm_feature(&cpu->env, ARM_FEATURE_V7)) { | ||
82 | goto bad_offset; | ||
64 | -- | 83 | -- |
65 | 2.20.1 | 84 | 2.20.1 |
66 | 85 | ||
67 | 86 | diff view generated by jsdifflib |
1 | From: Samuel Ortiz <sameo@linux.intel.com> | 1 | v8.1M introduces a new TRD flag in the CCR register, which enables |
---|---|---|---|
2 | checking for stack frame integrity signatures on SG instructions. | ||
3 | Add the code in the SG insn implementation for the new behaviour. | ||
2 | 4 | ||
3 | Those helpers are a software implementation of the ARM v8 memory zeroing | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | op code. They should be moved to the op helper file, which is going to | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | eventually be built only when TCG is enabled. | 7 | Message-id: 20201119215617.29887-24-peter.maydell@linaro.org |
8 | --- | ||
9 | target/arm/m_helper.c | 86 +++++++++++++++++++++++++++++++++++++++++++ | ||
10 | 1 file changed, 86 insertions(+) | ||
6 | 11 | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 12 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
8 | Reviewed-by: Robert Bradford <robert.bradford@intel.com> | ||
9 | Signed-off-by: Samuel Ortiz <sameo@linux.intel.com> | ||
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
11 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Message-id: 20190701132516.26392-10-philmd@redhat.com | ||
13 | [PMD: Rebased] | ||
14 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | target/arm/helper.c | 92 ----------------------------------------- | ||
19 | target/arm/op_helper.c | 93 ++++++++++++++++++++++++++++++++++++++++++ | ||
20 | 2 files changed, 93 insertions(+), 92 deletions(-) | ||
21 | |||
22 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/helper.c | 14 | --- a/target/arm/m_helper.c |
25 | +++ b/target/arm/helper.c | 15 | +++ b/target/arm/m_helper.c |
26 | @@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | 16 | @@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, |
27 | #endif | 17 | return true; |
28 | } | 18 | } |
29 | 19 | ||
30 | -void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | 20 | +static bool v7m_read_sg_stack_word(ARMCPU *cpu, ARMMMUIdx mmu_idx, |
31 | -{ | 21 | + uint32_t addr, uint32_t *spdata) |
32 | - /* | ||
33 | - * Implement DC ZVA, which zeroes a fixed-length block of memory. | ||
34 | - * Note that we do not implement the (architecturally mandated) | ||
35 | - * alignment fault for attempts to use this on Device memory | ||
36 | - * (which matches the usual QEMU behaviour of not implementing either | ||
37 | - * alignment faults or any memory attribute handling). | ||
38 | - */ | ||
39 | - | ||
40 | - ARMCPU *cpu = env_archcpu(env); | ||
41 | - uint64_t blocklen = 4 << cpu->dcz_blocksize; | ||
42 | - uint64_t vaddr = vaddr_in & ~(blocklen - 1); | ||
43 | - | ||
44 | -#ifndef CONFIG_USER_ONLY | ||
45 | - { | ||
46 | - /* | ||
47 | - * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than | ||
48 | - * the block size so we might have to do more than one TLB lookup. | ||
49 | - * We know that in fact for any v8 CPU the page size is at least 4K | ||
50 | - * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only | ||
51 | - * 1K as an artefact of legacy v5 subpage support being present in the | ||
52 | - * same QEMU executable. So in practice the hostaddr[] array has | ||
53 | - * two entries, given the current setting of TARGET_PAGE_BITS_MIN. | ||
54 | - */ | ||
55 | - int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE); | ||
56 | - void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)]; | ||
57 | - int try, i; | ||
58 | - unsigned mmu_idx = cpu_mmu_index(env, false); | ||
59 | - TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); | ||
60 | - | ||
61 | - assert(maxidx <= ARRAY_SIZE(hostaddr)); | ||
62 | - | ||
63 | - for (try = 0; try < 2; try++) { | ||
64 | - | ||
65 | - for (i = 0; i < maxidx; i++) { | ||
66 | - hostaddr[i] = tlb_vaddr_to_host(env, | ||
67 | - vaddr + TARGET_PAGE_SIZE * i, | ||
68 | - 1, mmu_idx); | ||
69 | - if (!hostaddr[i]) { | ||
70 | - break; | ||
71 | - } | ||
72 | - } | ||
73 | - if (i == maxidx) { | ||
74 | - /* | ||
75 | - * If it's all in the TLB it's fair game for just writing to; | ||
76 | - * we know we don't need to update dirty status, etc. | ||
77 | - */ | ||
78 | - for (i = 0; i < maxidx - 1; i++) { | ||
79 | - memset(hostaddr[i], 0, TARGET_PAGE_SIZE); | ||
80 | - } | ||
81 | - memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE)); | ||
82 | - return; | ||
83 | - } | ||
84 | - /* | ||
85 | - * OK, try a store and see if we can populate the tlb. This | ||
86 | - * might cause an exception if the memory isn't writable, | ||
87 | - * in which case we will longjmp out of here. We must for | ||
88 | - * this purpose use the actual register value passed to us | ||
89 | - * so that we get the fault address right. | ||
90 | - */ | ||
91 | - helper_ret_stb_mmu(env, vaddr_in, 0, oi, GETPC()); | ||
92 | - /* Now we can populate the other TLB entries, if any */ | ||
93 | - for (i = 0; i < maxidx; i++) { | ||
94 | - uint64_t va = vaddr + TARGET_PAGE_SIZE * i; | ||
95 | - if (va != (vaddr_in & TARGET_PAGE_MASK)) { | ||
96 | - helper_ret_stb_mmu(env, va, 0, oi, GETPC()); | ||
97 | - } | ||
98 | - } | ||
99 | - } | ||
100 | - | ||
101 | - /* | ||
102 | - * Slow path (probably attempt to do this to an I/O device or | ||
103 | - * similar, or clearing of a block of code we have translations | ||
104 | - * cached for). Just do a series of byte writes as the architecture | ||
105 | - * demands. It's not worth trying to use a cpu_physical_memory_map(), | ||
106 | - * memset(), unmap() sequence here because: | ||
107 | - * + we'd need to account for the blocksize being larger than a page | ||
108 | - * + the direct-RAM access case is almost always going to be dealt | ||
109 | - * with in the fastpath code above, so there's no speed benefit | ||
110 | - * + we would have to deal with the map returning NULL because the | ||
111 | - * bounce buffer was in use | ||
112 | - */ | ||
113 | - for (i = 0; i < blocklen; i++) { | ||
114 | - helper_ret_stb_mmu(env, vaddr + i, 0, oi, GETPC()); | ||
115 | - } | ||
116 | - } | ||
117 | -#else | ||
118 | - memset(g2h(vaddr), 0, blocklen); | ||
119 | -#endif | ||
120 | -} | ||
121 | - | ||
122 | /* Note that signed overflow is undefined in C. The following routines are | ||
123 | careful to use unsigned types where modulo arithmetic is required. | ||
124 | Failure to do so _will_ break on newer gcc. */ | ||
125 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
126 | index XXXXXXX..XXXXXXX 100644 | ||
127 | --- a/target/arm/op_helper.c | ||
128 | +++ b/target/arm/op_helper.c | ||
129 | @@ -XXX,XX +XXX,XX @@ | ||
130 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
131 | */ | ||
132 | #include "qemu/osdep.h" | ||
133 | +#include "qemu/units.h" | ||
134 | #include "qemu/log.h" | ||
135 | #include "qemu/main-loop.h" | ||
136 | #include "cpu.h" | ||
137 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(ror_cc)(CPUARMState *env, uint32_t x, uint32_t i) | ||
138 | return ((uint32_t)x >> shift) | (x << (32 - shift)); | ||
139 | } | ||
140 | } | ||
141 | + | ||
142 | +void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | ||
143 | +{ | 22 | +{ |
144 | + /* | 23 | + /* |
145 | + * Implement DC ZVA, which zeroes a fixed-length block of memory. | 24 | + * Read a word of data from the stack for the SG instruction, |
146 | + * Note that we do not implement the (architecturally mandated) | 25 | + * writing the value into *spdata. If the load succeeds, return |
147 | + * alignment fault for attempts to use this on Device memory | 26 | + * true; otherwise pend an appropriate exception and return false. |
148 | + * (which matches the usual QEMU behaviour of not implementing either | 27 | + * (We can't use data load helpers here that throw an exception |
149 | + * alignment faults or any memory attribute handling). | 28 | + * because of the context we're called in, which is halfway through |
29 | + * arm_v7m_cpu_do_interrupt().) | ||
150 | + */ | 30 | + */ |
31 | + CPUState *cs = CPU(cpu); | ||
32 | + CPUARMState *env = &cpu->env; | ||
33 | + MemTxAttrs attrs = {}; | ||
34 | + MemTxResult txres; | ||
35 | + target_ulong page_size; | ||
36 | + hwaddr physaddr; | ||
37 | + int prot; | ||
38 | + ARMMMUFaultInfo fi = {}; | ||
39 | + ARMCacheAttrs cacheattrs = {}; | ||
40 | + uint32_t value; | ||
151 | + | 41 | + |
152 | + ARMCPU *cpu = env_archcpu(env); | 42 | + if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &physaddr, |
153 | + uint64_t blocklen = 4 << cpu->dcz_blocksize; | 43 | + &attrs, &prot, &page_size, &fi, &cacheattrs)) { |
154 | + uint64_t vaddr = vaddr_in & ~(blocklen - 1); | 44 | + /* MPU/SAU lookup failed */ |
45 | + if (fi.type == ARMFault_QEMU_SFault) { | ||
46 | + qemu_log_mask(CPU_LOG_INT, | ||
47 | + "...SecureFault during stack word read\n"); | ||
48 | + env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK | R_V7M_SFSR_SFARVALID_MASK; | ||
49 | + env->v7m.sfar = addr; | ||
50 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
51 | + } else { | ||
52 | + qemu_log_mask(CPU_LOG_INT, | ||
53 | + "...MemManageFault during stack word read\n"); | ||
54 | + env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_DACCVIOL_MASK | | ||
55 | + R_V7M_CFSR_MMARVALID_MASK; | ||
56 | + env->v7m.mmfar[M_REG_S] = addr; | ||
57 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM, false); | ||
58 | + } | ||
59 | + return false; | ||
60 | + } | ||
61 | + value = address_space_ldl(arm_addressspace(cs, attrs), physaddr, | ||
62 | + attrs, &txres); | ||
63 | + if (txres != MEMTX_OK) { | ||
64 | + /* BusFault trying to read the data */ | ||
65 | + qemu_log_mask(CPU_LOG_INT, | ||
66 | + "...BusFault during stack word read\n"); | ||
67 | + env->v7m.cfsr[M_REG_NS] |= | ||
68 | + (R_V7M_CFSR_PRECISERR_MASK | R_V7M_CFSR_BFARVALID_MASK); | ||
69 | + env->v7m.bfar = addr; | ||
70 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false); | ||
71 | + return false; | ||
72 | + } | ||
155 | + | 73 | + |
156 | +#ifndef CONFIG_USER_ONLY | 74 | + *spdata = value; |
157 | + { | 75 | + return true; |
76 | +} | ||
77 | + | ||
78 | static bool v7m_handle_execute_nsc(ARMCPU *cpu) | ||
79 | { | ||
80 | /* | ||
81 | @@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu) | ||
82 | */ | ||
83 | qemu_log_mask(CPU_LOG_INT, "...really an SG instruction at 0x%08" PRIx32 | ||
84 | ", executing it\n", env->regs[15]); | ||
85 | + | ||
86 | + if (cpu_isar_feature(aa32_m_sec_state, cpu) && | ||
87 | + !arm_v7m_is_handler_mode(env)) { | ||
158 | + /* | 88 | + /* |
159 | + * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than | 89 | + * v8.1M exception stack frame integrity check. Note that we |
160 | + * the block size so we might have to do more than one TLB lookup. | 90 | + * must perform the memory access even if CCR_S.TRD is zero |
161 | + * We know that in fact for any v8 CPU the page size is at least 4K | 91 | + * and we aren't going to check what the data loaded is. |
162 | + * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only | ||
163 | + * 1K as an artefact of legacy v5 subpage support being present in the | ||
164 | + * same QEMU executable. So in practice the hostaddr[] array has | ||
165 | + * two entries, given the current setting of TARGET_PAGE_BITS_MIN. | ||
166 | + */ | 92 | + */ |
167 | + int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE); | 93 | + uint32_t spdata, sp; |
168 | + void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)]; | ||
169 | + int try, i; | ||
170 | + unsigned mmu_idx = cpu_mmu_index(env, false); | ||
171 | + TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); | ||
172 | + | 94 | + |
173 | + assert(maxidx <= ARRAY_SIZE(hostaddr)); | 95 | + /* |
96 | + * We know we are currently NS, so the S stack pointers must be | ||
97 | + * in other_ss_{psp,msp}, not in regs[13]/other_sp. | ||
98 | + */ | ||
99 | + sp = v7m_using_psp(env) ? env->v7m.other_ss_psp : env->v7m.other_ss_msp; | ||
100 | + if (!v7m_read_sg_stack_word(cpu, mmu_idx, sp, &spdata)) { | ||
101 | + /* Stack access failed and an exception has been pended */ | ||
102 | + return false; | ||
103 | + } | ||
174 | + | 104 | + |
175 | + for (try = 0; try < 2; try++) { | 105 | + if (env->v7m.ccr[M_REG_S] & R_V7M_CCR_TRD_MASK) { |
176 | + | 106 | + if (((spdata & ~1) == 0xfefa125a) || |
177 | + for (i = 0; i < maxidx; i++) { | 107 | + !(env->v7m.control[M_REG_S] & 1)) { |
178 | + hostaddr[i] = tlb_vaddr_to_host(env, | 108 | + goto gen_invep; |
179 | + vaddr + TARGET_PAGE_SIZE * i, | ||
180 | + 1, mmu_idx); | ||
181 | + if (!hostaddr[i]) { | ||
182 | + break; | ||
183 | + } | ||
184 | + } | ||
185 | + if (i == maxidx) { | ||
186 | + /* | ||
187 | + * If it's all in the TLB it's fair game for just writing to; | ||
188 | + * we know we don't need to update dirty status, etc. | ||
189 | + */ | ||
190 | + for (i = 0; i < maxidx - 1; i++) { | ||
191 | + memset(hostaddr[i], 0, TARGET_PAGE_SIZE); | ||
192 | + } | ||
193 | + memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE)); | ||
194 | + return; | ||
195 | + } | ||
196 | + /* | ||
197 | + * OK, try a store and see if we can populate the tlb. This | ||
198 | + * might cause an exception if the memory isn't writable, | ||
199 | + * in which case we will longjmp out of here. We must for | ||
200 | + * this purpose use the actual register value passed to us | ||
201 | + * so that we get the fault address right. | ||
202 | + */ | ||
203 | + helper_ret_stb_mmu(env, vaddr_in, 0, oi, GETPC()); | ||
204 | + /* Now we can populate the other TLB entries, if any */ | ||
205 | + for (i = 0; i < maxidx; i++) { | ||
206 | + uint64_t va = vaddr + TARGET_PAGE_SIZE * i; | ||
207 | + if (va != (vaddr_in & TARGET_PAGE_MASK)) { | ||
208 | + helper_ret_stb_mmu(env, va, 0, oi, GETPC()); | ||
209 | + } | ||
210 | + } | 109 | + } |
211 | + } | 110 | + } |
111 | + } | ||
212 | + | 112 | + |
213 | + /* | 113 | env->regs[14] &= ~1; |
214 | + * Slow path (probably attempt to do this to an I/O device or | 114 | env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; |
215 | + * similar, or clearing of a block of code we have translations | 115 | switch_v7m_security_state(env, true); |
216 | + * cached for). Just do a series of byte writes as the architecture | ||
217 | + * demands. It's not worth trying to use a cpu_physical_memory_map(), | ||
218 | + * memset(), unmap() sequence here because: | ||
219 | + * + we'd need to account for the blocksize being larger than a page | ||
220 | + * + the direct-RAM access case is almost always going to be dealt | ||
221 | + * with in the fastpath code above, so there's no speed benefit | ||
222 | + * + we would have to deal with the map returning NULL because the | ||
223 | + * bounce buffer was in use | ||
224 | + */ | ||
225 | + for (i = 0; i < blocklen; i++) { | ||
226 | + helper_ret_stb_mmu(env, vaddr + i, 0, oi, GETPC()); | ||
227 | + } | ||
228 | + } | ||
229 | +#else | ||
230 | + memset(g2h(vaddr), 0, blocklen); | ||
231 | +#endif | ||
232 | +} | ||
233 | -- | 116 | -- |
234 | 2.20.1 | 117 | 2.20.1 |
235 | 118 | ||
236 | 119 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | In commit 077d7449100d824a4 we added code to handle the v8M |
---|---|---|---|
2 | requirement that returns from NMI or HardFault forcibly deactivate | ||
3 | those exceptions regardless of what interrupt the guest is trying to | ||
4 | deactivate. Unfortunately this broke the handling of the "illegal | ||
5 | exception return because the returning exception number is not | ||
6 | active" check for those cases. In the pseudocode this test is done | ||
7 | on the exception the guest asks to return from, but because our | ||
8 | implementation was doing this in armv7m_nvic_complete_irq() after the | ||
9 | new "deactivate NMI/HardFault regardless" code we ended up doing the | ||
10 | test on the VecInfo for that exception instead, which usually meant | ||
11 | failing to raise the illegal exception return fault. | ||
2 | 12 | ||
3 | The vfp_set_fpscr() helper contains code specific to the host | 13 | In the case for "configurable exception targeting the opposite |
4 | floating point implementation (here the SoftFloat library). | 14 | security state" we detected the illegal-return case but went ahead |
5 | Extract this code to vfp_set_fpscr_to_host(). | 15 | and deactivated the VecInfo anyway, which is wrong because that is |
16 | the VecInfo for the other security state. | ||
6 | 17 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 18 | Rearrange the code so that we first identify the illegal return |
8 | Message-id: 20190701132516.26392-16-philmd@redhat.com | 19 | cases, then see if we really need to deactivate NMI or HardFault |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 20 | instead, and finally do the deactivation. |
21 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
24 | Message-id: 20201119215617.29887-25-peter.maydell@linaro.org | ||
11 | --- | 25 | --- |
12 | target/arm/vfp_helper.c | 127 +++++++++++++++++++++------------------- | 26 | hw/intc/armv7m_nvic.c | 59 +++++++++++++++++++++++-------------------- |
13 | 1 file changed, 66 insertions(+), 61 deletions(-) | 27 | 1 file changed, 32 insertions(+), 27 deletions(-) |
14 | 28 | ||
15 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | 29 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
16 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/vfp_helper.c | 31 | --- a/hw/intc/armv7m_nvic.c |
18 | +++ b/target/arm/vfp_helper.c | 32 | +++ b/hw/intc/armv7m_nvic.c |
19 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits) | 33 | @@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure) |
20 | return host_bits; | ||
21 | } | ||
22 | |||
23 | -uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | ||
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 | { | 34 | { |
52 | int i; | 35 | NVICState *s = (NVICState *)opaque; |
53 | uint32_t changed = env->vfp.xregs[ARM_VFP_FPSCR]; | 36 | VecInfo *vec = NULL; |
54 | 37 | - int ret; | |
55 | - /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ | 38 | + int ret = 0; |
56 | - if (!cpu_isar_feature(aa64_fp16, env_archcpu(env))) { | 39 | |
57 | - val &= ~FPCR_FZ16; | 40 | assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq); |
41 | |||
42 | + trace_nvic_complete_irq(irq, secure); | ||
43 | + | ||
44 | + if (secure && exc_is_banked(irq)) { | ||
45 | + vec = &s->sec_vectors[irq]; | ||
46 | + } else { | ||
47 | + vec = &s->vectors[irq]; | ||
48 | + } | ||
49 | + | ||
50 | + /* | ||
51 | + * Identify illegal exception return cases. We can't immediately | ||
52 | + * return at this point because we still need to deactivate | ||
53 | + * (either this exception or NMI/HardFault) first. | ||
54 | + */ | ||
55 | + if (!exc_is_banked(irq) && exc_targets_secure(s, irq) != secure) { | ||
56 | + /* | ||
57 | + * Return from a configurable exception targeting the opposite | ||
58 | + * security state from the one we're trying to complete it for. | ||
59 | + * Clear vec because it's not really the VecInfo for this | ||
60 | + * (irq, secstate) so we mustn't deactivate it. | ||
61 | + */ | ||
62 | + ret = -1; | ||
63 | + vec = NULL; | ||
64 | + } else if (!vec->active) { | ||
65 | + /* Return from an inactive interrupt */ | ||
66 | + ret = -1; | ||
67 | + } else { | ||
68 | + /* Legal return, we will return the RETTOBASE bit value to the caller */ | ||
69 | + ret = nvic_rettobase(s); | ||
70 | + } | ||
71 | + | ||
72 | /* | ||
73 | * For negative priorities, v8M will forcibly deactivate the appropriate | ||
74 | * NMI or HardFault regardless of what interrupt we're being asked to | ||
75 | @@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure) | ||
76 | } | ||
77 | |||
78 | if (!vec) { | ||
79 | - if (secure && exc_is_banked(irq)) { | ||
80 | - vec = &s->sec_vectors[irq]; | ||
81 | - } else { | ||
82 | - vec = &s->vectors[irq]; | ||
83 | - } | ||
58 | - } | 84 | - } |
59 | - | 85 | - |
60 | - if (arm_feature(env, ARM_FEATURE_M)) { | 86 | - trace_nvic_complete_irq(irq, secure); |
61 | - /* | 87 | - |
62 | - * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits | 88 | - if (!vec->active) { |
63 | - * and also for the trapped-exception-handling bits IxE. | 89 | - /* Tell the caller this was an illegal exception return */ |
64 | - */ | 90 | - return -1; |
65 | - val &= 0xf7c0009f; | ||
66 | - } | 91 | - } |
67 | - | 92 | - |
68 | - /* | 93 | - /* |
69 | - * We don't implement trapped exception handling, so the | 94 | - * If this is a configurable exception and it is currently |
70 | - * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) | 95 | - * targeting the opposite security state from the one we're trying |
71 | - * | 96 | - * to complete it for, this counts as an illegal exception return. |
72 | - * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC | 97 | - * We still need to deactivate whatever vector the logic above has |
73 | - * (which are stored in fp_status), and the other RES0 bits | 98 | - * selected, though, as it might not be the same as the one for the |
74 | - * in between, then we clear all of the low 16 bits. | 99 | - * requested exception number. |
75 | - */ | 100 | - */ |
76 | - env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000; | 101 | - if (!exc_is_banked(irq) && exc_targets_secure(s, irq) != secure) { |
77 | - env->vfp.vec_len = (val >> 16) & 7; | 102 | - ret = -1; |
78 | - env->vfp.vec_stride = (val >> 20) & 3; | 103 | - } else { |
79 | - | 104 | - ret = nvic_rettobase(s); |
80 | - /* | 105 | + return ret; |
81 | - * The bit we set within fpscr_q is arbitrary; the register as a | 106 | } |
82 | - * whole being zero/non-zero is what counts. | 107 | |
83 | - */ | 108 | vec->active = 0; |
84 | - env->vfp.qc[0] = val & FPCR_QC; | ||
85 | - env->vfp.qc[1] = 0; | ||
86 | - env->vfp.qc[2] = 0; | ||
87 | - env->vfp.qc[3] = 0; | ||
88 | - | ||
89 | changed ^= val; | ||
90 | if (changed & (3 << 22)) { | ||
91 | i = (val >> 22) & 3; | ||
92 | @@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | ||
93 | set_float_exception_flags(0, &env->vfp.standard_fp_status); | ||
94 | } | ||
95 | |||
96 | +uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | ||
97 | +{ | ||
98 | + uint32_t i, fpscr; | ||
99 | + | ||
100 | + fpscr = env->vfp.xregs[ARM_VFP_FPSCR] | ||
101 | + | (env->vfp.vec_len << 16) | ||
102 | + | (env->vfp.vec_stride << 20); | ||
103 | + | ||
104 | + i = get_float_exception_flags(&env->vfp.fp_status); | ||
105 | + i |= get_float_exception_flags(&env->vfp.standard_fp_status); | ||
106 | + /* FZ16 does not generate an input denormal exception. */ | ||
107 | + i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | ||
108 | + & ~float_flag_input_denormal); | ||
109 | + fpscr |= vfp_exceptbits_from_host(i); | ||
110 | + | ||
111 | + i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; | ||
112 | + fpscr |= i ? FPCR_QC : 0; | ||
113 | + | ||
114 | + return fpscr; | ||
115 | +} | ||
116 | + | ||
117 | +uint32_t vfp_get_fpscr(CPUARMState *env) | ||
118 | +{ | ||
119 | + return HELPER(vfp_get_fpscr)(env); | ||
120 | +} | ||
121 | + | ||
122 | +void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | ||
123 | +{ | ||
124 | + /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ | ||
125 | + if (!cpu_isar_feature(aa64_fp16, env_archcpu(env))) { | ||
126 | + val &= ~FPCR_FZ16; | ||
127 | + } | ||
128 | + | ||
129 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
130 | + /* | ||
131 | + * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits | ||
132 | + * and also for the trapped-exception-handling bits IxE. | ||
133 | + */ | ||
134 | + val &= 0xf7c0009f; | ||
135 | + } | ||
136 | + | ||
137 | + /* | ||
138 | + * We don't implement trapped exception handling, so the | ||
139 | + * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) | ||
140 | + * | ||
141 | + * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC | ||
142 | + * (which are stored in fp_status), and the other RES0 bits | ||
143 | + * in between, then we clear all of the low 16 bits. | ||
144 | + */ | ||
145 | + env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000; | ||
146 | + env->vfp.vec_len = (val >> 16) & 7; | ||
147 | + env->vfp.vec_stride = (val >> 20) & 3; | ||
148 | + | ||
149 | + /* | ||
150 | + * The bit we set within fpscr_q is arbitrary; the register as a | ||
151 | + * whole being zero/non-zero is what counts. | ||
152 | + */ | ||
153 | + env->vfp.qc[0] = val & FPCR_QC; | ||
154 | + env->vfp.qc[1] = 0; | ||
155 | + env->vfp.qc[2] = 0; | ||
156 | + env->vfp.qc[3] = 0; | ||
157 | + | ||
158 | + vfp_set_fpscr_to_host(env, val); | ||
159 | +} | ||
160 | + | ||
161 | void vfp_set_fpscr(CPUARMState *env, uint32_t val) | ||
162 | { | ||
163 | HELPER(vfp_set_fpscr)(env, val); | ||
164 | -- | 109 | -- |
165 | 2.20.1 | 110 | 2.20.1 |
166 | 111 | ||
167 | 112 | diff view generated by jsdifflib |
1 | From: Adriana Kobylak <anoo@us.ibm.com> | 1 | For v8.1M the architecture mandates that CPUs must provide at |
---|---|---|---|
2 | least the "minimal RAS implementation" from the Reliability, | ||
3 | Availability and Serviceability extension. This consists of: | ||
4 | * an ESB instruction which is a NOP | ||
5 | -- since it is in the HINT space we need only add a comment | ||
6 | * an RFSR register which will RAZ/WI | ||
7 | * a RAZ/WI AIRCR.IESB bit | ||
8 | -- the code which handles writes to AIRCR does not allow setting | ||
9 | of RES0 bits, so we already treat this as RAZ/WI; add a comment | ||
10 | noting that this is deliberate | ||
11 | * minimal implementation of the RAS register block at 0xe0005000 | ||
12 | -- this will be in a subsequent commit | ||
13 | * setting the ID_PFR0.RAS field to 0b0010 | ||
14 | -- we will do this when we add the Cortex-M55 CPU model | ||
2 | 15 | ||
3 | The Swift board is an OpenPOWER system hosting POWER processors. | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Add support for their BMC including the I2C devices as found on HW. | 17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
18 | Message-id: 20201119215617.29887-26-peter.maydell@linaro.org | ||
19 | --- | ||
20 | target/arm/cpu.h | 14 ++++++++++++++ | ||
21 | target/arm/t32.decode | 4 ++++ | ||
22 | hw/intc/armv7m_nvic.c | 13 +++++++++++++ | ||
23 | 3 files changed, 31 insertions(+) | ||
5 | 24 | ||
6 | Signed-off-by: Adriana Kobylak <anoo@us.ibm.com> | 25 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
9 | Message-id: 20190618165311.27066-20-clg@kaod.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/arm/aspeed.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ | ||
13 | 1 file changed, 50 insertions(+) | ||
14 | |||
15 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/aspeed.c | 27 | --- a/target/arm/cpu.h |
18 | +++ b/hw/arm/aspeed.c | 28 | +++ b/target/arm/cpu.h |
19 | @@ -XXX,XX +XXX,XX @@ struct AspeedBoardState { | 29 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_MMFR4, LSM, 20, 4) |
20 | SCU_AST2500_HW_STRAP_ACPI_ENABLE | \ | 30 | FIELD(ID_MMFR4, CCIDX, 24, 4) |
21 | SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER)) | 31 | FIELD(ID_MMFR4, EVT, 28, 4) |
22 | 32 | ||
23 | +/* Swift hardware value: 0xF11AD206 */ | 33 | +FIELD(ID_PFR0, STATE0, 0, 4) |
24 | +#define SWIFT_BMC_HW_STRAP1 ( \ | 34 | +FIELD(ID_PFR0, STATE1, 4, 4) |
25 | + AST2500_HW_STRAP1_DEFAULTS | \ | 35 | +FIELD(ID_PFR0, STATE2, 8, 4) |
26 | + SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \ | 36 | +FIELD(ID_PFR0, STATE3, 12, 4) |
27 | + SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \ | 37 | +FIELD(ID_PFR0, CSV2, 16, 4) |
28 | + SCU_AST2500_HW_STRAP_UART_DEBUG | \ | 38 | +FIELD(ID_PFR0, AMU, 20, 4) |
29 | + SCU_AST2500_HW_STRAP_DDR4_ENABLE | \ | 39 | +FIELD(ID_PFR0, DIT, 24, 4) |
30 | + SCU_H_PLL_BYPASS_EN | \ | 40 | +FIELD(ID_PFR0, RAS, 28, 4) |
31 | + SCU_AST2500_HW_STRAP_ACPI_ENABLE | \ | ||
32 | + SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER)) | ||
33 | + | 41 | + |
34 | /* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */ | 42 | FIELD(ID_PFR1, PROGMOD, 0, 4) |
35 | #define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1 | 43 | FIELD(ID_PFR1, SECURITY, 4, 4) |
36 | 44 | FIELD(ID_PFR1, MPROGMOD, 8, 4) | |
37 | @@ -XXX,XX +XXX,XX @@ static void romulus_bmc_i2c_init(AspeedBoardState *bmc) | 45 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_predinv(const ARMISARegisters *id) |
38 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); | 46 | return FIELD_EX32(id->id_isar6, ID_ISAR6, SPECRES) != 0; |
39 | } | 47 | } |
40 | 48 | ||
41 | +static void swift_bmc_i2c_init(AspeedBoardState *bmc) | 49 | +static inline bool isar_feature_aa32_ras(const ARMISARegisters *id) |
42 | +{ | 50 | +{ |
43 | + AspeedSoCState *soc = &bmc->soc; | 51 | + return FIELD_EX32(id->id_pfr0, ID_PFR0, RAS) != 0; |
44 | + | ||
45 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60); | ||
46 | + | ||
47 | + /* The swift board expects a TMP275 but a TMP105 is compatible */ | ||
48 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x48); | ||
49 | + /* The swift board expects a pca9551 but a pca9552 is compatible */ | ||
50 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "pca9552", 0x60); | ||
51 | + | ||
52 | + /* The swift board expects an Epson RX8900 RTC but a ds1338 is compatible */ | ||
53 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "ds1338", 0x32); | ||
54 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x60); | ||
55 | + | ||
56 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp423", 0x4c); | ||
57 | + /* The swift board expects a pca9539 but a pca9552 is compatible */ | ||
58 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "pca9552", 0x74); | ||
59 | + | ||
60 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "tmp423", 0x4c); | ||
61 | + /* The swift board expects a pca9539 but a pca9552 is compatible */ | ||
62 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "pca9552", | ||
63 | + 0x74); | ||
64 | + | ||
65 | + /* The swift board expects a TMP275 but a TMP105 is compatible */ | ||
66 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x48); | ||
67 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x4a); | ||
68 | +} | 52 | +} |
69 | + | 53 | + |
70 | static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | 54 | static inline bool isar_feature_aa32_mprofile(const ARMISARegisters *id) |
71 | { | 55 | { |
72 | AspeedSoCState *soc = &bmc->soc; | 56 | return FIELD_EX32(id->id_pfr1, ID_PFR1, MPROGMOD) != 0; |
73 | @@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = { | 57 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode |
74 | .num_cs = 2, | 58 | index XXXXXXX..XXXXXXX 100644 |
75 | .i2c_init = romulus_bmc_i2c_init, | 59 | --- a/target/arm/t32.decode |
76 | .ram = 512 * MiB, | 60 | +++ b/target/arm/t32.decode |
77 | + }, { | 61 | @@ -XXX,XX +XXX,XX @@ CLZ 1111 1010 1011 ---- 1111 .... 1000 .... @rdm |
78 | + .name = MACHINE_TYPE_NAME("swift-bmc"), | 62 | # SEV 1111 0011 1010 1111 1000 0000 0000 0100 |
79 | + .desc = "OpenPOWER Swift BMC (ARM1176)", | 63 | # SEVL 1111 0011 1010 1111 1000 0000 0000 0101 |
80 | + .soc_name = "ast2500-a1", | 64 | |
81 | + .hw_strap1 = SWIFT_BMC_HW_STRAP1, | 65 | + # For M-profile minimal-RAS ESB can be a NOP, which is the |
82 | + .fmc_model = "mx66l1g45g", | 66 | + # default behaviour since it is in the hint space. |
83 | + .spi_model = "mx66l1g45g", | 67 | + # ESB 1111 0011 1010 1111 1000 0000 0001 0000 |
84 | + .num_cs = 2, | 68 | + |
85 | + .i2c_init = swift_bmc_i2c_init, | 69 | # The canonical nop ends in 0000 0000, but the whole rest |
86 | + .ram = 512 * MiB, | 70 | # of the space is "reserved hint, behaves as nop". |
87 | }, { | 71 | NOP 1111 0011 1010 1111 1000 0000 ---- ---- |
88 | .name = MACHINE_TYPE_NAME("witherspoon-bmc"), | 72 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
89 | .desc = "OpenPOWER Witherspoon BMC (ARM1176)", | 73 | index XXXXXXX..XXXXXXX 100644 |
74 | --- a/hw/intc/armv7m_nvic.c | ||
75 | +++ b/hw/intc/armv7m_nvic.c | ||
76 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
77 | return 0; | ||
78 | } | ||
79 | return cpu->env.v7m.sfar; | ||
80 | + case 0xf04: /* RFSR */ | ||
81 | + if (!cpu_isar_feature(aa32_ras, cpu)) { | ||
82 | + goto bad_offset; | ||
83 | + } | ||
84 | + /* We provide minimal-RAS only: RFSR is RAZ/WI */ | ||
85 | + return 0; | ||
86 | case 0xf34: /* FPCCR */ | ||
87 | if (!cpu_isar_feature(aa32_vfp_simd, cpu)) { | ||
88 | return 0; | ||
89 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
90 | R_V7M_AIRCR_PRIGROUP_SHIFT, | ||
91 | R_V7M_AIRCR_PRIGROUP_LENGTH); | ||
92 | } | ||
93 | + /* AIRCR.IESB is RAZ/WI because we implement only minimal RAS */ | ||
94 | if (attrs.secure) { | ||
95 | /* These bits are only writable by secure */ | ||
96 | cpu->env.v7m.aircr = value & | ||
97 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
98 | } | ||
99 | break; | ||
100 | } | ||
101 | + case 0xf04: /* RFSR */ | ||
102 | + if (!cpu_isar_feature(aa32_ras, cpu)) { | ||
103 | + goto bad_offset; | ||
104 | + } | ||
105 | + /* We provide minimal-RAS only: RFSR is RAZ/WI */ | ||
106 | + break; | ||
107 | case 0xf34: /* FPCCR */ | ||
108 | if (cpu_isar_feature(aa32_vfp_simd, cpu)) { | ||
109 | /* Not all bits here are banked. */ | ||
90 | -- | 110 | -- |
91 | 2.20.1 | 111 | 2.20.1 |
92 | 112 | ||
93 | 113 | diff view generated by jsdifflib |
1 | From: Eddie James <eajames@linux.ibm.com> | 1 | The RAS feature has a block of memory-mapped registers at offset |
---|---|---|---|
2 | 0x5000 within the PPB. For a "minimal RAS" implementation we provide | ||
3 | no error records and so the only registers that exist in the block | ||
4 | are ERRIIDR and ERRDEVID. | ||
2 | 5 | ||
3 | The XDMA engine embedded in the Aspeed SOCs performs PCI DMA operations | 6 | The "RAZ/WI for privileged, BusFault for nonprivileged" behaviour |
4 | between the SOC (acting as a BMC) and a host processor in a server. | 7 | of the "nvic-default" region is actually valid for minimal-RAS, |
8 | so the main benefit of providing an explicit implementation of | ||
9 | the register block is more accurate LOG_UNIMP messages, and a | ||
10 | framework for where we could add a real RAS implementation later | ||
11 | if necessary. | ||
5 | 12 | ||
6 | The XDMA engine exists on the AST2400, AST2500, and AST2600 SOCs, so | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | enable it for all of those. Add trace events on the important register | 14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | writes in the XDMA engine. | 15 | Message-id: 20201119215617.29887-27-peter.maydell@linaro.org |
16 | --- | ||
17 | include/hw/intc/armv7m_nvic.h | 1 + | ||
18 | hw/intc/armv7m_nvic.c | 56 +++++++++++++++++++++++++++++++++++ | ||
19 | 2 files changed, 57 insertions(+) | ||
9 | 20 | ||
10 | Signed-off-by: Eddie James <eajames@linux.ibm.com> | 21 | diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h |
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> | ||
17 | --- | ||
18 | hw/misc/Makefile.objs | 1 + | ||
19 | include/hw/arm/aspeed_soc.h | 3 + | ||
20 | include/hw/misc/aspeed_xdma.h | 30 +++++++ | ||
21 | hw/arm/aspeed_soc.c | 17 ++++ | ||
22 | hw/misc/aspeed_xdma.c | 165 ++++++++++++++++++++++++++++++++++ | ||
23 | hw/misc/trace-events | 3 + | ||
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 | 22 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/hw/misc/Makefile.objs | 23 | --- a/include/hw/intc/armv7m_nvic.h |
31 | +++ b/hw/misc/Makefile.objs | 24 | +++ b/include/hw/intc/armv7m_nvic.h |
32 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_ARMSSE_MHU) += armsse-mhu.o | 25 | @@ -XXX,XX +XXX,XX @@ struct NVICState { |
33 | 26 | MemoryRegion sysreg_ns_mem; | |
34 | obj-$(CONFIG_PVPANIC) += pvpanic.o | 27 | MemoryRegion systickmem; |
35 | obj-$(CONFIG_AUX) += auxbus.o | 28 | MemoryRegion systick_ns_mem; |
36 | +obj-$(CONFIG_ASPEED_SOC) += aspeed_xdma.o | 29 | + MemoryRegion ras_mem; |
37 | obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o | 30 | MemoryRegion container; |
38 | obj-$(CONFIG_MSF2) += msf2-sysreg.o | 31 | MemoryRegion defaultmem; |
39 | obj-$(CONFIG_NRF51_SOC) += nrf51_rng.o | 32 | |
40 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | 33 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
41 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/include/hw/arm/aspeed_soc.h | 35 | --- a/hw/intc/armv7m_nvic.c |
43 | +++ b/include/hw/arm/aspeed_soc.h | 36 | +++ b/hw/intc/armv7m_nvic.c |
44 | @@ -XXX,XX +XXX,XX @@ | 37 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps nvic_systick_ops = { |
45 | #include "hw/intc/aspeed_vic.h" | 38 | .endianness = DEVICE_NATIVE_ENDIAN, |
46 | #include "hw/misc/aspeed_scu.h" | ||
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 | }; | 39 | }; |
66 | 40 | ||
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 | + | 41 | + |
82 | +#ifndef ASPEED_XDMA_H | 42 | +static MemTxResult ras_read(void *opaque, hwaddr addr, |
83 | +#define ASPEED_XDMA_H | 43 | + uint64_t *data, unsigned size, |
84 | + | 44 | + MemTxAttrs attrs) |
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 | } | ||
140 | |||
141 | static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
142 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
143 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, | ||
144 | aspeed_soc_get_irq(s, ASPEED_ETH1 + i)); | ||
145 | } | ||
146 | + | ||
147 | + /* XDMA */ | ||
148 | + object_property_set_bool(OBJECT(&s->xdma), true, "realized", &err); | ||
149 | + if (err) { | ||
150 | + error_propagate(errp, err); | ||
151 | + return; | ||
152 | + } | ||
153 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->xdma), 0, | ||
154 | + sc->info->memmap[ASPEED_XDMA]); | ||
155 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0, | ||
156 | + aspeed_soc_get_irq(s, ASPEED_XDMA)); | ||
157 | } | ||
158 | static Property aspeed_soc_properties[] = { | ||
159 | DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), | ||
160 | diff --git a/hw/misc/aspeed_xdma.c b/hw/misc/aspeed_xdma.c | ||
161 | new file mode 100644 | ||
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 | +{ | 45 | +{ |
202 | + uint32_t val = 0; | 46 | + if (attrs.user) { |
203 | + AspeedXDMAState *xdma = opaque; | 47 | + return MEMTX_ERROR; |
204 | + | ||
205 | + if (addr < ASPEED_XDMA_REG_SIZE) { | ||
206 | + val = xdma->regs[TO_REG(addr)]; | ||
207 | + } | ||
208 | + | ||
209 | + return (uint64_t)val; | ||
210 | +} | ||
211 | + | ||
212 | +static void aspeed_xdma_write(void *opaque, hwaddr addr, uint64_t val, | ||
213 | + unsigned int size) | ||
214 | +{ | ||
215 | + unsigned int idx; | ||
216 | + uint32_t val32 = (uint32_t)val; | ||
217 | + AspeedXDMAState *xdma = opaque; | ||
218 | + | ||
219 | + if (addr >= ASPEED_XDMA_REG_SIZE) { | ||
220 | + return; | ||
221 | + } | 48 | + } |
222 | + | 49 | + |
223 | + switch (addr) { | 50 | + switch (addr) { |
224 | + case XDMA_BMC_CMDQ_ENDP: | 51 | + case 0xe10: /* ERRIIDR */ |
225 | + xdma->regs[TO_REG(addr)] = val32 & XDMA_BMC_CMDQ_W_MASK; | 52 | + /* architect field = Arm; product/variant/revision 0 */ |
53 | + *data = 0x43b; | ||
226 | + break; | 54 | + break; |
227 | + case XDMA_BMC_CMDQ_WRP: | 55 | + case 0xfc8: /* ERRDEVID */ |
228 | + idx = TO_REG(addr); | 56 | + /* Minimal RAS: we implement 0 error record indexes */ |
229 | + xdma->regs[idx] = val32 & XDMA_BMC_CMDQ_W_MASK; | 57 | + *data = 0; |
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 | + } | ||
264 | + break; | 58 | + break; |
265 | + default: | 59 | + default: |
266 | + xdma->regs[TO_REG(addr)] = val32; | 60 | + qemu_log_mask(LOG_UNIMP, "Read RAS register offset 0x%x\n", |
61 | + (uint32_t)addr); | ||
62 | + *data = 0; | ||
267 | + break; | 63 | + break; |
268 | + } | 64 | + } |
65 | + return MEMTX_OK; | ||
269 | +} | 66 | +} |
270 | + | 67 | + |
271 | +static const MemoryRegionOps aspeed_xdma_ops = { | 68 | +static MemTxResult ras_write(void *opaque, hwaddr addr, |
272 | + .read = aspeed_xdma_read, | 69 | + uint64_t value, unsigned size, |
273 | + .write = aspeed_xdma_write, | 70 | + MemTxAttrs attrs) |
71 | +{ | ||
72 | + if (attrs.user) { | ||
73 | + return MEMTX_ERROR; | ||
74 | + } | ||
75 | + | ||
76 | + switch (addr) { | ||
77 | + default: | ||
78 | + qemu_log_mask(LOG_UNIMP, "Write to RAS register offset 0x%x\n", | ||
79 | + (uint32_t)addr); | ||
80 | + break; | ||
81 | + } | ||
82 | + return MEMTX_OK; | ||
83 | +} | ||
84 | + | ||
85 | +static const MemoryRegionOps ras_ops = { | ||
86 | + .read_with_attrs = ras_read, | ||
87 | + .write_with_attrs = ras_write, | ||
274 | + .endianness = DEVICE_NATIVE_ENDIAN, | 88 | + .endianness = DEVICE_NATIVE_ENDIAN, |
275 | + .valid.min_access_size = 4, | ||
276 | + .valid.max_access_size = 4, | ||
277 | +}; | 89 | +}; |
278 | + | 90 | + |
279 | +static void aspeed_xdma_realize(DeviceState *dev, Error **errp) | 91 | /* |
280 | +{ | 92 | * Unassigned portions of the PPB space are RAZ/WI for privileged |
281 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | 93 | * accesses, and fault for non-privileged accesses. |
282 | + AspeedXDMAState *xdma = ASPEED_XDMA(dev); | 94 | @@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) |
95 | &s->systick_ns_mem, 1); | ||
96 | } | ||
97 | |||
98 | + if (cpu_isar_feature(aa32_ras, s->cpu)) { | ||
99 | + memory_region_init_io(&s->ras_mem, OBJECT(s), | ||
100 | + &ras_ops, s, "nvic_ras", 0x1000); | ||
101 | + memory_region_add_subregion(&s->container, 0x5000, &s->ras_mem); | ||
102 | + } | ||
283 | + | 103 | + |
284 | + sysbus_init_irq(sbd, &xdma->irq); | 104 | sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->container); |
285 | + memory_region_init_io(&xdma->iomem, OBJECT(xdma), &aspeed_xdma_ops, xdma, | 105 | } |
286 | + TYPE_ASPEED_XDMA, XDMA_MEM_SIZE); | 106 | |
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 | ||
333 | --- a/hw/misc/trace-events | ||
334 | +++ b/hw/misc/trace-events | ||
335 | @@ -XXX,XX +XXX,XX @@ armsse_cpuid_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 CPU_I | ||
336 | # armsse-mhu.c | ||
337 | armsse_mhu_read(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | ||
338 | armsse_mhu_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | ||
339 | + | ||
340 | +# aspeed_xdma.c | ||
341 | +aspeed_xdma_write(uint64_t offset, uint64_t data) "XDMA write: offset 0x%" PRIx64 " data 0x%" PRIx64 | ||
342 | -- | 107 | -- |
343 | 2.20.1 | 108 | 2.20.1 |
344 | 109 | ||
345 | 110 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | Correct a typo in the name we give the NVIC object. |
---|---|---|---|
2 | 2 | ||
3 | Datasheet for i.MX7 is incorrect and i.MX7's PCI IRQ mapping matches | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | that of i.MX6: | 4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20201119215617.29887-28-peter.maydell@linaro.org | ||
7 | --- | ||
8 | hw/arm/armv7m.c | 2 +- | ||
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
5 | 10 | ||
6 | * INTD/MSI 122 | 11 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c |
7 | * INTC 123 | ||
8 | * INTB 124 | ||
9 | * INTA 125 | ||
10 | |||
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> | ||
26 | --- | ||
27 | include/hw/arm/fsl-imx7.h | 8 ++++---- | ||
28 | hw/pci-host/designware.c | 6 ++++-- | ||
29 | 2 files changed, 8 insertions(+), 6 deletions(-) | ||
30 | |||
31 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/include/hw/arm/fsl-imx7.h | 13 | --- a/hw/arm/armv7m.c |
34 | +++ b/include/hw/arm/fsl-imx7.h | 14 | +++ b/hw/arm/armv7m.c |
35 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7IRQs { | 15 | @@ -XXX,XX +XXX,XX @@ static void armv7m_instance_init(Object *obj) |
36 | FSL_IMX7_USB2_IRQ = 42, | 16 | |
37 | FSL_IMX7_USB3_IRQ = 40, | 17 | memory_region_init(&s->container, obj, "armv7m-container", UINT64_MAX); |
38 | 18 | ||
39 | - FSL_IMX7_PCI_INTA_IRQ = 122, | 19 | - object_initialize_child(obj, "nvnic", &s->nvic, TYPE_NVIC); |
40 | - FSL_IMX7_PCI_INTB_IRQ = 123, | 20 | + object_initialize_child(obj, "nvic", &s->nvic, TYPE_NVIC); |
41 | - FSL_IMX7_PCI_INTC_IRQ = 124, | 21 | object_property_add_alias(obj, "num-irq", |
42 | - FSL_IMX7_PCI_INTD_IRQ = 125, | 22 | OBJECT(&s->nvic), "num-irq"); |
43 | + FSL_IMX7_PCI_INTA_IRQ = 125, | ||
44 | + FSL_IMX7_PCI_INTB_IRQ = 124, | ||
45 | + FSL_IMX7_PCI_INTC_IRQ = 123, | ||
46 | + FSL_IMX7_PCI_INTD_IRQ = 122, | ||
47 | |||
48 | FSL_IMX7_UART7_IRQ = 126, | ||
49 | |||
50 | diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/hw/pci-host/designware.c | ||
53 | +++ b/hw/pci-host/designware.c | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
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 | } | ||
70 | } | ||
71 | |||
72 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, | ||
73 | case DESIGNWARE_PCIE_MSI_INTR0_STATUS: | ||
74 | root->msi.intr[0].status ^= val; | ||
75 | if (!root->msi.intr[0].status) { | ||
76 | - qemu_set_irq(host->pci.irqs[0], 0); | ||
77 | + qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 0); | ||
78 | } | ||
79 | break; | ||
80 | 23 | ||
81 | -- | 24 | -- |
82 | 2.20.1 | 25 | 2.20.1 |
83 | 26 | ||
84 | 27 | 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 slightly different address space and have a different set | ||
5 | of controllers. | ||
6 | |||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
10 | Message-id: 20190618165311.27066-3-clg@kaod.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | include/hw/arm/aspeed_soc.h | 4 +- | ||
14 | hw/arm/aspeed.c | 8 +-- | ||
15 | hw/arm/aspeed_soc.c | 117 ++++++++++++++++++++++-------------- | ||
16 | 3 files changed, 78 insertions(+), 51 deletions(-) | ||
17 | |||
18 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/include/hw/arm/aspeed_soc.h | ||
21 | +++ b/include/hw/arm/aspeed_soc.h | ||
22 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { | ||
23 | const char *name; | ||
24 | const char *cpu_type; | ||
25 | uint32_t silicon_rev; | ||
26 | - hwaddr sdram_base; | ||
27 | uint64_t sram_size; | ||
28 | int spis_num; | ||
29 | - const hwaddr *spi_bases; | ||
30 | const char *fmc_typename; | ||
31 | const char **spi_typename; | ||
32 | int wdts_num; | ||
33 | const int *irqmap; | ||
34 | + const hwaddr *memmap; | ||
35 | } AspeedSoCInfo; | ||
36 | |||
37 | typedef struct AspeedSoCClass { | ||
38 | @@ -XXX,XX +XXX,XX @@ enum { | ||
39 | ASPEED_I2C, | ||
40 | ASPEED_ETH1, | ||
41 | ASPEED_ETH2, | ||
42 | + ASPEED_SDRAM, | ||
43 | }; | ||
44 | |||
45 | #endif /* ASPEED_SOC_H */ | ||
46 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/arm/aspeed.c | ||
49 | +++ b/hw/arm/aspeed.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
51 | &error_abort); | ||
52 | |||
53 | memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); | ||
54 | - memory_region_add_subregion(get_system_memory(), sc->info->sdram_base, | ||
55 | - &bmc->ram); | ||
56 | + memory_region_add_subregion(get_system_memory(), | ||
57 | + sc->info->memmap[ASPEED_SDRAM], &bmc->ram); | ||
58 | object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram), | ||
59 | &error_abort); | ||
60 | |||
61 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
62 | memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL, | ||
63 | "max_ram", max_ram_size - ram_size); | ||
64 | memory_region_add_subregion(get_system_memory(), | ||
65 | - sc->info->sdram_base + ram_size, | ||
66 | + sc->info->memmap[ASPEED_SDRAM] + ram_size, | ||
67 | &bmc->max_ram); | ||
68 | |||
69 | aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort); | ||
70 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
71 | aspeed_board_binfo.initrd_filename = machine->initrd_filename; | ||
72 | aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline; | ||
73 | aspeed_board_binfo.ram_size = ram_size; | ||
74 | - aspeed_board_binfo.loader_start = sc->info->sdram_base; | ||
75 | + aspeed_board_binfo.loader_start = sc->info->memmap[ASPEED_SDRAM]; | ||
76 | |||
77 | if (cfg->i2c_init) { | ||
78 | cfg->i2c_init(bmc); | ||
79 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/hw/arm/aspeed_soc.c | ||
82 | +++ b/hw/arm/aspeed_soc.c | ||
83 | @@ -XXX,XX +XXX,XX @@ | ||
84 | #include "hw/i2c/aspeed_i2c.h" | ||
85 | #include "net/net.h" | ||
86 | |||
87 | -#define ASPEED_SOC_UART_5_BASE 0x00184000 | ||
88 | #define ASPEED_SOC_IOMEM_SIZE 0x00200000 | ||
89 | -#define ASPEED_SOC_IOMEM_BASE 0x1E600000 | ||
90 | -#define ASPEED_SOC_FMC_BASE 0x1E620000 | ||
91 | -#define ASPEED_SOC_SPI_BASE 0x1E630000 | ||
92 | -#define ASPEED_SOC_SPI2_BASE 0x1E631000 | ||
93 | -#define ASPEED_SOC_VIC_BASE 0x1E6C0000 | ||
94 | -#define ASPEED_SOC_SDMC_BASE 0x1E6E0000 | ||
95 | -#define ASPEED_SOC_SCU_BASE 0x1E6E2000 | ||
96 | -#define ASPEED_SOC_SRAM_BASE 0x1E720000 | ||
97 | -#define ASPEED_SOC_TIMER_BASE 0x1E782000 | ||
98 | -#define ASPEED_SOC_WDT_BASE 0x1E785000 | ||
99 | -#define ASPEED_SOC_I2C_BASE 0x1E78A000 | ||
100 | -#define ASPEED_SOC_ETH1_BASE 0x1E660000 | ||
101 | -#define ASPEED_SOC_ETH2_BASE 0x1E680000 | ||
102 | + | ||
103 | +static const hwaddr aspeed_soc_ast2400_memmap[] = { | ||
104 | + [ASPEED_IOMEM] = 0x1E600000, | ||
105 | + [ASPEED_FMC] = 0x1E620000, | ||
106 | + [ASPEED_SPI1] = 0x1E630000, | ||
107 | + [ASPEED_VIC] = 0x1E6C0000, | ||
108 | + [ASPEED_SDMC] = 0x1E6E0000, | ||
109 | + [ASPEED_SCU] = 0x1E6E2000, | ||
110 | + [ASPEED_ADC] = 0x1E6E9000, | ||
111 | + [ASPEED_SRAM] = 0x1E720000, | ||
112 | + [ASPEED_GPIO] = 0x1E780000, | ||
113 | + [ASPEED_RTC] = 0x1E781000, | ||
114 | + [ASPEED_TIMER1] = 0x1E782000, | ||
115 | + [ASPEED_WDT] = 0x1E785000, | ||
116 | + [ASPEED_PWM] = 0x1E786000, | ||
117 | + [ASPEED_LPC] = 0x1E789000, | ||
118 | + [ASPEED_IBT] = 0x1E789140, | ||
119 | + [ASPEED_I2C] = 0x1E78A000, | ||
120 | + [ASPEED_ETH1] = 0x1E660000, | ||
121 | + [ASPEED_ETH2] = 0x1E680000, | ||
122 | + [ASPEED_UART1] = 0x1E783000, | ||
123 | + [ASPEED_UART5] = 0x1E784000, | ||
124 | + [ASPEED_VUART] = 0x1E787000, | ||
125 | + [ASPEED_SDRAM] = 0x40000000, | ||
126 | +}; | ||
127 | + | ||
128 | +static const hwaddr aspeed_soc_ast2500_memmap[] = { | ||
129 | + [ASPEED_IOMEM] = 0x1E600000, | ||
130 | + [ASPEED_FMC] = 0x1E620000, | ||
131 | + [ASPEED_SPI1] = 0x1E630000, | ||
132 | + [ASPEED_SPI2] = 0x1E631000, | ||
133 | + [ASPEED_VIC] = 0x1E6C0000, | ||
134 | + [ASPEED_SDMC] = 0x1E6E0000, | ||
135 | + [ASPEED_SCU] = 0x1E6E2000, | ||
136 | + [ASPEED_ADC] = 0x1E6E9000, | ||
137 | + [ASPEED_SRAM] = 0x1E720000, | ||
138 | + [ASPEED_GPIO] = 0x1E780000, | ||
139 | + [ASPEED_RTC] = 0x1E781000, | ||
140 | + [ASPEED_TIMER1] = 0x1E782000, | ||
141 | + [ASPEED_WDT] = 0x1E785000, | ||
142 | + [ASPEED_PWM] = 0x1E786000, | ||
143 | + [ASPEED_LPC] = 0x1E789000, | ||
144 | + [ASPEED_IBT] = 0x1E789140, | ||
145 | + [ASPEED_I2C] = 0x1E78A000, | ||
146 | + [ASPEED_ETH1] = 0x1E660000, | ||
147 | + [ASPEED_ETH2] = 0x1E680000, | ||
148 | + [ASPEED_UART1] = 0x1E783000, | ||
149 | + [ASPEED_UART5] = 0x1E784000, | ||
150 | + [ASPEED_VUART] = 0x1E787000, | ||
151 | + [ASPEED_SDRAM] = 0x80000000, | ||
152 | +}; | ||
153 | |||
154 | static const int aspeed_soc_ast2400_irqmap[] = { | ||
155 | [ASPEED_UART1] = 9, | ||
156 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2400_irqmap[] = { | ||
157 | [ASPEED_ETH2] = 3, | ||
158 | }; | ||
159 | |||
160 | -#define AST2400_SDRAM_BASE 0x40000000 | ||
161 | -#define AST2500_SDRAM_BASE 0x80000000 | ||
162 | - | ||
163 | -/* AST2500 uses the same IRQs as the AST2400 */ | ||
164 | #define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap | ||
165 | |||
166 | -static const hwaddr aspeed_soc_ast2400_spi_bases[] = { ASPEED_SOC_SPI_BASE }; | ||
167 | static const char *aspeed_soc_ast2400_typenames[] = { "aspeed.smc.spi" }; | ||
168 | - | ||
169 | -static const hwaddr aspeed_soc_ast2500_spi_bases[] = { ASPEED_SOC_SPI_BASE, | ||
170 | - ASPEED_SOC_SPI2_BASE}; | ||
171 | static const char *aspeed_soc_ast2500_typenames[] = { | ||
172 | "aspeed.smc.ast2500-spi1", "aspeed.smc.ast2500-spi2" }; | ||
173 | |||
174 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
175 | .name = "ast2400-a0", | ||
176 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | ||
177 | .silicon_rev = AST2400_A0_SILICON_REV, | ||
178 | - .sdram_base = AST2400_SDRAM_BASE, | ||
179 | .sram_size = 0x8000, | ||
180 | .spis_num = 1, | ||
181 | - .spi_bases = aspeed_soc_ast2400_spi_bases, | ||
182 | .fmc_typename = "aspeed.smc.fmc", | ||
183 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
184 | .wdts_num = 2, | ||
185 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
186 | + .memmap = aspeed_soc_ast2400_memmap, | ||
187 | }, { | ||
188 | .name = "ast2400-a1", | ||
189 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | ||
190 | .silicon_rev = AST2400_A1_SILICON_REV, | ||
191 | - .sdram_base = AST2400_SDRAM_BASE, | ||
192 | .sram_size = 0x8000, | ||
193 | .spis_num = 1, | ||
194 | - .spi_bases = aspeed_soc_ast2400_spi_bases, | ||
195 | .fmc_typename = "aspeed.smc.fmc", | ||
196 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
197 | .wdts_num = 2, | ||
198 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
199 | + .memmap = aspeed_soc_ast2400_memmap, | ||
200 | }, { | ||
201 | .name = "ast2400", | ||
202 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | ||
203 | .silicon_rev = AST2400_A0_SILICON_REV, | ||
204 | - .sdram_base = AST2400_SDRAM_BASE, | ||
205 | .sram_size = 0x8000, | ||
206 | .spis_num = 1, | ||
207 | - .spi_bases = aspeed_soc_ast2400_spi_bases, | ||
208 | .fmc_typename = "aspeed.smc.fmc", | ||
209 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
210 | .wdts_num = 2, | ||
211 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
212 | + .memmap = aspeed_soc_ast2400_memmap, | ||
213 | }, { | ||
214 | .name = "ast2500-a1", | ||
215 | .cpu_type = ARM_CPU_TYPE_NAME("arm1176"), | ||
216 | .silicon_rev = AST2500_A1_SILICON_REV, | ||
217 | - .sdram_base = AST2500_SDRAM_BASE, | ||
218 | .sram_size = 0x9000, | ||
219 | .spis_num = 2, | ||
220 | - .spi_bases = aspeed_soc_ast2500_spi_bases, | ||
221 | .fmc_typename = "aspeed.smc.ast2500-fmc", | ||
222 | .spi_typename = aspeed_soc_ast2500_typenames, | ||
223 | .wdts_num = 3, | ||
224 | .irqmap = aspeed_soc_ast2500_irqmap, | ||
225 | + .memmap = aspeed_soc_ast2500_memmap, | ||
226 | }, | ||
227 | }; | ||
228 | |||
229 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
230 | Error *err = NULL, *local_err = NULL; | ||
231 | |||
232 | /* IO space */ | ||
233 | - create_unimplemented_device("aspeed_soc.io", | ||
234 | - ASPEED_SOC_IOMEM_BASE, ASPEED_SOC_IOMEM_SIZE); | ||
235 | + create_unimplemented_device("aspeed_soc.io", sc->info->memmap[ASPEED_IOMEM], | ||
236 | + ASPEED_SOC_IOMEM_SIZE); | ||
237 | |||
238 | /* CPU */ | ||
239 | object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); | ||
240 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
241 | error_propagate(errp, err); | ||
242 | return; | ||
243 | } | ||
244 | - memory_region_add_subregion(get_system_memory(), ASPEED_SOC_SRAM_BASE, | ||
245 | - &s->sram); | ||
246 | + memory_region_add_subregion(get_system_memory(), | ||
247 | + sc->info->memmap[ASPEED_SRAM], &s->sram); | ||
248 | |||
249 | /* SCU */ | ||
250 | object_property_set_bool(OBJECT(&s->scu), true, "realized", &err); | ||
251 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
252 | error_propagate(errp, err); | ||
253 | return; | ||
254 | } | ||
255 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, ASPEED_SOC_SCU_BASE); | ||
256 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->info->memmap[ASPEED_SCU]); | ||
257 | |||
258 | /* VIC */ | ||
259 | object_property_set_bool(OBJECT(&s->vic), true, "realized", &err); | ||
260 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
261 | error_propagate(errp, err); | ||
262 | return; | ||
263 | } | ||
264 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->vic), 0, ASPEED_SOC_VIC_BASE); | ||
265 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->vic), 0, sc->info->memmap[ASPEED_VIC]); | ||
266 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 0, | ||
267 | qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ)); | ||
268 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 1, | ||
269 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
270 | error_propagate(errp, err); | ||
271 | return; | ||
272 | } | ||
273 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, ASPEED_SOC_TIMER_BASE); | ||
274 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, | ||
275 | + sc->info->memmap[ASPEED_TIMER1]); | ||
276 | for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { | ||
277 | qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_TIMER1 + i); | ||
278 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq); | ||
279 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
280 | /* UART - attach an 8250 to the IO space as our UART5 */ | ||
281 | if (serial_hd(0)) { | ||
282 | qemu_irq uart5 = aspeed_soc_get_irq(s, ASPEED_UART5); | ||
283 | - serial_mm_init(get_system_memory(), | ||
284 | - ASPEED_SOC_IOMEM_BASE + ASPEED_SOC_UART_5_BASE, 2, | ||
285 | + serial_mm_init(get_system_memory(), sc->info->memmap[ASPEED_UART5], 2, | ||
286 | uart5, 38400, serial_hd(0), DEVICE_LITTLE_ENDIAN); | ||
287 | } | ||
288 | |||
289 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
290 | error_propagate(errp, err); | ||
291 | return; | ||
292 | } | ||
293 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, ASPEED_SOC_I2C_BASE); | ||
294 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, sc->info->memmap[ASPEED_I2C]); | ||
295 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c), 0, | ||
296 | aspeed_soc_get_irq(s, ASPEED_I2C)); | ||
297 | |||
298 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
299 | error_propagate(errp, err); | ||
300 | return; | ||
301 | } | ||
302 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, ASPEED_SOC_FMC_BASE); | ||
303 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, sc->info->memmap[ASPEED_FMC]); | ||
304 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1, | ||
305 | s->fmc.ctrl->flash_window_base); | ||
306 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0, | ||
307 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
308 | error_propagate(errp, err); | ||
309 | return; | ||
310 | } | ||
311 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, sc->info->spi_bases[i]); | ||
312 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, | ||
313 | + sc->info->memmap[ASPEED_SPI1 + i]); | ||
314 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 1, | ||
315 | s->spi[i].ctrl->flash_window_base); | ||
316 | } | ||
317 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
318 | error_propagate(errp, err); | ||
319 | return; | ||
320 | } | ||
321 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, ASPEED_SOC_SDMC_BASE); | ||
322 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, sc->info->memmap[ASPEED_SDMC]); | ||
323 | |||
324 | /* Watch dog */ | ||
325 | for (i = 0; i < sc->info->wdts_num; i++) { | ||
326 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
327 | return; | ||
328 | } | ||
329 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, | ||
330 | - ASPEED_SOC_WDT_BASE + i * 0x20); | ||
331 | + sc->info->memmap[ASPEED_WDT] + i * 0x20); | ||
332 | } | ||
333 | |||
334 | /* Net */ | ||
335 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
336 | error_propagate(errp, err); | ||
337 | return; | ||
338 | } | ||
339 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, ASPEED_SOC_ETH1_BASE); | ||
340 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, | ||
341 | + sc->info->memmap[ASPEED_ETH1]); | ||
342 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, | ||
343 | aspeed_soc_get_irq(s, ASPEED_ETH1)); | ||
344 | } | ||
345 | -- | ||
346 | 2.20.1 | ||
347 | |||
348 | 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 |
Deleted patch | |||
---|---|---|---|
1 | From: Christian Svensson <bluecmd@google.com> | ||
2 | 1 | ||
3 | If the host decrements the counter register that results in a negative | ||
4 | delta. This is then passed to muldiv64 which only handles unsigned | ||
5 | numbers resulting in bogus results. | ||
6 | |||
7 | This fix ensures the delta being operated on is positive. | ||
8 | |||
9 | Test case: kexec a kernel using aspeed_timer and it will freeze on the | ||
10 | second bootup when the kernel initializes the timer. With this patch | ||
11 | that no longer happens and the timer appears to run OK. | ||
12 | |||
13 | Signed-off-by: Christian Svensson <bluecmd@google.com> | ||
14 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
15 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
16 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | ||
17 | Message-id: 20190618165311.27066-12-clg@kaod.org | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | --- | ||
20 | hw/timer/aspeed_timer.c | 6 +++++- | ||
21 | 1 file changed, 5 insertions(+), 1 deletion(-) | ||
22 | |||
23 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/hw/timer/aspeed_timer.c | ||
26 | +++ b/hw/timer/aspeed_timer.c | ||
27 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg, | ||
28 | int64_t delta = (int64_t) value - (int64_t) calculate_ticks(t, now); | ||
29 | uint32_t rate = calculate_rate(t); | ||
30 | |||
31 | - t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate); | ||
32 | + if (delta >= 0) { | ||
33 | + t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate); | ||
34 | + } else { | ||
35 | + t->start -= muldiv64(-delta, NANOSECONDS_PER_SECOND, rate); | ||
36 | + } | ||
37 | aspeed_timer_mod(t); | ||
38 | } | ||
39 | break; | ||
40 | -- | ||
41 | 2.20.1 | ||
42 | |||
43 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | It has never been used as far as I can tell from the git history. | ||
4 | |||
5 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
6 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
7 | Message-id: 20190618165311.27066-13-clg@kaod.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/arm/aspeed.c | 2 -- | ||
11 | 1 file changed, 2 deletions(-) | ||
12 | |||
13 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/arm/aspeed.c | ||
16 | +++ b/hw/arm/aspeed.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
18 | memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); | ||
19 | memory_region_add_subregion(get_system_memory(), | ||
20 | sc->info->memmap[ASPEED_SDRAM], &bmc->ram); | ||
21 | - object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram), | ||
22 | - &error_abort); | ||
23 | |||
24 | max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size", | ||
25 | &error_abort); | ||
26 | -- | ||
27 | 2.20.1 | ||
28 | |||
29 | diff view generated by jsdifflib |