1 | First pullreq for arm of the 4.1 series, since I'm back from | 1 | target-arm queue for softfreeze: this is quite big as I |
---|---|---|---|
2 | holiday now. This is mostly my M-profile FPU series and Philippe's | 2 | was on holiday last week, so this is all just sneaking in |
3 | devices.h cleanup. I have a pile of other patchsets to work through | 3 | under the wire. I particularly wanted to get Philippe's |
4 | in my to-review folder, but 42 patches is definitely quite | 4 | patches in before freeze as that sort of code-movement |
5 | big enough to send now... | 5 | patchset is painful to have to rebase. |
6 | 6 | ||
7 | thanks | 7 | thanks |
8 | -- PMM | 8 | -- PMM |
9 | 9 | ||
10 | The following changes since commit 413a99a92c13ec408dcf2adaa87918dc81e890c8: | 10 | The following changes since commit ae9108f8f0746ce64d02afb1a216153a50926132: |
11 | 11 | ||
12 | Add Nios II semihosting support. (2019-04-29 16:09:51 +0100) | 12 | Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-4.1-pull-request' into staging (2019-07-01 15:55:40 +0100) |
13 | 13 | ||
14 | are available in the Git repository at: | 14 | are available in the Git repository at: |
15 | 15 | ||
16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190429 | 16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190701 |
17 | 17 | ||
18 | for you to fetch changes up to 437cc27ddfded3bbab6afd5ac1761e0e195edba7: | 18 | for you to fetch changes up to 787a7e76c2e93a48c47b324fea592c9910a70483: |
19 | 19 | ||
20 | hw/devices: Move SMSC 91C111 declaration into a new header (2019-04-29 17:57:21 +0100) | 20 | target/arm: Declare some M-profile functions publicly (2019-07-01 17:29:01 +0100) |
21 | 21 | ||
22 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
23 | target-arm queue: | 23 | target-arm queue: |
24 | * remove "bag of random stuff" hw/devices.h header | 24 | * hw/arm/boot: fix direct kernel boot with initrd |
25 | * implement FPU for Cortex-M and enable it for Cortex-M4 and -M33 | 25 | * hw/arm/msf2-som: Exit when the cpu is not the expected one |
26 | * hw/dma: Compile the bcm2835_dma device as common object | 26 | * i.mx7: fix bugs in PCI controller needed to boot recent kernels |
27 | * configure: Remove --source-path option | 27 | * aspeed: add RTC device |
28 | * hw/ssi/xilinx_spips: Avoid variable length array | 28 | * aspeed: fix some timer device bugs |
29 | * hw/arm/smmuv3: Remove SMMUNotifierNode | 29 | * aspeed: add swift-bmc board |
30 | * aspeed: vic: Add support for legacy register interface | ||
31 | * aspeed: add aspeed-xdma device | ||
32 | * Add new sbsa-ref board for aarch64 | ||
33 | * target/arm: code refactoring in preparation for support of | ||
34 | compilation with TCG disabled | ||
30 | 35 | ||
31 | ---------------------------------------------------------------- | 36 | ---------------------------------------------------------------- |
32 | Eric Auger (1): | 37 | Adriana Kobylak (1): |
33 | hw/arm/smmuv3: Remove SMMUNotifierNode | 38 | aspeed: Add support for the swift-bmc board |
34 | 39 | ||
35 | Peter Maydell (28): | 40 | Andrew Jeffery (3): |
36 | hw/ssi/xilinx_spips: Avoid variable length array | 41 | aspeed/timer: Status register contains reload for stopped timer |
37 | configure: Remove --source-path option | 42 | aspeed/timer: Fix match calculations |
38 | target/arm: Make sure M-profile FPSCR RES0 bits are not settable | 43 | aspeed: vic: Add support for legacy register interface |
39 | hw/intc/armv7m_nvic: Allow reading of M-profile MVFR* registers | ||
40 | target/arm: Implement dummy versions of M-profile FP-related registers | ||
41 | target/arm: Disable most VFP sysregs for M-profile | ||
42 | target/arm: Honour M-profile FP enable bits | ||
43 | target/arm: Decode FP instructions for M profile | ||
44 | target/arm: Clear CONTROL_S.SFPA in SG insn if FPU present | ||
45 | target/arm: Handle SFPA and FPCA bits in reads and writes of CONTROL | ||
46 | target/arm/helper: don't return early for STKOF faults during stacking | ||
47 | target/arm: Handle floating point registers in exception entry | ||
48 | target/arm: Implement v7m_update_fpccr() | ||
49 | target/arm: Clear CONTROL.SFPA in BXNS and BLXNS | ||
50 | target/arm: Clean excReturn bits when tail chaining | ||
51 | target/arm: Allow for floating point in callee stack integrity check | ||
52 | target/arm: Handle floating point registers in exception return | ||
53 | target/arm: Move NS TBFLAG from bit 19 to bit 6 | ||
54 | target/arm: Overlap VECSTRIDE and XSCALE_CPAR TB flags | ||
55 | target/arm: Set FPCCR.S when executing M-profile floating point insns | ||
56 | target/arm: Activate M-profile floating point context when FPCCR.ASPEN is set | ||
57 | target/arm: New helper function arm_v7m_mmu_idx_all() | ||
58 | target/arm: New function armv7m_nvic_set_pending_lazyfp() | ||
59 | target/arm: Add lazy-FP-stacking support to v7m_stack_write() | ||
60 | target/arm: Implement M-profile lazy FP state preservation | ||
61 | target/arm: Implement VLSTM for v7M CPUs with an FPU | ||
62 | target/arm: Implement VLLDM for v7M CPUs with an FPU | ||
63 | target/arm: Enable FPU for Cortex-M4 and Cortex-M33 | ||
64 | 44 | ||
65 | Philippe Mathieu-Daudé (13): | 45 | Andrew Jones (1): |
66 | hw/dma: Compile the bcm2835_dma device as common object | 46 | hw/arm/boot: fix direct kernel boot with initrd |
67 | hw/arm/aspeed: Use TYPE_TMP105/TYPE_PCA9552 instead of hardcoded string | ||
68 | hw/arm/nseries: Use TYPE_TMP105 instead of hardcoded string | ||
69 | hw/display/tc6393xb: Remove unused functions | ||
70 | hw/devices: Move TC6393XB declarations into a new header | ||
71 | hw/devices: Move Blizzard declarations into a new header | ||
72 | hw/devices: Move CBus declarations into a new header | ||
73 | hw/devices: Move Gamepad declarations into a new header | ||
74 | hw/devices: Move TI touchscreen declarations into a new header | ||
75 | hw/devices: Move LAN9118 declarations into a new header | ||
76 | hw/net/ne2000-isa: Add guards to the header | ||
77 | hw/net/lan9118: Export TYPE_LAN9118 and use it instead of hardcoded string | ||
78 | hw/devices: Move SMSC 91C111 declaration into a new header | ||
79 | 47 | ||
80 | configure | 10 +- | 48 | Andrey Smirnov (5): |
81 | hw/dma/Makefile.objs | 2 +- | 49 | i.mx7d: Add no-op/unimplemented APBH DMA module |
82 | include/hw/arm/omap.h | 6 +- | 50 | i.mx7d: Add no-op/unimplemented PCIE PHY IP block |
83 | include/hw/arm/smmu-common.h | 8 +- | 51 | pci: designware: Update MSI mapping unconditionally |
84 | include/hw/devices.h | 62 --- | 52 | pci: designware: Update MSI mapping when MSI address changes |
85 | include/hw/display/blizzard.h | 22 ++ | 53 | i.mx7d: pci: Update PCI IRQ mapping to match HW |
86 | include/hw/display/tc6393xb.h | 24 ++ | ||
87 | include/hw/input/gamepad.h | 19 + | ||
88 | include/hw/input/tsc2xxx.h | 36 ++ | ||
89 | include/hw/misc/cbus.h | 32 ++ | ||
90 | include/hw/net/lan9118.h | 21 + | ||
91 | include/hw/net/ne2000-isa.h | 6 + | ||
92 | include/hw/net/smc91c111.h | 19 + | ||
93 | include/qemu/typedefs.h | 1 - | ||
94 | target/arm/cpu.h | 95 ++++- | ||
95 | target/arm/helper.h | 5 + | ||
96 | target/arm/translate.h | 3 + | ||
97 | hw/arm/aspeed.c | 13 +- | ||
98 | hw/arm/exynos4_boards.c | 3 +- | ||
99 | hw/arm/gumstix.c | 2 +- | ||
100 | hw/arm/integratorcp.c | 2 +- | ||
101 | hw/arm/kzm.c | 2 +- | ||
102 | hw/arm/mainstone.c | 2 +- | ||
103 | hw/arm/mps2-tz.c | 3 +- | ||
104 | hw/arm/mps2.c | 2 +- | ||
105 | hw/arm/nseries.c | 7 +- | ||
106 | hw/arm/palm.c | 2 +- | ||
107 | hw/arm/realview.c | 3 +- | ||
108 | hw/arm/smmu-common.c | 6 +- | ||
109 | hw/arm/smmuv3.c | 28 +- | ||
110 | hw/arm/stellaris.c | 2 +- | ||
111 | hw/arm/tosa.c | 2 +- | ||
112 | hw/arm/versatilepb.c | 2 +- | ||
113 | hw/arm/vexpress.c | 2 +- | ||
114 | hw/display/blizzard.c | 2 +- | ||
115 | hw/display/tc6393xb.c | 18 +- | ||
116 | hw/input/stellaris_input.c | 2 +- | ||
117 | hw/input/tsc2005.c | 2 +- | ||
118 | hw/input/tsc210x.c | 4 +- | ||
119 | hw/intc/armv7m_nvic.c | 261 +++++++++++++ | ||
120 | hw/misc/cbus.c | 2 +- | ||
121 | hw/net/lan9118.c | 3 +- | ||
122 | hw/net/smc91c111.c | 2 +- | ||
123 | hw/ssi/xilinx_spips.c | 6 +- | ||
124 | target/arm/cpu.c | 20 + | ||
125 | target/arm/helper.c | 873 +++++++++++++++++++++++++++++++++++++++--- | ||
126 | target/arm/machine.c | 16 + | ||
127 | target/arm/translate.c | 150 +++++++- | ||
128 | target/arm/vfp_helper.c | 8 + | ||
129 | MAINTAINERS | 7 + | ||
130 | 50 files changed, 1595 insertions(+), 235 deletions(-) | ||
131 | delete mode 100644 include/hw/devices.h | ||
132 | create mode 100644 include/hw/display/blizzard.h | ||
133 | create mode 100644 include/hw/display/tc6393xb.h | ||
134 | create mode 100644 include/hw/input/gamepad.h | ||
135 | create mode 100644 include/hw/input/tsc2xxx.h | ||
136 | create mode 100644 include/hw/misc/cbus.h | ||
137 | create mode 100644 include/hw/net/lan9118.h | ||
138 | create mode 100644 include/hw/net/smc91c111.h | ||
139 | 54 | ||
55 | Christian Svensson (1): | ||
56 | aspeed/timer: Ensure positive muldiv delta | ||
57 | |||
58 | Cédric Le Goater (7): | ||
59 | aspeed: add a per SoC mapping for the interrupt space | ||
60 | aspeed: add a per SoC mapping for the memory space | ||
61 | aspeed: introduce a configurable number of CPU per machine | ||
62 | aspeed: add support for multiple NICs | ||
63 | aspeed: remove the "ram" link | ||
64 | aspeed: add a RAM memory region container | ||
65 | aspeed/smc: add a 'sdram_base' property | ||
66 | |||
67 | Eddie James (1): | ||
68 | hw/misc/aspeed_xdma: New device | ||
69 | |||
70 | Hongbo Zhang (2): | ||
71 | hw/arm: Add arm SBSA reference machine, skeleton part | ||
72 | hw/arm: Add arm SBSA reference machine, devices part | ||
73 | |||
74 | Jan Kiszka (1): | ||
75 | hw/arm/virt: Add support for Cortex-A7 | ||
76 | |||
77 | Joel Stanley (4): | ||
78 | hw: timer: Add ASPEED RTC device | ||
79 | hw/arm/aspeed: Add RTC to SoC | ||
80 | aspeed/timer: Fix behaviour running Linux | ||
81 | aspeed: Link SCU to the watchdog | ||
82 | |||
83 | Philippe Mathieu-Daudé (19): | ||
84 | hw/arm/msf2-som: Exit when the cpu is not the expected one | ||
85 | target/arm: Makefile cleanup (Aarch64) | ||
86 | target/arm: Makefile cleanup (ARM) | ||
87 | target/arm: Makefile cleanup (KVM) | ||
88 | target/arm: Makefile cleanup (softmmu) | ||
89 | target/arm: Add copyright boilerplate | ||
90 | target/arm/helper: Remove unused include | ||
91 | target/arm: Fix multiline comment syntax | ||
92 | target/arm: Fix coding style issues | ||
93 | target/arm: Move CPU state dumping routines to cpu.c | ||
94 | target/arm: Declare get_phys_addr() function publicly | ||
95 | target/arm: Move TLB related routines to tlb_helper.c | ||
96 | target/arm/vfp_helper: Move code around | ||
97 | target/arm/vfp_helper: Extract vfp_set_fpscr_to_host() | ||
98 | target/arm/vfp_helper: Extract vfp_set_fpscr_from_host() | ||
99 | target/arm/vfp_helper: Restrict the SoftFloat use to TCG | ||
100 | target/arm: Restrict PSCI to TCG | ||
101 | target/arm: Declare arm_log_exception() function publicly | ||
102 | target/arm: Declare some M-profile functions publicly | ||
103 | |||
104 | Samuel Ortiz (1): | ||
105 | target/arm: Move the DC ZVA helper into op_helper | ||
106 | |||
107 | hw/arm/Makefile.objs | 1 + | ||
108 | hw/misc/Makefile.objs | 1 + | ||
109 | hw/timer/Makefile.objs | 2 +- | ||
110 | target/arm/Makefile.objs | 24 +- | ||
111 | include/hw/arm/aspeed_soc.h | 53 ++- | ||
112 | include/hw/arm/fsl-imx7.h | 14 +- | ||
113 | include/hw/misc/aspeed_xdma.h | 30 ++ | ||
114 | include/hw/ssi/aspeed_smc.h | 3 + | ||
115 | include/hw/timer/aspeed_rtc.h | 31 ++ | ||
116 | include/hw/watchdog/wdt_aspeed.h | 1 + | ||
117 | target/arm/cpu.h | 2 - | ||
118 | target/arm/internals.h | 69 ++- | ||
119 | target/arm/translate.h | 5 - | ||
120 | hw/arm/aspeed.c | 76 +++- | ||
121 | hw/arm/aspeed_soc.c | 262 +++++++++--- | ||
122 | hw/arm/boot.c | 3 +- | ||
123 | hw/arm/fsl-imx7.c | 11 + | ||
124 | hw/arm/msf2-som.c | 1 + | ||
125 | hw/arm/sbsa-ref.c | 806 ++++++++++++++++++++++++++++++++++++ | ||
126 | hw/arm/virt.c | 1 + | ||
127 | hw/intc/aspeed_vic.c | 105 +++-- | ||
128 | hw/misc/aspeed_xdma.c | 165 ++++++++ | ||
129 | hw/pci-host/designware.c | 18 +- | ||
130 | hw/ssi/aspeed_smc.c | 1 + | ||
131 | hw/timer/aspeed_rtc.c | 180 ++++++++ | ||
132 | hw/timer/aspeed_timer.c | 76 ++-- | ||
133 | hw/watchdog/wdt_aspeed.c | 20 + | ||
134 | target/arm/cpu.c | 232 ++++++++++- | ||
135 | target/arm/helper.c | 498 +++++++++------------- | ||
136 | target/arm/op_helper.c | 262 ++++++------ | ||
137 | target/arm/tlb_helper.c | 200 +++++++++ | ||
138 | target/arm/translate-a64.c | 128 ------ | ||
139 | target/arm/translate.c | 91 +--- | ||
140 | target/arm/vfp_helper.c | 199 +++++---- | ||
141 | MAINTAINERS | 8 + | ||
142 | default-configs/aarch64-softmmu.mak | 1 + | ||
143 | hw/arm/Kconfig | 14 + | ||
144 | hw/misc/trace-events | 3 + | ||
145 | hw/timer/trace-events | 4 + | ||
146 | 39 files changed, 2675 insertions(+), 926 deletions(-) | ||
147 | create mode 100644 include/hw/misc/aspeed_xdma.h | ||
148 | create mode 100644 include/hw/timer/aspeed_rtc.h | ||
149 | create mode 100644 hw/arm/sbsa-ref.c | ||
150 | create mode 100644 hw/misc/aspeed_xdma.c | ||
151 | create mode 100644 hw/timer/aspeed_rtc.c | ||
152 | create mode 100644 target/arm/tlb_helper.c | ||
153 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Andrew Jones <drjones@redhat.com> | ||
1 | 2 | ||
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: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | This commit finally deletes "hw/devices.h". | 3 | This machine correctly defines its default_cpu_type to cortex-m3 |
4 | and report an error if the user requested another cpu_type, | ||
5 | however it does not exit, and this can confuse users trying | ||
6 | to use another core: | ||
4 | 7 | ||
5 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 8 | $ qemu-system-arm -M emcraft-sf2 -cpu cortex-m4 -kernel test-m4.elf |
9 | qemu-system-arm: This board can only be used with CPU cortex-m3-arm-cpu | ||
10 | [output related to M3 core ...] | ||
11 | |||
12 | The CPU is indeed a M3 core: | ||
13 | |||
14 | (qemu) info qom-tree | ||
15 | /machine (emcraft-sf2-machine) | ||
16 | /unattached (container) | ||
17 | /device[0] (msf2-soc) | ||
18 | /armv7m (armv7m) | ||
19 | /cpu (cortex-m3-arm-cpu) | ||
20 | |||
21 | Add the missing exit() call to return to the shell. | ||
22 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 23 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
7 | Message-id: 20190412165416.7977-13-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 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 28 | --- |
10 | include/hw/devices.h | 11 ----------- | 29 | hw/arm/msf2-som.c | 1 + |
11 | include/hw/net/smc91c111.h | 19 +++++++++++++++++++ | 30 | 1 file changed, 1 insertion(+) |
12 | hw/arm/gumstix.c | 2 +- | ||
13 | hw/arm/integratorcp.c | 2 +- | ||
14 | hw/arm/mainstone.c | 2 +- | ||
15 | hw/arm/realview.c | 2 +- | ||
16 | hw/arm/versatilepb.c | 2 +- | ||
17 | hw/net/smc91c111.c | 2 +- | ||
18 | 8 files changed, 25 insertions(+), 17 deletions(-) | ||
19 | delete mode 100644 include/hw/devices.h | ||
20 | create mode 100644 include/hw/net/smc91c111.h | ||
21 | 31 | ||
22 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 32 | diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c |
23 | deleted file mode 100644 | ||
24 | index XXXXXXX..XXXXXXX | ||
25 | --- a/include/hw/devices.h | ||
26 | +++ /dev/null | ||
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | -#ifndef QEMU_DEVICES_H | ||
29 | -#define QEMU_DEVICES_H | ||
30 | - | ||
31 | -/* Devices that have nowhere better to go. */ | ||
32 | - | ||
33 | -#include "hw/hw.h" | ||
34 | - | ||
35 | -/* smc91c111.c */ | ||
36 | -void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | ||
37 | - | ||
38 | -#endif | ||
39 | diff --git a/include/hw/net/smc91c111.h b/include/hw/net/smc91c111.h | ||
40 | new file mode 100644 | ||
41 | index XXXXXXX..XXXXXXX | ||
42 | --- /dev/null | ||
43 | +++ b/include/hw/net/smc91c111.h | ||
44 | @@ -XXX,XX +XXX,XX @@ | ||
45 | +/* | ||
46 | + * SMSC 91C111 Ethernet interface emulation | ||
47 | + * | ||
48 | + * Copyright (c) 2005 CodeSourcery, LLC. | ||
49 | + * Written by Paul Brook | ||
50 | + * | ||
51 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
52 | + * See the COPYING file in the top-level directory. | ||
53 | + */ | ||
54 | + | ||
55 | +#ifndef HW_NET_SMC91C111_H | ||
56 | +#define HW_NET_SMC91C111_H | ||
57 | + | ||
58 | +#include "hw/irq.h" | ||
59 | +#include "net/net.h" | ||
60 | + | ||
61 | +void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | ||
62 | + | ||
63 | +#endif | ||
64 | diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
66 | --- a/hw/arm/gumstix.c | 34 | --- a/hw/arm/msf2-som.c |
67 | +++ b/hw/arm/gumstix.c | 35 | +++ b/hw/arm/msf2-som.c |
68 | @@ -XXX,XX +XXX,XX @@ | 36 | @@ -XXX,XX +XXX,XX @@ static void emcraft_sf2_s2s010_init(MachineState *machine) |
69 | #include "hw/arm/pxa.h" | 37 | if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) { |
70 | #include "net/net.h" | 38 | error_report("This board can only be used with CPU %s", |
71 | #include "hw/block/flash.h" | 39 | mc->default_cpu_type); |
72 | -#include "hw/devices.h" | 40 | + exit(1); |
73 | +#include "hw/net/smc91c111.h" | 41 | } |
74 | #include "hw/boards.h" | 42 | |
75 | #include "exec/address-spaces.h" | 43 | memory_region_init_ram(ddr, NULL, "ddr-ram", DDR_SIZE, |
76 | #include "sysemu/qtest.h" | ||
77 | diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/hw/arm/integratorcp.c | ||
80 | +++ b/hw/arm/integratorcp.c | ||
81 | @@ -XXX,XX +XXX,XX @@ | ||
82 | #include "qemu-common.h" | ||
83 | #include "cpu.h" | ||
84 | #include "hw/sysbus.h" | ||
85 | -#include "hw/devices.h" | ||
86 | #include "hw/boards.h" | ||
87 | #include "hw/arm/arm.h" | ||
88 | #include "hw/misc/arm_integrator_debug.h" | ||
89 | +#include "hw/net/smc91c111.h" | ||
90 | #include "net/net.h" | ||
91 | #include "exec/address-spaces.h" | ||
92 | #include "sysemu/sysemu.h" | ||
93 | diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/hw/arm/mainstone.c | ||
96 | +++ b/hw/arm/mainstone.c | ||
97 | @@ -XXX,XX +XXX,XX @@ | ||
98 | #include "hw/arm/pxa.h" | ||
99 | #include "hw/arm/arm.h" | ||
100 | #include "net/net.h" | ||
101 | -#include "hw/devices.h" | ||
102 | +#include "hw/net/smc91c111.h" | ||
103 | #include "hw/boards.h" | ||
104 | #include "hw/block/flash.h" | ||
105 | #include "hw/sysbus.h" | ||
106 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/hw/arm/realview.c | ||
109 | +++ b/hw/arm/realview.c | ||
110 | @@ -XXX,XX +XXX,XX @@ | ||
111 | #include "hw/sysbus.h" | ||
112 | #include "hw/arm/arm.h" | ||
113 | #include "hw/arm/primecell.h" | ||
114 | -#include "hw/devices.h" | ||
115 | #include "hw/net/lan9118.h" | ||
116 | +#include "hw/net/smc91c111.h" | ||
117 | #include "hw/pci/pci.h" | ||
118 | #include "net/net.h" | ||
119 | #include "sysemu/sysemu.h" | ||
120 | diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c | ||
121 | index XXXXXXX..XXXXXXX 100644 | ||
122 | --- a/hw/arm/versatilepb.c | ||
123 | +++ b/hw/arm/versatilepb.c | ||
124 | @@ -XXX,XX +XXX,XX @@ | ||
125 | #include "cpu.h" | ||
126 | #include "hw/sysbus.h" | ||
127 | #include "hw/arm/arm.h" | ||
128 | -#include "hw/devices.h" | ||
129 | +#include "hw/net/smc91c111.h" | ||
130 | #include "net/net.h" | ||
131 | #include "sysemu/sysemu.h" | ||
132 | #include "hw/pci/pci.h" | ||
133 | diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c | ||
134 | index XXXXXXX..XXXXXXX 100644 | ||
135 | --- a/hw/net/smc91c111.c | ||
136 | +++ b/hw/net/smc91c111.c | ||
137 | @@ -XXX,XX +XXX,XX @@ | ||
138 | #include "qemu/osdep.h" | ||
139 | #include "hw/sysbus.h" | ||
140 | #include "net/net.h" | ||
141 | -#include "hw/devices.h" | ||
142 | +#include "hw/net/smc91c111.h" | ||
143 | #include "qemu/log.h" | ||
144 | /* For crc32 */ | ||
145 | #include <zlib.h> | ||
146 | -- | 44 | -- |
147 | 2.20.1 | 45 | 2.20.1 |
148 | 46 | ||
149 | 47 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jan Kiszka <jan.kiszka@siemens.com> | ||
1 | 2 | ||
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 |
1 | Implement the code which updates the FPCCR register on an | 1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> |
---|---|---|---|
2 | exception entry where we are going to use lazy FP stacking. | ||
3 | We have to defer to the NVIC to determine whether the | ||
4 | various exceptions are currently ready or not. | ||
5 | 2 | ||
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 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Message-id: 20190416125744.27770-12-peter.maydell@linaro.org | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 12 | --- |
9 | target/arm/cpu.h | 14 +++++++++ | 13 | include/hw/arm/fsl-imx7.h | 3 +++ |
10 | hw/intc/armv7m_nvic.c | 34 ++++++++++++++++++++++ | 14 | hw/arm/fsl-imx7.c | 6 ++++++ |
11 | target/arm/helper.c | 67 ++++++++++++++++++++++++++++++++++++++++++- | 15 | 2 files changed, 9 insertions(+) |
12 | 3 files changed, 114 insertions(+), 1 deletion(-) | ||
13 | 16 | ||
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 17 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.h | 19 | --- a/include/hw/arm/fsl-imx7.h |
17 | +++ b/target/arm/cpu.h | 20 | +++ b/include/hw/arm/fsl-imx7.h |
18 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque); | 21 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { |
19 | * (Ignoring -1, this is the same as the RETTOBASE value before completion.) | 22 | FSL_IMX7_PCIE_REG_SIZE = 16 * 1024, |
20 | */ | 23 | |
21 | int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure); | 24 | FSL_IMX7_GPR_ADDR = 0x30340000, |
22 | +/** | 25 | + |
23 | + * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) | 26 | + FSL_IMX7_DMA_APBH_ADDR = 0x33000000, |
24 | + * @opaque: the NVIC | 27 | + FSL_IMX7_DMA_APBH_SIZE = 0x2000, |
25 | + * @irq: the exception number to mark pending | 28 | }; |
26 | + * @secure: false for non-banked exceptions or for the nonsecure | 29 | |
27 | + * version of a banked exception, true for the secure version of a banked | 30 | enum FslIMX7IRQs { |
28 | + * exception. | 31 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c |
29 | + * | ||
30 | + * Return whether an exception is "ready", i.e. whether the exception is | ||
31 | + * enabled and is configured at a priority which would allow it to | ||
32 | + * interrupt the current execution priority. This controls whether the | ||
33 | + * RDY bit for it in the FPCCR is set. | ||
34 | + */ | ||
35 | +bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure); | ||
36 | /** | ||
37 | * armv7m_nvic_raw_execution_priority: return the raw execution priority | ||
38 | * @opaque: the NVIC | ||
39 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/hw/intc/armv7m_nvic.c | 33 | --- a/hw/arm/fsl-imx7.c |
42 | +++ b/hw/intc/armv7m_nvic.c | 34 | +++ b/hw/arm/fsl-imx7.c |
43 | @@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure) | 35 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) |
44 | return ret; | 36 | */ |
45 | } | 37 | create_unimplemented_device("lcdif", FSL_IMX7_LCDIF_ADDR, |
46 | 38 | FSL_IMX7_LCDIF_SIZE); | |
47 | +bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) | ||
48 | +{ | ||
49 | + /* | ||
50 | + * Return whether an exception is "ready", i.e. it is enabled and is | ||
51 | + * configured at a priority which would allow it to interrupt the | ||
52 | + * current execution priority. | ||
53 | + * | ||
54 | + * irq and secure have the same semantics as for armv7m_nvic_set_pending(): | ||
55 | + * for non-banked exceptions secure is always false; for banked exceptions | ||
56 | + * it indicates which of the exceptions is required. | ||
57 | + */ | ||
58 | + NVICState *s = (NVICState *)opaque; | ||
59 | + bool banked = exc_is_banked(irq); | ||
60 | + VecInfo *vec; | ||
61 | + int running = nvic_exec_prio(s); | ||
62 | + | ||
63 | + assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq); | ||
64 | + assert(!secure || banked); | ||
65 | + | 39 | + |
66 | + /* | 40 | + /* |
67 | + * HardFault is an odd special case: we always check against -1, | 41 | + * DMA APBH |
68 | + * even if we're secure and HardFault has priority -3; we never | ||
69 | + * need to check for enabled state. | ||
70 | + */ | 42 | + */ |
71 | + if (irq == ARMV7M_EXCP_HARD) { | 43 | + create_unimplemented_device("dma-apbh", FSL_IMX7_DMA_APBH_ADDR, |
72 | + return running > -1; | 44 | + FSL_IMX7_DMA_APBH_SIZE); |
73 | + } | ||
74 | + | ||
75 | + vec = (banked && secure) ? &s->sec_vectors[irq] : &s->vectors[irq]; | ||
76 | + | ||
77 | + return vec->enabled && | ||
78 | + exc_group_prio(s, vec->prio, secure) < running; | ||
79 | +} | ||
80 | + | ||
81 | /* callback when external interrupt line is changed */ | ||
82 | static void set_irq_level(void *opaque, int n, int level) | ||
83 | { | ||
84 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/target/arm/helper.c | ||
87 | +++ b/target/arm/helper.c | ||
88 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
89 | env->thumb = addr & 1; | ||
90 | } | 45 | } |
91 | 46 | ||
92 | +static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr, | 47 | static void fsl_imx7_class_init(ObjectClass *oc, void *data) |
93 | + bool apply_splim) | ||
94 | +{ | ||
95 | + /* | ||
96 | + * Like the pseudocode UpdateFPCCR: save state in FPCAR and FPCCR | ||
97 | + * that we will need later in order to do lazy FP reg stacking. | ||
98 | + */ | ||
99 | + bool is_secure = env->v7m.secure; | ||
100 | + void *nvic = env->nvic; | ||
101 | + /* | ||
102 | + * Some bits are unbanked and live always in fpccr[M_REG_S]; some bits | ||
103 | + * are banked and we want to update the bit in the bank for the | ||
104 | + * current security state; and in one case we want to specifically | ||
105 | + * update the NS banked version of a bit even if we are secure. | ||
106 | + */ | ||
107 | + uint32_t *fpccr_s = &env->v7m.fpccr[M_REG_S]; | ||
108 | + uint32_t *fpccr_ns = &env->v7m.fpccr[M_REG_NS]; | ||
109 | + uint32_t *fpccr = &env->v7m.fpccr[is_secure]; | ||
110 | + bool hfrdy, bfrdy, mmrdy, ns_ufrdy, s_ufrdy, sfrdy, monrdy; | ||
111 | + | ||
112 | + env->v7m.fpcar[is_secure] = frameptr & ~0x7; | ||
113 | + | ||
114 | + if (apply_splim && arm_feature(env, ARM_FEATURE_V8)) { | ||
115 | + bool splimviol; | ||
116 | + uint32_t splim = v7m_sp_limit(env); | ||
117 | + bool ign = armv7m_nvic_neg_prio_requested(nvic, is_secure) && | ||
118 | + (env->v7m.ccr[is_secure] & R_V7M_CCR_STKOFHFNMIGN_MASK); | ||
119 | + | ||
120 | + splimviol = !ign && frameptr < splim; | ||
121 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, SPLIMVIOL, splimviol); | ||
122 | + } | ||
123 | + | ||
124 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, LSPACT, 1); | ||
125 | + | ||
126 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, S, is_secure); | ||
127 | + | ||
128 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, USER, arm_current_el(env) == 0); | ||
129 | + | ||
130 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, THREAD, | ||
131 | + !arm_v7m_is_handler_mode(env)); | ||
132 | + | ||
133 | + hfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_HARD, false); | ||
134 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, HFRDY, hfrdy); | ||
135 | + | ||
136 | + bfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_BUS, false); | ||
137 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, BFRDY, bfrdy); | ||
138 | + | ||
139 | + mmrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_MEM, is_secure); | ||
140 | + *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, MMRDY, mmrdy); | ||
141 | + | ||
142 | + ns_ufrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_USAGE, false); | ||
143 | + *fpccr_ns = FIELD_DP32(*fpccr_ns, V7M_FPCCR, UFRDY, ns_ufrdy); | ||
144 | + | ||
145 | + monrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_DEBUG, false); | ||
146 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, MONRDY, monrdy); | ||
147 | + | ||
148 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
149 | + s_ufrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_USAGE, true); | ||
150 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, UFRDY, s_ufrdy); | ||
151 | + | ||
152 | + sfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_SECURE, false); | ||
153 | + *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, SFRDY, sfrdy); | ||
154 | + } | ||
155 | +} | ||
156 | + | ||
157 | static bool v7m_push_stack(ARMCPU *cpu) | ||
158 | { | ||
159 | /* Do the "set up stack frame" part of exception entry, | ||
160 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
161 | } | ||
162 | } else { | ||
163 | /* Lazy stacking enabled, save necessary info to stack later */ | ||
164 | - /* TODO : equivalent of UpdateFPCCR() pseudocode */ | ||
165 | + v7m_update_fpccr(env, frameptr + 0x20, true); | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | -- | 48 | -- |
170 | 2.20.1 | 49 | 2.20.1 |
171 | 50 | ||
172 | 51 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
1 | 2 | ||
3 | Add no-op/unimplemented PCIE PHY IP block. Needed by new kernels to | ||
4 | use PCIE. | ||
5 | |||
6 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
7 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Cc: Michael S. Tsirkin <mst@redhat.com> | ||
9 | Cc: qemu-devel@nongnu.org | ||
10 | Cc: qemu-arm@nongnu.org | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | include/hw/arm/fsl-imx7.h | 3 +++ | ||
15 | hw/arm/fsl-imx7.c | 5 +++++ | ||
16 | 2 files changed, 8 insertions(+) | ||
17 | |||
18 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/include/hw/arm/fsl-imx7.h | ||
21 | +++ b/include/hw/arm/fsl-imx7.h | ||
22 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { | ||
23 | FSL_IMX7_ADC2_ADDR = 0x30620000, | ||
24 | FSL_IMX7_ADCn_SIZE = 0x1000, | ||
25 | |||
26 | + FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000, | ||
27 | + FSL_IMX7_PCIE_PHY_SIZE = 0x10000, | ||
28 | + | ||
29 | FSL_IMX7_GPC_ADDR = 0x303A0000, | ||
30 | |||
31 | FSL_IMX7_I2C1_ADDR = 0x30A20000, | ||
32 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/hw/arm/fsl-imx7.c | ||
35 | +++ b/hw/arm/fsl-imx7.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
37 | */ | ||
38 | create_unimplemented_device("dma-apbh", FSL_IMX7_DMA_APBH_ADDR, | ||
39 | FSL_IMX7_DMA_APBH_SIZE); | ||
40 | + /* | ||
41 | + * PCIe PHY | ||
42 | + */ | ||
43 | + create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR, | ||
44 | + FSL_IMX7_PCIE_PHY_SIZE); | ||
45 | } | ||
46 | |||
47 | static void fsl_imx7_class_init(ObjectClass *oc, void *data) | ||
48 | -- | ||
49 | 2.20.1 | ||
50 | |||
51 | diff view generated by jsdifflib |
1 | Normally configure identifies the source path by looking | 1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> |
---|---|---|---|
2 | at the location where the configure script itself exists. | ||
3 | We also provide a --source-path option which lets the user | ||
4 | manually override this. | ||
5 | 2 | ||
6 | There isn't really an obvious use case for the --source-path | 3 | Expression to calculate update_msi_mapping in code handling writes to |
7 | option, and in commit 927128222b0a91f56c13a in 2017 we | 4 | DESIGNWARE_PCIE_MSI_INTR0_ENABLE is missing an ! operator and should |
8 | accidentally added some logic that looks at $source_path | 5 | be: |
9 | before the command line option that overrides it has been | ||
10 | processed. | ||
11 | 6 | ||
12 | The fact that nobody complained suggests that there isn't | 7 | !!root->msi.intr[0].enable ^ !!val; |
13 | any use of this option and we aren't testing it either; | ||
14 | remove it. This allows us to move the "make $source_path | ||
15 | absolute" logic up so that there is no window in the script | ||
16 | where $source_path is set but not yet absolute. | ||
17 | 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> | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
20 | Message-id: 20190318134019.23729-1-peter.maydell@linaro.org | ||
21 | --- | 22 | --- |
22 | configure | 10 ++-------- | 23 | hw/pci-host/designware.c | 10 ++-------- |
23 | 1 file changed, 2 insertions(+), 8 deletions(-) | 24 | 1 file changed, 2 insertions(+), 8 deletions(-) |
24 | 25 | ||
25 | diff --git a/configure b/configure | 26 | diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c |
26 | index XXXXXXX..XXXXXXX 100755 | 27 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/configure | 28 | --- a/hw/pci-host/designware.c |
28 | +++ b/configure | 29 | +++ b/hw/pci-host/designware.c |
29 | @@ -XXX,XX +XXX,XX @@ ld_has() { | 30 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, |
30 | 31 | root->msi.base |= (uint64_t)val << 32; | |
31 | # default parameters | 32 | break; |
32 | source_path=$(dirname "$0") | 33 | |
33 | +# make source path absolute | 34 | - case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: { |
34 | +source_path=$(cd "$source_path"; pwd) | 35 | - const bool update_msi_mapping = !root->msi.intr[0].enable ^ !!val; |
35 | cpu="" | ||
36 | iasl="iasl" | ||
37 | interp_prefix="/usr/gnemul/qemu-%M" | ||
38 | @@ -XXX,XX +XXX,XX @@ for opt do | ||
39 | ;; | ||
40 | --cxx=*) CXX="$optarg" | ||
41 | ;; | ||
42 | - --source-path=*) source_path="$optarg" | ||
43 | - ;; | ||
44 | --cpu=*) cpu="$optarg" | ||
45 | ;; | ||
46 | --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg" | ||
47 | @@ -XXX,XX +XXX,XX @@ if test "$debug_info" = "yes"; then | ||
48 | LDFLAGS="-g $LDFLAGS" | ||
49 | fi | ||
50 | |||
51 | -# make source path absolute | ||
52 | -source_path=$(cd "$source_path"; pwd) | ||
53 | - | 36 | - |
54 | # running configure in the source tree? | 37 | + case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: |
55 | # we know that's the case if configure is there. | 38 | root->msi.intr[0].enable = val; |
56 | if test -f "./configure"; then | 39 | - |
57 | @@ -XXX,XX +XXX,XX @@ for opt do | 40 | - if (update_msi_mapping) { |
58 | ;; | 41 | - designware_pcie_root_update_msi_mapping(root); |
59 | --interp-prefix=*) interp_prefix="$optarg" | 42 | - } |
60 | ;; | 43 | + designware_pcie_root_update_msi_mapping(root); |
61 | - --source-path=*) | 44 | break; |
62 | - ;; | 45 | - } |
63 | --cross-prefix=*) | 46 | |
64 | ;; | 47 | case DESIGNWARE_PCIE_MSI_INTR0_MASK: |
65 | --cc=*) | 48 | root->msi.intr[0].mask = val; |
66 | @@ -XXX,XX +XXX,XX @@ $(echo Available targets: $default_target_list | \ | ||
67 | --target-list-exclude=LIST exclude a set of targets from the default target-list | ||
68 | |||
69 | Advanced options (experts only): | ||
70 | - --source-path=PATH path of source code [$source_path] | ||
71 | --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix] | ||
72 | --cc=CC use C compiler CC [$cc] | ||
73 | --iasl=IASL use ACPI compiler IASL [$iasl] | ||
74 | -- | 49 | -- |
75 | 2.20.1 | 50 | 2.20.1 |
76 | 51 | ||
77 | 52 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
1 | 2 | ||
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: Eric Auger <eric.auger@redhat.com> | 1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | The SMMUNotifierNode struct is not necessary and brings extra | 3 | Datasheet for i.MX7 is incorrect and i.MX7's PCI IRQ mapping matches |
4 | complexity so let's remove it. We now directly track the SMMUDevices | 4 | that of i.MX6: |
5 | which have registered IOMMU MR notifiers. | ||
6 | 5 | ||
7 | This is inspired from the same transformation on intel-iommu | 6 | * INTD/MSI 122 |
8 | done in commit b4a4ba0d68f50f218ee3957b6638dbee32a5eeef | 7 | * INTC 123 |
9 | ("intel-iommu: remove IntelIOMMUNotifierNode") | 8 | * INTB 124 |
9 | * INTA 125 | ||
10 | 10 | ||
11 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 11 | Fix all of the relevant code to reflect that fact. Needed by latest |
12 | Reviewed-by: Peter Xu <peterx@redhat.com> | 12 | Linux kernels. |
13 | Message-id: 20190409160219.19026-1-eric.auger@redhat.com | 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] | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 26 | --- |
16 | include/hw/arm/smmu-common.h | 8 ++------ | 27 | include/hw/arm/fsl-imx7.h | 8 ++++---- |
17 | hw/arm/smmu-common.c | 6 +++--- | 28 | hw/pci-host/designware.c | 6 ++++-- |
18 | hw/arm/smmuv3.c | 28 +++++++--------------------- | 29 | 2 files changed, 8 insertions(+), 6 deletions(-) |
19 | 3 files changed, 12 insertions(+), 30 deletions(-) | ||
20 | 30 | ||
21 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h | 31 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
22 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/include/hw/arm/smmu-common.h | 33 | --- a/include/hw/arm/fsl-imx7.h |
24 | +++ b/include/hw/arm/smmu-common.h | 34 | +++ b/include/hw/arm/fsl-imx7.h |
25 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUDevice { | 35 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7IRQs { |
26 | AddressSpace as; | 36 | FSL_IMX7_USB2_IRQ = 42, |
27 | uint32_t cfg_cache_hits; | 37 | FSL_IMX7_USB3_IRQ = 40, |
28 | uint32_t cfg_cache_misses; | 38 | |
29 | + QLIST_ENTRY(SMMUDevice) next; | 39 | - FSL_IMX7_PCI_INTA_IRQ = 122, |
30 | } SMMUDevice; | 40 | - FSL_IMX7_PCI_INTB_IRQ = 123, |
31 | 41 | - FSL_IMX7_PCI_INTC_IRQ = 124, | |
32 | -typedef struct SMMUNotifierNode { | 42 | - FSL_IMX7_PCI_INTD_IRQ = 125, |
33 | - SMMUDevice *sdev; | 43 | + FSL_IMX7_PCI_INTA_IRQ = 125, |
34 | - QLIST_ENTRY(SMMUNotifierNode) next; | 44 | + FSL_IMX7_PCI_INTB_IRQ = 124, |
35 | -} SMMUNotifierNode; | 45 | + FSL_IMX7_PCI_INTC_IRQ = 123, |
36 | - | 46 | + FSL_IMX7_PCI_INTD_IRQ = 122, |
37 | typedef struct SMMUPciBus { | 47 | |
38 | PCIBus *bus; | 48 | FSL_IMX7_UART7_IRQ = 126, |
39 | SMMUDevice *pbdev[0]; /* Parent array is sparse, so dynamically alloc */ | 49 | |
40 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUState { | 50 | diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c |
41 | GHashTable *iotlb; | ||
42 | SMMUPciBus *smmu_pcibus_by_bus_num[SMMU_PCI_BUS_MAX]; | ||
43 | PCIBus *pci_bus; | ||
44 | - QLIST_HEAD(, SMMUNotifierNode) notifiers_list; | ||
45 | + QLIST_HEAD(, SMMUDevice) devices_with_notifiers; | ||
46 | uint8_t bus_num; | ||
47 | PCIBus *primary_bus; | ||
48 | } SMMUState; | ||
49 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | 51 | index XXXXXXX..XXXXXXX 100644 |
51 | --- a/hw/arm/smmu-common.c | 52 | --- a/hw/pci-host/designware.c |
52 | +++ b/hw/arm/smmu-common.c | 53 | +++ b/hw/pci-host/designware.c |
53 | @@ -XXX,XX +XXX,XX @@ inline void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr) | 54 | @@ -XXX,XX +XXX,XX @@ |
54 | /* Unmap all notifiers of all mr's */ | 55 | #define DESIGNWARE_PCIE_ATU_DEVFN(x) (((x) >> 16) & 0xff) |
55 | void smmu_inv_notifiers_all(SMMUState *s) | 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) | ||
56 | { | 62 | { |
57 | - SMMUNotifierNode *node; | 63 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_msi_write(void *opaque, hwaddr addr, |
58 | + SMMUDevice *sdev; | 64 | root->msi.intr[0].status |= BIT(val) & root->msi.intr[0].enable; |
59 | 65 | ||
60 | - QLIST_FOREACH(node, &s->notifiers_list, next) { | 66 | if (root->msi.intr[0].status & ~root->msi.intr[0].mask) { |
61 | - smmu_inv_notifiers_mr(&node->sdev->iommu); | 67 | - qemu_set_irq(host->pci.irqs[0], 1); |
62 | + QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) { | 68 | + qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 1); |
63 | + smmu_inv_notifiers_mr(&sdev->iommu); | ||
64 | } | 69 | } |
65 | } | 70 | } |
66 | 71 | ||
67 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | 72 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, |
68 | index XXXXXXX..XXXXXXX 100644 | 73 | case DESIGNWARE_PCIE_MSI_INTR0_STATUS: |
69 | --- a/hw/arm/smmuv3.c | 74 | root->msi.intr[0].status ^= val; |
70 | +++ b/hw/arm/smmuv3.c | 75 | if (!root->msi.intr[0].status) { |
71 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, | 76 | - qemu_set_irq(host->pci.irqs[0], 0); |
72 | /* invalidate an asid/iova tuple in all mr's */ | 77 | + qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 0); |
73 | static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova) | 78 | } |
74 | { | 79 | break; |
75 | - SMMUNotifierNode *node; | ||
76 | + SMMUDevice *sdev; | ||
77 | |||
78 | - QLIST_FOREACH(node, &s->notifiers_list, next) { | ||
79 | - IOMMUMemoryRegion *mr = &node->sdev->iommu; | ||
80 | + QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) { | ||
81 | + IOMMUMemoryRegion *mr = &sdev->iommu; | ||
82 | IOMMUNotifier *n; | ||
83 | |||
84 | trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, iova); | ||
85 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, | ||
86 | SMMUDevice *sdev = container_of(iommu, SMMUDevice, iommu); | ||
87 | SMMUv3State *s3 = sdev->smmu; | ||
88 | SMMUState *s = &(s3->smmu_state); | ||
89 | - SMMUNotifierNode *node = NULL; | ||
90 | - SMMUNotifierNode *next_node = NULL; | ||
91 | |||
92 | if (new & IOMMU_NOTIFIER_MAP) { | ||
93 | int bus_num = pci_bus_num(sdev->bus); | ||
94 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, | ||
95 | |||
96 | if (old == IOMMU_NOTIFIER_NONE) { | ||
97 | trace_smmuv3_notify_flag_add(iommu->parent_obj.name); | ||
98 | - node = g_malloc0(sizeof(*node)); | ||
99 | - node->sdev = sdev; | ||
100 | - QLIST_INSERT_HEAD(&s->notifiers_list, node, next); | ||
101 | - return; | ||
102 | - } | ||
103 | - | ||
104 | - /* update notifier node with new flags */ | ||
105 | - QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) { | ||
106 | - if (node->sdev == sdev) { | ||
107 | - if (new == IOMMU_NOTIFIER_NONE) { | ||
108 | - trace_smmuv3_notify_flag_del(iommu->parent_obj.name); | ||
109 | - QLIST_REMOVE(node, next); | ||
110 | - g_free(node); | ||
111 | - } | ||
112 | - return; | ||
113 | - } | ||
114 | + QLIST_INSERT_HEAD(&s->devices_with_notifiers, sdev, next); | ||
115 | + } else if (new == IOMMU_NOTIFIER_NONE) { | ||
116 | + trace_smmuv3_notify_flag_del(iommu->parent_obj.name); | ||
117 | + QLIST_REMOVE(sdev, next); | ||
118 | } | ||
119 | } | ||
120 | 80 | ||
121 | -- | 81 | -- |
122 | 2.20.1 | 82 | 2.20.1 |
123 | 83 | ||
124 | 84 | diff view generated by jsdifflib |
1 | Pushing registers to the stack for v7M needs to handle three cases: | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | * the "normal" case where we pend exceptions | 2 | |
3 | * an "ignore faults" case where we set FSR bits but | 3 | This will simplify the definition of new SoCs, like the AST2600 which |
4 | do not pend exceptions (this is used when we are | 4 | should use a different CPU and a different IRQ number layout. |
5 | handling some kinds of derived exception on exception entry) | 5 | |
6 | * a "lazy FP stacking" case, where different FSR bits | 6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
7 | are set and the exception is pended differently | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
8 | 8 | Reviewed-by: Joel Stanley <joel@jms.id.au> | |
9 | Implement this by changing the existing flag argument that | 9 | Message-id: 20190618165311.27066-2-clg@kaod.org |
10 | tells us whether to ignore faults or not into an enum that | ||
11 | specifies which of the 3 modes we should handle. | ||
12 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20190416125744.27770-23-peter.maydell@linaro.org | ||
16 | --- | 11 | --- |
17 | target/arm/helper.c | 118 +++++++++++++++++++++++++++++--------------- | 12 | include/hw/arm/aspeed_soc.h | 36 +++++++++++++++++++++++ |
18 | 1 file changed, 79 insertions(+), 39 deletions(-) | 13 | hw/arm/aspeed_soc.c | 57 +++++++++++++++++++++++++++++++------ |
19 | 14 | 2 files changed, 85 insertions(+), 8 deletions(-) | |
20 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 15 | |
16 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.c | 18 | --- a/include/hw/arm/aspeed_soc.h |
23 | +++ b/target/arm/helper.c | 19 | +++ b/include/hw/arm/aspeed_soc.h |
24 | @@ -XXX,XX +XXX,XX @@ static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv) | 20 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { |
25 | } | 21 | const char *fmc_typename; |
22 | const char **spi_typename; | ||
23 | int wdts_num; | ||
24 | + const int *irqmap; | ||
25 | } AspeedSoCInfo; | ||
26 | |||
27 | typedef struct AspeedSoCClass { | ||
28 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCClass { | ||
29 | #define ASPEED_SOC_GET_CLASS(obj) \ | ||
30 | OBJECT_GET_CLASS(AspeedSoCClass, (obj), TYPE_ASPEED_SOC) | ||
31 | |||
32 | +enum { | ||
33 | + ASPEED_IOMEM, | ||
34 | + ASPEED_UART1, | ||
35 | + ASPEED_UART2, | ||
36 | + ASPEED_UART3, | ||
37 | + ASPEED_UART4, | ||
38 | + ASPEED_UART5, | ||
39 | + ASPEED_VUART, | ||
40 | + ASPEED_FMC, | ||
41 | + ASPEED_SPI1, | ||
42 | + ASPEED_SPI2, | ||
43 | + ASPEED_VIC, | ||
44 | + ASPEED_SDMC, | ||
45 | + ASPEED_SCU, | ||
46 | + ASPEED_ADC, | ||
47 | + ASPEED_SRAM, | ||
48 | + ASPEED_GPIO, | ||
49 | + ASPEED_RTC, | ||
50 | + ASPEED_TIMER1, | ||
51 | + ASPEED_TIMER2, | ||
52 | + ASPEED_TIMER3, | ||
53 | + ASPEED_TIMER4, | ||
54 | + ASPEED_TIMER5, | ||
55 | + ASPEED_TIMER6, | ||
56 | + ASPEED_TIMER7, | ||
57 | + ASPEED_TIMER8, | ||
58 | + ASPEED_WDT, | ||
59 | + ASPEED_PWM, | ||
60 | + ASPEED_LPC, | ||
61 | + ASPEED_IBT, | ||
62 | + ASPEED_I2C, | ||
63 | + ASPEED_ETH1, | ||
64 | + ASPEED_ETH2, | ||
65 | +}; | ||
66 | + | ||
67 | #endif /* ASPEED_SOC_H */ | ||
68 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/arm/aspeed_soc.c | ||
71 | +++ b/hw/arm/aspeed_soc.c | ||
72 | @@ -XXX,XX +XXX,XX @@ | ||
73 | #define ASPEED_SOC_ETH1_BASE 0x1E660000 | ||
74 | #define ASPEED_SOC_ETH2_BASE 0x1E680000 | ||
75 | |||
76 | -static const int uart_irqs[] = { 9, 32, 33, 34, 10 }; | ||
77 | -static const int timer_irqs[] = { 16, 17, 18, 35, 36, 37, 38, 39, }; | ||
78 | +static const int aspeed_soc_ast2400_irqmap[] = { | ||
79 | + [ASPEED_UART1] = 9, | ||
80 | + [ASPEED_UART2] = 32, | ||
81 | + [ASPEED_UART3] = 33, | ||
82 | + [ASPEED_UART4] = 34, | ||
83 | + [ASPEED_UART5] = 10, | ||
84 | + [ASPEED_VUART] = 8, | ||
85 | + [ASPEED_FMC] = 19, | ||
86 | + [ASPEED_SDMC] = 0, | ||
87 | + [ASPEED_SCU] = 21, | ||
88 | + [ASPEED_ADC] = 31, | ||
89 | + [ASPEED_GPIO] = 20, | ||
90 | + [ASPEED_RTC] = 22, | ||
91 | + [ASPEED_TIMER1] = 16, | ||
92 | + [ASPEED_TIMER2] = 17, | ||
93 | + [ASPEED_TIMER3] = 18, | ||
94 | + [ASPEED_TIMER4] = 35, | ||
95 | + [ASPEED_TIMER5] = 36, | ||
96 | + [ASPEED_TIMER6] = 37, | ||
97 | + [ASPEED_TIMER7] = 38, | ||
98 | + [ASPEED_TIMER8] = 39, | ||
99 | + [ASPEED_WDT] = 27, | ||
100 | + [ASPEED_PWM] = 28, | ||
101 | + [ASPEED_LPC] = 8, | ||
102 | + [ASPEED_IBT] = 8, /* LPC */ | ||
103 | + [ASPEED_I2C] = 12, | ||
104 | + [ASPEED_ETH1] = 2, | ||
105 | + [ASPEED_ETH2] = 3, | ||
106 | +}; | ||
107 | |||
108 | #define AST2400_SDRAM_BASE 0x40000000 | ||
109 | #define AST2500_SDRAM_BASE 0x80000000 | ||
110 | |||
111 | +/* AST2500 uses the same IRQs as the AST2400 */ | ||
112 | +#define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap | ||
113 | + | ||
114 | static const hwaddr aspeed_soc_ast2400_spi_bases[] = { ASPEED_SOC_SPI_BASE }; | ||
115 | static const char *aspeed_soc_ast2400_typenames[] = { "aspeed.smc.spi" }; | ||
116 | |||
117 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
118 | .fmc_typename = "aspeed.smc.fmc", | ||
119 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
120 | .wdts_num = 2, | ||
121 | + .irqmap = aspeed_soc_ast2400_irqmap, | ||
122 | }, { | ||
123 | .name = "ast2400-a1", | ||
124 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | ||
125 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
126 | .fmc_typename = "aspeed.smc.fmc", | ||
127 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
128 | .wdts_num = 2, | ||
129 | + .irqmap = aspeed_soc_ast2400_irqmap, | ||
130 | }, { | ||
131 | .name = "ast2400", | ||
132 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | ||
133 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
134 | .fmc_typename = "aspeed.smc.fmc", | ||
135 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
136 | .wdts_num = 2, | ||
137 | + .irqmap = aspeed_soc_ast2400_irqmap, | ||
138 | }, { | ||
139 | .name = "ast2500-a1", | ||
140 | .cpu_type = ARM_CPU_TYPE_NAME("arm1176"), | ||
141 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
142 | .fmc_typename = "aspeed.smc.ast2500-fmc", | ||
143 | .spi_typename = aspeed_soc_ast2500_typenames, | ||
144 | .wdts_num = 3, | ||
145 | + .irqmap = aspeed_soc_ast2500_irqmap, | ||
146 | }, | ||
147 | }; | ||
148 | |||
149 | +static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl) | ||
150 | +{ | ||
151 | + AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
152 | + | ||
153 | + return qdev_get_gpio_in(DEVICE(&s->vic), sc->info->irqmap[ctrl]); | ||
154 | +} | ||
155 | + | ||
156 | static void aspeed_soc_init(Object *obj) | ||
157 | { | ||
158 | AspeedSoCState *s = ASPEED_SOC(obj); | ||
159 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
160 | return; | ||
161 | } | ||
162 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, ASPEED_SOC_TIMER_BASE); | ||
163 | - for (i = 0; i < ARRAY_SIZE(timer_irqs); i++) { | ||
164 | - qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->vic), timer_irqs[i]); | ||
165 | + for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { | ||
166 | + qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_TIMER1 + i); | ||
167 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq); | ||
168 | } | ||
169 | |||
170 | /* UART - attach an 8250 to the IO space as our UART5 */ | ||
171 | if (serial_hd(0)) { | ||
172 | - qemu_irq uart5 = qdev_get_gpio_in(DEVICE(&s->vic), uart_irqs[4]); | ||
173 | + qemu_irq uart5 = aspeed_soc_get_irq(s, ASPEED_UART5); | ||
174 | serial_mm_init(get_system_memory(), | ||
175 | ASPEED_SOC_IOMEM_BASE + ASPEED_SOC_UART_5_BASE, 2, | ||
176 | uart5, 38400, serial_hd(0), DEVICE_LITTLE_ENDIAN); | ||
177 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
178 | } | ||
179 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, ASPEED_SOC_I2C_BASE); | ||
180 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c), 0, | ||
181 | - qdev_get_gpio_in(DEVICE(&s->vic), 12)); | ||
182 | + aspeed_soc_get_irq(s, ASPEED_I2C)); | ||
183 | |||
184 | /* FMC, The number of CS is set at the board level */ | ||
185 | object_property_set_bool(OBJECT(&s->fmc), true, "realized", &err); | ||
186 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
187 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1, | ||
188 | s->fmc.ctrl->flash_window_base); | ||
189 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0, | ||
190 | - qdev_get_gpio_in(DEVICE(&s->vic), 19)); | ||
191 | + aspeed_soc_get_irq(s, ASPEED_FMC)); | ||
192 | |||
193 | /* SPI */ | ||
194 | for (i = 0; i < sc->info->spis_num; i++) { | ||
195 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
196 | } | ||
197 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, ASPEED_SOC_ETH1_BASE); | ||
198 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, | ||
199 | - qdev_get_gpio_in(DEVICE(&s->vic), 2)); | ||
200 | + aspeed_soc_get_irq(s, ASPEED_ETH1)); | ||
26 | } | 201 | } |
27 | 202 | ||
28 | +/* | 203 | static void aspeed_soc_class_init(ObjectClass *oc, void *data) |
29 | + * What kind of stack write are we doing? This affects how exceptions | ||
30 | + * generated during the stacking are treated. | ||
31 | + */ | ||
32 | +typedef enum StackingMode { | ||
33 | + STACK_NORMAL, | ||
34 | + STACK_IGNFAULTS, | ||
35 | + STACK_LAZYFP, | ||
36 | +} StackingMode; | ||
37 | + | ||
38 | static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | ||
39 | - ARMMMUIdx mmu_idx, bool ignfault) | ||
40 | + ARMMMUIdx mmu_idx, StackingMode mode) | ||
41 | { | ||
42 | CPUState *cs = CPU(cpu); | ||
43 | CPUARMState *env = &cpu->env; | ||
44 | @@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | ||
45 | &attrs, &prot, &page_size, &fi, NULL)) { | ||
46 | /* MPU/SAU lookup failed */ | ||
47 | if (fi.type == ARMFault_QEMU_SFault) { | ||
48 | - qemu_log_mask(CPU_LOG_INT, | ||
49 | - "...SecureFault with SFSR.AUVIOL during stacking\n"); | ||
50 | - env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK | R_V7M_SFSR_SFARVALID_MASK; | ||
51 | + if (mode == STACK_LAZYFP) { | ||
52 | + qemu_log_mask(CPU_LOG_INT, | ||
53 | + "...SecureFault with SFSR.LSPERR " | ||
54 | + "during lazy stacking\n"); | ||
55 | + env->v7m.sfsr |= R_V7M_SFSR_LSPERR_MASK; | ||
56 | + } else { | ||
57 | + qemu_log_mask(CPU_LOG_INT, | ||
58 | + "...SecureFault with SFSR.AUVIOL " | ||
59 | + "during stacking\n"); | ||
60 | + env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK; | ||
61 | + } | ||
62 | + env->v7m.sfsr |= R_V7M_SFSR_SFARVALID_MASK; | ||
63 | env->v7m.sfar = addr; | ||
64 | exc = ARMV7M_EXCP_SECURE; | ||
65 | exc_secure = false; | ||
66 | } else { | ||
67 | - qemu_log_mask(CPU_LOG_INT, "...MemManageFault with CFSR.MSTKERR\n"); | ||
68 | - env->v7m.cfsr[secure] |= R_V7M_CFSR_MSTKERR_MASK; | ||
69 | + if (mode == STACK_LAZYFP) { | ||
70 | + qemu_log_mask(CPU_LOG_INT, | ||
71 | + "...MemManageFault with CFSR.MLSPERR\n"); | ||
72 | + env->v7m.cfsr[secure] |= R_V7M_CFSR_MLSPERR_MASK; | ||
73 | + } else { | ||
74 | + qemu_log_mask(CPU_LOG_INT, | ||
75 | + "...MemManageFault with CFSR.MSTKERR\n"); | ||
76 | + env->v7m.cfsr[secure] |= R_V7M_CFSR_MSTKERR_MASK; | ||
77 | + } | ||
78 | exc = ARMV7M_EXCP_MEM; | ||
79 | exc_secure = secure; | ||
80 | } | ||
81 | @@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | ||
82 | attrs, &txres); | ||
83 | if (txres != MEMTX_OK) { | ||
84 | /* BusFault trying to write the data */ | ||
85 | - qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.STKERR\n"); | ||
86 | - env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_STKERR_MASK; | ||
87 | + if (mode == STACK_LAZYFP) { | ||
88 | + qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.LSPERR\n"); | ||
89 | + env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_LSPERR_MASK; | ||
90 | + } else { | ||
91 | + qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.STKERR\n"); | ||
92 | + env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_STKERR_MASK; | ||
93 | + } | ||
94 | exc = ARMV7M_EXCP_BUS; | ||
95 | exc_secure = false; | ||
96 | goto pend_fault; | ||
97 | @@ -XXX,XX +XXX,XX @@ pend_fault: | ||
98 | * later if we have two derived exceptions. | ||
99 | * The only case when we must not pend the exception but instead | ||
100 | * throw it away is if we are doing the push of the callee registers | ||
101 | - * and we've already generated a derived exception. Even in this | ||
102 | - * case we will still update the fault status registers. | ||
103 | + * and we've already generated a derived exception (this is indicated | ||
104 | + * by the caller passing STACK_IGNFAULTS). Even in this case we will | ||
105 | + * still update the fault status registers. | ||
106 | */ | ||
107 | - if (!ignfault) { | ||
108 | + switch (mode) { | ||
109 | + case STACK_NORMAL: | ||
110 | armv7m_nvic_set_pending_derived(env->nvic, exc, exc_secure); | ||
111 | + break; | ||
112 | + case STACK_LAZYFP: | ||
113 | + armv7m_nvic_set_pending_lazyfp(env->nvic, exc, exc_secure); | ||
114 | + break; | ||
115 | + case STACK_IGNFAULTS: | ||
116 | + break; | ||
117 | } | ||
118 | return false; | ||
119 | } | ||
120 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
121 | uint32_t limit; | ||
122 | bool want_psp; | ||
123 | uint32_t sig; | ||
124 | + StackingMode smode = ignore_faults ? STACK_IGNFAULTS : STACK_NORMAL; | ||
125 | |||
126 | if (dotailchain) { | ||
127 | bool mode = lr & R_V7M_EXCRET_MODE_MASK; | ||
128 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
129 | */ | ||
130 | sig = v7m_integrity_sig(env, lr); | ||
131 | stacked_ok = | ||
132 | - v7m_stack_write(cpu, frameptr, sig, mmu_idx, ignore_faults) && | ||
133 | - v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx, | ||
134 | - ignore_faults) && | ||
135 | - v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx, | ||
136 | - ignore_faults) && | ||
137 | - v7m_stack_write(cpu, frameptr + 0x10, env->regs[6], mmu_idx, | ||
138 | - ignore_faults) && | ||
139 | - v7m_stack_write(cpu, frameptr + 0x14, env->regs[7], mmu_idx, | ||
140 | - ignore_faults) && | ||
141 | - v7m_stack_write(cpu, frameptr + 0x18, env->regs[8], mmu_idx, | ||
142 | - ignore_faults) && | ||
143 | - v7m_stack_write(cpu, frameptr + 0x1c, env->regs[9], mmu_idx, | ||
144 | - ignore_faults) && | ||
145 | - v7m_stack_write(cpu, frameptr + 0x20, env->regs[10], mmu_idx, | ||
146 | - ignore_faults) && | ||
147 | - v7m_stack_write(cpu, frameptr + 0x24, env->regs[11], mmu_idx, | ||
148 | - ignore_faults); | ||
149 | + v7m_stack_write(cpu, frameptr, sig, mmu_idx, smode) && | ||
150 | + v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx, smode) && | ||
151 | + v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx, smode) && | ||
152 | + v7m_stack_write(cpu, frameptr + 0x10, env->regs[6], mmu_idx, smode) && | ||
153 | + v7m_stack_write(cpu, frameptr + 0x14, env->regs[7], mmu_idx, smode) && | ||
154 | + v7m_stack_write(cpu, frameptr + 0x18, env->regs[8], mmu_idx, smode) && | ||
155 | + v7m_stack_write(cpu, frameptr + 0x1c, env->regs[9], mmu_idx, smode) && | ||
156 | + v7m_stack_write(cpu, frameptr + 0x20, env->regs[10], mmu_idx, smode) && | ||
157 | + v7m_stack_write(cpu, frameptr + 0x24, env->regs[11], mmu_idx, smode); | ||
158 | |||
159 | /* Update SP regardless of whether any of the stack accesses failed. */ | ||
160 | *frame_sp_p = frameptr; | ||
161 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
162 | * if it has higher priority). | ||
163 | */ | ||
164 | stacked_ok = stacked_ok && | ||
165 | - v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, false) && | ||
166 | - v7m_stack_write(cpu, frameptr + 4, env->regs[1], mmu_idx, false) && | ||
167 | - v7m_stack_write(cpu, frameptr + 8, env->regs[2], mmu_idx, false) && | ||
168 | - v7m_stack_write(cpu, frameptr + 12, env->regs[3], mmu_idx, false) && | ||
169 | - v7m_stack_write(cpu, frameptr + 16, env->regs[12], mmu_idx, false) && | ||
170 | - v7m_stack_write(cpu, frameptr + 20, env->regs[14], mmu_idx, false) && | ||
171 | - v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) && | ||
172 | - v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false); | ||
173 | + v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, STACK_NORMAL) && | ||
174 | + v7m_stack_write(cpu, frameptr + 4, env->regs[1], | ||
175 | + mmu_idx, STACK_NORMAL) && | ||
176 | + v7m_stack_write(cpu, frameptr + 8, env->regs[2], | ||
177 | + mmu_idx, STACK_NORMAL) && | ||
178 | + v7m_stack_write(cpu, frameptr + 12, env->regs[3], | ||
179 | + mmu_idx, STACK_NORMAL) && | ||
180 | + v7m_stack_write(cpu, frameptr + 16, env->regs[12], | ||
181 | + mmu_idx, STACK_NORMAL) && | ||
182 | + v7m_stack_write(cpu, frameptr + 20, env->regs[14], | ||
183 | + mmu_idx, STACK_NORMAL) && | ||
184 | + v7m_stack_write(cpu, frameptr + 24, env->regs[15], | ||
185 | + mmu_idx, STACK_NORMAL) && | ||
186 | + v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, STACK_NORMAL); | ||
187 | |||
188 | if (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) { | ||
189 | /* FPU is active, try to save its registers */ | ||
190 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
191 | faddr += 8; /* skip the slot for the FPSCR */ | ||
192 | } | ||
193 | stacked_ok = stacked_ok && | ||
194 | - v7m_stack_write(cpu, faddr, slo, mmu_idx, false) && | ||
195 | - v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, false); | ||
196 | + v7m_stack_write(cpu, faddr, slo, | ||
197 | + mmu_idx, STACK_NORMAL) && | ||
198 | + v7m_stack_write(cpu, faddr + 4, shi, | ||
199 | + mmu_idx, STACK_NORMAL); | ||
200 | } | ||
201 | stacked_ok = stacked_ok && | ||
202 | v7m_stack_write(cpu, frameptr + 0x60, | ||
203 | - vfp_get_fpscr(env), mmu_idx, false); | ||
204 | + vfp_get_fpscr(env), mmu_idx, STACK_NORMAL); | ||
205 | if (cpacr_pass) { | ||
206 | for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) { | ||
207 | *aa32_vfp_dreg(env, i / 2) = 0; | ||
208 | -- | 204 | -- |
209 | 2.20.1 | 205 | 2.20.1 |
210 | 206 | ||
211 | 207 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 3 | This will simplify the definition of new SoCs, like the AST2600 which |
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 4 | should use a slightly different address space and have a different set |
5 | Message-id: 20190412165416.7977-12-philmd@redhat.com | 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 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 12 | --- |
8 | include/hw/net/lan9118.h | 2 ++ | 13 | include/hw/arm/aspeed_soc.h | 4 +- |
9 | hw/arm/exynos4_boards.c | 3 ++- | 14 | hw/arm/aspeed.c | 8 +-- |
10 | hw/arm/mps2-tz.c | 3 ++- | 15 | hw/arm/aspeed_soc.c | 117 ++++++++++++++++++++++-------------- |
11 | hw/net/lan9118.c | 1 - | 16 | 3 files changed, 78 insertions(+), 51 deletions(-) |
12 | 4 files changed, 6 insertions(+), 3 deletions(-) | 17 | |
13 | 18 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | |
14 | diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/net/lan9118.h | 20 | --- a/include/hw/arm/aspeed_soc.h |
17 | +++ b/include/hw/net/lan9118.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 | ||
18 | @@ -XXX,XX +XXX,XX @@ | 83 | @@ -XXX,XX +XXX,XX @@ |
19 | #include "hw/irq.h" | 84 | #include "hw/i2c/aspeed_i2c.h" |
20 | #include "net/net.h" | 85 | #include "net/net.h" |
21 | 86 | ||
22 | +#define TYPE_LAN9118 "lan9118" | 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 | ||
23 | + | 102 | + |
24 | void lan9118_init(NICInfo *, uint32_t, qemu_irq); | 103 | +static const hwaddr aspeed_soc_ast2400_memmap[] = { |
25 | 104 | + [ASPEED_IOMEM] = 0x1E600000, | |
26 | #endif | 105 | + [ASPEED_FMC] = 0x1E620000, |
27 | diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c | 106 | + [ASPEED_SPI1] = 0x1E630000, |
28 | index XXXXXXX..XXXXXXX 100644 | 107 | + [ASPEED_VIC] = 0x1E6C0000, |
29 | --- a/hw/arm/exynos4_boards.c | 108 | + [ASPEED_SDMC] = 0x1E6E0000, |
30 | +++ b/hw/arm/exynos4_boards.c | 109 | + [ASPEED_SCU] = 0x1E6E2000, |
31 | @@ -XXX,XX +XXX,XX @@ | 110 | + [ASPEED_ADC] = 0x1E6E9000, |
32 | #include "hw/arm/arm.h" | 111 | + [ASPEED_SRAM] = 0x1E720000, |
33 | #include "exec/address-spaces.h" | 112 | + [ASPEED_GPIO] = 0x1E780000, |
34 | #include "hw/arm/exynos4210.h" | 113 | + [ASPEED_RTC] = 0x1E781000, |
35 | +#include "hw/net/lan9118.h" | 114 | + [ASPEED_TIMER1] = 0x1E782000, |
36 | #include "hw/boards.h" | 115 | + [ASPEED_WDT] = 0x1E785000, |
37 | 116 | + [ASPEED_PWM] = 0x1E786000, | |
38 | #undef DEBUG | 117 | + [ASPEED_LPC] = 0x1E789000, |
39 | @@ -XXX,XX +XXX,XX @@ static void lan9215_init(uint32_t base, qemu_irq irq) | 118 | + [ASPEED_IBT] = 0x1E789140, |
40 | /* This should be a 9215 but the 9118 is close enough */ | 119 | + [ASPEED_I2C] = 0x1E78A000, |
41 | if (nd_table[0].used) { | 120 | + [ASPEED_ETH1] = 0x1E660000, |
42 | qemu_check_nic_model(&nd_table[0], "lan9118"); | 121 | + [ASPEED_ETH2] = 0x1E680000, |
43 | - dev = qdev_create(NULL, "lan9118"); | 122 | + [ASPEED_UART1] = 0x1E783000, |
44 | + dev = qdev_create(NULL, TYPE_LAN9118); | 123 | + [ASPEED_UART5] = 0x1E784000, |
45 | qdev_set_nic_properties(dev, &nd_table[0]); | 124 | + [ASPEED_VUART] = 0x1E787000, |
46 | qdev_prop_set_uint32(dev, "mode_16bit", 1); | 125 | + [ASPEED_SDRAM] = 0x40000000, |
47 | qdev_init_nofail(dev); | 126 | +}; |
48 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 127 | + |
49 | index XXXXXXX..XXXXXXX 100644 | 128 | +static const hwaddr aspeed_soc_ast2500_memmap[] = { |
50 | --- a/hw/arm/mps2-tz.c | 129 | + [ASPEED_IOMEM] = 0x1E600000, |
51 | +++ b/hw/arm/mps2-tz.c | 130 | + [ASPEED_FMC] = 0x1E620000, |
52 | @@ -XXX,XX +XXX,XX @@ | 131 | + [ASPEED_SPI1] = 0x1E630000, |
53 | #include "hw/arm/armsse.h" | 132 | + [ASPEED_SPI2] = 0x1E631000, |
54 | #include "hw/dma/pl080.h" | 133 | + [ASPEED_VIC] = 0x1E6C0000, |
55 | #include "hw/ssi/pl022.h" | 134 | + [ASPEED_SDMC] = 0x1E6E0000, |
56 | +#include "hw/net/lan9118.h" | 135 | + [ASPEED_SCU] = 0x1E6E2000, |
57 | #include "net/net.h" | 136 | + [ASPEED_ADC] = 0x1E6E9000, |
58 | #include "hw/core/split-irq.h" | 137 | + [ASPEED_SRAM] = 0x1E720000, |
59 | 138 | + [ASPEED_GPIO] = 0x1E780000, | |
60 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque, | 139 | + [ASPEED_RTC] = 0x1E781000, |
61 | * except that it doesn't support the checksum-offload feature. | 140 | + [ASPEED_TIMER1] = 0x1E782000, |
62 | */ | 141 | + [ASPEED_WDT] = 0x1E785000, |
63 | qemu_check_nic_model(nd, "lan9118"); | 142 | + [ASPEED_PWM] = 0x1E786000, |
64 | - mms->lan9118 = qdev_create(NULL, "lan9118"); | 143 | + [ASPEED_LPC] = 0x1E789000, |
65 | + mms->lan9118 = qdev_create(NULL, TYPE_LAN9118); | 144 | + [ASPEED_IBT] = 0x1E789140, |
66 | qdev_set_nic_properties(mms->lan9118, nd); | 145 | + [ASPEED_I2C] = 0x1E78A000, |
67 | qdev_init_nofail(mms->lan9118); | 146 | + [ASPEED_ETH1] = 0x1E660000, |
68 | 147 | + [ASPEED_ETH2] = 0x1E680000, | |
69 | diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c | 148 | + [ASPEED_UART1] = 0x1E783000, |
70 | index XXXXXXX..XXXXXXX 100644 | 149 | + [ASPEED_UART5] = 0x1E784000, |
71 | --- a/hw/net/lan9118.c | 150 | + [ASPEED_VUART] = 0x1E787000, |
72 | +++ b/hw/net/lan9118.c | 151 | + [ASPEED_SDRAM] = 0x80000000, |
73 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_lan9118_packet = { | 152 | +}; |
74 | } | 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, | ||
75 | }; | 158 | }; |
76 | 159 | ||
77 | -#define TYPE_LAN9118 "lan9118" | 160 | -#define AST2400_SDRAM_BASE 0x40000000 |
78 | #define LAN9118(obj) OBJECT_CHECK(lan9118_state, (obj), TYPE_LAN9118) | 161 | -#define AST2500_SDRAM_BASE 0x80000000 |
79 | 162 | - | |
80 | typedef struct { | 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 | } | ||
81 | -- | 345 | -- |
82 | 2.20.1 | 346 | 2.20.1 |
83 | 347 | ||
84 | 348 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 3 | The RTC is modeled to provide time and date functionality. It is |
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 4 | initialised at zero to match the hardware. |
5 | Message-id: 20190412165416.7977-10-philmd@redhat.com | 5 | |
6 | There is no modelling of the alarm functionality, which includes the IRQ | ||
7 | line. As there is no guest code to exercise this function that is | ||
8 | acceptable for now. | ||
9 | |||
10 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Message-id: 20190618165311.27066-4-clg@kaod.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 14 | --- |
8 | include/hw/devices.h | 3 --- | 15 | hw/timer/Makefile.objs | 2 +- |
9 | include/hw/net/lan9118.h | 19 +++++++++++++++++++ | 16 | include/hw/timer/aspeed_rtc.h | 31 ++++++ |
10 | hw/arm/kzm.c | 2 +- | 17 | hw/timer/aspeed_rtc.c | 180 ++++++++++++++++++++++++++++++++++ |
11 | hw/arm/mps2.c | 2 +- | 18 | hw/timer/trace-events | 4 + |
12 | hw/arm/realview.c | 1 + | 19 | 4 files changed, 216 insertions(+), 1 deletion(-) |
13 | hw/arm/vexpress.c | 2 +- | 20 | create mode 100644 include/hw/timer/aspeed_rtc.h |
14 | hw/net/lan9118.c | 2 +- | 21 | create mode 100644 hw/timer/aspeed_rtc.c |
15 | 7 files changed, 24 insertions(+), 7 deletions(-) | 22 | |
16 | create mode 100644 include/hw/net/lan9118.h | 23 | diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs |
17 | |||
18 | diff --git a/include/hw/devices.h b/include/hw/devices.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/devices.h | 25 | --- a/hw/timer/Makefile.objs |
21 | +++ b/include/hw/devices.h | 26 | +++ b/hw/timer/Makefile.objs |
22 | @@ -XXX,XX +XXX,XX @@ | 27 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MC146818RTC) += mc146818rtc.o |
23 | /* smc91c111.c */ | 28 | obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o |
24 | void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | 29 | |
25 | 30 | common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o | |
26 | -/* lan9118.c */ | 31 | -common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o |
27 | -void lan9118_init(NICInfo *, uint32_t, qemu_irq); | 32 | +common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o |
28 | - | 33 | |
29 | #endif | 34 | common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o |
30 | diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h | 35 | common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o |
36 | diff --git a/include/hw/timer/aspeed_rtc.h b/include/hw/timer/aspeed_rtc.h | ||
31 | new file mode 100644 | 37 | new file mode 100644 |
32 | index XXXXXXX..XXXXXXX | 38 | index XXXXXXX..XXXXXXX |
33 | --- /dev/null | 39 | --- /dev/null |
34 | +++ b/include/hw/net/lan9118.h | 40 | +++ b/include/hw/timer/aspeed_rtc.h |
35 | @@ -XXX,XX +XXX,XX @@ | 41 | @@ -XXX,XX +XXX,XX @@ |
36 | +/* | 42 | +/* |
37 | + * SMSC LAN9118 Ethernet interface emulation | 43 | + * ASPEED Real Time Clock |
44 | + * Joel Stanley <joel@jms.id.au> | ||
38 | + * | 45 | + * |
39 | + * Copyright (c) 2009 CodeSourcery, LLC. | 46 | + * Copyright 2019 IBM Corp |
40 | + * Written by Paul Brook | 47 | + * SPDX-License-Identifier: GPL-2.0-or-later |
48 | + */ | ||
49 | +#ifndef ASPEED_RTC_H | ||
50 | +#define ASPEED_RTC_H | ||
51 | + | ||
52 | +#include <stdint.h> | ||
53 | + | ||
54 | +#include "hw/hw.h" | ||
55 | +#include "hw/irq.h" | ||
56 | +#include "hw/sysbus.h" | ||
57 | + | ||
58 | +typedef struct AspeedRtcState { | ||
59 | + SysBusDevice parent_obj; | ||
60 | + | ||
61 | + MemoryRegion iomem; | ||
62 | + qemu_irq irq; | ||
63 | + | ||
64 | + uint32_t reg[0x18]; | ||
65 | + int offset; | ||
66 | + | ||
67 | +} AspeedRtcState; | ||
68 | + | ||
69 | +#define TYPE_ASPEED_RTC "aspeed.rtc" | ||
70 | +#define ASPEED_RTC(obj) OBJECT_CHECK(AspeedRtcState, (obj), TYPE_ASPEED_RTC) | ||
71 | + | ||
72 | +#endif /* ASPEED_RTC_H */ | ||
73 | diff --git a/hw/timer/aspeed_rtc.c b/hw/timer/aspeed_rtc.c | ||
74 | new file mode 100644 | ||
75 | index XXXXXXX..XXXXXXX | ||
76 | --- /dev/null | ||
77 | +++ b/hw/timer/aspeed_rtc.c | ||
78 | @@ -XXX,XX +XXX,XX @@ | ||
79 | +/* | ||
80 | + * ASPEED Real Time Clock | ||
81 | + * Joel Stanley <joel@jms.id.au> | ||
41 | + * | 82 | + * |
42 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 83 | + * Copyright 2019 IBM Corp |
43 | + * See the COPYING file in the top-level directory. | 84 | + * SPDX-License-Identifier: GPL-2.0-or-later |
44 | + */ | 85 | + */ |
45 | + | 86 | + |
46 | +#ifndef HW_NET_LAN9118_H | 87 | +#include "qemu/osdep.h" |
47 | +#define HW_NET_LAN9118_H | 88 | +#include "qemu-common.h" |
48 | + | 89 | +#include "hw/timer/aspeed_rtc.h" |
49 | +#include "hw/irq.h" | 90 | +#include "qemu/log.h" |
50 | +#include "net/net.h" | 91 | +#include "qemu/timer.h" |
51 | + | 92 | + |
52 | +void lan9118_init(NICInfo *, uint32_t, qemu_irq); | 93 | +#include "trace.h" |
53 | + | 94 | + |
54 | +#endif | 95 | +#define COUNTER1 (0x00 / 4) |
55 | diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c | 96 | +#define COUNTER2 (0x04 / 4) |
97 | +#define ALARM (0x08 / 4) | ||
98 | +#define CONTROL (0x10 / 4) | ||
99 | +#define ALARM_STATUS (0x14 / 4) | ||
100 | + | ||
101 | +#define RTC_UNLOCKED BIT(1) | ||
102 | +#define RTC_ENABLED BIT(0) | ||
103 | + | ||
104 | +static void aspeed_rtc_calc_offset(AspeedRtcState *rtc) | ||
105 | +{ | ||
106 | + struct tm tm; | ||
107 | + uint32_t year, cent; | ||
108 | + uint32_t reg1 = rtc->reg[COUNTER1]; | ||
109 | + uint32_t reg2 = rtc->reg[COUNTER2]; | ||
110 | + | ||
111 | + tm.tm_mday = (reg1 >> 24) & 0x1f; | ||
112 | + tm.tm_hour = (reg1 >> 16) & 0x1f; | ||
113 | + tm.tm_min = (reg1 >> 8) & 0x3f; | ||
114 | + tm.tm_sec = (reg1 >> 0) & 0x3f; | ||
115 | + | ||
116 | + cent = (reg2 >> 16) & 0x1f; | ||
117 | + year = (reg2 >> 8) & 0x7f; | ||
118 | + tm.tm_mon = ((reg2 >> 0) & 0x0f) - 1; | ||
119 | + tm.tm_year = year + (cent * 100) - 1900; | ||
120 | + | ||
121 | + rtc->offset = qemu_timedate_diff(&tm); | ||
122 | +} | ||
123 | + | ||
124 | +static uint32_t aspeed_rtc_get_counter(AspeedRtcState *rtc, int r) | ||
125 | +{ | ||
126 | + uint32_t year, cent; | ||
127 | + struct tm now; | ||
128 | + | ||
129 | + qemu_get_timedate(&now, rtc->offset); | ||
130 | + | ||
131 | + switch (r) { | ||
132 | + case COUNTER1: | ||
133 | + return (now.tm_mday << 24) | (now.tm_hour << 16) | | ||
134 | + (now.tm_min << 8) | now.tm_sec; | ||
135 | + case COUNTER2: | ||
136 | + cent = (now.tm_year + 1900) / 100; | ||
137 | + year = now.tm_year % 100; | ||
138 | + return ((cent & 0x1f) << 16) | ((year & 0x7f) << 8) | | ||
139 | + ((now.tm_mon + 1) & 0xf); | ||
140 | + default: | ||
141 | + g_assert_not_reached(); | ||
142 | + } | ||
143 | +} | ||
144 | + | ||
145 | +static uint64_t aspeed_rtc_read(void *opaque, hwaddr addr, | ||
146 | + unsigned size) | ||
147 | +{ | ||
148 | + AspeedRtcState *rtc = opaque; | ||
149 | + uint64_t val; | ||
150 | + uint32_t r = addr >> 2; | ||
151 | + | ||
152 | + switch (r) { | ||
153 | + case COUNTER1: | ||
154 | + case COUNTER2: | ||
155 | + if (rtc->reg[CONTROL] & RTC_ENABLED) { | ||
156 | + rtc->reg[r] = aspeed_rtc_get_counter(rtc, r); | ||
157 | + } | ||
158 | + /* fall through */ | ||
159 | + case CONTROL: | ||
160 | + val = rtc->reg[r]; | ||
161 | + break; | ||
162 | + case ALARM: | ||
163 | + case ALARM_STATUS: | ||
164 | + default: | ||
165 | + qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx "\n", __func__, addr); | ||
166 | + return 0; | ||
167 | + } | ||
168 | + | ||
169 | + trace_aspeed_rtc_read(addr, val); | ||
170 | + | ||
171 | + return val; | ||
172 | +} | ||
173 | + | ||
174 | +static void aspeed_rtc_write(void *opaque, hwaddr addr, | ||
175 | + uint64_t val, unsigned size) | ||
176 | +{ | ||
177 | + AspeedRtcState *rtc = opaque; | ||
178 | + uint32_t r = addr >> 2; | ||
179 | + | ||
180 | + switch (r) { | ||
181 | + case COUNTER1: | ||
182 | + case COUNTER2: | ||
183 | + if (!(rtc->reg[CONTROL] & RTC_UNLOCKED)) { | ||
184 | + break; | ||
185 | + } | ||
186 | + /* fall through */ | ||
187 | + case CONTROL: | ||
188 | + rtc->reg[r] = val; | ||
189 | + aspeed_rtc_calc_offset(rtc); | ||
190 | + break; | ||
191 | + case ALARM: | ||
192 | + case ALARM_STATUS: | ||
193 | + default: | ||
194 | + qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx "\n", __func__, addr); | ||
195 | + break; | ||
196 | + } | ||
197 | + trace_aspeed_rtc_write(addr, val); | ||
198 | +} | ||
199 | + | ||
200 | +static void aspeed_rtc_reset(DeviceState *d) | ||
201 | +{ | ||
202 | + AspeedRtcState *rtc = ASPEED_RTC(d); | ||
203 | + | ||
204 | + rtc->offset = 0; | ||
205 | + memset(rtc->reg, 0, sizeof(rtc->reg)); | ||
206 | +} | ||
207 | + | ||
208 | +static const MemoryRegionOps aspeed_rtc_ops = { | ||
209 | + .read = aspeed_rtc_read, | ||
210 | + .write = aspeed_rtc_write, | ||
211 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
212 | +}; | ||
213 | + | ||
214 | +static const VMStateDescription vmstate_aspeed_rtc = { | ||
215 | + .name = TYPE_ASPEED_RTC, | ||
216 | + .version_id = 1, | ||
217 | + .fields = (VMStateField[]) { | ||
218 | + VMSTATE_UINT32_ARRAY(reg, AspeedRtcState, 0x18), | ||
219 | + VMSTATE_INT32(offset, AspeedRtcState), | ||
220 | + VMSTATE_INT32(offset, AspeedRtcState), | ||
221 | + VMSTATE_END_OF_LIST() | ||
222 | + } | ||
223 | +}; | ||
224 | + | ||
225 | +static void aspeed_rtc_realize(DeviceState *dev, Error **errp) | ||
226 | +{ | ||
227 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
228 | + AspeedRtcState *s = ASPEED_RTC(dev); | ||
229 | + | ||
230 | + sysbus_init_irq(sbd, &s->irq); | ||
231 | + | ||
232 | + memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_rtc_ops, s, | ||
233 | + "aspeed-rtc", 0x18ULL); | ||
234 | + sysbus_init_mmio(sbd, &s->iomem); | ||
235 | +} | ||
236 | + | ||
237 | +static void aspeed_rtc_class_init(ObjectClass *klass, void *data) | ||
238 | +{ | ||
239 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
240 | + | ||
241 | + dc->realize = aspeed_rtc_realize; | ||
242 | + dc->vmsd = &vmstate_aspeed_rtc; | ||
243 | + dc->reset = aspeed_rtc_reset; | ||
244 | +} | ||
245 | + | ||
246 | +static const TypeInfo aspeed_rtc_info = { | ||
247 | + .name = TYPE_ASPEED_RTC, | ||
248 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
249 | + .instance_size = sizeof(AspeedRtcState), | ||
250 | + .class_init = aspeed_rtc_class_init, | ||
251 | +}; | ||
252 | + | ||
253 | +static void aspeed_rtc_register_types(void) | ||
254 | +{ | ||
255 | + type_register_static(&aspeed_rtc_info); | ||
256 | +} | ||
257 | + | ||
258 | +type_init(aspeed_rtc_register_types) | ||
259 | diff --git a/hw/timer/trace-events b/hw/timer/trace-events | ||
56 | index XXXXXXX..XXXXXXX 100644 | 260 | index XXXXXXX..XXXXXXX 100644 |
57 | --- a/hw/arm/kzm.c | 261 | --- a/hw/timer/trace-events |
58 | +++ b/hw/arm/kzm.c | 262 | +++ b/hw/timer/trace-events |
59 | @@ -XXX,XX +XXX,XX @@ | 263 | @@ -XXX,XX +XXX,XX @@ cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK A |
60 | #include "qemu/error-report.h" | 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" |
61 | #include "exec/address-spaces.h" | 265 | cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset" |
62 | #include "net/net.h" | 266 | |
63 | -#include "hw/devices.h" | 267 | +# hw/timer/aspeed-rtc.c |
64 | +#include "hw/net/lan9118.h" | 268 | +aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64 |
65 | #include "hw/char/serial.h" | 269 | +aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64 |
66 | #include "sysemu/qtest.h" | 270 | + |
67 | 271 | # sun4v-rtc.c | |
68 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | 272 | sun4v_rtc_read(uint64_t addr, uint64_t value) "read: addr 0x%" PRIx64 " value 0x%" PRIx64 |
69 | index XXXXXXX..XXXXXXX 100644 | 273 | sun4v_rtc_write(uint64_t addr, uint64_t value) "write: addr 0x%" PRIx64 " value 0x%" PRIx64 |
70 | --- a/hw/arm/mps2.c | ||
71 | +++ b/hw/arm/mps2.c | ||
72 | @@ -XXX,XX +XXX,XX @@ | ||
73 | #include "hw/timer/cmsdk-apb-timer.h" | ||
74 | #include "hw/timer/cmsdk-apb-dualtimer.h" | ||
75 | #include "hw/misc/mps2-scc.h" | ||
76 | -#include "hw/devices.h" | ||
77 | +#include "hw/net/lan9118.h" | ||
78 | #include "net/net.h" | ||
79 | |||
80 | typedef enum MPS2FPGAType { | ||
81 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/hw/arm/realview.c | ||
84 | +++ b/hw/arm/realview.c | ||
85 | @@ -XXX,XX +XXX,XX @@ | ||
86 | #include "hw/arm/arm.h" | ||
87 | #include "hw/arm/primecell.h" | ||
88 | #include "hw/devices.h" | ||
89 | +#include "hw/net/lan9118.h" | ||
90 | #include "hw/pci/pci.h" | ||
91 | #include "net/net.h" | ||
92 | #include "sysemu/sysemu.h" | ||
93 | diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/hw/arm/vexpress.c | ||
96 | +++ b/hw/arm/vexpress.c | ||
97 | @@ -XXX,XX +XXX,XX @@ | ||
98 | #include "hw/sysbus.h" | ||
99 | #include "hw/arm/arm.h" | ||
100 | #include "hw/arm/primecell.h" | ||
101 | -#include "hw/devices.h" | ||
102 | +#include "hw/net/lan9118.h" | ||
103 | #include "hw/i2c/i2c.h" | ||
104 | #include "net/net.h" | ||
105 | #include "sysemu/sysemu.h" | ||
106 | diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/hw/net/lan9118.c | ||
109 | +++ b/hw/net/lan9118.c | ||
110 | @@ -XXX,XX +XXX,XX @@ | ||
111 | #include "hw/sysbus.h" | ||
112 | #include "net/net.h" | ||
113 | #include "net/eth.h" | ||
114 | -#include "hw/devices.h" | ||
115 | +#include "hw/net/lan9118.h" | ||
116 | #include "sysemu/sysemu.h" | ||
117 | #include "hw/ptimer.h" | ||
118 | #include "qemu/log.h" | ||
119 | -- | 274 | -- |
120 | 2.20.1 | 275 | 2.20.1 |
121 | 276 | ||
122 | 277 | diff view generated by jsdifflib |
1 | Enable the FPU by default for the Cortex-M4 and Cortex-M33. | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | 2 | ||
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 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20190416125744.27770-27-peter.maydell@linaro.org | ||
6 | --- | 12 | --- |
7 | target/arm/cpu.c | 8 ++++++++ | 13 | include/hw/arm/aspeed_soc.h | 2 ++ |
8 | 1 file changed, 8 insertions(+) | 14 | hw/arm/aspeed_soc.c | 13 +++++++++++++ |
15 | 2 files changed, 15 insertions(+) | ||
9 | 16 | ||
10 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 17 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
11 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/target/arm/cpu.c | 19 | --- a/include/hw/arm/aspeed_soc.h |
13 | +++ b/target/arm/cpu.c | 20 | +++ b/include/hw/arm/aspeed_soc.h |
14 | @@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj) | 21 | @@ -XXX,XX +XXX,XX @@ |
15 | set_feature(&cpu->env, ARM_FEATURE_M); | 22 | #include "hw/misc/aspeed_scu.h" |
16 | set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | 23 | #include "hw/misc/aspeed_sdmc.h" |
17 | set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | 24 | #include "hw/timer/aspeed_timer.h" |
18 | + set_feature(&cpu->env, ARM_FEATURE_VFP4); | 25 | +#include "hw/timer/aspeed_rtc.h" |
19 | cpu->midr = 0x410fc240; /* r0p0 */ | 26 | #include "hw/i2c/aspeed_i2c.h" |
20 | cpu->pmsav7_dregion = 8; | 27 | #include "hw/ssi/aspeed_smc.h" |
21 | + cpu->isar.mvfr0 = 0x10110021; | 28 | #include "hw/watchdog/wdt_aspeed.h" |
22 | + cpu->isar.mvfr1 = 0x11000011; | 29 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { |
23 | + cpu->isar.mvfr2 = 0x00000000; | 30 | ARMCPU cpu; |
24 | cpu->id_pfr0 = 0x00000030; | 31 | MemoryRegion sram; |
25 | cpu->id_pfr1 = 0x00000200; | 32 | AspeedVICState vic; |
26 | cpu->id_dfr0 = 0x00100000; | 33 | + AspeedRtcState rtc; |
27 | @@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj) | 34 | AspeedTimerCtrlState timerctrl; |
28 | set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | 35 | AspeedI2CState i2c; |
29 | set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | 36 | AspeedSCUState scu; |
30 | set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | 37 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c |
31 | + set_feature(&cpu->env, ARM_FEATURE_VFP4); | 38 | index XXXXXXX..XXXXXXX 100644 |
32 | cpu->midr = 0x410fd213; /* r0p3 */ | 39 | --- a/hw/arm/aspeed_soc.c |
33 | cpu->pmsav7_dregion = 16; | 40 | +++ b/hw/arm/aspeed_soc.c |
34 | cpu->sau_sregion = 8; | 41 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) |
35 | + cpu->isar.mvfr0 = 0x10110021; | 42 | sysbus_init_child_obj(obj, "vic", OBJECT(&s->vic), sizeof(s->vic), |
36 | + cpu->isar.mvfr1 = 0x11000011; | 43 | TYPE_ASPEED_VIC); |
37 | + cpu->isar.mvfr2 = 0x00000040; | 44 | |
38 | cpu->id_pfr0 = 0x00000030; | 45 | + sysbus_init_child_obj(obj, "rtc", OBJECT(&s->rtc), sizeof(s->rtc), |
39 | cpu->id_pfr1 = 0x00000210; | 46 | + TYPE_ASPEED_RTC); |
40 | cpu->id_dfr0 = 0x00200000; | 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) { | ||
41 | -- | 68 | -- |
42 | 2.20.1 | 69 | 2.20.1 |
43 | 70 | ||
44 | 71 | diff view generated by jsdifflib |
1 | The M-profile FPCCR.ASPEN bit indicates that automatic floating-point | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | context preservation is enabled. Before executing any floating-point | 2 | |
3 | instruction, if FPCCR.ASPEN is set and the CONTROL FPCA/SFPA bits | 3 | The current models of the Aspeed SoCs only have one CPU but future |
4 | indicate that there is no active floating point context then we | 4 | ones will support SMP. Introduce a new num_cpus field at the SoC class |
5 | must create a new context (by initializing FPSCR and setting | 5 | level to define the number of available CPUs per SoC and also |
6 | FPCA/SFPA to indicate that the context is now active). In the | 6 | introduce a 'num-cpus' property to activate the CPUs configured for |
7 | pseudocode this is handled by ExecuteFPCheck(). | 7 | the machine. |
8 | 8 | ||
9 | Implement this with a new TB flag which tracks whether we | 9 | The max_cpus limit of the machine should depend on the SoC definition |
10 | need to create a new FP context. | 10 | but, unfortunately, these values are not available when the machine |
11 | 11 | class is initialized. This is the reason why we add a check on | |
12 | num_cpus in the AspeedSoC realize handler. | ||
13 | |||
14 | SMP support will be activated when models for such SoCs are implemented. | ||
15 | |||
16 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
17 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
18 | Message-id: 20190618165311.27066-6-clg@kaod.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20190416125744.27770-20-peter.maydell@linaro.org | ||
15 | --- | 20 | --- |
16 | target/arm/cpu.h | 2 ++ | 21 | include/hw/arm/aspeed_soc.h | 5 ++++- |
17 | target/arm/translate.h | 1 + | 22 | hw/arm/aspeed.c | 7 +++++-- |
18 | target/arm/helper.c | 13 +++++++++++++ | 23 | hw/arm/aspeed_soc.c | 33 +++++++++++++++++++++++++++------ |
19 | target/arm/translate.c | 29 +++++++++++++++++++++++++++++ | 24 | 3 files changed, 36 insertions(+), 9 deletions(-) |
20 | 4 files changed, 45 insertions(+) | 25 | |
21 | 26 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | |
22 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/cpu.h | 28 | --- a/include/hw/arm/aspeed_soc.h |
25 | +++ b/target/arm/cpu.h | 29 | +++ b/include/hw/arm/aspeed_soc.h |
26 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1) | 30 | @@ -XXX,XX +XXX,XX @@ |
27 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | 31 | |
28 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | 32 | #define ASPEED_SPIS_NUM 2 |
29 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | 33 | #define ASPEED_WDTS_NUM 3 |
30 | +/* For M profile only, set if we must create a new FP context */ | 34 | +#define ASPEED_CPUS_NUM 2 |
31 | +FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1) | 35 | |
32 | /* For M profile only, set if FPCCR.S does not match current security state */ | 36 | typedef struct AspeedSoCState { |
33 | FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1) | 37 | /*< private >*/ |
34 | /* For M profile only, Handler (ie not Thread) mode */ | 38 | DeviceState parent; |
35 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 39 | |
40 | /*< public >*/ | ||
41 | - ARMCPU cpu; | ||
42 | + ARMCPU cpu[ASPEED_CPUS_NUM]; | ||
43 | + uint32_t num_cpus; | ||
44 | MemoryRegion sram; | ||
45 | AspeedVICState vic; | ||
46 | AspeedRtcState rtc; | ||
47 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { | ||
48 | int wdts_num; | ||
49 | const int *irqmap; | ||
50 | const hwaddr *memmap; | ||
51 | + uint32_t num_cpus; | ||
52 | } AspeedSoCInfo; | ||
53 | |||
54 | typedef struct AspeedSoCClass { | ||
55 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | 56 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/target/arm/translate.h | 57 | --- a/hw/arm/aspeed.c |
38 | +++ b/target/arm/translate.h | 58 | +++ b/hw/arm/aspeed.c |
39 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 59 | @@ -XXX,XX +XXX,XX @@ |
40 | bool v8m_secure; /* true if v8M and we're in Secure mode */ | 60 | #include "hw/misc/tmp105.h" |
41 | bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */ | 61 | #include "qemu/log.h" |
42 | bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */ | 62 | #include "sysemu/block-backend.h" |
43 | + bool v7m_new_fp_ctxt_needed; /* ASPEN set but no active FP context */ | 63 | +#include "sysemu/sysemu.h" |
44 | /* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI | 64 | #include "hw/loader.h" |
45 | * so that top level loop can generate correct syndrome information. | 65 | #include "qemu/error-report.h" |
46 | */ | 66 | #include "qemu/units.h" |
47 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 67 | |
68 | static struct arm_boot_info aspeed_board_binfo = { | ||
69 | .board_id = -1, /* device-tree-only board */ | ||
70 | - .nb_cpus = 1, | ||
71 | }; | ||
72 | |||
73 | struct AspeedBoardState { | ||
74 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
75 | &error_abort); | ||
76 | object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs", | ||
77 | &error_abort); | ||
78 | + object_property_set_int(OBJECT(&bmc->soc), smp_cpus, "num-cpus", | ||
79 | + &error_abort); | ||
80 | if (machine->kernel_filename) { | ||
81 | /* | ||
82 | * When booting with a -kernel command line there is no u-boot | ||
83 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
84 | aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline; | ||
85 | aspeed_board_binfo.ram_size = ram_size; | ||
86 | aspeed_board_binfo.loader_start = sc->info->memmap[ASPEED_SDRAM]; | ||
87 | + aspeed_board_binfo.nb_cpus = bmc->soc.num_cpus; | ||
88 | |||
89 | if (cfg->i2c_init) { | ||
90 | cfg->i2c_init(bmc); | ||
91 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_class_init(ObjectClass *oc, void *data) | ||
92 | |||
93 | mc->desc = board->desc; | ||
94 | mc->init = aspeed_machine_init; | ||
95 | - mc->max_cpus = 1; | ||
96 | + mc->max_cpus = ASPEED_CPUS_NUM; | ||
97 | mc->no_sdcard = 1; | ||
98 | mc->no_floppy = 1; | ||
99 | mc->no_cdrom = 1; | ||
100 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | 101 | index XXXXXXX..XXXXXXX 100644 |
49 | --- a/target/arm/helper.c | 102 | --- a/hw/arm/aspeed_soc.c |
50 | +++ b/target/arm/helper.c | 103 | +++ b/hw/arm/aspeed_soc.c |
51 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 104 | @@ -XXX,XX +XXX,XX @@ |
52 | flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1); | 105 | #include "hw/char/serial.h" |
53 | } | 106 | #include "qemu/log.h" |
54 | 107 | #include "qemu/module.h" | |
55 | + if (arm_feature(env, ARM_FEATURE_M) && | 108 | +#include "qemu/error-report.h" |
56 | + (env->v7m.fpccr[env->v7m.secure] & R_V7M_FPCCR_ASPEN_MASK) && | 109 | #include "hw/i2c/aspeed_i2c.h" |
57 | + (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) || | 110 | #include "net/net.h" |
58 | + (env->v7m.secure && | 111 | |
59 | + !(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)))) { | 112 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { |
60 | + /* | 113 | .wdts_num = 2, |
61 | + * ASPEN is set, but FPCA/SFPA indicate that there is no active | 114 | .irqmap = aspeed_soc_ast2400_irqmap, |
62 | + * FP context; we must create a new FP context before executing | 115 | .memmap = aspeed_soc_ast2400_memmap, |
63 | + * any FP insn. | 116 | + .num_cpus = 1, |
64 | + */ | 117 | }, { |
65 | + flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1); | 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; | ||
66 | + } | 166 | + } |
67 | + | 167 | + |
68 | *pflags = flags; | 168 | /* CPU */ |
69 | *cs_base = 0; | 169 | - object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); |
70 | } | 170 | - if (err) { |
71 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 171 | - error_propagate(errp, err); |
72 | index XXXXXXX..XXXXXXX 100644 | 172 | - return; |
73 | --- a/target/arm/translate.c | 173 | + for (i = 0; i < s->num_cpus; i++) { |
74 | +++ b/target/arm/translate.c | 174 | + object_property_set_bool(OBJECT(&s->cpu[i]), true, "realized", &err); |
75 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | 175 | + if (err) { |
76 | /* Don't need to do this for any further FP insns in this TB */ | 176 | + error_propagate(errp, err); |
77 | s->v8m_fpccr_s_wrong = false; | 177 | + return; |
78 | } | ||
79 | + | ||
80 | + if (s->v7m_new_fp_ctxt_needed) { | ||
81 | + /* | ||
82 | + * Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA | ||
83 | + * and the FPSCR. | ||
84 | + */ | ||
85 | + TCGv_i32 control, fpscr; | ||
86 | + uint32_t bits = R_V7M_CONTROL_FPCA_MASK; | ||
87 | + | ||
88 | + fpscr = load_cpu_field(v7m.fpdscr[s->v8m_secure]); | ||
89 | + gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
90 | + tcg_temp_free_i32(fpscr); | ||
91 | + /* | ||
92 | + * We don't need to arrange to end the TB, because the only | ||
93 | + * parts of FPSCR which we cache in the TB flags are the VECLEN | ||
94 | + * and VECSTRIDE, and those don't exist for M-profile. | ||
95 | + */ | ||
96 | + | ||
97 | + if (s->v8m_secure) { | ||
98 | + bits |= R_V7M_CONTROL_SFPA_MASK; | ||
99 | + } | ||
100 | + control = load_cpu_field(v7m.control[M_REG_S]); | ||
101 | + tcg_gen_ori_i32(control, control, bits); | ||
102 | + store_cpu_field(control, v7m.control[M_REG_S]); | ||
103 | + /* Don't need to do this for any further FP insns in this TB */ | ||
104 | + s->v7m_new_fp_ctxt_needed = false; | ||
105 | + } | 178 | + } |
106 | } | 179 | } |
107 | 180 | ||
108 | if (extract32(insn, 28, 4) == 0xf) { | 181 | /* SRAM */ |
109 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 182 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
110 | regime_is_secure(env, dc->mmu_idx); | 183 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, |
111 | dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_A32, STACKCHECK); | 184 | aspeed_soc_get_irq(s, ASPEED_ETH1)); |
112 | dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG); | 185 | } |
113 | + dc->v7m_new_fp_ctxt_needed = | 186 | +static Property aspeed_soc_properties[] = { |
114 | + FIELD_EX32(tb_flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED); | 187 | + DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), |
115 | dc->cp_regs = cpu->cp_regs; | 188 | + DEFINE_PROP_END_OF_LIST(), |
116 | dc->features = env->features; | 189 | +}; |
117 | 190 | ||
191 | static void aspeed_soc_class_init(ObjectClass *oc, void *data) | ||
192 | { | ||
193 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_class_init(ObjectClass *oc, void *data) | ||
194 | dc->realize = aspeed_soc_realize; | ||
195 | /* Reason: Uses serial_hds and nd_table in realize() directly */ | ||
196 | dc->user_creatable = false; | ||
197 | + dc->props = aspeed_soc_properties; | ||
198 | } | ||
199 | |||
200 | static const TypeInfo aspeed_soc_type_info = { | ||
118 | -- | 201 | -- |
119 | 2.20.1 | 202 | 2.20.1 |
120 | 203 | ||
121 | 204 | diff view generated by jsdifflib |
1 | The M-profile FPCCR.S bit indicates the security status of | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | the floating point context. In the pseudocode ExecuteFPCheck() | ||
3 | function it is unconditionally set to match the current | ||
4 | security state whenever a floating point instruction is | ||
5 | executed. | ||
6 | 2 | ||
7 | Implement this by adding a new TB flag which tracks whether | 3 | The Aspeed SoCs have two MACs. Extend the Aspeed model to support a |
8 | FPCCR.S is different from the current security state, so | 4 | second NIC. |
9 | that we only need to emit the code to update it in the | ||
10 | less-common case when it is not already set correctly. | ||
11 | 5 | ||
12 | Note that we will add the handling for the other work done | 6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
13 | by ExecuteFPCheck() in later commits. | 7 | Reviewed-by: Joel Stanley <joel@jms.id.au> |
8 | Message-id: 20190618165311.27066-7-clg@kaod.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/arm/aspeed_soc.h | 3 ++- | ||
12 | hw/arm/aspeed_soc.c | 33 +++++++++++++++++++-------------- | ||
13 | 2 files changed, 21 insertions(+), 15 deletions(-) | ||
14 | 14 | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Message-id: 20190416125744.27770-19-peter.maydell@linaro.org | ||
18 | --- | ||
19 | target/arm/cpu.h | 2 ++ | ||
20 | target/arm/translate.h | 1 + | ||
21 | target/arm/helper.c | 5 +++++ | ||
22 | target/arm/translate.c | 20 ++++++++++++++++++++ | ||
23 | 4 files changed, 28 insertions(+) | ||
24 | |||
25 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/cpu.h | 17 | --- a/include/hw/arm/aspeed_soc.h |
28 | +++ b/target/arm/cpu.h | 18 | +++ b/include/hw/arm/aspeed_soc.h |
29 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1) | 19 | @@ -XXX,XX +XXX,XX @@ |
30 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | 20 | #define ASPEED_SPIS_NUM 2 |
31 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | 21 | #define ASPEED_WDTS_NUM 3 |
32 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | 22 | #define ASPEED_CPUS_NUM 2 |
33 | +/* For M profile only, set if FPCCR.S does not match current security state */ | 23 | +#define ASPEED_MACS_NUM 2 |
34 | +FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1) | 24 | |
35 | /* For M profile only, Handler (ie not Thread) mode */ | 25 | typedef struct AspeedSoCState { |
36 | FIELD(TBFLAG_A32, HANDLER, 21, 1) | 26 | /*< private >*/ |
37 | /* For M profile only, whether we should generate stack-limit checks */ | 27 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { |
38 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 28 | AspeedSMCState spi[ASPEED_SPIS_NUM]; |
29 | AspeedSDMCState sdmc; | ||
30 | AspeedWDTState wdt[ASPEED_WDTS_NUM]; | ||
31 | - FTGMAC100State ftgmac100; | ||
32 | + FTGMAC100State ftgmac100[ASPEED_MACS_NUM]; | ||
33 | } AspeedSoCState; | ||
34 | |||
35 | #define TYPE_ASPEED_SOC "aspeed-soc" | ||
36 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/target/arm/translate.h | 38 | --- a/hw/arm/aspeed_soc.c |
41 | +++ b/target/arm/translate.h | 39 | +++ b/hw/arm/aspeed_soc.c |
42 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) |
43 | bool v7m_handler_mode; | 41 | sc->info->silicon_rev); |
44 | bool v8m_secure; /* true if v8M and we're in Secure mode */ | ||
45 | bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */ | ||
46 | + bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */ | ||
47 | /* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI | ||
48 | * so that top level loop can generate correct syndrome information. | ||
49 | */ | ||
50 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/helper.c | ||
53 | +++ b/target/arm/helper.c | ||
54 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
55 | flags = FIELD_DP32(flags, TBFLAG_A32, STACKCHECK, 1); | ||
56 | } | 42 | } |
57 | 43 | ||
58 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY) && | 44 | - sysbus_init_child_obj(obj, "ftgmac100", OBJECT(&s->ftgmac100), |
59 | + FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) != env->v7m.secure) { | 45 | - sizeof(s->ftgmac100), TYPE_FTGMAC100); |
60 | + flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1); | 46 | + for (i = 0; i < ASPEED_MACS_NUM; i++) { |
47 | + sysbus_init_child_obj(obj, "ftgmac100[*]", OBJECT(&s->ftgmac100[i]), | ||
48 | + sizeof(s->ftgmac100[i]), TYPE_FTGMAC100); | ||
61 | + } | 49 | + } |
62 | + | ||
63 | *pflags = flags; | ||
64 | *cs_base = 0; | ||
65 | } | 50 | } |
66 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 51 | |
67 | index XXXXXXX..XXXXXXX 100644 | 52 | static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
68 | --- a/target/arm/translate.c | 53 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
69 | +++ b/target/arm/translate.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
71 | } | ||
72 | } | 54 | } |
73 | 55 | ||
74 | + if (arm_dc_feature(s, ARM_FEATURE_M)) { | 56 | /* Net */ |
75 | + /* Handle M-profile lazy FP state mechanics */ | 57 | - qdev_set_nic_properties(DEVICE(&s->ftgmac100), &nd_table[0]); |
76 | + | 58 | - object_property_set_bool(OBJECT(&s->ftgmac100), true, "aspeed", &err); |
77 | + /* Update ownership of FP context: set FPCCR.S to match current state */ | 59 | - object_property_set_bool(OBJECT(&s->ftgmac100), true, "realized", |
78 | + if (s->v8m_fpccr_s_wrong) { | 60 | - &local_err); |
79 | + TCGv_i32 tmp; | 61 | - error_propagate(&err, local_err); |
80 | + | 62 | - if (err) { |
81 | + tmp = load_cpu_field(v7m.fpccr[M_REG_S]); | 63 | - error_propagate(errp, err); |
82 | + if (s->v8m_secure) { | 64 | - return; |
83 | + tcg_gen_ori_i32(tmp, tmp, R_V7M_FPCCR_S_MASK); | 65 | + for (i = 0; i < nb_nics; i++) { |
84 | + } else { | 66 | + qdev_set_nic_properties(DEVICE(&s->ftgmac100[i]), &nd_table[i]); |
85 | + tcg_gen_andi_i32(tmp, tmp, ~R_V7M_FPCCR_S_MASK); | 67 | + object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "aspeed", |
86 | + } | 68 | + &err); |
87 | + store_cpu_field(tmp, v7m.fpccr[M_REG_S]); | 69 | + object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "realized", |
88 | + /* Don't need to do this for any further FP insns in this TB */ | 70 | + &local_err); |
89 | + s->v8m_fpccr_s_wrong = false; | 71 | + error_propagate(&err, local_err); |
72 | + if (err) { | ||
73 | + error_propagate(errp, err); | ||
74 | + return; | ||
90 | + } | 75 | + } |
91 | + } | 76 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, |
92 | + | 77 | + sc->info->memmap[ASPEED_ETH1 + i]); |
93 | if (extract32(insn, 28, 4) == 0xf) { | 78 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, |
94 | /* | 79 | + aspeed_soc_get_irq(s, ASPEED_ETH1 + i)); |
95 | * Encodings with T=1 (Thumb) or unconditional (ARM): | 80 | } |
96 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 81 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, |
97 | dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) && | 82 | - sc->info->memmap[ASPEED_ETH1]); |
98 | regime_is_secure(env, dc->mmu_idx); | 83 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, |
99 | dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_A32, STACKCHECK); | 84 | - aspeed_soc_get_irq(s, ASPEED_ETH1)); |
100 | + dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG); | 85 | } |
101 | dc->cp_regs = cpu->cp_regs; | 86 | static Property aspeed_soc_properties[] = { |
102 | dc->features = env->features; | 87 | DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), |
103 | |||
104 | -- | 88 | -- |
105 | 2.20.1 | 89 | 2.20.1 |
106 | 90 | ||
107 | 91 | diff view generated by jsdifflib |
1 | In the v7M architecture, if an exception is generated in the process | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | of doing the lazy stacking of FP registers, the handling of | ||
3 | possible escalation to HardFault is treated differently to the normal | ||
4 | approach: it works based on the saved information about exception | ||
5 | readiness that was stored in the FPCCR when the stack frame was | ||
6 | created. Provide a new function armv7m_nvic_set_pending_lazyfp() | ||
7 | which pends exceptions during lazy stacking, and implements | ||
8 | this logic. | ||
9 | 2 | ||
10 | This corresponds to the pseudocode TakePreserveFPException(). | 3 | The Linux kernel driver was updated in commit 4451d3f59f2a |
4 | ("clocksource/drivers/fttmr010: Fix set_next_event handler) to fix an | ||
5 | issue observed on hardware: | ||
11 | 6 | ||
7 | > RELOAD register is loaded into COUNT register when the aspeed timer | ||
8 | > is enabled, which means the next event may be delayed because timer | ||
9 | > interrupt won't be generated until <0xFFFFFFFF - current_count + | ||
10 | > cycles>. | ||
11 | |||
12 | When running under Qemu, the system appeared "laggy". The guest is now | ||
13 | scheduling timer events too regularly, starving the host of CPU time. | ||
14 | |||
15 | This patch modifies the timer model to attempt to schedule the timer | ||
16 | expiry as the guest requests, but if we have missed the deadline we | ||
17 | re interrupt and try again, which allows the guest to catch up. | ||
18 | |||
19 | Provides expected behaviour with old and new guest code. | ||
20 | |||
21 | Fixes: c04bd47db6b9 ("hw/timer: Add ASPEED timer device model") | ||
22 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
23 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
24 | Message-id: 20190618165311.27066-8-clg@kaod.org | ||
25 | [clg: - merged a fix from Andrew Jeffery <andrew@aj.id.au> | ||
26 | "Fire interrupt on failure to meet deadline" | ||
27 | https://lists.ozlabs.org/pipermail/openbmc/2019-January/014641.html | ||
28 | - adapted commit log | ||
29 | - checkpatch fixes ] | ||
30 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 31 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20190416125744.27770-22-peter.maydell@linaro.org | ||
15 | --- | 32 | --- |
16 | target/arm/cpu.h | 12 ++++++ | 33 | hw/timer/aspeed_timer.c | 57 ++++++++++++++++++++++------------------- |
17 | hw/intc/armv7m_nvic.c | 96 +++++++++++++++++++++++++++++++++++++++++++ | 34 | 1 file changed, 30 insertions(+), 27 deletions(-) |
18 | 2 files changed, 108 insertions(+) | ||
19 | 35 | ||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 36 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c |
21 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu.h | 38 | --- a/hw/timer/aspeed_timer.c |
23 | +++ b/target/arm/cpu.h | 39 | +++ b/hw/timer/aspeed_timer.c |
24 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure); | 40 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks) |
25 | * a different exception). | 41 | |
26 | */ | 42 | static uint64_t calculate_next(struct AspeedTimer *t) |
27 | void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure); | 43 | { |
28 | +/** | 44 | - uint64_t next = 0; |
29 | + * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending | 45 | - uint32_t rate = calculate_rate(t); |
30 | + * @opaque: the NVIC | 46 | + uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); |
31 | + * @irq: the exception number to mark pending | 47 | + uint64_t next; |
32 | + * @secure: false for non-banked exceptions or for the nonsecure | 48 | |
33 | + * version of a banked exception, true for the secure version of a banked | 49 | - while (!next) { |
34 | + * exception. | 50 | - /* We don't know the relationship between the values in the match |
35 | + * | 51 | - * registers, so sort using MAX/MIN/zero. We sort in that order as the |
36 | + * Similar to armv7m_nvic_set_pending(), but specifically for exceptions | 52 | - * timer counts down to zero. */ |
37 | + * generated in the course of lazy stacking of FP registers. | 53 | - uint64_t seq[] = { |
38 | + */ | 54 | - calculate_time(t, MAX(t->match[0], t->match[1])), |
39 | +void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure); | 55 | - calculate_time(t, MIN(t->match[0], t->match[1])), |
40 | /** | 56 | - calculate_time(t, 0), |
41 | * armv7m_nvic_get_pending_irq_info: return highest priority pending | 57 | - }; |
42 | * exception, and whether it targets Secure state | 58 | - uint64_t reload_ns; |
43 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 59 | - uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); |
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/hw/intc/armv7m_nvic.c | ||
46 | +++ b/hw/intc/armv7m_nvic.c | ||
47 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure) | ||
48 | do_armv7m_nvic_set_pending(opaque, irq, secure, true); | ||
49 | } | ||
50 | |||
51 | +void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure) | ||
52 | +{ | ||
53 | + /* | 60 | + /* |
54 | + * Pend an exception during lazy FP stacking. This differs | 61 | + * We don't know the relationship between the values in the match |
55 | + * from the usual exception pending because the logic for | 62 | + * registers, so sort using MAX/MIN/zero. We sort in that order as |
56 | + * whether we should escalate depends on the saved context | 63 | + * the timer counts down to zero. |
57 | + * in the FPCCR register, not on the current state of the CPU/NVIC. | ||
58 | + */ | 64 | + */ |
59 | + NVICState *s = (NVICState *)opaque; | 65 | |
60 | + bool banked = exc_is_banked(irq); | 66 | - if (now < seq[0]) { |
61 | + VecInfo *vec; | 67 | - next = seq[0]; |
62 | + bool targets_secure; | 68 | - } else if (now < seq[1]) { |
63 | + bool escalate = false; | 69 | - next = seq[1]; |
64 | + /* | 70 | - } else if (now < seq[2]) { |
65 | + * We will only look at bits in fpccr if this is a banked exception | 71 | - next = seq[2]; |
66 | + * (in which case 'secure' tells us whether it is the S or NS version). | 72 | - } else if (t->reload) { |
67 | + * All the bits for the non-banked exceptions are in fpccr_s. | 73 | - reload_ns = muldiv64(t->reload, NANOSECONDS_PER_SECOND, rate); |
68 | + */ | 74 | - t->start = now - ((now - t->start) % reload_ns); |
69 | + uint32_t fpccr_s = s->cpu->env.v7m.fpccr[M_REG_S]; | 75 | - } else { |
70 | + uint32_t fpccr = s->cpu->env.v7m.fpccr[secure]; | 76 | - /* no reload value, return 0 */ |
71 | + | 77 | - break; |
72 | + assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq); | 78 | - } |
73 | + assert(!secure || banked); | 79 | + next = calculate_time(t, MAX(t->match[0], t->match[1])); |
74 | + | 80 | + if (now < next) { |
75 | + vec = (banked && secure) ? &s->sec_vectors[irq] : &s->vectors[irq]; | 81 | + return next; |
76 | + | 82 | } |
77 | + targets_secure = banked ? secure : exc_targets_secure(s, irq); | 83 | |
78 | + | 84 | - return next; |
79 | + switch (irq) { | 85 | + next = calculate_time(t, MIN(t->match[0], t->match[1])); |
80 | + case ARMV7M_EXCP_DEBUG: | 86 | + if (now < next) { |
81 | + if (!(fpccr_s & R_V7M_FPCCR_MONRDY_MASK)) { | 87 | + return next; |
82 | + /* Ignore DebugMonitor exception */ | ||
83 | + return; | ||
84 | + } | ||
85 | + break; | ||
86 | + case ARMV7M_EXCP_MEM: | ||
87 | + escalate = !(fpccr & R_V7M_FPCCR_MMRDY_MASK); | ||
88 | + break; | ||
89 | + case ARMV7M_EXCP_USAGE: | ||
90 | + escalate = !(fpccr & R_V7M_FPCCR_UFRDY_MASK); | ||
91 | + break; | ||
92 | + case ARMV7M_EXCP_BUS: | ||
93 | + escalate = !(fpccr_s & R_V7M_FPCCR_BFRDY_MASK); | ||
94 | + break; | ||
95 | + case ARMV7M_EXCP_SECURE: | ||
96 | + escalate = !(fpccr_s & R_V7M_FPCCR_SFRDY_MASK); | ||
97 | + break; | ||
98 | + default: | ||
99 | + g_assert_not_reached(); | ||
100 | + } | 88 | + } |
101 | + | 89 | + |
102 | + if (escalate) { | 90 | + next = calculate_time(t, 0); |
103 | + /* | 91 | + if (now < next) { |
104 | + * Escalate to HardFault: faults that initially targeted Secure | 92 | + return next; |
105 | + * continue to do so, even if HF normally targets NonSecure. | ||
106 | + */ | ||
107 | + irq = ARMV7M_EXCP_HARD; | ||
108 | + if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY) && | ||
109 | + (targets_secure || | ||
110 | + !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK))) { | ||
111 | + vec = &s->sec_vectors[irq]; | ||
112 | + } else { | ||
113 | + vec = &s->vectors[irq]; | ||
114 | + } | ||
115 | + } | 93 | + } |
116 | + | 94 | + |
117 | + if (!vec->enabled || | 95 | + /* We've missed all deadlines, fire interrupt and try again */ |
118 | + nvic_exec_prio(s) <= exc_group_prio(s, vec->prio, secure)) { | 96 | + timer_del(&t->timer); |
119 | + if (!(fpccr_s & R_V7M_FPCCR_HFRDY_MASK)) { | 97 | + |
120 | + /* | 98 | + if (timer_overflow_interrupt(t)) { |
121 | + * We want to escalate to HardFault but the context the | 99 | + t->level = !t->level; |
122 | + * FP state belongs to prevents the exception pre-empting. | 100 | + qemu_set_irq(t->irq, t->level); |
123 | + */ | ||
124 | + cpu_abort(&s->cpu->parent_obj, | ||
125 | + "Lockup: can't escalate to HardFault during " | ||
126 | + "lazy FP register stacking\n"); | ||
127 | + } | ||
128 | + } | 101 | + } |
129 | + | 102 | + |
130 | + if (escalate) { | 103 | + t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); |
131 | + s->cpu->env.v7m.hfsr |= R_V7M_HFSR_FORCED_MASK; | 104 | + return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0)); |
132 | + } | 105 | } |
133 | + if (!vec->pending) { | 106 | |
134 | + vec->pending = 1; | 107 | static void aspeed_timer_mod(AspeedTimer *t) |
135 | + /* | ||
136 | + * We do not call nvic_irq_update(), because we know our caller | ||
137 | + * is going to handle causing us to take the exception by | ||
138 | + * raising EXCP_LAZYFP, so raising the IRQ line would be | ||
139 | + * pointless extra work. We just need to recompute the | ||
140 | + * priorities so that armv7m_nvic_can_take_pending_exception() | ||
141 | + * returns the right answer. | ||
142 | + */ | ||
143 | + nvic_recompute_state(s); | ||
144 | + } | ||
145 | +} | ||
146 | + | ||
147 | /* Make pending IRQ active. */ | ||
148 | void armv7m_nvic_acknowledge_irq(void *opaque) | ||
149 | { | ||
150 | -- | 108 | -- |
151 | 2.20.1 | 109 | 2.20.1 |
152 | 110 | ||
153 | 111 | diff view generated by jsdifflib |
1 | The M-profile CONTROL register has two bits -- SFPA and FPCA -- | 1 | From: Andrew Jeffery <andrew@aj.id.au> |
---|---|---|---|
2 | which relate to floating-point support, and should be RES0 otherwise. | ||
3 | Handle them correctly in the MSR/MRS register access code. | ||
4 | Neither is banked between security states, so they are stored | ||
5 | in v7m.control[M_REG_S] regardless of current security state. | ||
6 | 2 | ||
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 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20190416125744.27770-9-peter.maydell@linaro.org | ||
10 | --- | 16 | --- |
11 | target/arm/helper.c | 57 ++++++++++++++++++++++++++++++++++++++------- | 17 | hw/timer/aspeed_timer.c | 6 +++++- |
12 | 1 file changed, 49 insertions(+), 8 deletions(-) | 18 | 1 file changed, 5 insertions(+), 1 deletion(-) |
13 | 19 | ||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 20 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c |
15 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 22 | --- a/hw/timer/aspeed_timer.c |
17 | +++ b/target/arm/helper.c | 23 | +++ b/hw/timer/aspeed_timer.c |
18 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | 24 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_timer_get_value(AspeedTimer *t, int reg) |
19 | return xpsr_read(env) & mask; | 25 | |
20 | break; | 26 | switch (reg) { |
21 | case 20: /* CONTROL */ | 27 | case TIMER_REG_STATUS: |
22 | - return env->v7m.control[env->v7m.secure]; | 28 | - value = calculate_ticks(t, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); |
23 | + { | 29 | + if (timer_enabled(t)) { |
24 | + uint32_t value = env->v7m.control[env->v7m.secure]; | 30 | + value = calculate_ticks(t, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); |
25 | + if (!env->v7m.secure) { | 31 | + } else { |
26 | + /* SFPA is RAZ/WI from NS; FPCA is stored in the M_REG_S bank */ | 32 | + value = t->reload; |
27 | + value |= env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK; | ||
28 | + } | ||
29 | + return value; | ||
30 | + } | ||
31 | case 0x94: /* CONTROL_NS */ | ||
32 | /* We have to handle this here because unprivileged Secure code | ||
33 | * can read the NS CONTROL register. | ||
34 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | ||
35 | if (!env->v7m.secure) { | ||
36 | return 0; | ||
37 | } | ||
38 | - return env->v7m.control[M_REG_NS]; | ||
39 | + return env->v7m.control[M_REG_NS] | | ||
40 | + (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK); | ||
41 | } | ||
42 | |||
43 | if (el == 0) { | ||
44 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
45 | */ | ||
46 | uint32_t mask = extract32(maskreg, 8, 4); | ||
47 | uint32_t reg = extract32(maskreg, 0, 8); | ||
48 | + int cur_el = arm_current_el(env); | ||
49 | |||
50 | - if (arm_current_el(env) == 0 && reg > 7) { | ||
51 | - /* only xPSR sub-fields may be written by unprivileged */ | ||
52 | + if (cur_el == 0 && reg > 7 && reg != 20) { | ||
53 | + /* | ||
54 | + * only xPSR sub-fields and CONTROL.SFPA may be written by | ||
55 | + * unprivileged code | ||
56 | + */ | ||
57 | return; | ||
58 | } | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
61 | env->v7m.control[M_REG_NS] &= ~R_V7M_CONTROL_NPRIV_MASK; | ||
62 | env->v7m.control[M_REG_NS] |= val & R_V7M_CONTROL_NPRIV_MASK; | ||
63 | } | ||
64 | + /* | ||
65 | + * SFPA is RAZ/WI from NS. FPCA is RO if NSACR.CP10 == 0, | ||
66 | + * RES0 if the FPU is not present, and is stored in the S bank | ||
67 | + */ | ||
68 | + if (arm_feature(env, ARM_FEATURE_VFP) && | ||
69 | + extract32(env->v7m.nsacr, 10, 1)) { | ||
70 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK; | ||
71 | + env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK; | ||
72 | + } | ||
73 | return; | ||
74 | case 0x98: /* SP_NS */ | ||
75 | { | ||
76 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
77 | env->v7m.faultmask[env->v7m.secure] = val & 1; | ||
78 | break; | ||
79 | case 20: /* CONTROL */ | ||
80 | - /* Writing to the SPSEL bit only has an effect if we are in | ||
81 | + /* | ||
82 | + * Writing to the SPSEL bit only has an effect if we are in | ||
83 | * thread mode; other bits can be updated by any privileged code. | ||
84 | * write_v7m_control_spsel() deals with updating the SPSEL bit in | ||
85 | * env->v7m.control, so we only need update the others. | ||
86 | * For v7M, we must just ignore explicit writes to SPSEL in handler | ||
87 | * mode; for v8M the write is permitted but will have no effect. | ||
88 | + * All these bits are writes-ignored from non-privileged code, | ||
89 | + * except for SFPA. | ||
90 | */ | ||
91 | - if (arm_feature(env, ARM_FEATURE_V8) || | ||
92 | - !arm_v7m_is_handler_mode(env)) { | ||
93 | + if (cur_el > 0 && (arm_feature(env, ARM_FEATURE_V8) || | ||
94 | + !arm_v7m_is_handler_mode(env))) { | ||
95 | write_v7m_control_spsel(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0); | ||
96 | } | ||
97 | - if (arm_feature(env, ARM_FEATURE_M_MAIN)) { | ||
98 | + if (cur_el > 0 && arm_feature(env, ARM_FEATURE_M_MAIN)) { | ||
99 | env->v7m.control[env->v7m.secure] &= ~R_V7M_CONTROL_NPRIV_MASK; | ||
100 | env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK; | ||
101 | } | ||
102 | + if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
103 | + /* | ||
104 | + * SFPA is RAZ/WI from NS or if no FPU. | ||
105 | + * FPCA is RO if NSACR.CP10 == 0, RES0 if the FPU is not present. | ||
106 | + * Both are stored in the S bank. | ||
107 | + */ | ||
108 | + if (env->v7m.secure) { | ||
109 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | ||
110 | + env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_SFPA_MASK; | ||
111 | + } | ||
112 | + if (cur_el > 0 && | ||
113 | + (env->v7m.secure || !arm_feature(env, ARM_FEATURE_M_SECURITY) || | ||
114 | + extract32(env->v7m.nsacr, 10, 1))) { | ||
115 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK; | ||
116 | + env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK; | ||
117 | + } | ||
118 | + } | 33 | + } |
119 | break; | 34 | break; |
120 | default: | 35 | case TIMER_REG_RELOAD: |
121 | bad_reg: | 36 | value = t->reload; |
122 | -- | 37 | -- |
123 | 2.20.1 | 38 | 2.20.1 |
124 | 39 | ||
125 | 40 | diff view generated by jsdifflib |
1 | Implement the VLLDM instruction for v7M for the FPU present cas. | 1 | From: Andrew Jeffery <andrew@aj.id.au> |
---|---|---|---|
2 | 2 | ||
3 | If the match value exceeds reload then we don't want to include it in | ||
4 | calculations for the next event. | ||
5 | |||
6 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> | ||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Message-id: 20190618165311.27066-10-clg@kaod.org | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20190416125744.27770-26-peter.maydell@linaro.org | ||
6 | --- | 10 | --- |
7 | target/arm/helper.h | 1 + | 11 | hw/timer/aspeed_timer.c | 13 ++++++++++--- |
8 | target/arm/helper.c | 54 ++++++++++++++++++++++++++++++++++++++++++ | 12 | 1 file changed, 10 insertions(+), 3 deletions(-) |
9 | target/arm/translate.c | 2 +- | ||
10 | 3 files changed, 56 insertions(+), 1 deletion(-) | ||
11 | 13 | ||
12 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 14 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c |
13 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/helper.h | 16 | --- a/hw/timer/aspeed_timer.c |
15 | +++ b/target/arm/helper.h | 17 | +++ b/hw/timer/aspeed_timer.c |
16 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_tt, i32, env, i32, i32) | 18 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks) |
17 | DEF_HELPER_1(v7m_preserve_fp_state, void, env) | 19 | return t->start + delta_ns; |
18 | |||
19 | DEF_HELPER_2(v7m_vlstm, void, env, i32) | ||
20 | +DEF_HELPER_2(v7m_vlldm, void, env, i32) | ||
21 | |||
22 | DEF_HELPER_2(v8m_stackcheck, void, env, i32) | ||
23 | |||
24 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/helper.c | ||
27 | +++ b/target/arm/helper.c | ||
28 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr) | ||
29 | g_assert_not_reached(); | ||
30 | } | 20 | } |
31 | 21 | ||
32 | +void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) | 22 | +static inline uint32_t calculate_match(struct AspeedTimer *t, int i) |
33 | +{ | 23 | +{ |
34 | + /* translate.c should never generate calls here in user-only mode */ | 24 | + return t->match[i] < t->reload ? t->match[i] : 0; |
35 | + g_assert_not_reached(); | ||
36 | +} | 25 | +} |
37 | + | 26 | + |
38 | uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | 27 | static uint64_t calculate_next(struct AspeedTimer *t) |
39 | { | 28 | { |
40 | /* The TT instructions can be used by unprivileged code, but in | 29 | uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); |
41 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr) | 30 | @@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t) |
42 | env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK; | 31 | * the timer counts down to zero. |
32 | */ | ||
33 | |||
34 | - next = calculate_time(t, MAX(t->match[0], t->match[1])); | ||
35 | + next = calculate_time(t, MAX(calculate_match(t, 0), calculate_match(t, 1))); | ||
36 | if (now < next) { | ||
37 | return next; | ||
38 | } | ||
39 | |||
40 | - next = calculate_time(t, MIN(t->match[0], t->match[1])); | ||
41 | + next = calculate_time(t, MIN(calculate_match(t, 0), calculate_match(t, 1))); | ||
42 | if (now < next) { | ||
43 | return next; | ||
44 | } | ||
45 | @@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t) | ||
46 | qemu_set_irq(t->irq, t->level); | ||
47 | } | ||
48 | |||
49 | + next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0); | ||
50 | t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
51 | - return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0)); | ||
52 | + | ||
53 | + return calculate_time(t, next); | ||
43 | } | 54 | } |
44 | 55 | ||
45 | +void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) | 56 | static void aspeed_timer_mod(AspeedTimer *t) |
46 | +{ | ||
47 | + /* fptr is the value of Rn, the frame pointer we load the FP regs from */ | ||
48 | + assert(env->v7m.secure); | ||
49 | + | ||
50 | + if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) { | ||
51 | + return; | ||
52 | + } | ||
53 | + | ||
54 | + /* Check access to the coprocessor is permitted */ | ||
55 | + if (!v7m_cpacr_pass(env, true, arm_current_el(env) != 0)) { | ||
56 | + raise_exception_ra(env, EXCP_NOCP, 0, 1, GETPC()); | ||
57 | + } | ||
58 | + | ||
59 | + if (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK) { | ||
60 | + /* State in FP is still valid */ | ||
61 | + env->v7m.fpccr[M_REG_S] &= ~R_V7M_FPCCR_LSPACT_MASK; | ||
62 | + } else { | ||
63 | + bool ts = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK; | ||
64 | + int i; | ||
65 | + uint32_t fpscr; | ||
66 | + | ||
67 | + if (fptr & 7) { | ||
68 | + raise_exception_ra(env, EXCP_UNALIGNED, 0, 1, GETPC()); | ||
69 | + } | ||
70 | + | ||
71 | + for (i = 0; i < (ts ? 32 : 16); i += 2) { | ||
72 | + uint32_t slo, shi; | ||
73 | + uint64_t dn; | ||
74 | + uint32_t faddr = fptr + 4 * i; | ||
75 | + | ||
76 | + if (i >= 16) { | ||
77 | + faddr += 8; /* skip the slot for the FPSCR */ | ||
78 | + } | ||
79 | + | ||
80 | + slo = cpu_ldl_data(env, faddr); | ||
81 | + shi = cpu_ldl_data(env, faddr + 4); | ||
82 | + | ||
83 | + dn = (uint64_t) shi << 32 | slo; | ||
84 | + *aa32_vfp_dreg(env, i / 2) = dn; | ||
85 | + } | ||
86 | + fpscr = cpu_ldl_data(env, fptr + 0x40); | ||
87 | + vfp_set_fpscr(env, fpscr); | ||
88 | + } | ||
89 | + | ||
90 | + env->v7m.control[M_REG_S] |= R_V7M_CONTROL_FPCA_MASK; | ||
91 | +} | ||
92 | + | ||
93 | static bool v7m_push_stack(ARMCPU *cpu) | ||
94 | { | ||
95 | /* Do the "set up stack frame" part of exception entry, | ||
96 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/target/arm/translate.c | ||
99 | +++ b/target/arm/translate.c | ||
100 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
101 | TCGv_i32 fptr = load_reg(s, rn); | ||
102 | |||
103 | if (extract32(insn, 20, 1)) { | ||
104 | - /* VLLDM */ | ||
105 | + gen_helper_v7m_vlldm(cpu_env, fptr); | ||
106 | } else { | ||
107 | gen_helper_v7m_vlstm(cpu_env, fptr); | ||
108 | } | ||
109 | -- | 57 | -- |
110 | 2.20.1 | 58 | 2.20.1 |
111 | 59 | ||
112 | 60 | diff view generated by jsdifflib |
1 | Move the NS TBFLAG down from bit 19 to bit 6, which has not | 1 | From: Christian Svensson <bluecmd@google.com> |
---|---|---|---|
2 | been used since commit c1e3781090b9d36c60 in 2015, when we | ||
3 | started passing the entire MMU index in the TB flags rather | ||
4 | than just a 'privilege level' bit. | ||
5 | 2 | ||
6 | This rearrangement is not strictly necessary, but means that | 3 | If the host decrements the counter register that results in a negative |
7 | we can put M-profile-only bits next to each other rather | 4 | delta. This is then passed to muldiv64 which only handles unsigned |
8 | than scattered across the flag word. | 5 | numbers resulting in bogus results. |
9 | 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 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20190416125744.27770-17-peter.maydell@linaro.org | ||
13 | --- | 19 | --- |
14 | target/arm/cpu.h | 11 ++++++----- | 20 | hw/timer/aspeed_timer.c | 6 +++++- |
15 | 1 file changed, 6 insertions(+), 5 deletions(-) | 21 | 1 file changed, 5 insertions(+), 1 deletion(-) |
16 | 22 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 23 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c |
18 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 25 | --- a/hw/timer/aspeed_timer.c |
20 | +++ b/target/arm/cpu.h | 26 | +++ b/hw/timer/aspeed_timer.c |
21 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1) | 27 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg, |
22 | FIELD(TBFLAG_A32, THUMB, 0, 1) | 28 | int64_t delta = (int64_t) value - (int64_t) calculate_ticks(t, now); |
23 | FIELD(TBFLAG_A32, VECLEN, 1, 3) | 29 | uint32_t rate = calculate_rate(t); |
24 | FIELD(TBFLAG_A32, VECSTRIDE, 4, 2) | 30 | |
25 | +/* | 31 | - t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate); |
26 | + * Indicates whether cp register reads and writes by guest code should access | 32 | + if (delta >= 0) { |
27 | + * the secure or nonsecure bank of banked registers; note that this is not | 33 | + t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate); |
28 | + * the same thing as the current security state of the processor! | 34 | + } else { |
29 | + */ | 35 | + t->start -= muldiv64(-delta, NANOSECONDS_PER_SECOND, rate); |
30 | +FIELD(TBFLAG_A32, NS, 6, 1) | 36 | + } |
31 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | 37 | aspeed_timer_mod(t); |
32 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | 38 | } |
33 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | 39 | break; |
34 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | ||
35 | * checks on the other bits at runtime | ||
36 | */ | ||
37 | FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2) | ||
38 | -/* Indicates whether cp register reads and writes by guest code should access | ||
39 | - * the secure or nonsecure bank of banked registers; note that this is not | ||
40 | - * the same thing as the current security state of the processor! | ||
41 | - */ | ||
42 | -FIELD(TBFLAG_A32, NS, 19, 1) | ||
43 | /* For M profile only, Handler (ie not Thread) mode */ | ||
44 | FIELD(TBFLAG_A32, HANDLER, 21, 1) | ||
45 | /* For M profile only, whether we should generate stack-limit checks */ | ||
46 | -- | 40 | -- |
47 | 2.20.1 | 41 | 2.20.1 |
48 | 42 | ||
49 | 43 | diff view generated by jsdifflib |
1 | For M-profile the MVFR* ID registers are memory mapped, in the | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | range we implement via the NVIC. Allow them to be read. | ||
3 | (If the CPU has no FPU, these registers are defined to be RAZ.) | ||
4 | 2 | ||
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 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20190416125744.27770-3-peter.maydell@linaro.org | ||
8 | --- | 9 | --- |
9 | hw/intc/armv7m_nvic.c | 6 ++++++ | 10 | hw/arm/aspeed.c | 2 -- |
10 | 1 file changed, 6 insertions(+) | 11 | 1 file changed, 2 deletions(-) |
11 | 12 | ||
12 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 13 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c |
13 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/intc/armv7m_nvic.c | 15 | --- a/hw/arm/aspeed.c |
15 | +++ b/hw/intc/armv7m_nvic.c | 16 | +++ b/hw/arm/aspeed.c |
16 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 17 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, |
17 | return 0; | 18 | memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); |
18 | } | 19 | memory_region_add_subregion(get_system_memory(), |
19 | return cpu->env.v7m.sfar; | 20 | sc->info->memmap[ASPEED_SDRAM], &bmc->ram); |
20 | + case 0xf40: /* MVFR0 */ | 21 | - object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram), |
21 | + return cpu->isar.mvfr0; | 22 | - &error_abort); |
22 | + case 0xf44: /* MVFR1 */ | 23 | |
23 | + return cpu->isar.mvfr1; | 24 | max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size", |
24 | + case 0xf48: /* MVFR2 */ | 25 | &error_abort); |
25 | + return cpu->isar.mvfr2; | ||
26 | default: | ||
27 | bad_offset: | ||
28 | qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset); | ||
29 | -- | 26 | -- |
30 | 2.20.1 | 27 | 2.20.1 |
31 | 28 | ||
32 | 29 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 3 | The RAM memory region is defined after the SoC is realized when the |
4 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 4 | SDMC controller has checked that the defined RAM size for the machine |
5 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 5 | is correct. This is problematic for controller models requiring a link |
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 6 | on the RAM region, for DMA support in the SMC controller for instance. |
7 | Message-id: 20190412165416.7977-2-philmd@redhat.com | 7 | |
8 | Introduce a container memory region for the RAM that we can link into | ||
9 | the controllers early, before the SoC is realized. It will be | ||
10 | populated with the RAM region after the checks have be done. | ||
11 | |||
12 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
13 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
14 | Message-id: 20190618165311.27066-14-clg@kaod.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 16 | --- |
10 | hw/arm/aspeed.c | 13 +++++++++---- | 17 | hw/arm/aspeed.c | 13 +++++++++---- |
11 | 1 file changed, 9 insertions(+), 4 deletions(-) | 18 | 1 file changed, 9 insertions(+), 4 deletions(-) |
12 | 19 | ||
13 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 20 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c |
14 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/aspeed.c | 22 | --- a/hw/arm/aspeed.c |
16 | +++ b/hw/arm/aspeed.c | 23 | +++ b/hw/arm/aspeed.c |
17 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ static struct arm_boot_info aspeed_board_binfo = { |
18 | #include "hw/arm/aspeed_soc.h" | 25 | |
19 | #include "hw/boards.h" | 26 | struct AspeedBoardState { |
20 | #include "hw/i2c/smbus_eeprom.h" | 27 | AspeedSoCState soc; |
21 | +#include "hw/misc/pca9552.h" | 28 | + MemoryRegion ram_container; |
22 | +#include "hw/misc/tmp105.h" | 29 | MemoryRegion ram; |
23 | #include "qemu/log.h" | 30 | MemoryRegion max_ram; |
24 | #include "sysemu/block-backend.h" | 31 | }; |
25 | #include "hw/loader.h" | 32 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, |
26 | @@ -XXX,XX +XXX,XX @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc) | 33 | ram_addr_t max_ram_size; |
27 | eeprom_buf); | 34 | |
28 | 35 | bmc = g_new0(AspeedBoardState, 1); | |
29 | /* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ | 36 | + |
30 | - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d); | 37 | + memory_region_init(&bmc->ram_container, NULL, "aspeed-ram-container", |
31 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), | 38 | + UINT32_MAX); |
32 | + TYPE_TMP105, 0x4d); | 39 | + |
33 | 40 | object_initialize_child(OBJECT(machine), "soc", &bmc->soc, | |
34 | /* The AST2500 EVB does not have an RTC. Let's pretend that one is | 41 | (sizeof(bmc->soc)), cfg->soc_name, &error_abort, |
35 | * plugged on the I2C bus header */ | 42 | NULL); |
36 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | 43 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, |
37 | AspeedSoCState *soc = &bmc->soc; | 44 | &error_abort); |
38 | uint8_t *eeprom_buf = g_malloc0(8 * 1024); | 45 | |
39 | 46 | memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); | |
40 | - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60); | 47 | + memory_region_add_subregion(&bmc->ram_container, 0, &bmc->ram); |
41 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), TYPE_PCA9552, | 48 | memory_region_add_subregion(get_system_memory(), |
42 | + 0x60); | 49 | - sc->info->memmap[ASPEED_SDRAM], &bmc->ram); |
43 | 50 | + sc->info->memmap[ASPEED_SDRAM], | |
44 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c); | 51 | + &bmc->ram_container); |
45 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c); | 52 | |
46 | 53 | max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size", | |
47 | /* The Witherspoon expects a TMP275 but a TMP105 is compatible */ | 54 | &error_abort); |
48 | - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a); | 55 | memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL, |
49 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), TYPE_TMP105, | 56 | "max_ram", max_ram_size - ram_size); |
50 | + 0x4a); | 57 | - memory_region_add_subregion(get_system_memory(), |
51 | 58 | - sc->info->memmap[ASPEED_SDRAM] + ram_size, | |
52 | /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is | 59 | - &bmc->max_ram); |
53 | * good enough */ | 60 | + memory_region_add_subregion(&bmc->ram_container, ram_size, &bmc->max_ram); |
54 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | 61 | |
55 | 62 | aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort); | |
56 | smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51, | 63 | aspeed_board_init_flashes(&bmc->soc.spi[0], cfg->spi_model, &error_abort); |
57 | eeprom_buf); | ||
58 | - i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "pca9552", | ||
59 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), TYPE_PCA9552, | ||
60 | 0x60); | ||
61 | } | ||
62 | |||
63 | -- | 64 | -- |
64 | 2.20.1 | 65 | 2.20.1 |
65 | 66 | ||
66 | 67 | diff view generated by jsdifflib |
1 | The M-profile floating point support has three associated config | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | registers: FPCAR, FPCCR and FPDSCR. It also makes the registers | ||
3 | CPACR and NSACR have behaviour other than reads-as-zero. | ||
4 | Add support for all of these as simple reads-as-written registers. | ||
5 | We will hook up actual functionality later. | ||
6 | 2 | ||
7 | The main complexity here is handling the FPCCR register, which | 3 | The DRAM address of a DMA transaction depends on the DRAM base address |
8 | has a mix of banked and unbanked bits. | 4 | of the SoC. Inform the SMC controller model with this value. |
9 | 5 | ||
10 | Note that we don't share storage with the A-profile | 6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
11 | cpu->cp15.nsacr and cpu->cp15.cpacr_el1, though the behaviour | 7 | Reviewed-by: Joel Stanley <joel@jms.id.au> |
12 | is quite similar, for two reasons: | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
13 | * the M profile CPACR is banked between security states | 9 | Message-id: 20190618165311.27066-15-clg@kaod.org |
14 | * it preserves the invariant that M profile uses no state | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | inside the cp15 substruct | 11 | --- |
12 | include/hw/ssi/aspeed_smc.h | 3 +++ | ||
13 | hw/arm/aspeed_soc.c | 6 ++++++ | ||
14 | hw/ssi/aspeed_smc.c | 1 + | ||
15 | 3 files changed, 10 insertions(+) | ||
16 | 16 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Message-id: 20190416125744.27770-4-peter.maydell@linaro.org | ||
20 | --- | ||
21 | target/arm/cpu.h | 34 ++++++++++++ | ||
22 | hw/intc/armv7m_nvic.c | 125 ++++++++++++++++++++++++++++++++++++++++++ | ||
23 | target/arm/cpu.c | 5 ++ | ||
24 | target/arm/machine.c | 16 ++++++ | ||
25 | 4 files changed, 180 insertions(+) | ||
26 | |||
27 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
28 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/arm/cpu.h | 19 | --- a/include/hw/ssi/aspeed_smc.h |
30 | +++ b/target/arm/cpu.h | 20 | +++ b/include/hw/ssi/aspeed_smc.h |
31 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 21 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCState { |
32 | uint32_t scr[M_REG_NUM_BANKS]; | 22 | uint8_t r_timings; |
33 | uint32_t msplim[M_REG_NUM_BANKS]; | 23 | uint8_t conf_enable_w0; |
34 | uint32_t psplim[M_REG_NUM_BANKS]; | 24 | |
35 | + uint32_t fpcar[M_REG_NUM_BANKS]; | 25 | + /* for DMA support */ |
36 | + uint32_t fpccr[M_REG_NUM_BANKS]; | 26 | + uint64_t sdram_base; |
37 | + uint32_t fpdscr[M_REG_NUM_BANKS]; | ||
38 | + uint32_t cpacr[M_REG_NUM_BANKS]; | ||
39 | + uint32_t nsacr; | ||
40 | } v7m; | ||
41 | |||
42 | /* Information associated with an exception about to be taken: | ||
43 | @@ -XXX,XX +XXX,XX @@ FIELD(V7M_CSSELR, LEVEL, 1, 3) | ||
44 | */ | ||
45 | FIELD(V7M_CSSELR, INDEX, 0, 4) | ||
46 | |||
47 | +/* v7M FPCCR bits */ | ||
48 | +FIELD(V7M_FPCCR, LSPACT, 0, 1) | ||
49 | +FIELD(V7M_FPCCR, USER, 1, 1) | ||
50 | +FIELD(V7M_FPCCR, S, 2, 1) | ||
51 | +FIELD(V7M_FPCCR, THREAD, 3, 1) | ||
52 | +FIELD(V7M_FPCCR, HFRDY, 4, 1) | ||
53 | +FIELD(V7M_FPCCR, MMRDY, 5, 1) | ||
54 | +FIELD(V7M_FPCCR, BFRDY, 6, 1) | ||
55 | +FIELD(V7M_FPCCR, SFRDY, 7, 1) | ||
56 | +FIELD(V7M_FPCCR, MONRDY, 8, 1) | ||
57 | +FIELD(V7M_FPCCR, SPLIMVIOL, 9, 1) | ||
58 | +FIELD(V7M_FPCCR, UFRDY, 10, 1) | ||
59 | +FIELD(V7M_FPCCR, RES0, 11, 15) | ||
60 | +FIELD(V7M_FPCCR, TS, 26, 1) | ||
61 | +FIELD(V7M_FPCCR, CLRONRETS, 27, 1) | ||
62 | +FIELD(V7M_FPCCR, CLRONRET, 28, 1) | ||
63 | +FIELD(V7M_FPCCR, LSPENS, 29, 1) | ||
64 | +FIELD(V7M_FPCCR, LSPEN, 30, 1) | ||
65 | +FIELD(V7M_FPCCR, ASPEN, 31, 1) | ||
66 | +/* These bits are banked. Others are non-banked and live in the M_REG_S bank */ | ||
67 | +#define R_V7M_FPCCR_BANKED_MASK \ | ||
68 | + (R_V7M_FPCCR_LSPACT_MASK | \ | ||
69 | + R_V7M_FPCCR_USER_MASK | \ | ||
70 | + R_V7M_FPCCR_THREAD_MASK | \ | ||
71 | + R_V7M_FPCCR_MMRDY_MASK | \ | ||
72 | + R_V7M_FPCCR_SPLIMVIOL_MASK | \ | ||
73 | + R_V7M_FPCCR_UFRDY_MASK | \ | ||
74 | + R_V7M_FPCCR_ASPEN_MASK) | ||
75 | + | 27 | + |
76 | /* | 28 | AspeedSMCFlash *flashes; |
77 | * System register ID fields. | 29 | |
78 | */ | 30 | uint8_t snoop_index; |
79 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 31 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c |
80 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
81 | --- a/hw/intc/armv7m_nvic.c | 33 | --- a/hw/arm/aspeed_soc.c |
82 | +++ b/hw/intc/armv7m_nvic.c | 34 | +++ b/hw/arm/aspeed_soc.c |
83 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 35 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
84 | } | 36 | aspeed_soc_get_irq(s, ASPEED_I2C)); |
85 | case 0xd84: /* CSSELR */ | 37 | |
86 | return cpu->env.v7m.csselr[attrs.secure]; | 38 | /* FMC, The number of CS is set at the board level */ |
87 | + case 0xd88: /* CPACR */ | 39 | + object_property_set_int(OBJECT(&s->fmc), sc->info->memmap[ASPEED_SDRAM], |
88 | + if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | 40 | + "sdram-base", &err); |
89 | + return 0; | 41 | + if (err) { |
90 | + } | 42 | + error_propagate(errp, err); |
91 | + return cpu->env.v7m.cpacr[attrs.secure]; | 43 | + return; |
92 | + case 0xd8c: /* NSACR */ | 44 | + } |
93 | + if (!attrs.secure || !arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | 45 | object_property_set_bool(OBJECT(&s->fmc), true, "realized", &err); |
94 | + return 0; | 46 | if (err) { |
95 | + } | 47 | error_propagate(errp, err); |
96 | + return cpu->env.v7m.nsacr; | 48 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c |
97 | /* TODO: Implement debug registers. */ | ||
98 | case 0xd90: /* MPU_TYPE */ | ||
99 | /* Unified MPU; if the MPU is not present this value is zero */ | ||
100 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
101 | return 0; | ||
102 | } | ||
103 | return cpu->env.v7m.sfar; | ||
104 | + case 0xf34: /* FPCCR */ | ||
105 | + if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
106 | + return 0; | ||
107 | + } | ||
108 | + if (attrs.secure) { | ||
109 | + return cpu->env.v7m.fpccr[M_REG_S]; | ||
110 | + } else { | ||
111 | + /* | ||
112 | + * NS can read LSPEN, CLRONRET and MONRDY. It can read | ||
113 | + * BFRDY and HFRDY if AIRCR.BFHFNMINS != 0; | ||
114 | + * other non-banked bits RAZ. | ||
115 | + * TODO: MONRDY should RAZ/WI if DEMCR.SDME is set. | ||
116 | + */ | ||
117 | + uint32_t value = cpu->env.v7m.fpccr[M_REG_S]; | ||
118 | + uint32_t mask = R_V7M_FPCCR_LSPEN_MASK | | ||
119 | + R_V7M_FPCCR_CLRONRET_MASK | | ||
120 | + R_V7M_FPCCR_MONRDY_MASK; | ||
121 | + | ||
122 | + if (s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) { | ||
123 | + mask |= R_V7M_FPCCR_BFRDY_MASK | R_V7M_FPCCR_HFRDY_MASK; | ||
124 | + } | ||
125 | + | ||
126 | + value &= mask; | ||
127 | + | ||
128 | + value |= cpu->env.v7m.fpccr[M_REG_NS]; | ||
129 | + return value; | ||
130 | + } | ||
131 | + case 0xf38: /* FPCAR */ | ||
132 | + if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
133 | + return 0; | ||
134 | + } | ||
135 | + return cpu->env.v7m.fpcar[attrs.secure]; | ||
136 | + case 0xf3c: /* FPDSCR */ | ||
137 | + if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
138 | + return 0; | ||
139 | + } | ||
140 | + return cpu->env.v7m.fpdscr[attrs.secure]; | ||
141 | case 0xf40: /* MVFR0 */ | ||
142 | return cpu->isar.mvfr0; | ||
143 | case 0xf44: /* MVFR1 */ | ||
144 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
145 | cpu->env.v7m.csselr[attrs.secure] = value & R_V7M_CSSELR_INDEX_MASK; | ||
146 | } | ||
147 | break; | ||
148 | + case 0xd88: /* CPACR */ | ||
149 | + if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
150 | + /* We implement only the Floating Point extension's CP10/CP11 */ | ||
151 | + cpu->env.v7m.cpacr[attrs.secure] = value & (0xf << 20); | ||
152 | + } | ||
153 | + break; | ||
154 | + case 0xd8c: /* NSACR */ | ||
155 | + if (attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
156 | + /* We implement only the Floating Point extension's CP10/CP11 */ | ||
157 | + cpu->env.v7m.nsacr = value & (3 << 10); | ||
158 | + } | ||
159 | + break; | ||
160 | case 0xd90: /* MPU_TYPE */ | ||
161 | return; /* RO */ | ||
162 | case 0xd94: /* MPU_CTRL */ | ||
163 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
164 | } | ||
165 | break; | ||
166 | } | ||
167 | + case 0xf34: /* FPCCR */ | ||
168 | + if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
169 | + /* Not all bits here are banked. */ | ||
170 | + uint32_t fpccr_s; | ||
171 | + | ||
172 | + if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { | ||
173 | + /* Don't allow setting of bits not present in v7M */ | ||
174 | + value &= (R_V7M_FPCCR_LSPACT_MASK | | ||
175 | + R_V7M_FPCCR_USER_MASK | | ||
176 | + R_V7M_FPCCR_THREAD_MASK | | ||
177 | + R_V7M_FPCCR_HFRDY_MASK | | ||
178 | + R_V7M_FPCCR_MMRDY_MASK | | ||
179 | + R_V7M_FPCCR_BFRDY_MASK | | ||
180 | + R_V7M_FPCCR_MONRDY_MASK | | ||
181 | + R_V7M_FPCCR_LSPEN_MASK | | ||
182 | + R_V7M_FPCCR_ASPEN_MASK); | ||
183 | + } | ||
184 | + value &= ~R_V7M_FPCCR_RES0_MASK; | ||
185 | + | ||
186 | + if (!attrs.secure) { | ||
187 | + /* Some non-banked bits are configurably writable by NS */ | ||
188 | + fpccr_s = cpu->env.v7m.fpccr[M_REG_S]; | ||
189 | + if (!(fpccr_s & R_V7M_FPCCR_LSPENS_MASK)) { | ||
190 | + uint32_t lspen = FIELD_EX32(value, V7M_FPCCR, LSPEN); | ||
191 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, LSPEN, lspen); | ||
192 | + } | ||
193 | + if (!(fpccr_s & R_V7M_FPCCR_CLRONRETS_MASK)) { | ||
194 | + uint32_t cor = FIELD_EX32(value, V7M_FPCCR, CLRONRET); | ||
195 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, CLRONRET, cor); | ||
196 | + } | ||
197 | + if ((s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | ||
198 | + uint32_t hfrdy = FIELD_EX32(value, V7M_FPCCR, HFRDY); | ||
199 | + uint32_t bfrdy = FIELD_EX32(value, V7M_FPCCR, BFRDY); | ||
200 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, HFRDY, hfrdy); | ||
201 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, BFRDY, bfrdy); | ||
202 | + } | ||
203 | + /* TODO MONRDY should RAZ/WI if DEMCR.SDME is set */ | ||
204 | + { | ||
205 | + uint32_t monrdy = FIELD_EX32(value, V7M_FPCCR, MONRDY); | ||
206 | + fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, MONRDY, monrdy); | ||
207 | + } | ||
208 | + | ||
209 | + /* | ||
210 | + * All other non-banked bits are RAZ/WI from NS; write | ||
211 | + * just the banked bits to fpccr[M_REG_NS]. | ||
212 | + */ | ||
213 | + value &= R_V7M_FPCCR_BANKED_MASK; | ||
214 | + cpu->env.v7m.fpccr[M_REG_NS] = value; | ||
215 | + } else { | ||
216 | + fpccr_s = value; | ||
217 | + } | ||
218 | + cpu->env.v7m.fpccr[M_REG_S] = fpccr_s; | ||
219 | + } | ||
220 | + break; | ||
221 | + case 0xf38: /* FPCAR */ | ||
222 | + if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
223 | + value &= ~7; | ||
224 | + cpu->env.v7m.fpcar[attrs.secure] = value; | ||
225 | + } | ||
226 | + break; | ||
227 | + case 0xf3c: /* FPDSCR */ | ||
228 | + if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) { | ||
229 | + value &= 0x07c00000; | ||
230 | + cpu->env.v7m.fpdscr[attrs.secure] = value; | ||
231 | + } | ||
232 | + break; | ||
233 | case 0xf50: /* ICIALLU */ | ||
234 | case 0xf58: /* ICIMVAU */ | ||
235 | case 0xf5c: /* DCIMVAC */ | ||
236 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
237 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
238 | --- a/target/arm/cpu.c | 50 | --- a/hw/ssi/aspeed_smc.c |
239 | +++ b/target/arm/cpu.c | 51 | +++ b/hw/ssi/aspeed_smc.c |
240 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | 52 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_smc = { |
241 | env->v7m.ccr[M_REG_S] |= R_V7M_CCR_UNALIGN_TRP_MASK; | 53 | |
242 | } | 54 | static Property aspeed_smc_properties[] = { |
243 | 55 | DEFINE_PROP_UINT32("num-cs", AspeedSMCState, num_cs, 1), | |
244 | + if (arm_feature(env, ARM_FEATURE_VFP)) { | 56 | + DEFINE_PROP_UINT64("sdram-base", AspeedSMCState, sdram_base, 0), |
245 | + env->v7m.fpccr[M_REG_NS] = R_V7M_FPCCR_ASPEN_MASK; | 57 | DEFINE_PROP_END_OF_LIST(), |
246 | + env->v7m.fpccr[M_REG_S] = R_V7M_FPCCR_ASPEN_MASK | | ||
247 | + R_V7M_FPCCR_LSPEN_MASK | R_V7M_FPCCR_S_MASK; | ||
248 | + } | ||
249 | /* Unlike A/R profile, M profile defines the reset LR value */ | ||
250 | env->regs[14] = 0xffffffff; | ||
251 | |||
252 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
253 | index XXXXXXX..XXXXXXX 100644 | ||
254 | --- a/target/arm/machine.c | ||
255 | +++ b/target/arm/machine.c | ||
256 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_v8m = { | ||
257 | } | ||
258 | }; | 58 | }; |
259 | 59 | ||
260 | +static const VMStateDescription vmstate_m_fp = { | ||
261 | + .name = "cpu/m/fp", | ||
262 | + .version_id = 1, | ||
263 | + .minimum_version_id = 1, | ||
264 | + .needed = vfp_needed, | ||
265 | + .fields = (VMStateField[]) { | ||
266 | + VMSTATE_UINT32_ARRAY(env.v7m.fpcar, ARMCPU, M_REG_NUM_BANKS), | ||
267 | + VMSTATE_UINT32_ARRAY(env.v7m.fpccr, ARMCPU, M_REG_NUM_BANKS), | ||
268 | + VMSTATE_UINT32_ARRAY(env.v7m.fpdscr, ARMCPU, M_REG_NUM_BANKS), | ||
269 | + VMSTATE_UINT32_ARRAY(env.v7m.cpacr, ARMCPU, M_REG_NUM_BANKS), | ||
270 | + VMSTATE_UINT32(env.v7m.nsacr, ARMCPU), | ||
271 | + VMSTATE_END_OF_LIST() | ||
272 | + } | ||
273 | +}; | ||
274 | + | ||
275 | static const VMStateDescription vmstate_m = { | ||
276 | .name = "cpu/m", | ||
277 | .version_id = 4, | ||
278 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = { | ||
279 | &vmstate_m_scr, | ||
280 | &vmstate_m_other_sp, | ||
281 | &vmstate_m_v8m, | ||
282 | + &vmstate_m_fp, | ||
283 | NULL | ||
284 | } | ||
285 | }; | ||
286 | -- | 60 | -- |
287 | 2.20.1 | 61 | 2.20.1 |
288 | 62 | ||
289 | 63 | diff view generated by jsdifflib |
1 | The magic value pushed onto the callee stack as an integrity | 1 | From: Adriana Kobylak <anoo@us.ibm.com> |
---|---|---|---|
2 | check is different if floating point is present. | ||
3 | 2 | ||
3 | The Swift board is an OpenPOWER system hosting POWER processors. | ||
4 | Add support for their BMC including the I2C devices as found on HW. | ||
5 | |||
6 | Signed-off-by: Adriana Kobylak <anoo@us.ibm.com> | ||
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
9 | Message-id: 20190618165311.27066-20-clg@kaod.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20190416125744.27770-15-peter.maydell@linaro.org | ||
7 | --- | 11 | --- |
8 | target/arm/helper.c | 22 +++++++++++++++++++--- | 12 | hw/arm/aspeed.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ |
9 | 1 file changed, 19 insertions(+), 3 deletions(-) | 13 | 1 file changed, 50 insertions(+) |
10 | 14 | ||
11 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 15 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/helper.c | 17 | --- a/hw/arm/aspeed.c |
14 | +++ b/target/arm/helper.c | 18 | +++ b/hw/arm/aspeed.c |
15 | @@ -XXX,XX +XXX,XX @@ load_fail: | 19 | @@ -XXX,XX +XXX,XX @@ struct AspeedBoardState { |
16 | return false; | 20 | SCU_AST2500_HW_STRAP_ACPI_ENABLE | \ |
21 | SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER)) | ||
22 | |||
23 | +/* Swift hardware value: 0xF11AD206 */ | ||
24 | +#define SWIFT_BMC_HW_STRAP1 ( \ | ||
25 | + AST2500_HW_STRAP1_DEFAULTS | \ | ||
26 | + SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \ | ||
27 | + SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \ | ||
28 | + SCU_AST2500_HW_STRAP_UART_DEBUG | \ | ||
29 | + SCU_AST2500_HW_STRAP_DDR4_ENABLE | \ | ||
30 | + SCU_H_PLL_BYPASS_EN | \ | ||
31 | + SCU_AST2500_HW_STRAP_ACPI_ENABLE | \ | ||
32 | + SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER)) | ||
33 | + | ||
34 | /* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */ | ||
35 | #define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1 | ||
36 | |||
37 | @@ -XXX,XX +XXX,XX @@ static void romulus_bmc_i2c_init(AspeedBoardState *bmc) | ||
38 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); | ||
17 | } | 39 | } |
18 | 40 | ||
19 | +static uint32_t v7m_integrity_sig(CPUARMState *env, uint32_t lr) | 41 | +static void swift_bmc_i2c_init(AspeedBoardState *bmc) |
20 | +{ | 42 | +{ |
21 | + /* | 43 | + AspeedSoCState *soc = &bmc->soc; |
22 | + * Return the integrity signature value for the callee-saves | ||
23 | + * stack frame section. @lr is the exception return payload/LR value | ||
24 | + * whose FType bit forms bit 0 of the signature if FP is present. | ||
25 | + */ | ||
26 | + uint32_t sig = 0xfefa125a; | ||
27 | + | 44 | + |
28 | + if (!arm_feature(env, ARM_FEATURE_VFP) || (lr & R_V7M_EXCRET_FTYPE_MASK)) { | 45 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60); |
29 | + sig |= 1; | 46 | + |
30 | + } | 47 | + /* The swift board expects a TMP275 but a TMP105 is compatible */ |
31 | + return sig; | 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); | ||
32 | +} | 68 | +} |
33 | + | 69 | + |
34 | static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 70 | static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) |
35 | bool ignore_faults) | ||
36 | { | 71 | { |
37 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 72 | AspeedSoCState *soc = &bmc->soc; |
38 | bool stacked_ok; | 73 | @@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = { |
39 | uint32_t limit; | 74 | .num_cs = 2, |
40 | bool want_psp; | 75 | .i2c_init = romulus_bmc_i2c_init, |
41 | + uint32_t sig; | 76 | .ram = 512 * MiB, |
42 | 77 | + }, { | |
43 | if (dotailchain) { | 78 | + .name = MACHINE_TYPE_NAME("swift-bmc"), |
44 | bool mode = lr & R_V7M_EXCRET_MODE_MASK; | 79 | + .desc = "OpenPOWER Swift BMC (ARM1176)", |
45 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 80 | + .soc_name = "ast2500-a1", |
46 | /* Write as much of the stack frame as we can. A write failure may | 81 | + .hw_strap1 = SWIFT_BMC_HW_STRAP1, |
47 | * cause us to pend a derived exception. | 82 | + .fmc_model = "mx66l1g45g", |
48 | */ | 83 | + .spi_model = "mx66l1g45g", |
49 | + sig = v7m_integrity_sig(env, lr); | 84 | + .num_cs = 2, |
50 | stacked_ok = | 85 | + .i2c_init = swift_bmc_i2c_init, |
51 | - v7m_stack_write(cpu, frameptr, 0xfefa125b, mmu_idx, ignore_faults) && | 86 | + .ram = 512 * MiB, |
52 | + v7m_stack_write(cpu, frameptr, sig, mmu_idx, ignore_faults) && | 87 | }, { |
53 | v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx, | 88 | .name = MACHINE_TYPE_NAME("witherspoon-bmc"), |
54 | ignore_faults) && | 89 | .desc = "OpenPOWER Witherspoon BMC (ARM1176)", |
55 | v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx, | ||
56 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
57 | if (return_to_secure && | ||
58 | ((excret & R_V7M_EXCRET_ES_MASK) == 0 || | ||
59 | (excret & R_V7M_EXCRET_DCRS_MASK) == 0)) { | ||
60 | - uint32_t expected_sig = 0xfefa125b; | ||
61 | uint32_t actual_sig; | ||
62 | |||
63 | pop_ok = v7m_stack_read(cpu, &actual_sig, frameptr, mmu_idx); | ||
64 | |||
65 | - if (pop_ok && expected_sig != actual_sig) { | ||
66 | + if (pop_ok && v7m_integrity_sig(env, excret) != actual_sig) { | ||
67 | /* Take a SecureFault on the current stack */ | ||
68 | env->v7m.sfsr |= R_V7M_SFSR_INVIS_MASK; | ||
69 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
70 | -- | 90 | -- |
71 | 2.20.1 | 91 | 2.20.1 |
72 | 92 | ||
73 | 93 | diff view generated by jsdifflib |
1 | Implement the VLSTM instruction for v7M for the FPU present case. | 1 | From: Eddie James <eajames@linux.ibm.com> |
---|---|---|---|
2 | 2 | ||
3 | The XDMA engine embedded in the Aspeed SOCs performs PCI DMA operations | ||
4 | between the SOC (acting as a BMC) and a host processor in a server. | ||
5 | |||
6 | The XDMA engine exists on the AST2400, AST2500, and AST2600 SOCs, so | ||
7 | enable it for all of those. Add trace events on the important register | ||
8 | writes in the XDMA engine. | ||
9 | |||
10 | Signed-off-by: Eddie James <eajames@linux.ibm.com> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
13 | Message-id: 20190618165311.27066-21-clg@kaod.org | ||
14 | [clg: - changed title ] | ||
15 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20190416125744.27770-25-peter.maydell@linaro.org | ||
6 | --- | 17 | --- |
7 | target/arm/cpu.h | 2 + | 18 | hw/misc/Makefile.objs | 1 + |
8 | target/arm/helper.h | 2 + | 19 | include/hw/arm/aspeed_soc.h | 3 + |
9 | target/arm/helper.c | 84 ++++++++++++++++++++++++++++++++++++++++++ | 20 | include/hw/misc/aspeed_xdma.h | 30 +++++++ |
10 | target/arm/translate.c | 15 +++++++- | 21 | hw/arm/aspeed_soc.c | 17 ++++ |
11 | 4 files changed, 102 insertions(+), 1 deletion(-) | 22 | hw/misc/aspeed_xdma.c | 165 ++++++++++++++++++++++++++++++++++ |
12 | 23 | hw/misc/trace-events | 3 + | |
13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 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 | ||
14 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/cpu.h | 30 | --- a/hw/misc/Makefile.objs |
16 | +++ b/target/arm/cpu.h | 31 | +++ b/hw/misc/Makefile.objs |
32 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_ARMSSE_MHU) += armsse-mhu.o | ||
33 | |||
34 | obj-$(CONFIG_PVPANIC) += pvpanic.o | ||
35 | obj-$(CONFIG_AUX) += auxbus.o | ||
36 | +obj-$(CONFIG_ASPEED_SOC) += aspeed_xdma.o | ||
37 | obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o | ||
38 | obj-$(CONFIG_MSF2) += msf2-sysreg.o | ||
39 | obj-$(CONFIG_NRF51_SOC) += nrf51_rng.o | ||
40 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/include/hw/arm/aspeed_soc.h | ||
43 | +++ b/include/hw/arm/aspeed_soc.h | ||
17 | @@ -XXX,XX +XXX,XX @@ | 44 | @@ -XXX,XX +XXX,XX @@ |
18 | #define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */ | 45 | #include "hw/intc/aspeed_vic.h" |
19 | #define EXCP_STKOF 19 /* v8M STKOF UsageFault */ | 46 | #include "hw/misc/aspeed_scu.h" |
20 | #define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */ | 47 | #include "hw/misc/aspeed_sdmc.h" |
21 | +#define EXCP_LSERR 21 /* v8M LSERR SecureFault */ | 48 | +#include "hw/misc/aspeed_xdma.h" |
22 | +#define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */ | 49 | #include "hw/timer/aspeed_timer.h" |
23 | /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ | 50 | #include "hw/timer/aspeed_rtc.h" |
24 | 51 | #include "hw/i2c/aspeed_i2c.h" | |
25 | #define ARMV7M_EXCP_RESET 1 | 52 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { |
26 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 53 | AspeedTimerCtrlState timerctrl; |
54 | AspeedI2CState i2c; | ||
55 | AspeedSCUState scu; | ||
56 | + AspeedXDMAState xdma; | ||
57 | AspeedSMCState fmc; | ||
58 | AspeedSMCState spi[ASPEED_SPIS_NUM]; | ||
59 | AspeedSDMCState sdmc; | ||
60 | @@ -XXX,XX +XXX,XX @@ enum { | ||
61 | ASPEED_ETH1, | ||
62 | ASPEED_ETH2, | ||
63 | ASPEED_SDRAM, | ||
64 | + ASPEED_XDMA, | ||
65 | }; | ||
66 | |||
67 | #endif /* ASPEED_SOC_H */ | ||
68 | diff --git a/include/hw/misc/aspeed_xdma.h b/include/hw/misc/aspeed_xdma.h | ||
69 | new file mode 100644 | ||
70 | index XXXXXXX..XXXXXXX | ||
71 | --- /dev/null | ||
72 | +++ b/include/hw/misc/aspeed_xdma.h | ||
73 | @@ -XXX,XX +XXX,XX @@ | ||
74 | +/* | ||
75 | + * ASPEED XDMA Controller | ||
76 | + * Eddie James <eajames@linux.ibm.com> | ||
77 | + * | ||
78 | + * Copyright (C) 2019 IBM Corp. | ||
79 | + * SPDX-License-Identifer: GPL-2.0-or-later | ||
80 | + */ | ||
81 | + | ||
82 | +#ifndef ASPEED_XDMA_H | ||
83 | +#define ASPEED_XDMA_H | ||
84 | + | ||
85 | +#include "hw/sysbus.h" | ||
86 | + | ||
87 | +#define TYPE_ASPEED_XDMA "aspeed.xdma" | ||
88 | +#define ASPEED_XDMA(obj) OBJECT_CHECK(AspeedXDMAState, (obj), TYPE_ASPEED_XDMA) | ||
89 | + | ||
90 | +#define ASPEED_XDMA_NUM_REGS (ASPEED_XDMA_REG_SIZE / sizeof(uint32_t)) | ||
91 | +#define ASPEED_XDMA_REG_SIZE 0x7C | ||
92 | + | ||
93 | +typedef struct AspeedXDMAState { | ||
94 | + SysBusDevice parent; | ||
95 | + | ||
96 | + MemoryRegion iomem; | ||
97 | + qemu_irq irq; | ||
98 | + | ||
99 | + char bmc_cmdq_readp_set; | ||
100 | + uint32_t regs[ASPEED_XDMA_NUM_REGS]; | ||
101 | +} AspeedXDMAState; | ||
102 | + | ||
103 | +#endif /* ASPEED_XDMA_H */ | ||
104 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | 105 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/target/arm/helper.h | 106 | --- a/hw/arm/aspeed_soc.c |
29 | +++ b/target/arm/helper.h | 107 | +++ b/hw/arm/aspeed_soc.c |
30 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_tt, i32, env, i32, i32) | 108 | @@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2400_memmap[] = { |
31 | 109 | [ASPEED_VIC] = 0x1E6C0000, | |
32 | DEF_HELPER_1(v7m_preserve_fp_state, void, env) | 110 | [ASPEED_SDMC] = 0x1E6E0000, |
33 | 111 | [ASPEED_SCU] = 0x1E6E2000, | |
34 | +DEF_HELPER_2(v7m_vlstm, void, env, i32) | 112 | + [ASPEED_XDMA] = 0x1E6E7000, |
35 | + | 113 | [ASPEED_ADC] = 0x1E6E9000, |
36 | DEF_HELPER_2(v8m_stackcheck, void, env, i32) | 114 | [ASPEED_SRAM] = 0x1E720000, |
37 | 115 | [ASPEED_GPIO] = 0x1E780000, | |
38 | DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32) | 116 | @@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2500_memmap[] = { |
39 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 117 | [ASPEED_VIC] = 0x1E6C0000, |
40 | index XXXXXXX..XXXXXXX 100644 | 118 | [ASPEED_SDMC] = 0x1E6E0000, |
41 | --- a/target/arm/helper.c | 119 | [ASPEED_SCU] = 0x1E6E2000, |
42 | +++ b/target/arm/helper.c | 120 | + [ASPEED_XDMA] = 0x1E6E7000, |
43 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env) | 121 | [ASPEED_ADC] = 0x1E6E9000, |
44 | g_assert_not_reached(); | 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); | ||
45 | } | 139 | } |
46 | 140 | ||
47 | +void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr) | 141 | static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
48 | +{ | 142 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
49 | + /* translate.c should never generate calls here in user-only mode */ | 143 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, |
50 | + g_assert_not_reached(); | 144 | aspeed_soc_get_irq(s, ASPEED_ETH1 + i)); |
51 | +} | ||
52 | + | ||
53 | uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
54 | { | ||
55 | /* The TT instructions can be used by unprivileged code, but in | ||
56 | @@ -XXX,XX +XXX,XX @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr, | ||
57 | } | 145 | } |
58 | } | 146 | + |
59 | 147 | + /* XDMA */ | |
60 | +void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr) | 148 | + object_property_set_bool(OBJECT(&s->xdma), true, "realized", &err); |
61 | +{ | 149 | + if (err) { |
62 | + /* fptr is the value of Rn, the frame pointer we store the FP regs to */ | 150 | + error_propagate(errp, err); |
63 | + bool s = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | ||
64 | + bool lspact = env->v7m.fpccr[s] & R_V7M_FPCCR_LSPACT_MASK; | ||
65 | + | ||
66 | + assert(env->v7m.secure); | ||
67 | + | ||
68 | + if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) { | ||
69 | + return; | 151 | + return; |
70 | + } | 152 | + } |
71 | + | 153 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->xdma), 0, |
72 | + /* Check access to the coprocessor is permitted */ | 154 | + sc->info->memmap[ASPEED_XDMA]); |
73 | + if (!v7m_cpacr_pass(env, true, arm_current_el(env) != 0)) { | 155 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0, |
74 | + raise_exception_ra(env, EXCP_NOCP, 0, 1, GETPC()); | 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 | +{ | ||
202 | + uint32_t val = 0; | ||
203 | + AspeedXDMAState *xdma = opaque; | ||
204 | + | ||
205 | + if (addr < ASPEED_XDMA_REG_SIZE) { | ||
206 | + val = xdma->regs[TO_REG(addr)]; | ||
75 | + } | 207 | + } |
76 | + | 208 | + |
77 | + if (lspact) { | 209 | + return (uint64_t)val; |
78 | + /* LSPACT should not be active when there is active FP state */ | 210 | +} |
79 | + raise_exception_ra(env, EXCP_LSERR, 0, 1, GETPC()); | 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; | ||
80 | + } | 221 | + } |
81 | + | 222 | + |
82 | + if (fptr & 7) { | 223 | + switch (addr) { |
83 | + raise_exception_ra(env, EXCP_UNALIGNED, 0, 1, GETPC()); | 224 | + case XDMA_BMC_CMDQ_ENDP: |
225 | + xdma->regs[TO_REG(addr)] = val32 & XDMA_BMC_CMDQ_W_MASK; | ||
226 | + break; | ||
227 | + case XDMA_BMC_CMDQ_WRP: | ||
228 | + idx = TO_REG(addr); | ||
229 | + xdma->regs[idx] = val32 & XDMA_BMC_CMDQ_W_MASK; | ||
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; | ||
265 | + default: | ||
266 | + xdma->regs[TO_REG(addr)] = val32; | ||
267 | + break; | ||
84 | + } | 268 | + } |
85 | + | 269 | +} |
86 | + /* | 270 | + |
87 | + * Note that we do not use v7m_stack_write() here, because the | 271 | +static const MemoryRegionOps aspeed_xdma_ops = { |
88 | + * accesses should not set the FSR bits for stacking errors if they | 272 | + .read = aspeed_xdma_read, |
89 | + * fail. (In pseudocode terms, they are AccType_NORMAL, not AccType_STACK | 273 | + .write = aspeed_xdma_write, |
90 | + * or AccType_LAZYFP). Faults in cpu_stl_data() will throw exceptions | 274 | + .endianness = DEVICE_NATIVE_ENDIAN, |
91 | + * and longjmp out. | 275 | + .valid.min_access_size = 4, |
92 | + */ | 276 | + .valid.max_access_size = 4, |
93 | + if (!(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPEN_MASK)) { | 277 | +}; |
94 | + bool ts = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK; | 278 | + |
95 | + int i; | 279 | +static void aspeed_xdma_realize(DeviceState *dev, Error **errp) |
96 | + | 280 | +{ |
97 | + for (i = 0; i < (ts ? 32 : 16); i += 2) { | 281 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); |
98 | + uint64_t dn = *aa32_vfp_dreg(env, i / 2); | 282 | + AspeedXDMAState *xdma = ASPEED_XDMA(dev); |
99 | + uint32_t faddr = fptr + 4 * i; | 283 | + |
100 | + uint32_t slo = extract64(dn, 0, 32); | 284 | + sysbus_init_irq(sbd, &xdma->irq); |
101 | + uint32_t shi = extract64(dn, 32, 32); | 285 | + memory_region_init_io(&xdma->iomem, OBJECT(xdma), &aspeed_xdma_ops, xdma, |
102 | + | 286 | + TYPE_ASPEED_XDMA, XDMA_MEM_SIZE); |
103 | + if (i >= 16) { | 287 | + sysbus_init_mmio(sbd, &xdma->iomem); |
104 | + faddr += 8; /* skip the slot for the FPSCR */ | 288 | +} |
105 | + } | 289 | + |
106 | + cpu_stl_data(env, faddr, slo); | 290 | +static void aspeed_xdma_reset(DeviceState *dev) |
107 | + cpu_stl_data(env, faddr + 4, shi); | 291 | +{ |
108 | + } | 292 | + AspeedXDMAState *xdma = ASPEED_XDMA(dev); |
109 | + cpu_stl_data(env, fptr + 0x40, vfp_get_fpscr(env)); | 293 | + |
110 | + | 294 | + xdma->bmc_cmdq_readp_set = 0; |
111 | + /* | 295 | + memset(xdma->regs, 0, ASPEED_XDMA_REG_SIZE); |
112 | + * If TS is 0 then s0 to s15 and FPSCR are UNKNOWN; we choose to | 296 | + xdma->regs[TO_REG(XDMA_IRQ_ENG_STAT)] = XDMA_IRQ_ENG_STAT_RESET; |
113 | + * leave them unchanged, matching our choice in v7m_preserve_fp_state. | 297 | + |
114 | + */ | 298 | + qemu_irq_lower(xdma->irq); |
115 | + if (ts) { | 299 | +} |
116 | + for (i = 0; i < 32; i += 2) { | 300 | + |
117 | + *aa32_vfp_dreg(env, i / 2) = 0; | 301 | +static const VMStateDescription aspeed_xdma_vmstate = { |
118 | + } | 302 | + .name = TYPE_ASPEED_XDMA, |
119 | + vfp_set_fpscr(env, 0); | 303 | + .version_id = 1, |
120 | + } | 304 | + .fields = (VMStateField[]) { |
121 | + } else { | 305 | + VMSTATE_UINT32_ARRAY(regs, AspeedXDMAState, ASPEED_XDMA_NUM_REGS), |
122 | + v7m_update_fpccr(env, fptr, false); | 306 | + VMSTATE_END_OF_LIST(), |
123 | + } | 307 | + }, |
124 | + | 308 | +}; |
125 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK; | 309 | + |
126 | +} | 310 | +static void aspeed_xdma_class_init(ObjectClass *classp, void *data) |
127 | + | 311 | +{ |
128 | static bool v7m_push_stack(ARMCPU *cpu) | 312 | + DeviceClass *dc = DEVICE_CLASS(classp); |
129 | { | 313 | + |
130 | /* Do the "set up stack frame" part of exception entry, | 314 | + dc->realize = aspeed_xdma_realize; |
131 | @@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx) | 315 | + dc->reset = aspeed_xdma_reset; |
132 | [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | 316 | + dc->vmsd = &aspeed_xdma_vmstate; |
133 | [EXCP_STKOF] = "v8M STKOF UsageFault", | 317 | +} |
134 | [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | 318 | + |
135 | + [EXCP_LSERR] = "v8M LSERR UsageFault", | 319 | +static const TypeInfo aspeed_xdma_info = { |
136 | + [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | 320 | + .name = TYPE_ASPEED_XDMA, |
137 | }; | 321 | + .parent = TYPE_SYS_BUS_DEVICE, |
138 | 322 | + .instance_size = sizeof(AspeedXDMAState), | |
139 | if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | 323 | + .class_init = aspeed_xdma_class_init, |
140 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 324 | +}; |
141 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | 325 | + |
142 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_STKOF_MASK; | 326 | +static void aspeed_xdma_register_type(void) |
143 | break; | 327 | +{ |
144 | + case EXCP_LSERR: | 328 | + type_register_static(&aspeed_xdma_info); |
145 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | 329 | +} |
146 | + env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; | 330 | +type_init(aspeed_xdma_register_type); |
147 | + break; | 331 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events |
148 | + case EXCP_UNALIGNED: | ||
149 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
150 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; | ||
151 | + break; | ||
152 | case EXCP_SWI: | ||
153 | /* The PC already points to the next instruction. */ | ||
154 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure); | ||
155 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
156 | index XXXXXXX..XXXXXXX 100644 | 332 | index XXXXXXX..XXXXXXX 100644 |
157 | --- a/target/arm/translate.c | 333 | --- a/hw/misc/trace-events |
158 | +++ b/target/arm/translate.c | 334 | +++ b/hw/misc/trace-events |
159 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 335 | @@ -XXX,XX +XXX,XX @@ armsse_cpuid_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 CPU_I |
160 | if (!s->v8m_secure || (insn & 0x0040f0ff)) { | 336 | # armsse-mhu.c |
161 | goto illegal_op; | 337 | armsse_mhu_read(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" |
162 | } | 338 | armsse_mhu_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" |
163 | - /* Just NOP since FP support is not implemented */ | 339 | + |
164 | + | 340 | +# aspeed_xdma.c |
165 | + if (arm_dc_feature(s, ARM_FEATURE_VFP)) { | 341 | +aspeed_xdma_write(uint64_t offset, uint64_t data) "XDMA write: offset 0x%" PRIx64 " data 0x%" PRIx64 |
166 | + TCGv_i32 fptr = load_reg(s, rn); | ||
167 | + | ||
168 | + if (extract32(insn, 20, 1)) { | ||
169 | + /* VLLDM */ | ||
170 | + } else { | ||
171 | + gen_helper_v7m_vlstm(cpu_env, fptr); | ||
172 | + } | ||
173 | + tcg_temp_free_i32(fptr); | ||
174 | + | ||
175 | + /* End the TB, because we have updated FP control bits */ | ||
176 | + s->base.is_jmp = DISAS_UPDATE; | ||
177 | + } | ||
178 | break; | ||
179 | } | ||
180 | if (arm_dc_feature(s, ARM_FEATURE_VFP) && | ||
181 | -- | 342 | -- |
182 | 2.20.1 | 343 | 2.20.1 |
183 | 344 | ||
184 | 345 | diff view generated by jsdifflib |
1 | In the stripe8() function we use a variable length array; however | 1 | From: Andrew Jeffery <andrew@aj.id.au> |
---|---|---|---|
2 | we know that the maximum length required is MAX_NUM_BUSSES. Use | 2 | |
3 | a fixed-length array and an assert instead. | 3 | The legacy interface only supported up to 32 IRQs, which became |
4 | 4 | restrictive around the AST2400 generation. QEMU support for the SoCs | |
5 | started with the AST2400 along with an effort to reimplement and | ||
6 | upstream drivers for Linux, so up until this point the consumers of the | ||
7 | QEMU ASPEED support only required the 64 IRQ register interface. | ||
8 | |||
9 | In an effort to support older BMC firmware, add support for the 32 IRQ | ||
10 | interface. | ||
11 | |||
12 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> | ||
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
15 | Message-id: 20190618165311.27066-22-clg@kaod.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> | ||
10 | Message-id: 20190328152635.2794-1-peter.maydell@linaro.org | ||
11 | --- | 17 | --- |
12 | hw/ssi/xilinx_spips.c | 6 ++++-- | 18 | hw/intc/aspeed_vic.c | 105 ++++++++++++++++++++++++++----------------- |
13 | 1 file changed, 4 insertions(+), 2 deletions(-) | 19 | 1 file changed, 63 insertions(+), 42 deletions(-) |
14 | 20 | ||
15 | diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c | 21 | diff --git a/hw/intc/aspeed_vic.c b/hw/intc/aspeed_vic.c |
16 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/ssi/xilinx_spips.c | 23 | --- a/hw/intc/aspeed_vic.c |
18 | +++ b/hw/ssi/xilinx_spips.c | 24 | +++ b/hw/intc/aspeed_vic.c |
19 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_qspips_reset(DeviceState *d) | 25 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_set_irq(void *opaque, int irq, int level) |
20 | 26 | ||
21 | static inline void stripe8(uint8_t *x, int num, bool dir) | 27 | static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size) |
22 | { | 28 | { |
23 | - uint8_t r[num]; | 29 | - uint64_t val; |
24 | - memset(r, 0, sizeof(uint8_t) * num); | 30 | - const bool high = !!(offset & 0x4); |
25 | + uint8_t r[MAX_NUM_BUSSES]; | 31 | - hwaddr n_offset = (offset & ~0x4); |
26 | int idx[2] = {0, 0}; | 32 | AspeedVICState *s = (AspeedVICState *)opaque; |
27 | int bit[2] = {0, 7}; | 33 | + hwaddr n_offset; |
28 | int d = dir; | 34 | + uint64_t val; |
29 | 35 | + bool high; | |
30 | + assert(num <= MAX_NUM_BUSSES); | 36 | |
31 | + memset(r, 0, sizeof(uint8_t) * num); | 37 | if (offset < AVIC_NEW_BASE_OFFSET) { |
32 | + | 38 | - qemu_log_mask(LOG_UNIMP, "%s: Ignoring read from legacy registers " |
33 | for (idx[0] = 0; idx[0] < num; ++idx[0]) { | 39 | - "at 0x%" HWADDR_PRIx "[%u]\n", __func__, offset, size); |
34 | for (bit[0] = 7; bit[0] >= 0; bit[0]--) { | 40 | - return 0; |
35 | r[idx[!d]] |= x[idx[d]] & 1 << bit[d] ? 1 << bit[!d] : 0; | 41 | + high = false; |
42 | + n_offset = offset; | ||
43 | + } else { | ||
44 | + high = !!(offset & 0x4); | ||
45 | + n_offset = (offset & ~0x4); | ||
46 | } | ||
47 | |||
48 | - n_offset -= AVIC_NEW_BASE_OFFSET; | ||
49 | - | ||
50 | switch (n_offset) { | ||
51 | - case 0x0: /* IRQ Status */ | ||
52 | + case 0x80: /* IRQ Status */ | ||
53 | + case 0x00: | ||
54 | val = s->raw & ~s->select & s->enable; | ||
55 | break; | ||
56 | - case 0x08: /* FIQ Status */ | ||
57 | + case 0x88: /* FIQ Status */ | ||
58 | + case 0x04: | ||
59 | val = s->raw & s->select & s->enable; | ||
60 | break; | ||
61 | - case 0x10: /* Raw Interrupt Status */ | ||
62 | + case 0x90: /* Raw Interrupt Status */ | ||
63 | + case 0x08: | ||
64 | val = s->raw; | ||
65 | break; | ||
66 | - case 0x18: /* Interrupt Selection */ | ||
67 | + case 0x98: /* Interrupt Selection */ | ||
68 | + case 0x0c: | ||
69 | val = s->select; | ||
70 | break; | ||
71 | - case 0x20: /* Interrupt Enable */ | ||
72 | + case 0xa0: /* Interrupt Enable */ | ||
73 | + case 0x10: | ||
74 | val = s->enable; | ||
75 | break; | ||
76 | - case 0x30: /* Software Interrupt */ | ||
77 | + case 0xb0: /* Software Interrupt */ | ||
78 | + case 0x18: | ||
79 | val = s->trigger; | ||
80 | break; | ||
81 | - case 0x40: /* Interrupt Sensitivity */ | ||
82 | + case 0xc0: /* Interrupt Sensitivity */ | ||
83 | + case 0x24: | ||
84 | val = s->sense; | ||
85 | break; | ||
86 | - case 0x48: /* Interrupt Both Edge Trigger Control */ | ||
87 | + case 0xc8: /* Interrupt Both Edge Trigger Control */ | ||
88 | + case 0x28: | ||
89 | val = s->dual_edge; | ||
90 | break; | ||
91 | - case 0x50: /* Interrupt Event */ | ||
92 | + case 0xd0: /* Interrupt Event */ | ||
93 | + case 0x2c: | ||
94 | val = s->event; | ||
95 | break; | ||
96 | - case 0x60: /* Edge Triggered Interrupt Status */ | ||
97 | + case 0xe0: /* Edge Triggered Interrupt Status */ | ||
98 | val = s->raw & ~s->sense; | ||
99 | break; | ||
100 | /* Illegal */ | ||
101 | - case 0x28: /* Interrupt Enable Clear */ | ||
102 | - case 0x38: /* Software Interrupt Clear */ | ||
103 | - case 0x58: /* Edge Triggered Interrupt Clear */ | ||
104 | + case 0xa8: /* Interrupt Enable Clear */ | ||
105 | + case 0xb8: /* Software Interrupt Clear */ | ||
106 | + case 0xd8: /* Edge Triggered Interrupt Clear */ | ||
107 | qemu_log_mask(LOG_GUEST_ERROR, | ||
108 | "%s: Read of write-only register with offset 0x%" | ||
109 | HWADDR_PRIx "\n", __func__, offset); | ||
110 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size) | ||
111 | } | ||
112 | if (high) { | ||
113 | val = extract64(val, 32, 19); | ||
114 | + } else { | ||
115 | + val = extract64(val, 0, 32); | ||
116 | } | ||
117 | trace_aspeed_vic_read(offset, size, val); | ||
118 | return val; | ||
119 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size) | ||
120 | static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
121 | unsigned size) | ||
122 | { | ||
123 | - const bool high = !!(offset & 0x4); | ||
124 | - hwaddr n_offset = (offset & ~0x4); | ||
125 | AspeedVICState *s = (AspeedVICState *)opaque; | ||
126 | + hwaddr n_offset; | ||
127 | + bool high; | ||
128 | |||
129 | if (offset < AVIC_NEW_BASE_OFFSET) { | ||
130 | - qemu_log_mask(LOG_UNIMP, | ||
131 | - "%s: Ignoring write to legacy registers at 0x%" | ||
132 | - HWADDR_PRIx "[%u] <- 0x%" PRIx64 "\n", __func__, offset, | ||
133 | - size, data); | ||
134 | - return; | ||
135 | + high = false; | ||
136 | + n_offset = offset; | ||
137 | + } else { | ||
138 | + high = !!(offset & 0x4); | ||
139 | + n_offset = (offset & ~0x4); | ||
140 | } | ||
141 | |||
142 | - n_offset -= AVIC_NEW_BASE_OFFSET; | ||
143 | trace_aspeed_vic_write(offset, size, data); | ||
144 | |||
145 | /* Given we have members using separate enable/clear registers, deposit64() | ||
146 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
147 | } | ||
148 | |||
149 | switch (n_offset) { | ||
150 | - case 0x18: /* Interrupt Selection */ | ||
151 | + case 0x98: /* Interrupt Selection */ | ||
152 | + case 0x0c: | ||
153 | /* Register has deposit64() semantics - overwrite requested 32 bits */ | ||
154 | if (high) { | ||
155 | s->select &= AVIC_L_MASK; | ||
156 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
157 | } | ||
158 | s->select |= data; | ||
159 | break; | ||
160 | - case 0x20: /* Interrupt Enable */ | ||
161 | + case 0xa0: /* Interrupt Enable */ | ||
162 | + case 0x10: | ||
163 | s->enable |= data; | ||
164 | break; | ||
165 | - case 0x28: /* Interrupt Enable Clear */ | ||
166 | + case 0xa8: /* Interrupt Enable Clear */ | ||
167 | + case 0x14: | ||
168 | s->enable &= ~data; | ||
169 | break; | ||
170 | - case 0x30: /* Software Interrupt */ | ||
171 | + case 0xb0: /* Software Interrupt */ | ||
172 | + case 0x18: | ||
173 | qemu_log_mask(LOG_UNIMP, "%s: Software interrupts unavailable. " | ||
174 | "IRQs requested: 0x%016" PRIx64 "\n", __func__, data); | ||
175 | break; | ||
176 | - case 0x38: /* Software Interrupt Clear */ | ||
177 | + case 0xb8: /* Software Interrupt Clear */ | ||
178 | + case 0x1c: | ||
179 | qemu_log_mask(LOG_UNIMP, "%s: Software interrupts unavailable. " | ||
180 | "IRQs to be cleared: 0x%016" PRIx64 "\n", __func__, data); | ||
181 | break; | ||
182 | - case 0x50: /* Interrupt Event */ | ||
183 | + case 0xd0: /* Interrupt Event */ | ||
184 | /* Register has deposit64() semantics - overwrite the top four valid | ||
185 | * IRQ bits, as only the top four IRQs (GPIOs) can change their event | ||
186 | * type */ | ||
187 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
188 | "Ignoring invalid write to interrupt event register"); | ||
189 | } | ||
190 | break; | ||
191 | - case 0x58: /* Edge Triggered Interrupt Clear */ | ||
192 | + case 0xd8: /* Edge Triggered Interrupt Clear */ | ||
193 | + case 0x38: | ||
194 | s->raw &= ~(data & ~s->sense); | ||
195 | break; | ||
196 | - case 0x00: /* IRQ Status */ | ||
197 | - case 0x08: /* FIQ Status */ | ||
198 | - case 0x10: /* Raw Interrupt Status */ | ||
199 | - case 0x40: /* Interrupt Sensitivity */ | ||
200 | - case 0x48: /* Interrupt Both Edge Trigger Control */ | ||
201 | - case 0x60: /* Edge Triggered Interrupt Status */ | ||
202 | + case 0x80: /* IRQ Status */ | ||
203 | + case 0x00: | ||
204 | + case 0x88: /* FIQ Status */ | ||
205 | + case 0x04: | ||
206 | + case 0x90: /* Raw Interrupt Status */ | ||
207 | + case 0x08: | ||
208 | + case 0xc0: /* Interrupt Sensitivity */ | ||
209 | + case 0x24: | ||
210 | + case 0xc8: /* Interrupt Both Edge Trigger Control */ | ||
211 | + case 0x28: | ||
212 | + case 0xe0: /* Edge Triggered Interrupt Status */ | ||
213 | qemu_log_mask(LOG_GUEST_ERROR, | ||
214 | "%s: Write of read-only register with offset 0x%" | ||
215 | HWADDR_PRIx "\n", __func__, offset); | ||
36 | -- | 216 | -- |
37 | 2.20.1 | 217 | 2.20.1 |
38 | 218 | ||
39 | 219 | diff view generated by jsdifflib |
1 | The TailChain() pseudocode specifies that a tail chaining | 1 | From: Joel Stanley <joel@jms.id.au> |
---|---|---|---|
2 | exception should sanitize the excReturn all-ones bits and | ||
3 | (if there is no FPU) the excReturn FType bits; we weren't | ||
4 | doing this. | ||
5 | 2 | ||
3 | The ast2500 uses the watchdog to reset the SDRAM controller. This | ||
4 | operation is usually performed by u-boot's memory training procedure, | ||
5 | and it is enabled by setting a bit in the SCU and then causing the | ||
6 | watchdog to expire. Therefore, we need the watchdog to be able to | ||
7 | access the SCU's register space. | ||
8 | |||
9 | This causes the watchdog to not perform a system reset when the bit is | ||
10 | set. In the future it could perform a reset of the SDMC model. | ||
11 | |||
12 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
16 | Message-id: 20190621065242.32535-1-joel@jms.id.au | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20190416125744.27770-14-peter.maydell@linaro.org | ||
9 | --- | 18 | --- |
10 | target/arm/helper.c | 8 ++++++++ | 19 | include/hw/watchdog/wdt_aspeed.h | 1 + |
11 | 1 file changed, 8 insertions(+) | 20 | hw/arm/aspeed_soc.c | 2 ++ |
21 | hw/watchdog/wdt_aspeed.c | 20 ++++++++++++++++++++ | ||
22 | 3 files changed, 23 insertions(+) | ||
12 | 23 | ||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 24 | diff --git a/include/hw/watchdog/wdt_aspeed.h b/include/hw/watchdog/wdt_aspeed.h |
14 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.c | 26 | --- a/include/hw/watchdog/wdt_aspeed.h |
16 | +++ b/target/arm/helper.c | 27 | +++ b/include/hw/watchdog/wdt_aspeed.h |
17 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 28 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedWDTState { |
18 | qemu_log_mask(CPU_LOG_INT, "...taking pending %s exception %d\n", | 29 | MemoryRegion iomem; |
19 | targets_secure ? "secure" : "nonsecure", exc); | 30 | uint32_t regs[ASPEED_WDT_REGS_MAX]; |
20 | 31 | ||
21 | + if (dotailchain) { | 32 | + AspeedSCUState *scu; |
22 | + /* Sanitize LR FType and PREFIX bits */ | 33 | uint32_t pclk_freq; |
23 | + if (!arm_feature(env, ARM_FEATURE_VFP)) { | 34 | uint32_t silicon_rev; |
24 | + lr |= R_V7M_EXCRET_FTYPE_MASK; | 35 | uint32_t ext_pulse_width_mask; |
25 | + } | 36 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c |
26 | + lr = deposit32(lr, 24, 8, 0xff); | 37 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/arm/aspeed_soc.c | ||
39 | +++ b/hw/arm/aspeed_soc.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
41 | sizeof(s->wdt[i]), TYPE_ASPEED_WDT); | ||
42 | qdev_prop_set_uint32(DEVICE(&s->wdt[i]), "silicon-rev", | ||
43 | sc->info->silicon_rev); | ||
44 | + object_property_add_const_link(OBJECT(&s->wdt[i]), "scu", | ||
45 | + OBJECT(&s->scu), &error_abort); | ||
46 | } | ||
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 | + | ||
60 | static bool aspeed_wdt_is_enabled(const AspeedWDTState *s) | ||
61 | { | ||
62 | return s->regs[WDT_CTRL] & WDT_CTRL_ENABLE; | ||
63 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_timer_expired(void *dev) | ||
64 | { | ||
65 | AspeedWDTState *s = ASPEED_WDT(dev); | ||
66 | |||
67 | + /* Do not reset on SDRAM controller reset */ | ||
68 | + if (s->scu->regs[SCU_RESET_CONTROL1] & SCU_RESET_SDRAM) { | ||
69 | + timer_del(s->timer); | ||
70 | + s->regs[WDT_CTRL] = 0; | ||
71 | + return; | ||
27 | + } | 72 | + } |
28 | + | 73 | + |
29 | if (arm_feature(env, ARM_FEATURE_V8)) { | 74 | qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n"); |
30 | if (arm_feature(env, ARM_FEATURE_M_SECURITY) && | 75 | watchdog_perform_action(); |
31 | (lr & R_V7M_EXCRET_S_MASK)) { | 76 | timer_del(s->timer); |
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, | ||
32 | -- | 94 | -- |
33 | 2.20.1 | 95 | 2.20.1 |
34 | 96 | ||
35 | 97 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Hongbo Zhang <hongbo.zhang@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 3 | For AArch64, the existing "virt" machine is primarily meant to |
4 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 4 | run on KVM and execute virtualization workloads, but we need an |
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 5 | environment as faithful as possible to physical hardware, for supporting |
6 | Message-id: 20190412165416.7977-7-philmd@redhat.com | 6 | firmware and OS development for physical Aarch64 machines. |
7 | |||
8 | This patch introduces new machine type 'sbsa-ref' with main features: | ||
9 | - Based on 'virt' machine type. | ||
10 | - A new memory map. | ||
11 | - CPU type cortex-a57. | ||
12 | - EL2 and EL3 are enabled. | ||
13 | - GIC version 3. | ||
14 | - System bus AHCI controller. | ||
15 | - System bus EHCI controller. | ||
16 | - CDROM and hard disc on AHCI bus. | ||
17 | - E1000E ethernet card on PCIE bus. | ||
18 | - VGA display adaptor on PCIE bus. | ||
19 | - No virtio devices. | ||
20 | - No fw_cfg device. | ||
21 | - No ACPI table supplied. | ||
22 | - Only minimal device tree nodes. | ||
23 | |||
24 | Arm Trusted Firmware and UEFI porting to this are done accordingly, | ||
25 | and the firmware should supply ACPI tables to the guest OS. The | ||
26 | minimal device tree nodes supplied by QEMU for this platform are only | ||
27 | to pass the dynamic info reflecting command line input to firmware, | ||
28 | not for loading the guest OS. | ||
29 | |||
30 | To make the review easier, this task is split into two patches, the | ||
31 | fundamental skeleton part and the peripheral devices part; this patch is | ||
32 | the first part. | ||
33 | |||
34 | Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org> | ||
35 | Message-id: 1561890034-15921-2-git-send-email-hongbo.zhang@linaro.org | ||
36 | [PMM: commit message tweaks; moved some bits between patch 1 and 2 | ||
37 | to ensure patch 1 builds cleanly; removed unneeded lines from | ||
38 | Kconfig stanza; only provide board for qemu-system-aarch64, not | ||
39 | qemu-system-arm; added MAINTAINERS entry] | ||
40 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 41 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 42 | --- |
9 | include/hw/devices.h | 14 -------------- | 43 | hw/arm/Makefile.objs | 1 + |
10 | include/hw/misc/cbus.h | 32 ++++++++++++++++++++++++++++++++ | 44 | hw/arm/sbsa-ref.c | 271 ++++++++++++++++++++++++++++ |
11 | hw/arm/nseries.c | 1 + | 45 | MAINTAINERS | 8 + |
12 | hw/misc/cbus.c | 2 +- | 46 | default-configs/aarch64-softmmu.mak | 1 + |
13 | MAINTAINERS | 1 + | 47 | hw/arm/Kconfig | 14 ++ |
14 | 5 files changed, 35 insertions(+), 15 deletions(-) | 48 | 5 files changed, 295 insertions(+) |
15 | create mode 100644 include/hw/misc/cbus.h | 49 | create mode 100644 hw/arm/sbsa-ref.c |
16 | 50 | ||
17 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 51 | diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs |
18 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/devices.h | 53 | --- a/hw/arm/Makefile.objs |
20 | +++ b/include/hw/devices.h | 54 | +++ b/hw/arm/Makefile.objs |
21 | @@ -XXX,XX +XXX,XX @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | 55 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_SPITZ) += spitz.o |
22 | /* stellaris_input.c */ | 56 | obj-$(CONFIG_TOSA) += tosa.o |
23 | void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); | 57 | obj-$(CONFIG_Z2) += z2.o |
24 | 58 | obj-$(CONFIG_REALVIEW) += realview.o | |
25 | -/* cbus.c */ | 59 | +obj-$(CONFIG_SBSA_REF) += sbsa-ref.o |
26 | -typedef struct { | 60 | obj-$(CONFIG_STELLARIS) += stellaris.o |
27 | - qemu_irq clk; | 61 | obj-$(CONFIG_COLLIE) += collie.o |
28 | - qemu_irq dat; | 62 | obj-$(CONFIG_VERSATILE) += versatilepb.o |
29 | - qemu_irq sel; | 63 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
30 | -} CBus; | ||
31 | -CBus *cbus_init(qemu_irq dat_out); | ||
32 | -void cbus_attach(CBus *bus, void *slave_opaque); | ||
33 | - | ||
34 | -void *retu_init(qemu_irq irq, int vilma); | ||
35 | -void *tahvo_init(qemu_irq irq, int betty); | ||
36 | - | ||
37 | -void retu_key_event(void *retu, int state); | ||
38 | - | ||
39 | #endif | ||
40 | diff --git a/include/hw/misc/cbus.h b/include/hw/misc/cbus.h | ||
41 | new file mode 100644 | 64 | new file mode 100644 |
42 | index XXXXXXX..XXXXXXX | 65 | index XXXXXXX..XXXXXXX |
43 | --- /dev/null | 66 | --- /dev/null |
44 | +++ b/include/hw/misc/cbus.h | 67 | +++ b/hw/arm/sbsa-ref.c |
45 | @@ -XXX,XX +XXX,XX @@ | 68 | @@ -XXX,XX +XXX,XX @@ |
46 | +/* | 69 | +/* |
47 | + * CBUS three-pin bus and the Retu / Betty / Tahvo / Vilma / Avilma / | 70 | + * ARM SBSA Reference Platform emulation |
48 | + * Hinku / Vinku / Ahne / Pihi chips used in various Nokia platforms. | ||
49 | + * Based on reverse-engineering of a linux driver. | ||
50 | + * | 71 | + * |
51 | + * Copyright (C) 2008 Nokia Corporation | 72 | + * Copyright (c) 2018 Linaro Limited |
52 | + * Written by Andrzej Zaborowski | 73 | + * Written by Hongbo Zhang <hongbo.zhang@linaro.org> |
53 | + * | 74 | + * |
54 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 75 | + * This program is free software; you can redistribute it and/or modify it |
55 | + * See the COPYING file in the top-level directory. | 76 | + * under the terms and conditions of the GNU General Public License, |
77 | + * version 2 or later, as published by the Free Software Foundation. | ||
78 | + * | ||
79 | + * This program is distributed in the hope it will be useful, but WITHOUT | ||
80 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
81 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
82 | + * more details. | ||
83 | + * | ||
84 | + * You should have received a copy of the GNU General Public License along with | ||
85 | + * this program. If not, see <http://www.gnu.org/licenses/>. | ||
56 | + */ | 86 | + */ |
57 | + | 87 | + |
58 | +#ifndef HW_MISC_CBUS_H | 88 | +#include "qemu/osdep.h" |
59 | +#define HW_MISC_CBUS_H | 89 | +#include "qapi/error.h" |
60 | + | 90 | +#include "qemu/error-report.h" |
61 | +#include "hw/irq.h" | 91 | +#include "qemu/units.h" |
92 | +#include "sysemu/numa.h" | ||
93 | +#include "sysemu/sysemu.h" | ||
94 | +#include "exec/address-spaces.h" | ||
95 | +#include "exec/hwaddr.h" | ||
96 | +#include "kvm_arm.h" | ||
97 | +#include "hw/arm/boot.h" | ||
98 | +#include "hw/boards.h" | ||
99 | +#include "hw/intc/arm_gicv3_common.h" | ||
100 | + | ||
101 | +#define RAMLIMIT_GB 8192 | ||
102 | +#define RAMLIMIT_BYTES (RAMLIMIT_GB * GiB) | ||
103 | + | ||
104 | +enum { | ||
105 | + SBSA_FLASH, | ||
106 | + SBSA_MEM, | ||
107 | + SBSA_CPUPERIPHS, | ||
108 | + SBSA_GIC_DIST, | ||
109 | + SBSA_GIC_REDIST, | ||
110 | + SBSA_SMMU, | ||
111 | + SBSA_UART, | ||
112 | + SBSA_RTC, | ||
113 | + SBSA_PCIE, | ||
114 | + SBSA_PCIE_MMIO, | ||
115 | + SBSA_PCIE_MMIO_HIGH, | ||
116 | + SBSA_PCIE_PIO, | ||
117 | + SBSA_PCIE_ECAM, | ||
118 | + SBSA_GPIO, | ||
119 | + SBSA_SECURE_UART, | ||
120 | + SBSA_SECURE_UART_MM, | ||
121 | + SBSA_SECURE_MEM, | ||
122 | + SBSA_AHCI, | ||
123 | + SBSA_EHCI, | ||
124 | +}; | ||
125 | + | ||
126 | +typedef struct MemMapEntry { | ||
127 | + hwaddr base; | ||
128 | + hwaddr size; | ||
129 | +} MemMapEntry; | ||
62 | + | 130 | + |
63 | +typedef struct { | 131 | +typedef struct { |
64 | + qemu_irq clk; | 132 | + MachineState parent; |
65 | + qemu_irq dat; | 133 | + struct arm_boot_info bootinfo; |
66 | + qemu_irq sel; | 134 | + int smp_cpus; |
67 | +} CBus; | 135 | + void *fdt; |
68 | + | 136 | + int fdt_size; |
69 | +CBus *cbus_init(qemu_irq dat_out); | 137 | + int psci_conduit; |
70 | +void cbus_attach(CBus *bus, void *slave_opaque); | 138 | +} SBSAMachineState; |
71 | + | 139 | + |
72 | +void *retu_init(qemu_irq irq, int vilma); | 140 | +#define TYPE_SBSA_MACHINE MACHINE_TYPE_NAME("sbsa-ref") |
73 | +void *tahvo_init(qemu_irq irq, int betty); | 141 | +#define SBSA_MACHINE(obj) \ |
74 | + | 142 | + OBJECT_CHECK(SBSAMachineState, (obj), TYPE_SBSA_MACHINE) |
75 | +void retu_key_event(void *retu, int state); | 143 | + |
76 | + | 144 | +static const MemMapEntry sbsa_ref_memmap[] = { |
77 | +#endif | 145 | + /* 512M boot ROM */ |
78 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c | 146 | + [SBSA_FLASH] = { 0, 0x20000000 }, |
79 | index XXXXXXX..XXXXXXX 100644 | 147 | + /* 512M secure memory */ |
80 | --- a/hw/arm/nseries.c | 148 | + [SBSA_SECURE_MEM] = { 0x20000000, 0x20000000 }, |
81 | +++ b/hw/arm/nseries.c | 149 | + /* Space reserved for CPU peripheral devices */ |
82 | @@ -XXX,XX +XXX,XX @@ | 150 | + [SBSA_CPUPERIPHS] = { 0x40000000, 0x00040000 }, |
83 | #include "hw/i2c/i2c.h" | 151 | + [SBSA_GIC_DIST] = { 0x40060000, 0x00010000 }, |
84 | #include "hw/devices.h" | 152 | + [SBSA_GIC_REDIST] = { 0x40080000, 0x04000000 }, |
85 | #include "hw/display/blizzard.h" | 153 | + [SBSA_UART] = { 0x60000000, 0x00001000 }, |
86 | +#include "hw/misc/cbus.h" | 154 | + [SBSA_RTC] = { 0x60010000, 0x00001000 }, |
87 | #include "hw/misc/tmp105.h" | 155 | + [SBSA_GPIO] = { 0x60020000, 0x00001000 }, |
88 | #include "hw/block/flash.h" | 156 | + [SBSA_SECURE_UART] = { 0x60030000, 0x00001000 }, |
89 | #include "hw/hw.h" | 157 | + [SBSA_SECURE_UART_MM] = { 0x60040000, 0x00001000 }, |
90 | diff --git a/hw/misc/cbus.c b/hw/misc/cbus.c | 158 | + [SBSA_SMMU] = { 0x60050000, 0x00020000 }, |
91 | index XXXXXXX..XXXXXXX 100644 | 159 | + /* Space here reserved for more SMMUs */ |
92 | --- a/hw/misc/cbus.c | 160 | + [SBSA_AHCI] = { 0x60100000, 0x00010000 }, |
93 | +++ b/hw/misc/cbus.c | 161 | + [SBSA_EHCI] = { 0x60110000, 0x00010000 }, |
94 | @@ -XXX,XX +XXX,XX @@ | 162 | + /* Space here reserved for other devices */ |
95 | #include "qemu/osdep.h" | 163 | + [SBSA_PCIE_PIO] = { 0x7fff0000, 0x00010000 }, |
96 | #include "hw/hw.h" | 164 | + /* 32-bit address PCIE MMIO space */ |
97 | #include "hw/irq.h" | 165 | + [SBSA_PCIE_MMIO] = { 0x80000000, 0x70000000 }, |
98 | -#include "hw/devices.h" | 166 | + /* 256M PCIE ECAM space */ |
99 | +#include "hw/misc/cbus.h" | 167 | + [SBSA_PCIE_ECAM] = { 0xf0000000, 0x10000000 }, |
100 | #include "sysemu/sysemu.h" | 168 | + /* ~1TB PCIE MMIO space (4GB to 1024GB boundary) */ |
101 | 169 | + [SBSA_PCIE_MMIO_HIGH] = { 0x100000000ULL, 0xFF00000000ULL }, | |
102 | //#define DEBUG | 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 | + } | ||
188 | + | ||
189 | + if (kvm_enabled()) { | ||
190 | + error_report("sbsa-ref: KVM is not supported for this machine"); | ||
191 | + exit(1); | ||
192 | + } | ||
193 | + | ||
194 | + /* | ||
195 | + * This machine has EL3 enabled, external firmware should supply PSCI | ||
196 | + * implementation, so the QEMU's internal PSCI is disabled. | ||
197 | + */ | ||
198 | + sms->psci_conduit = QEMU_PSCI_CONDUIT_DISABLED; | ||
199 | + | ||
200 | + sbsa_max_cpus = sbsa_ref_memmap[SBSA_GIC_REDIST].size / GICV3_REDIST_SIZE; | ||
201 | + | ||
202 | + if (max_cpus > sbsa_max_cpus) { | ||
203 | + error_report("Number of SMP CPUs requested (%d) exceeds max CPUs " | ||
204 | + "supported by machine 'sbsa-ref' (%d)", | ||
205 | + max_cpus, sbsa_max_cpus); | ||
206 | + exit(1); | ||
207 | + } | ||
208 | + | ||
209 | + sms->smp_cpus = smp_cpus; | ||
210 | + | ||
211 | + if (machine->ram_size > sbsa_ref_memmap[SBSA_MEM].size) { | ||
212 | + error_report("sbsa-ref: cannot model more than %dGB RAM", RAMLIMIT_GB); | ||
213 | + exit(1); | ||
214 | + } | ||
215 | + | ||
216 | + possible_cpus = mc->possible_cpu_arch_ids(machine); | ||
217 | + for (n = 0; n < possible_cpus->len; n++) { | ||
218 | + Object *cpuobj; | ||
219 | + CPUState *cs; | ||
220 | + | ||
221 | + if (n >= smp_cpus) { | ||
222 | + break; | ||
223 | + } | ||
224 | + | ||
225 | + cpuobj = object_new(possible_cpus->cpus[n].type); | ||
226 | + object_property_set_int(cpuobj, possible_cpus->cpus[n].arch_id, | ||
227 | + "mp-affinity", NULL); | ||
228 | + | ||
229 | + cs = CPU(cpuobj); | ||
230 | + cs->cpu_index = n; | ||
231 | + | ||
232 | + numa_cpu_pre_plug(&possible_cpus->cpus[cs->cpu_index], DEVICE(cpuobj), | ||
233 | + &error_fatal); | ||
234 | + | ||
235 | + if (object_property_find(cpuobj, "reset-cbar", NULL)) { | ||
236 | + object_property_set_int(cpuobj, | ||
237 | + sbsa_ref_memmap[SBSA_CPUPERIPHS].base, | ||
238 | + "reset-cbar", &error_abort); | ||
239 | + } | ||
240 | + | ||
241 | + object_property_set_link(cpuobj, OBJECT(sysmem), "memory", | ||
242 | + &error_abort); | ||
243 | + | ||
244 | + object_property_set_link(cpuobj, OBJECT(secure_sysmem), | ||
245 | + "secure-memory", &error_abort); | ||
246 | + | ||
247 | + object_property_set_bool(cpuobj, true, "realized", &error_fatal); | ||
248 | + object_unref(cpuobj); | ||
249 | + } | ||
250 | + | ||
251 | + memory_region_allocate_system_memory(ram, NULL, "sbsa-ref.ram", | ||
252 | + machine->ram_size); | ||
253 | + memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ram); | ||
254 | + | ||
255 | + sms->bootinfo.ram_size = machine->ram_size; | ||
256 | + sms->bootinfo.kernel_filename = machine->kernel_filename; | ||
257 | + sms->bootinfo.nb_cpus = smp_cpus; | ||
258 | + sms->bootinfo.board_id = -1; | ||
259 | + sms->bootinfo.loader_start = sbsa_ref_memmap[SBSA_MEM].base; | ||
260 | + arm_load_kernel(ARM_CPU(first_cpu), &sms->bootinfo); | ||
261 | +} | ||
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); | ||
103 | diff --git a/MAINTAINERS b/MAINTAINERS | 340 | diff --git a/MAINTAINERS b/MAINTAINERS |
104 | index XXXXXXX..XXXXXXX 100644 | 341 | index XXXXXXX..XXXXXXX 100644 |
105 | --- a/MAINTAINERS | 342 | --- a/MAINTAINERS |
106 | +++ b/MAINTAINERS | 343 | +++ b/MAINTAINERS |
107 | @@ -XXX,XX +XXX,XX @@ F: hw/input/tsc2005.c | 344 | @@ -XXX,XX +XXX,XX @@ F: include/hw/arm/fsl-imx6.h |
108 | F: hw/misc/cbus.c | 345 | F: include/hw/misc/imx6_*.h |
109 | F: hw/timer/twl92230.c | 346 | F: include/hw/ssi/imx_spi.h |
110 | F: include/hw/display/blizzard.h | 347 | |
111 | +F: include/hw/misc/cbus.h | 348 | +SBSA-REF |
112 | 349 | +M: Radoslaw Biernacki <radoslaw.biernacki@linaro.org> | |
113 | Palm | 350 | +M: Peter Maydell <peter.maydell@linaro.org> |
114 | M: Andrzej Zaborowski <balrogg@gmail.com> | 351 | +R: Leif Lindholm <leif.lindholm@linaro.org> |
352 | +L: qemu-arm@nongnu.org | ||
353 | +S: Maintained | ||
354 | +F: hw/arm/sbsa-ref.c | ||
355 | + | ||
356 | Sharp SL-5500 (Collie) PDA | ||
357 | M: Peter Maydell <peter.maydell@linaro.org> | ||
358 | L: qemu-arm@nongnu.org | ||
359 | diff --git a/default-configs/aarch64-softmmu.mak b/default-configs/aarch64-softmmu.mak | ||
360 | index XXXXXXX..XXXXXXX 100644 | ||
361 | --- a/default-configs/aarch64-softmmu.mak | ||
362 | +++ b/default-configs/aarch64-softmmu.mak | ||
363 | @@ -XXX,XX +XXX,XX @@ include arm-softmmu.mak | ||
364 | |||
365 | CONFIG_XLNX_ZYNQMP_ARM=y | ||
366 | CONFIG_XLNX_VERSAL=y | ||
367 | +CONFIG_SBSA_REF=y | ||
368 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
369 | index XXXXXXX..XXXXXXX 100644 | ||
370 | --- a/hw/arm/Kconfig | ||
371 | +++ b/hw/arm/Kconfig | ||
372 | @@ -XXX,XX +XXX,XX @@ config REALVIEW | ||
373 | select DS1338 # I2C RTC+NVRAM | ||
374 | select USB_OHCI | ||
375 | |||
376 | +config SBSA_REF | ||
377 | + bool | ||
378 | + imply PCI_DEVICES | ||
379 | + select AHCI | ||
380 | + select ARM_SMMUV3 | ||
381 | + select GPIO_KEY | ||
382 | + select PCI_EXPRESS | ||
383 | + select PCI_EXPRESS_GENERIC_BRIDGE | ||
384 | + select PFLASH_CFI01 | ||
385 | + select PL011 # UART | ||
386 | + select PL031 # RTC | ||
387 | + select PL061 # GPIO | ||
388 | + select USB_EHCI_SYSBUS | ||
389 | + | ||
390 | config SABRELITE | ||
391 | bool | ||
392 | select FSL_IMX6 | ||
115 | -- | 393 | -- |
116 | 2.20.1 | 394 | 2.20.1 |
117 | 395 | ||
118 | 396 | diff view generated by jsdifflib |
1 | Correct the decode of the M-profile "coprocessor and | 1 | From: Hongbo Zhang <hongbo.zhang@linaro.org> |
---|---|---|---|
2 | floating-point instructions" space: | ||
3 | * op0 == 0b11 is always unallocated | ||
4 | * if the CPU has an FPU then all insns with op1 == 0b101 | ||
5 | are floating point and go to disas_vfp_insn() | ||
6 | 2 | ||
7 | For the moment we leave VLLDM and VLSTM as NOPs; in | 3 | Following the previous patch, this patch adds peripheral devices to the |
8 | a later commit we will fill in the proper implementation | 4 | newly introduced SBSA-ref machine. |
9 | for the case where an FPU is present. | ||
10 | 5 | ||
6 | Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org> | ||
7 | Message-id: 1561890034-15921-3-git-send-email-hongbo.zhang@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20190416125744.27770-7-peter.maydell@linaro.org | ||
14 | --- | 10 | --- |
15 | target/arm/translate.c | 26 ++++++++++++++++++++++---- | 11 | hw/arm/sbsa-ref.c | 535 ++++++++++++++++++++++++++++++++++++++++++++++ |
16 | 1 file changed, 22 insertions(+), 4 deletions(-) | 12 | 1 file changed, 535 insertions(+) |
17 | 13 | ||
18 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
19 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/translate.c | 16 | --- a/hw/arm/sbsa-ref.c |
21 | +++ b/target/arm/translate.c | 17 | +++ b/hw/arm/sbsa-ref.c |
22 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 18 | @@ -XXX,XX +XXX,XX @@ |
23 | case 6: case 7: case 14: case 15: | 19 | */ |
24 | /* Coprocessor. */ | 20 | |
25 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | 21 | #include "qemu/osdep.h" |
26 | - /* We don't currently implement M profile FP support, | 22 | +#include "qemu-common.h" |
27 | - * so this entire space should give a NOCP fault, with | 23 | #include "qapi/error.h" |
28 | - * the exception of the v8M VLLDM and VLSTM insns, which | 24 | #include "qemu/error-report.h" |
29 | - * must be NOPs in Secure state and UNDEF in Nonsecure state. | 25 | #include "qemu/units.h" |
30 | + /* 0b111x_11xx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx */ | 26 | +#include "sysemu/device_tree.h" |
31 | + if (extract32(insn, 24, 2) == 3) { | 27 | #include "sysemu/numa.h" |
32 | + goto illegal_op; /* op0 = 0b11 : unallocated */ | 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 | }; | ||
71 | |||
72 | +static const int sbsa_ref_irqmap[] = { | ||
73 | + [SBSA_UART] = 1, | ||
74 | + [SBSA_RTC] = 2, | ||
75 | + [SBSA_PCIE] = 3, /* ... to 6 */ | ||
76 | + [SBSA_GPIO] = 7, | ||
77 | + [SBSA_SECURE_UART] = 8, | ||
78 | + [SBSA_SECURE_UART_MM] = 9, | ||
79 | + [SBSA_AHCI] = 10, | ||
80 | + [SBSA_EHCI] = 11, | ||
81 | +}; | ||
82 | + | ||
83 | +/* | ||
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 | +{ | ||
91 | + void *fdt = create_device_tree(&sms->fdt_size); | ||
92 | + const MachineState *ms = MACHINE(sms); | ||
93 | + int cpu; | ||
94 | + | ||
95 | + if (!fdt) { | ||
96 | + error_report("create_device_tree() failed"); | ||
97 | + exit(1); | ||
98 | + } | ||
99 | + | ||
100 | + sms->fdt = fdt; | ||
101 | + | ||
102 | + qemu_fdt_setprop_string(fdt, "/", "compatible", "linux,sbsa-ref"); | ||
103 | + qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2); | ||
104 | + qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 0x2); | ||
105 | + | ||
106 | + if (have_numa_distance) { | ||
107 | + int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t); | ||
108 | + uint32_t *matrix = g_malloc0(size); | ||
109 | + int idx, i, j; | ||
110 | + | ||
111 | + for (i = 0; i < nb_numa_nodes; i++) { | ||
112 | + for (j = 0; j < nb_numa_nodes; j++) { | ||
113 | + idx = (i * nb_numa_nodes + j) * 3; | ||
114 | + matrix[idx + 0] = cpu_to_be32(i); | ||
115 | + matrix[idx + 1] = cpu_to_be32(j); | ||
116 | + matrix[idx + 2] = cpu_to_be32(numa_info[i].distance[j]); | ||
33 | + } | 117 | + } |
34 | + | 118 | + } |
35 | + /* | 119 | + |
36 | + * Decode VLLDM and VLSTM first: these are nonstandard because: | 120 | + qemu_fdt_add_subnode(fdt, "/distance-map"); |
37 | + * * if there is no FPU then these insns must NOP in | 121 | + qemu_fdt_setprop(fdt, "/distance-map", "distance-matrix", |
38 | + * Secure state and UNDEF in Nonsecure state | 122 | + matrix, size); |
39 | + * * if there is an FPU then these insns do not have | 123 | + g_free(matrix); |
40 | + * the usual behaviour that disas_vfp_insn() provides of | 124 | + } |
41 | + * being controlled by CPACR/NSACR enable bits or the | 125 | + |
42 | + * lazy-stacking logic. | 126 | + qemu_fdt_add_subnode(sms->fdt, "/cpus"); |
43 | */ | 127 | + |
44 | if (arm_dc_feature(s, ARM_FEATURE_V8) && | 128 | + for (cpu = sms->smp_cpus - 1; cpu >= 0; cpu--) { |
45 | (insn & 0xffa00f00) == 0xec200a00) { | 129 | + char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu); |
46 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 130 | + ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); |
47 | /* Just NOP since FP support is not implemented */ | 131 | + CPUState *cs = CPU(armcpu); |
48 | break; | 132 | + |
49 | } | 133 | + qemu_fdt_add_subnode(sms->fdt, nodename); |
50 | + if (arm_dc_feature(s, ARM_FEATURE_VFP) && | 134 | + |
51 | + ((insn >> 8) & 0xe) == 10) { | 135 | + if (ms->possible_cpus->cpus[cs->cpu_index].props.has_node_id) { |
52 | + /* FP, and the CPU supports it */ | 136 | + qemu_fdt_setprop_cell(sms->fdt, nodename, "numa-node-id", |
53 | + if (disas_vfp_insn(s, insn)) { | 137 | + ms->possible_cpus->cpus[cs->cpu_index].props.node_id); |
54 | + goto illegal_op; | 138 | + } |
55 | + } | 139 | + |
56 | + break; | 140 | + g_free(nodename); |
141 | + } | ||
142 | +} | ||
143 | + | ||
144 | +#define SBSA_FLASH_SECTOR_SIZE (256 * KiB) | ||
145 | + | ||
146 | +static PFlashCFI01 *sbsa_flash_create1(SBSAMachineState *sms, | ||
147 | + const char *name, | ||
148 | + const char *alias_prop_name) | ||
149 | +{ | ||
150 | + /* | ||
151 | + * Create a single flash device. We use the same parameters as | ||
152 | + * the flash devices on the Versatile Express board. | ||
153 | + */ | ||
154 | + DeviceState *dev = qdev_create(NULL, TYPE_PFLASH_CFI01); | ||
155 | + | ||
156 | + qdev_prop_set_uint64(dev, "sector-length", SBSA_FLASH_SECTOR_SIZE); | ||
157 | + qdev_prop_set_uint8(dev, "width", 4); | ||
158 | + qdev_prop_set_uint8(dev, "device-width", 2); | ||
159 | + qdev_prop_set_bit(dev, "big-endian", false); | ||
160 | + qdev_prop_set_uint16(dev, "id0", 0x89); | ||
161 | + qdev_prop_set_uint16(dev, "id1", 0x18); | ||
162 | + qdev_prop_set_uint16(dev, "id2", 0x00); | ||
163 | + qdev_prop_set_uint16(dev, "id3", 0x00); | ||
164 | + qdev_prop_set_string(dev, "name", name); | ||
165 | + object_property_add_child(OBJECT(sms), name, OBJECT(dev), | ||
166 | + &error_abort); | ||
167 | + object_property_add_alias(OBJECT(sms), alias_prop_name, | ||
168 | + OBJECT(dev), "drive", &error_abort); | ||
169 | + return PFLASH_CFI01(dev); | ||
170 | +} | ||
171 | + | ||
172 | +static void sbsa_flash_create(SBSAMachineState *sms) | ||
173 | +{ | ||
174 | + sms->flash[0] = sbsa_flash_create1(sms, "sbsa.flash0", "pflash0"); | ||
175 | + sms->flash[1] = sbsa_flash_create1(sms, "sbsa.flash1", "pflash1"); | ||
176 | +} | ||
177 | + | ||
178 | +static void sbsa_flash_map1(PFlashCFI01 *flash, | ||
179 | + hwaddr base, hwaddr size, | ||
180 | + MemoryRegion *sysmem) | ||
181 | +{ | ||
182 | + DeviceState *dev = DEVICE(flash); | ||
183 | + | ||
184 | + assert(size % SBSA_FLASH_SECTOR_SIZE == 0); | ||
185 | + assert(size / SBSA_FLASH_SECTOR_SIZE <= UINT32_MAX); | ||
186 | + qdev_prop_set_uint32(dev, "num-blocks", size / SBSA_FLASH_SECTOR_SIZE); | ||
187 | + qdev_init_nofail(dev); | ||
188 | + | ||
189 | + memory_region_add_subregion(sysmem, base, | ||
190 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), | ||
191 | + 0)); | ||
192 | +} | ||
193 | + | ||
194 | +static void sbsa_flash_map(SBSAMachineState *sms, | ||
195 | + MemoryRegion *sysmem, | ||
196 | + MemoryRegion *secure_sysmem) | ||
197 | +{ | ||
198 | + /* | ||
199 | + * Map two flash devices to fill the SBSA_FLASH space in the memmap. | ||
200 | + * sysmem is the system memory space. secure_sysmem is the secure view | ||
201 | + * of the system, and the first flash device should be made visible only | ||
202 | + * there. The second flash device is visible to both secure and nonsecure. | ||
203 | + * If sysmem == secure_sysmem this means there is no separate Secure | ||
204 | + * address space and both flash devices are generally visible. | ||
205 | + */ | ||
206 | + hwaddr flashsize = sbsa_ref_memmap[SBSA_FLASH].size / 2; | ||
207 | + hwaddr flashbase = sbsa_ref_memmap[SBSA_FLASH].base; | ||
208 | + | ||
209 | + sbsa_flash_map1(sms->flash[0], flashbase, flashsize, | ||
210 | + secure_sysmem); | ||
211 | + sbsa_flash_map1(sms->flash[1], flashbase + flashsize, flashsize, | ||
212 | + sysmem); | ||
213 | +} | ||
214 | + | ||
215 | +static bool sbsa_firmware_init(SBSAMachineState *sms, | ||
216 | + MemoryRegion *sysmem, | ||
217 | + MemoryRegion *secure_sysmem) | ||
218 | +{ | ||
219 | + int i; | ||
220 | + BlockBackend *pflash_blk0; | ||
221 | + | ||
222 | + /* Map legacy -drive if=pflash to machine properties */ | ||
223 | + for (i = 0; i < ARRAY_SIZE(sms->flash); i++) { | ||
224 | + pflash_cfi01_legacy_drive(sms->flash[i], | ||
225 | + drive_get(IF_PFLASH, 0, i)); | ||
226 | + } | ||
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"); | ||
57 | + } | 512 | + } |
58 | + | 513 | + |
59 | /* All other insns: NOCP */ | 514 | + pci_nic_init_nofail(nd, pci->bus, nd->model, NULL); |
60 | gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), | 515 | + } |
61 | default_exception_el(s)); | 516 | + } |
517 | + | ||
518 | + pci_create_simple(pci->bus, -1, "VGA"); | ||
519 | + | ||
520 | + create_smmu(sms, pic, pci->bus); | ||
521 | +} | ||
522 | + | ||
523 | +static void *sbsa_ref_dtb(const struct arm_boot_info *binfo, int *fdt_size) | ||
524 | +{ | ||
525 | + const SBSAMachineState *board = container_of(binfo, SBSAMachineState, | ||
526 | + bootinfo); | ||
527 | + | ||
528 | + *fdt_size = board->fdt_size; | ||
529 | + return board->fdt; | ||
530 | +} | ||
531 | + | ||
532 | static void sbsa_ref_init(MachineState *machine) | ||
533 | { | ||
534 | SBSAMachineState *sms = SBSA_MACHINE(machine); | ||
535 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | ||
536 | MemoryRegion *sysmem = get_system_memory(); | ||
537 | MemoryRegion *secure_sysmem = NULL; | ||
538 | MemoryRegion *ram = g_new(MemoryRegion, 1); | ||
539 | + bool firmware_loaded; | ||
540 | const CPUArchIdList *possible_cpus; | ||
541 | int n, sbsa_max_cpus; | ||
542 | + qemu_irq pic[NUM_IRQS]; | ||
543 | |||
544 | if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a57"))) { | ||
545 | error_report("sbsa-ref: CPU type other than the built-in " | ||
546 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | ||
547 | exit(1); | ||
548 | } | ||
549 | |||
550 | + /* | ||
551 | + * The Secure view of the world is the same as the NonSecure, | ||
552 | + * but with a few extra devices. Create it as a container region | ||
553 | + * containing the system memory at low priority; any secure-only | ||
554 | + * devices go in at higher priority and take precedence. | ||
555 | + */ | ||
556 | + secure_sysmem = g_new(MemoryRegion, 1); | ||
557 | + memory_region_init(secure_sysmem, OBJECT(machine), "secure-memory", | ||
558 | + UINT64_MAX); | ||
559 | + memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1); | ||
560 | + | ||
561 | + firmware_loaded = sbsa_firmware_init(sms, sysmem, | ||
562 | + secure_sysmem ?: sysmem); | ||
563 | + | ||
564 | + if (machine->kernel_filename && firmware_loaded) { | ||
565 | + error_report("sbsa-ref: No fw_cfg device on this machine, " | ||
566 | + "so -kernel option is not supported when firmware loaded, " | ||
567 | + "please load OS from hard disk instead"); | ||
568 | + exit(1); | ||
569 | + } | ||
570 | + | ||
571 | /* | ||
572 | * This machine has EL3 enabled, external firmware should supply PSCI | ||
573 | * implementation, so the QEMU's internal PSCI is disabled. | ||
574 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | ||
575 | machine->ram_size); | ||
576 | memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ram); | ||
577 | |||
578 | + create_fdt(sms); | ||
579 | + | ||
580 | + create_secure_ram(sms, secure_sysmem); | ||
581 | + | ||
582 | + create_gic(sms, pic); | ||
583 | + | ||
584 | + create_uart(sms, pic, SBSA_UART, sysmem, serial_hd(0)); | ||
585 | + create_uart(sms, pic, SBSA_SECURE_UART, secure_sysmem, serial_hd(1)); | ||
586 | + /* Second secure UART for RAS and MM from EL0 */ | ||
587 | + create_uart(sms, pic, SBSA_SECURE_UART_MM, secure_sysmem, serial_hd(2)); | ||
588 | + | ||
589 | + create_rtc(sms, pic); | ||
590 | + | ||
591 | + create_gpio(sms, pic); | ||
592 | + | ||
593 | + create_ahci(sms, pic); | ||
594 | + | ||
595 | + create_ehci(sms, pic); | ||
596 | + | ||
597 | + create_pcie(sms, pic); | ||
598 | + | ||
599 | sms->bootinfo.ram_size = machine->ram_size; | ||
600 | sms->bootinfo.kernel_filename = machine->kernel_filename; | ||
601 | sms->bootinfo.nb_cpus = smp_cpus; | ||
602 | sms->bootinfo.board_id = -1; | ||
603 | sms->bootinfo.loader_start = sbsa_ref_memmap[SBSA_MEM].base; | ||
604 | + sms->bootinfo.get_dtb = sbsa_ref_dtb; | ||
605 | + sms->bootinfo.firmware_loaded = firmware_loaded; | ||
606 | arm_load_kernel(ARM_CPU(first_cpu), &sms->bootinfo); | ||
607 | } | ||
608 | |||
609 | @@ -XXX,XX +XXX,XX @@ sbsa_ref_get_default_cpu_node_id(const MachineState *ms, int idx) | ||
610 | return idx % nb_numa_nodes; | ||
611 | } | ||
612 | |||
613 | +static void sbsa_ref_instance_init(Object *obj) | ||
614 | +{ | ||
615 | + SBSAMachineState *sms = SBSA_MACHINE(obj); | ||
616 | + | ||
617 | + sbsa_flash_create(sms); | ||
618 | +} | ||
619 | + | ||
620 | static void sbsa_ref_class_init(ObjectClass *oc, void *data) | ||
621 | { | ||
622 | MachineClass *mc = MACHINE_CLASS(oc); | ||
623 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data) | ||
624 | static const TypeInfo sbsa_ref_info = { | ||
625 | .name = TYPE_SBSA_MACHINE, | ||
626 | .parent = TYPE_MACHINE, | ||
627 | + .instance_init = sbsa_ref_instance_init, | ||
628 | .class_init = sbsa_ref_class_init, | ||
629 | .instance_size = sizeof(SBSAMachineState), | ||
630 | }; | ||
62 | -- | 631 | -- |
63 | 2.20.1 | 632 | 2.20.1 |
64 | 633 | ||
65 | 634 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Since uWireSlave is only used in this new header, there is no | 3 | Group Aarch64 rules together, TCG related ones at the bottom. |
4 | need to expose it via "qemu/typedefs.h". | 4 | This will help when restricting TCG-only objects. |
5 | 5 | ||
6 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
8 | Message-id: 20190412165416.7977-9-philmd@redhat.com | 8 | Message-id: 20190701132516.26392-2-philmd@redhat.com |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | include/hw/arm/omap.h | 6 +----- | 11 | target/arm/Makefile.objs | 5 +++-- |
12 | include/hw/devices.h | 15 --------------- | 12 | 1 file changed, 3 insertions(+), 2 deletions(-) |
13 | include/hw/input/tsc2xxx.h | 36 ++++++++++++++++++++++++++++++++++++ | ||
14 | include/qemu/typedefs.h | 1 - | ||
15 | hw/arm/nseries.c | 2 +- | ||
16 | hw/arm/palm.c | 2 +- | ||
17 | hw/input/tsc2005.c | 2 +- | ||
18 | hw/input/tsc210x.c | 4 ++-- | ||
19 | MAINTAINERS | 2 ++ | ||
20 | 9 files changed, 44 insertions(+), 26 deletions(-) | ||
21 | create mode 100644 include/hw/input/tsc2xxx.h | ||
22 | 13 | ||
23 | diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h | 14 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs |
24 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/arm/omap.h | 16 | --- a/target/arm/Makefile.objs |
26 | +++ b/include/hw/arm/omap.h | 17 | +++ b/target/arm/Makefile.objs |
27 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o |
28 | #include "exec/memory.h" | 19 | obj-y += translate.o op_helper.o helper.o cpu.o |
29 | # define hw_omap_h "omap.h" | 20 | obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o |
30 | #include "hw/irq.h" | 21 | obj-y += gdbstub.o |
31 | +#include "hw/input/tsc2xxx.h" | 22 | -obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o |
32 | #include "target/arm/cpu-qom.h" | 23 | -obj-$(TARGET_AARCH64) += pauth_helper.o |
33 | #include "qemu/log.h" | 24 | +obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o |
34 | 25 | obj-y += crypto_helper.o | |
35 | @@ -XXX,XX +XXX,XX @@ qemu_irq *omap_mpuio_in_get(struct omap_mpuio_s *s); | 26 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o |
36 | void omap_mpuio_out_set(struct omap_mpuio_s *s, int line, qemu_irq handler); | 27 | |
37 | void omap_mpuio_key(struct omap_mpuio_s *s, int row, int col, int down); | 28 | @@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c |
38 | 29 | target/arm/translate.o: target/arm/decode-vfp.inc.c | |
39 | -struct uWireSlave { | 30 | target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c |
40 | - uint16_t (*receive)(void *opaque); | 31 | |
41 | - void (*send)(void *opaque, uint16_t data); | 32 | +obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o |
42 | - void *opaque; | 33 | obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o |
43 | -}; | 34 | +obj-$(TARGET_AARCH64) += pauth_helper.o |
44 | struct omap_uwire_s; | ||
45 | void omap_uwire_attach(struct omap_uwire_s *s, | ||
46 | uWireSlave *slave, int chipselect); | ||
47 | diff --git a/include/hw/devices.h b/include/hw/devices.h | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/include/hw/devices.h | ||
50 | +++ b/include/hw/devices.h | ||
51 | @@ -XXX,XX +XXX,XX @@ | ||
52 | /* Devices that have nowhere better to go. */ | ||
53 | |||
54 | #include "hw/hw.h" | ||
55 | -#include "ui/console.h" | ||
56 | |||
57 | /* smc91c111.c */ | ||
58 | void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | ||
59 | @@ -XXX,XX +XXX,XX @@ void smc91c111_init(NICInfo *, uint32_t, qemu_irq); | ||
60 | /* lan9118.c */ | ||
61 | void lan9118_init(NICInfo *, uint32_t, qemu_irq); | ||
62 | |||
63 | -/* tsc210x.c */ | ||
64 | -uWireSlave *tsc2102_init(qemu_irq pint); | ||
65 | -uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav); | ||
66 | -I2SCodec *tsc210x_codec(uWireSlave *chip); | ||
67 | -uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len); | ||
68 | -void tsc210x_set_transform(uWireSlave *chip, | ||
69 | - MouseTransformInfo *info); | ||
70 | -void tsc210x_key_event(uWireSlave *chip, int key, int down); | ||
71 | - | ||
72 | -/* tsc2005.c */ | ||
73 | -void *tsc2005_init(qemu_irq pintdav); | ||
74 | -uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len); | ||
75 | -void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | ||
76 | - | ||
77 | #endif | ||
78 | diff --git a/include/hw/input/tsc2xxx.h b/include/hw/input/tsc2xxx.h | ||
79 | new file mode 100644 | ||
80 | index XXXXXXX..XXXXXXX | ||
81 | --- /dev/null | ||
82 | +++ b/include/hw/input/tsc2xxx.h | ||
83 | @@ -XXX,XX +XXX,XX @@ | ||
84 | +/* | ||
85 | + * TI touchscreen controller | ||
86 | + * | ||
87 | + * Copyright (c) 2006 Andrzej Zaborowski | ||
88 | + * Copyright (C) 2008 Nokia Corporation | ||
89 | + * | ||
90 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
91 | + * See the COPYING file in the top-level directory. | ||
92 | + */ | ||
93 | + | ||
94 | +#ifndef HW_INPUT_TSC2XXX_H | ||
95 | +#define HW_INPUT_TSC2XXX_H | ||
96 | + | ||
97 | +#include "hw/irq.h" | ||
98 | +#include "ui/console.h" | ||
99 | + | ||
100 | +typedef struct uWireSlave { | ||
101 | + uint16_t (*receive)(void *opaque); | ||
102 | + void (*send)(void *opaque, uint16_t data); | ||
103 | + void *opaque; | ||
104 | +} uWireSlave; | ||
105 | + | ||
106 | +/* tsc210x.c */ | ||
107 | +uWireSlave *tsc2102_init(qemu_irq pint); | ||
108 | +uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav); | ||
109 | +I2SCodec *tsc210x_codec(uWireSlave *chip); | ||
110 | +uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len); | ||
111 | +void tsc210x_set_transform(uWireSlave *chip, MouseTransformInfo *info); | ||
112 | +void tsc210x_key_event(uWireSlave *chip, int key, int down); | ||
113 | + | ||
114 | +/* tsc2005.c */ | ||
115 | +void *tsc2005_init(qemu_irq pintdav); | ||
116 | +uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len); | ||
117 | +void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | ||
118 | + | ||
119 | +#endif | ||
120 | diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h | ||
121 | index XXXXXXX..XXXXXXX 100644 | ||
122 | --- a/include/qemu/typedefs.h | ||
123 | +++ b/include/qemu/typedefs.h | ||
124 | @@ -XXX,XX +XXX,XX @@ typedef struct RAMBlock RAMBlock; | ||
125 | typedef struct Range Range; | ||
126 | typedef struct SHPCDevice SHPCDevice; | ||
127 | typedef struct SSIBus SSIBus; | ||
128 | -typedef struct uWireSlave uWireSlave; | ||
129 | typedef struct VirtIODevice VirtIODevice; | ||
130 | typedef struct Visitor Visitor; | ||
131 | typedef void SaveStateHandler(QEMUFile *f, void *opaque); | ||
132 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c | ||
133 | index XXXXXXX..XXXXXXX 100644 | ||
134 | --- a/hw/arm/nseries.c | ||
135 | +++ b/hw/arm/nseries.c | ||
136 | @@ -XXX,XX +XXX,XX @@ | ||
137 | #include "ui/console.h" | ||
138 | #include "hw/boards.h" | ||
139 | #include "hw/i2c/i2c.h" | ||
140 | -#include "hw/devices.h" | ||
141 | #include "hw/display/blizzard.h" | ||
142 | +#include "hw/input/tsc2xxx.h" | ||
143 | #include "hw/misc/cbus.h" | ||
144 | #include "hw/misc/tmp105.h" | ||
145 | #include "hw/block/flash.h" | ||
146 | diff --git a/hw/arm/palm.c b/hw/arm/palm.c | ||
147 | index XXXXXXX..XXXXXXX 100644 | ||
148 | --- a/hw/arm/palm.c | ||
149 | +++ b/hw/arm/palm.c | ||
150 | @@ -XXX,XX +XXX,XX @@ | ||
151 | #include "hw/arm/omap.h" | ||
152 | #include "hw/boards.h" | ||
153 | #include "hw/arm/arm.h" | ||
154 | -#include "hw/devices.h" | ||
155 | +#include "hw/input/tsc2xxx.h" | ||
156 | #include "hw/loader.h" | ||
157 | #include "exec/address-spaces.h" | ||
158 | #include "cpu.h" | ||
159 | diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c | ||
160 | index XXXXXXX..XXXXXXX 100644 | ||
161 | --- a/hw/input/tsc2005.c | ||
162 | +++ b/hw/input/tsc2005.c | ||
163 | @@ -XXX,XX +XXX,XX @@ | ||
164 | #include "hw/hw.h" | ||
165 | #include "qemu/timer.h" | ||
166 | #include "ui/console.h" | ||
167 | -#include "hw/devices.h" | ||
168 | +#include "hw/input/tsc2xxx.h" | ||
169 | #include "trace.h" | ||
170 | |||
171 | #define TSC_CUT_RESOLUTION(value, p) ((value) >> (16 - (p ? 12 : 10))) | ||
172 | diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c | ||
173 | index XXXXXXX..XXXXXXX 100644 | ||
174 | --- a/hw/input/tsc210x.c | ||
175 | +++ b/hw/input/tsc210x.c | ||
176 | @@ -XXX,XX +XXX,XX @@ | ||
177 | #include "audio/audio.h" | ||
178 | #include "qemu/timer.h" | ||
179 | #include "ui/console.h" | ||
180 | -#include "hw/arm/omap.h" /* For I2SCodec and uWireSlave */ | ||
181 | -#include "hw/devices.h" | ||
182 | +#include "hw/arm/omap.h" /* For I2SCodec */ | ||
183 | +#include "hw/input/tsc2xxx.h" | ||
184 | |||
185 | #define TSC_DATA_REGISTERS_PAGE 0x0 | ||
186 | #define TSC_CONTROL_REGISTERS_PAGE 0x1 | ||
187 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
188 | index XXXXXXX..XXXXXXX 100644 | ||
189 | --- a/MAINTAINERS | ||
190 | +++ b/MAINTAINERS | ||
191 | @@ -XXX,XX +XXX,XX @@ F: hw/input/tsc2005.c | ||
192 | F: hw/misc/cbus.c | ||
193 | F: hw/timer/twl92230.c | ||
194 | F: include/hw/display/blizzard.h | ||
195 | +F: include/hw/input/tsc2xxx.h | ||
196 | F: include/hw/misc/cbus.h | ||
197 | |||
198 | Palm | ||
199 | @@ -XXX,XX +XXX,XX @@ L: qemu-arm@nongnu.org | ||
200 | S: Odd Fixes | ||
201 | F: hw/arm/palm.c | ||
202 | F: hw/input/tsc210x.c | ||
203 | +F: include/hw/input/tsc2xxx.h | ||
204 | |||
205 | Raspberry Pi | ||
206 | M: Peter Maydell <peter.maydell@linaro.org> | ||
207 | -- | 35 | -- |
208 | 2.20.1 | 36 | 2.20.1 |
209 | 37 | ||
210 | 38 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 3 | Group ARM objects together, TCG related ones at the bottom. |
4 | This will help when restricting TCG-only objects. | ||
5 | |||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
5 | Message-id: 20190412165416.7977-8-philmd@redhat.com | 8 | Message-id: 20190701132516.26392-3-philmd@redhat.com |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | include/hw/devices.h | 3 --- | 11 | target/arm/Makefile.objs | 10 ++++++---- |
9 | include/hw/input/gamepad.h | 19 +++++++++++++++++++ | 12 | 1 file changed, 6 insertions(+), 4 deletions(-) |
10 | hw/arm/stellaris.c | 2 +- | ||
11 | hw/input/stellaris_input.c | 2 +- | ||
12 | MAINTAINERS | 1 + | ||
13 | 5 files changed, 22 insertions(+), 5 deletions(-) | ||
14 | create mode 100644 include/hw/input/gamepad.h | ||
15 | 13 | ||
16 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 14 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/devices.h | 16 | --- a/target/arm/Makefile.objs |
19 | +++ b/include/hw/devices.h | 17 | +++ b/target/arm/Makefile.objs |
20 | @@ -XXX,XX +XXX,XX @@ void *tsc2005_init(qemu_irq pintdav); | 18 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_KVM) += kvm.o |
21 | uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len); | 19 | obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o |
22 | void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | 20 | obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o |
23 | 21 | obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o | |
24 | -/* stellaris_input.c */ | 22 | -obj-y += translate.o op_helper.o helper.o cpu.o |
25 | -void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); | 23 | -obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o |
26 | - | 24 | -obj-y += gdbstub.o |
27 | #endif | 25 | +obj-y += helper.o vfp_helper.o |
28 | diff --git a/include/hw/input/gamepad.h b/include/hw/input/gamepad.h | 26 | +obj-y += cpu.o gdbstub.o |
29 | new file mode 100644 | 27 | obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o |
30 | index XXXXXXX..XXXXXXX | 28 | -obj-y += crypto_helper.o |
31 | --- /dev/null | 29 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o |
32 | +++ b/include/hw/input/gamepad.h | 30 | |
33 | @@ -XXX,XX +XXX,XX @@ | 31 | DECODETREE = $(SRC_PATH)/scripts/decodetree.py |
34 | +/* | 32 | @@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c |
35 | + * Gamepad style buttons connected to IRQ/GPIO lines | 33 | target/arm/translate.o: target/arm/decode-vfp.inc.c |
36 | + * | 34 | target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c |
37 | + * Copyright (c) 2007 CodeSourcery. | 35 | |
38 | + * Written by Paul Brook | 36 | +obj-y += translate.o op_helper.o |
39 | + * | 37 | +obj-y += crypto_helper.o |
40 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 38 | +obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o |
41 | + * See the COPYING file in the top-level directory. | ||
42 | + */ | ||
43 | + | 39 | + |
44 | +#ifndef HW_INPUT_GAMEPAD_H | 40 | obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o |
45 | +#define HW_INPUT_GAMEPAD_H | 41 | obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o |
46 | + | 42 | obj-$(TARGET_AARCH64) += pauth_helper.o |
47 | +#include "hw/irq.h" | ||
48 | + | ||
49 | +/* stellaris_input.c */ | ||
50 | +void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); | ||
51 | + | ||
52 | +#endif | ||
53 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/hw/arm/stellaris.c | ||
56 | +++ b/hw/arm/stellaris.c | ||
57 | @@ -XXX,XX +XXX,XX @@ | ||
58 | #include "hw/sysbus.h" | ||
59 | #include "hw/ssi/ssi.h" | ||
60 | #include "hw/arm/arm.h" | ||
61 | -#include "hw/devices.h" | ||
62 | #include "qemu/timer.h" | ||
63 | #include "hw/i2c/i2c.h" | ||
64 | #include "net/net.h" | ||
65 | @@ -XXX,XX +XXX,XX @@ | ||
66 | #include "sysemu/sysemu.h" | ||
67 | #include "hw/arm/armv7m.h" | ||
68 | #include "hw/char/pl011.h" | ||
69 | +#include "hw/input/gamepad.h" | ||
70 | #include "hw/watchdog/cmsdk-apb-watchdog.h" | ||
71 | #include "hw/misc/unimp.h" | ||
72 | #include "cpu.h" | ||
73 | diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_input.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/hw/input/stellaris_input.c | ||
76 | +++ b/hw/input/stellaris_input.c | ||
77 | @@ -XXX,XX +XXX,XX @@ | ||
78 | */ | ||
79 | #include "qemu/osdep.h" | ||
80 | #include "hw/hw.h" | ||
81 | -#include "hw/devices.h" | ||
82 | +#include "hw/input/gamepad.h" | ||
83 | #include "ui/console.h" | ||
84 | |||
85 | typedef struct { | ||
86 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/MAINTAINERS | ||
89 | +++ b/MAINTAINERS | ||
90 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | ||
91 | L: qemu-arm@nongnu.org | ||
92 | S: Maintained | ||
93 | F: hw/*/stellaris* | ||
94 | +F: include/hw/input/gamepad.h | ||
95 | |||
96 | Versatile Express | ||
97 | M: Peter Maydell <peter.maydell@linaro.org> | ||
98 | -- | 43 | -- |
99 | 2.20.1 | 44 | 2.20.1 |
100 | 45 | ||
101 | 46 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Add an entries the Blizzard device in MAINTAINERS. | 3 | Group KVM rules together. |
4 | 4 | ||
5 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
6 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
8 | Message-id: 20190412165416.7977-6-philmd@redhat.com | 7 | Message-id: 20190701132516.26392-4-philmd@redhat.com |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 9 | --- |
11 | include/hw/devices.h | 7 ------- | 10 | target/arm/Makefile.objs | 9 +++++---- |
12 | include/hw/display/blizzard.h | 22 ++++++++++++++++++++++ | 11 | 1 file changed, 5 insertions(+), 4 deletions(-) |
13 | hw/arm/nseries.c | 1 + | ||
14 | hw/display/blizzard.c | 2 +- | ||
15 | MAINTAINERS | 2 ++ | ||
16 | 5 files changed, 26 insertions(+), 8 deletions(-) | ||
17 | create mode 100644 include/hw/display/blizzard.h | ||
18 | 12 | ||
19 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 13 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs |
20 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/include/hw/devices.h | 15 | --- a/target/arm/Makefile.objs |
22 | +++ b/include/hw/devices.h | 16 | +++ b/target/arm/Makefile.objs |
23 | @@ -XXX,XX +XXX,XX @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); | ||
24 | /* stellaris_input.c */ | ||
25 | void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); | ||
26 | |||
27 | -/* blizzard.c */ | ||
28 | -void *s1d13745_init(qemu_irq gpio_int); | ||
29 | -void s1d13745_write(void *opaque, int dc, uint16_t value); | ||
30 | -void s1d13745_write_block(void *opaque, int dc, | ||
31 | - void *buf, size_t len, int pitch); | ||
32 | -uint16_t s1d13745_read(void *opaque, int dc); | ||
33 | - | ||
34 | /* cbus.c */ | ||
35 | typedef struct { | ||
36 | qemu_irq clk; | ||
37 | diff --git a/include/hw/display/blizzard.h b/include/hw/display/blizzard.h | ||
38 | new file mode 100644 | ||
39 | index XXXXXXX..XXXXXXX | ||
40 | --- /dev/null | ||
41 | +++ b/include/hw/display/blizzard.h | ||
42 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ |
43 | +/* | 18 | obj-y += arm-semi.o |
44 | + * Epson S1D13744/S1D13745 (Blizzard/Hailstorm/Tornado) LCD/TV controller. | 19 | obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o |
45 | + * | 20 | -obj-$(CONFIG_KVM) += kvm.o |
46 | + * Copyright (C) 2008 Nokia Corporation | 21 | -obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o |
47 | + * Written by Andrzej Zaborowski | 22 | -obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o |
48 | + * | 23 | -obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o |
49 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 24 | obj-y += helper.o vfp_helper.o |
50 | + * See the COPYING file in the top-level directory. | 25 | obj-y += cpu.o gdbstub.o |
51 | + */ | 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 | ||
52 | + | 33 | + |
53 | +#ifndef HW_DISPLAY_BLIZZARD_H | 34 | DECODETREE = $(SRC_PATH)/scripts/decodetree.py |
54 | +#define HW_DISPLAY_BLIZZARD_H | 35 | |
55 | + | 36 | target/arm/decode-sve.inc.c: $(SRC_PATH)/target/arm/sve.decode $(DECODETREE) |
56 | +#include "hw/irq.h" | ||
57 | + | ||
58 | +void *s1d13745_init(qemu_irq gpio_int); | ||
59 | +void s1d13745_write(void *opaque, int dc, uint16_t value); | ||
60 | +void s1d13745_write_block(void *opaque, int dc, | ||
61 | + void *buf, size_t len, int pitch); | ||
62 | +uint16_t s1d13745_read(void *opaque, int dc); | ||
63 | + | ||
64 | +#endif | ||
65 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/hw/arm/nseries.c | ||
68 | +++ b/hw/arm/nseries.c | ||
69 | @@ -XXX,XX +XXX,XX @@ | ||
70 | #include "hw/boards.h" | ||
71 | #include "hw/i2c/i2c.h" | ||
72 | #include "hw/devices.h" | ||
73 | +#include "hw/display/blizzard.h" | ||
74 | #include "hw/misc/tmp105.h" | ||
75 | #include "hw/block/flash.h" | ||
76 | #include "hw/hw.h" | ||
77 | diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/hw/display/blizzard.c | ||
80 | +++ b/hw/display/blizzard.c | ||
81 | @@ -XXX,XX +XXX,XX @@ | ||
82 | #include "qemu/osdep.h" | ||
83 | #include "qemu-common.h" | ||
84 | #include "ui/console.h" | ||
85 | -#include "hw/devices.h" | ||
86 | +#include "hw/display/blizzard.h" | ||
87 | #include "ui/pixel_ops.h" | ||
88 | |||
89 | typedef void (*blizzard_fn_t)(uint8_t *, const uint8_t *, unsigned int); | ||
90 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/MAINTAINERS | ||
93 | +++ b/MAINTAINERS | ||
94 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | ||
95 | L: qemu-arm@nongnu.org | ||
96 | S: Odd Fixes | ||
97 | F: hw/arm/nseries.c | ||
98 | +F: hw/display/blizzard.c | ||
99 | F: hw/input/lm832x.c | ||
100 | F: hw/input/tsc2005.c | ||
101 | F: hw/misc/cbus.c | ||
102 | F: hw/timer/twl92230.c | ||
103 | +F: include/hw/display/blizzard.h | ||
104 | |||
105 | Palm | ||
106 | M: Andrzej Zaborowski <balrogg@gmail.com> | ||
107 | -- | 37 | -- |
108 | 2.20.1 | 38 | 2.20.1 |
109 | 39 | ||
110 | 40 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 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> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
5 | Message-id: 20190412165416.7977-5-philmd@redhat.com | 8 | Message-id: 20190701132516.26392-5-philmd@redhat.com |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | include/hw/devices.h | 6 ------ | 11 | target/arm/Makefile.objs | 5 ++++- |
9 | include/hw/display/tc6393xb.h | 24 ++++++++++++++++++++++++ | 12 | 1 file changed, 4 insertions(+), 1 deletion(-) |
10 | hw/arm/tosa.c | 2 +- | ||
11 | hw/display/tc6393xb.c | 2 +- | ||
12 | MAINTAINERS | 1 + | ||
13 | 5 files changed, 27 insertions(+), 8 deletions(-) | ||
14 | create mode 100644 include/hw/display/tc6393xb.h | ||
15 | 13 | ||
16 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 14 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/devices.h | 16 | --- a/target/arm/Makefile.objs |
19 | +++ b/include/hw/devices.h | 17 | +++ b/target/arm/Makefile.objs |
20 | @@ -XXX,XX +XXX,XX @@ void *tahvo_init(qemu_irq irq, int betty); | ||
21 | |||
22 | void retu_key_event(void *retu, int state); | ||
23 | |||
24 | -/* tc6393xb.c */ | ||
25 | -typedef struct TC6393xbState TC6393xbState; | ||
26 | -TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem, | ||
27 | - uint32_t base, qemu_irq irq); | ||
28 | -qemu_irq tc6393xb_l3v_get(TC6393xbState *s); | ||
29 | - | ||
30 | #endif | ||
31 | diff --git a/include/hw/display/tc6393xb.h b/include/hw/display/tc6393xb.h | ||
32 | new file mode 100644 | ||
33 | index XXXXXXX..XXXXXXX | ||
34 | --- /dev/null | ||
35 | +++ b/include/hw/display/tc6393xb.h | ||
36 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ |
37 | +/* | 19 | obj-y += arm-semi.o |
38 | + * Toshiba TC6393XB I/O Controller. | 20 | -obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o |
39 | + * Found in Sharp Zaurus SL-6000 (tosa) or some | 21 | obj-y += helper.o vfp_helper.o |
40 | + * Toshiba e-Series PDAs. | 22 | obj-y += cpu.o gdbstub.o |
41 | + * | 23 | obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o |
42 | + * Copyright (c) 2007 Hervé Poussineau | ||
43 | + * | ||
44 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
45 | + * See the COPYING file in the top-level directory. | ||
46 | + */ | ||
47 | + | 24 | + |
48 | +#ifndef HW_DISPLAY_TC6393XB_H | 25 | +obj-$(CONFIG_SOFTMMU) += machine.o arch_dump.o monitor.o |
49 | +#define HW_DISPLAY_TC6393XB_H | 26 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o |
27 | |||
28 | obj-$(CONFIG_KVM) += kvm.o | ||
29 | @@ -XXX,XX +XXX,XX @@ obj-y += translate.o op_helper.o | ||
30 | obj-y += crypto_helper.o | ||
31 | obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o | ||
32 | |||
33 | +obj-$(CONFIG_SOFTMMU) += psci.o | ||
50 | + | 34 | + |
51 | +#include "exec/memory.h" | 35 | obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o |
52 | +#include "hw/irq.h" | 36 | obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o |
53 | + | 37 | obj-$(TARGET_AARCH64) += pauth_helper.o |
54 | +typedef struct TC6393xbState TC6393xbState; | ||
55 | + | ||
56 | +TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem, | ||
57 | + uint32_t base, qemu_irq irq); | ||
58 | +qemu_irq tc6393xb_l3v_get(TC6393xbState *s); | ||
59 | + | ||
60 | +#endif | ||
61 | diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/hw/arm/tosa.c | ||
64 | +++ b/hw/arm/tosa.c | ||
65 | @@ -XXX,XX +XXX,XX @@ | ||
66 | #include "hw/hw.h" | ||
67 | #include "hw/arm/pxa.h" | ||
68 | #include "hw/arm/arm.h" | ||
69 | -#include "hw/devices.h" | ||
70 | #include "hw/arm/sharpsl.h" | ||
71 | #include "hw/pcmcia.h" | ||
72 | #include "hw/boards.h" | ||
73 | +#include "hw/display/tc6393xb.h" | ||
74 | #include "hw/i2c/i2c.h" | ||
75 | #include "hw/ssi/ssi.h" | ||
76 | #include "hw/sysbus.h" | ||
77 | diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/hw/display/tc6393xb.c | ||
80 | +++ b/hw/display/tc6393xb.c | ||
81 | @@ -XXX,XX +XXX,XX @@ | ||
82 | #include "qapi/error.h" | ||
83 | #include "qemu/host-utils.h" | ||
84 | #include "hw/hw.h" | ||
85 | -#include "hw/devices.h" | ||
86 | +#include "hw/display/tc6393xb.h" | ||
87 | #include "hw/block/flash.h" | ||
88 | #include "ui/console.h" | ||
89 | #include "ui/pixel_ops.h" | ||
90 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/MAINTAINERS | ||
93 | +++ b/MAINTAINERS | ||
94 | @@ -XXX,XX +XXX,XX @@ F: hw/misc/mst_fpga.c | ||
95 | F: hw/misc/max111x.c | ||
96 | F: include/hw/arm/pxa.h | ||
97 | F: include/hw/arm/sharpsl.h | ||
98 | +F: include/hw/display/tc6393xb.h | ||
99 | |||
100 | SABRELITE / i.MX6 | ||
101 | M: Peter Maydell <peter.maydell@linaro.org> | ||
102 | -- | 38 | -- |
103 | 2.20.1 | 39 | 2.20.1 |
104 | 40 | ||
105 | 41 | diff view generated by jsdifflib |
1 | For v8M floating point support, transitions from Secure | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | to Non-secure state via BLNS and BLXNS must clear the | ||
3 | CONTROL.SFPA bit. (This corresponds to the pseudocode | ||
4 | BranchToNS() function.) | ||
5 | 2 | ||
3 | Reviewed-by: Robert Bradford <robert.bradford@intel.com> | ||
4 | Reviewed-by: Samuel Ortiz <sameo@linux.intel.com> | ||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Message-id: 20190701132516.26392-6-philmd@redhat.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20190416125744.27770-13-peter.maydell@linaro.org | ||
9 | --- | 9 | --- |
10 | target/arm/helper.c | 4 ++++ | 10 | target/arm/helper.c | 7 +++++++ |
11 | 1 file changed, 4 insertions(+) | 11 | 1 file changed, 7 insertions(+) |
12 | 12 | ||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 13 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.c | 15 | --- a/target/arm/helper.c |
16 | +++ b/target/arm/helper.c | 16 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | 17 | @@ -XXX,XX +XXX,XX @@ |
18 | /* translate.c should have made BXNS UNDEF unless we're secure */ | 18 | +/* |
19 | assert(env->v7m.secure); | 19 | + * ARM generic helpers. |
20 | 20 | + * | |
21 | + if (!(dest & 1)) { | 21 | + * This code is licensed under the GNU GPL v2 or later. |
22 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | 22 | + * |
23 | + } | 23 | + * SPDX-License-Identifier: GPL-2.0-or-later |
24 | switch_v7m_security_state(env, dest & 1); | 24 | + */ |
25 | env->thumb = 1; | 25 | #include "qemu/osdep.h" |
26 | env->regs[15] = dest & ~1; | 26 | #include "qemu/units.h" |
27 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | 27 | #include "target/arm/idau.h" |
28 | */ | ||
29 | write_v7m_exception(env, 1); | ||
30 | } | ||
31 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | ||
32 | switch_v7m_security_state(env, 0); | ||
33 | env->thumb = 1; | ||
34 | env->regs[15] = dest; | ||
35 | -- | 28 | -- |
36 | 2.20.1 | 29 | 2.20.1 |
37 | 30 | ||
38 | 31 | diff view generated by jsdifflib |
1 | Currently the code in v7m_push_stack() which detects a violation | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | of the v8M stack limit simply returns early if it does so. This | ||
3 | is OK for the current integer-only code, but won't work for the | ||
4 | floating point handling we're about to add. We need to continue | ||
5 | executing the rest of the function so that we check for other | ||
6 | exceptions like not having permission to use the FPU and so | ||
7 | that we correctly set the FPCCR state if we are doing lazy | ||
8 | stacking. Refactor to avoid the early return. | ||
9 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
4 | Message-id: 20190701132516.26392-7-philmd@redhat.com | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20190416125744.27770-10-peter.maydell@linaro.org | ||
13 | --- | 7 | --- |
14 | target/arm/helper.c | 23 ++++++++++++++++++----- | 8 | target/arm/helper.c | 2 -- |
15 | 1 file changed, 18 insertions(+), 5 deletions(-) | 9 | 1 file changed, 2 deletions(-) |
16 | 10 | ||
17 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 11 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.c | 13 | --- a/target/arm/helper.c |
20 | +++ b/target/arm/helper.c | 14 | +++ b/target/arm/helper.c |
21 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | 15 | @@ -XXX,XX +XXX,XX @@ |
22 | * should ignore further stack faults trying to process | 16 | #include "exec/gdbstub.h" |
23 | * that derived exception.) | 17 | #include "exec/helper-proto.h" |
24 | */ | 18 | #include "qemu/host-utils.h" |
25 | - bool stacked_ok; | 19 | -#include "sysemu/arch_init.h" |
26 | + bool stacked_ok = true, limitviol = false; | 20 | #include "sysemu/sysemu.h" |
27 | CPUARMState *env = &cpu->env; | 21 | #include "qemu/bitops.h" |
28 | uint32_t xpsr = xpsr_read(env); | 22 | #include "qemu/crc32c.h" |
29 | uint32_t frameptr = env->regs[13]; | 23 | @@ -XXX,XX +XXX,XX @@ |
30 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | 24 | #include "hw/semihosting/semihost.h" |
31 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | 25 | #include "sysemu/cpus.h" |
32 | env->v7m.secure); | 26 | #include "sysemu/kvm.h" |
33 | env->regs[13] = limit; | 27 | -#include "fpu/softfloat.h" |
34 | - return true; | 28 | #include "qemu/range.h" |
35 | + /* | 29 | #include "qapi/qapi-commands-target.h" |
36 | + * We won't try to perform any further memory accesses but | 30 | #include "qapi/error.h" |
37 | + * we must continue through the following code to check for | ||
38 | + * permission faults during FPU state preservation, and we | ||
39 | + * must update FPCCR if lazy stacking is enabled. | ||
40 | + */ | ||
41 | + limitviol = true; | ||
42 | + stacked_ok = false; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
47 | * (which may be taken in preference to the one we started with | ||
48 | * if it has higher priority). | ||
49 | */ | ||
50 | - stacked_ok = | ||
51 | + stacked_ok = stacked_ok && | ||
52 | v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, false) && | ||
53 | v7m_stack_write(cpu, frameptr + 4, env->regs[1], mmu_idx, false) && | ||
54 | v7m_stack_write(cpu, frameptr + 8, env->regs[2], mmu_idx, false) && | ||
55 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
56 | v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) && | ||
57 | v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false); | ||
58 | |||
59 | - /* Update SP regardless of whether any of the stack accesses failed. */ | ||
60 | - env->regs[13] = frameptr; | ||
61 | + /* | ||
62 | + * If we broke a stack limit then SP was already updated earlier; | ||
63 | + * otherwise we update SP regardless of whether any of the stack | ||
64 | + * accesses failed or we took some other kind of fault. | ||
65 | + */ | ||
66 | + if (!limitviol) { | ||
67 | + env->regs[13] = frameptr; | ||
68 | + } | ||
69 | |||
70 | return !stacked_ok; | ||
71 | } | ||
72 | -- | 31 | -- |
73 | 2.20.1 | 32 | 2.20.1 |
74 | 33 | ||
75 | 34 | diff view generated by jsdifflib |
1 | Handle floating point registers in exception entry. | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | This corresponds to the FP-specific parts of the pseudocode | ||
3 | functions ActivateException() and PushStack(). | ||
4 | 2 | ||
5 | We defer the code corresponding to UpdateFPCCR() to a later patch. | 3 | Since commit 8c06fbdf36b checkpatch.pl enforce a new multiline |
4 | comment syntax. Since we'll move this code around, fix its style | ||
5 | first. | ||
6 | 6 | ||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190701132516.26392-8-philmd@redhat.com | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20190416125744.27770-11-peter.maydell@linaro.org | ||
10 | --- | 11 | --- |
11 | target/arm/helper.c | 98 +++++++++++++++++++++++++++++++++++++++++++-- | 12 | target/arm/helper.c | 237 ++++++++++++++++++++++++++-------------- |
12 | 1 file changed, 95 insertions(+), 3 deletions(-) | 13 | target/arm/op_helper.c | 54 ++++++--- |
14 | target/arm/vfp_helper.c | 3 +- | ||
15 | 3 files changed, 196 insertions(+), 98 deletions(-) | ||
13 | 16 | ||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 17 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 19 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/helper.c | 20 | +++ b/target/arm/helper.c |
21 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) | ||
22 | |||
23 | uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
24 | { | ||
25 | - /* The TT instructions can be used by unprivileged code, but in | ||
26 | + /* | ||
27 | + * The TT instructions can be used by unprivileged code, but in | ||
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 | } | ||
63 | } | ||
64 | |||
65 | -/* Write to v7M CONTROL.SPSEL bit. This may change the current | ||
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 | } | ||
84 | |||
85 | - /* All the banked state is accessed by looking at env->v7m.secure | ||
86 | + /* | ||
87 | + * All the banked state is accessed by looking at env->v7m.secure | ||
88 | * except for the stack pointer; rearrange the SP appropriately. | ||
89 | */ | ||
90 | new_ss_msp = env->v7m.other_ss_msp; | ||
91 | @@ -XXX,XX +XXX,XX @@ static void switch_v7m_security_state(CPUARMState *env, bool new_secstate) | ||
92 | |||
93 | void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | ||
94 | { | ||
95 | - /* Handle v7M BXNS: | ||
96 | + /* | ||
97 | + * Handle v7M BXNS: | ||
98 | * - if the return value is a magic value, do exception return (like BX) | ||
99 | * - otherwise bit 0 of the return value is the target security state | ||
100 | */ | ||
101 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | ||
102 | } | ||
103 | |||
104 | if (dest >= min_magic) { | ||
105 | - /* This is an exception return magic value; put it where | ||
106 | + /* | ||
107 | + * This is an exception return magic value; put it where | ||
108 | * do_v7m_exception_exit() expects and raise EXCEPTION_EXIT. | ||
109 | * Note that if we ever add gen_ss_advance() singlestep support to | ||
110 | * M profile this should count as an "instruction execution complete" | ||
111 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | ||
112 | |||
113 | void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
114 | { | ||
115 | - /* Handle v7M BLXNS: | ||
116 | + /* | ||
117 | + * Handle v7M BLXNS: | ||
118 | * - bit 0 of the destination address is the target security state | ||
119 | */ | ||
120 | |||
121 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
122 | assert(env->v7m.secure); | ||
123 | |||
124 | if (dest & 1) { | ||
125 | - /* target is Secure, so this is just a normal BLX, | ||
126 | + /* | ||
127 | + * Target is Secure, so this is just a normal BLX, | ||
128 | * except that the low bit doesn't indicate Thumb/not. | ||
129 | */ | ||
130 | env->regs[14] = nextinst; | ||
131 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
132 | env->regs[13] = sp; | ||
133 | env->regs[14] = 0xfeffffff; | ||
134 | if (arm_v7m_is_handler_mode(env)) { | ||
135 | - /* Write a dummy value to IPSR, to avoid leaking the current secure | ||
136 | + /* | ||
137 | + * Write a dummy value to IPSR, to avoid leaking the current secure | ||
138 | * exception number to non-secure code. This is guaranteed not | ||
139 | * to cause write_v7m_exception() to actually change stacks. | ||
140 | */ | ||
141 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
142 | static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool threadmode, | ||
143 | bool spsel) | ||
144 | { | ||
145 | - /* Return a pointer to the location where we currently store the | ||
146 | + /* | ||
147 | + * Return a pointer to the location where we currently store the | ||
148 | * stack pointer for the requested security state and thread mode. | ||
149 | * This pointer will become invalid if the CPU state is updated | ||
150 | * such that the stack pointers are switched around (eg changing | ||
151 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure, | ||
152 | |||
153 | mmu_idx = arm_v7m_mmu_idx_for_secstate_and_priv(env, targets_secure, true); | ||
154 | |||
155 | - /* We don't do a get_phys_addr() here because the rules for vector | ||
156 | + /* | ||
157 | + * We don't do a get_phys_addr() here because the rules for vector | ||
158 | * loads are special: they always use the default memory map, and | ||
159 | * the default memory map permits reads from all addresses. | ||
160 | * Since there's no easy way to pass through to pmsav8_mpu_lookup() | ||
161 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure, | ||
162 | return true; | ||
163 | |||
164 | load_fail: | ||
165 | - /* All vector table fetch fails are reported as HardFault, with | ||
166 | + /* | ||
167 | + * All vector table fetch fails are reported as HardFault, with | ||
168 | * HFSR.VECTTBL and .FORCED set. (FORCED is set because | ||
169 | * technically the underlying exception is a MemManage or BusFault | ||
170 | * that is escalated to HardFault.) This is a terminal exception, | ||
171 | @@ -XXX,XX +XXX,XX @@ static uint32_t v7m_integrity_sig(CPUARMState *env, uint32_t lr) | ||
172 | static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
173 | bool ignore_faults) | ||
174 | { | ||
175 | - /* For v8M, push the callee-saves register part of the stack frame. | ||
176 | + /* | ||
177 | + * For v8M, push the callee-saves register part of the stack frame. | ||
178 | * Compare the v8M pseudocode PushCalleeStack(). | ||
179 | * In the tailchaining case this may not be the current stack. | ||
180 | */ | ||
181 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
182 | return true; | ||
183 | } | ||
184 | |||
185 | - /* Write as much of the stack frame as we can. A write failure may | ||
186 | + /* | ||
187 | + * Write as much of the stack frame as we can. A write failure may | ||
188 | * cause us to pend a derived exception. | ||
189 | */ | ||
190 | sig = v7m_integrity_sig(env, lr); | ||
191 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
192 | static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
193 | bool ignore_stackfaults) | ||
194 | { | ||
195 | - /* Do the "take the exception" parts of exception entry, | ||
196 | + /* | ||
197 | + * Do the "take the exception" parts of exception entry, | ||
198 | * but not the pushing of state to the stack. This is | ||
199 | * similar to the pseudocode ExceptionTaken() function. | ||
200 | */ | ||
18 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | 201 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, |
19 | switch_v7m_security_state(env, targets_secure); | 202 | if (arm_feature(env, ARM_FEATURE_V8)) { |
20 | write_v7m_control_spsel(env, 0); | 203 | if (arm_feature(env, ARM_FEATURE_M_SECURITY) && |
21 | arm_clear_exclusive(env); | 204 | (lr & R_V7M_EXCRET_S_MASK)) { |
22 | + /* Clear SFPA and FPCA (has no effect if no FPU) */ | 205 | - /* The background code (the owner of the registers in the |
23 | + env->v7m.control[M_REG_S] &= | 206 | + /* |
24 | + ~(R_V7M_CONTROL_FPCA_MASK | R_V7M_CONTROL_SFPA_MASK); | 207 | + * The background code (the owner of the registers in the |
25 | /* Clear IT bits */ | 208 | * exception frame) is Secure. This means it may either already |
26 | env->condexec_bits = 0; | 209 | * have or now needs to push callee-saves registers. |
27 | env->regs[14] = lr; | 210 | */ |
211 | if (targets_secure) { | ||
212 | if (dotailchain && !(lr & R_V7M_EXCRET_ES_MASK)) { | ||
213 | - /* We took an exception from Secure to NonSecure | ||
214 | + /* | ||
215 | + * We took an exception from Secure to NonSecure | ||
216 | * (which means the callee-saved registers got stacked) | ||
217 | * and are now tailchaining to a Secure exception. | ||
218 | * Clear DCRS so eventual return from this Secure | ||
219 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
220 | lr &= ~R_V7M_EXCRET_DCRS_MASK; | ||
221 | } | ||
222 | } else { | ||
223 | - /* We're going to a non-secure exception; push the | ||
224 | + /* | ||
225 | + * We're going to a non-secure exception; push the | ||
226 | * callee-saves registers to the stack now, if they're | ||
227 | * not already saved. | ||
228 | */ | ||
229 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
230 | lr |= R_V7M_EXCRET_SPSEL_MASK; | ||
231 | } | ||
232 | |||
233 | - /* Clear registers if necessary to prevent non-secure exception | ||
234 | + /* | ||
235 | + * Clear registers if necessary to prevent non-secure exception | ||
236 | * code being able to see register values from secure code. | ||
237 | * Where register values become architecturally UNKNOWN we leave | ||
238 | * them with their previous values. | ||
239 | */ | ||
240 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
241 | if (!targets_secure) { | ||
242 | - /* Always clear the caller-saved registers (they have been | ||
243 | + /* | ||
244 | + * Always clear the caller-saved registers (they have been | ||
245 | * pushed to the stack earlier in v7m_push_stack()). | ||
246 | * Clear callee-saved registers if the background code is | ||
247 | * Secure (in which case these regs were saved in | ||
248 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
249 | } | ||
250 | |||
251 | if (push_failed && !ignore_stackfaults) { | ||
252 | - /* Derived exception on callee-saves register stacking: | ||
253 | + /* | ||
254 | + * Derived exception on callee-saves register stacking: | ||
255 | * we might now want to take a different exception which | ||
256 | * targets a different security state, so try again from the top. | ||
257 | */ | ||
258 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
259 | return; | ||
260 | } | ||
261 | |||
262 | - /* Now we've done everything that might cause a derived exception | ||
263 | + /* | ||
264 | + * Now we've done everything that might cause a derived exception | ||
265 | * we can go ahead and activate whichever exception we're going to | ||
266 | * take (which might now be the derived exception). | ||
267 | */ | ||
268 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) | ||
269 | |||
270 | static bool v7m_push_stack(ARMCPU *cpu) | ||
271 | { | ||
272 | - /* Do the "set up stack frame" part of exception entry, | ||
273 | + /* | ||
274 | + * Do the "set up stack frame" part of exception entry, | ||
275 | * similar to pseudocode PushStack(). | ||
276 | * Return true if we generate a derived exception (and so | ||
277 | * should ignore further stack faults trying to process | ||
28 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | 278 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) |
29 | uint32_t xpsr = xpsr_read(env); | 279 | } |
30 | uint32_t frameptr = env->regs[13]; | 280 | } |
31 | ARMMMUIdx mmu_idx = arm_mmu_idx(env); | 281 | |
32 | + uint32_t framesize; | 282 | - /* Write as much of the stack frame as we can. If we fail a stack |
33 | + bool nsacr_cp10 = extract32(env->v7m.nsacr, 10, 1); | 283 | + /* |
34 | + | 284 | + * Write as much of the stack frame as we can. If we fail a stack |
35 | + if ((env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) && | 285 | * write this will result in a derived exception being pended |
36 | + (env->v7m.secure || nsacr_cp10)) { | 286 | * (which may be taken in preference to the one we started with |
37 | + if (env->v7m.secure && | 287 | * if it has higher priority). |
38 | + env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK) { | 288 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
39 | + framesize = 0xa8; | 289 | bool ftype; |
40 | + } else { | 290 | bool restore_s16_s31; |
41 | + framesize = 0x68; | 291 | |
42 | + } | 292 | - /* If we're not in Handler mode then jumps to magic exception-exit |
43 | + } else { | 293 | + /* |
44 | + framesize = 0x20; | 294 | + * If we're not in Handler mode then jumps to magic exception-exit |
45 | + } | 295 | * addresses don't have magic behaviour. However for the v8M |
46 | 296 | * security extensions the magic secure-function-return has to | |
47 | /* Align stack pointer if the guest wants that */ | 297 | * work in thread mode too, so to avoid doing an extra check in |
48 | if ((frameptr & 4) && | 298 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
49 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | 299 | return; |
50 | xpsr |= XPSR_SPREALIGN; | 300 | } |
51 | } | 301 | |
52 | 302 | - /* In the spec pseudocode ExceptionReturn() is called directly | |
53 | - frameptr -= 0x20; | 303 | + /* |
54 | + xpsr &= ~XPSR_SFPA; | 304 | + * In the spec pseudocode ExceptionReturn() is called directly |
55 | + if (env->v7m.secure && | 305 | * from BXWritePC() and gets the full target PC value including |
56 | + (env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) { | 306 | * bit zero. In QEMU's implementation we treat it as a normal |
57 | + xpsr |= XPSR_SFPA; | 307 | * jump-to-register (which is then caught later on), and so split |
58 | + } | 308 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
59 | + | 309 | } |
60 | + frameptr -= framesize; | 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) | ||
61 | 339 | ||
62 | if (arm_feature(env, ARM_FEATURE_V8)) { | 340 | if (arm_feature(env, ARM_FEATURE_V8)) { |
63 | uint32_t limit = v7m_sp_limit(env); | 341 | if (!arm_feature(env, ARM_FEATURE_M_SECURITY)) { |
64 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | 342 | - /* UNPREDICTABLE if S == 1 or DCRS == 0 or ES == 1 (R_XLCP); |
65 | v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) && | 343 | + /* |
66 | v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false); | 344 | + * UNPREDICTABLE if S == 1 or DCRS == 0 or ES == 1 (R_XLCP); |
67 | 345 | * we choose to take the UsageFault. | |
68 | + if (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) { | 346 | */ |
69 | + /* FPU is active, try to save its registers */ | 347 | if ((excret & R_V7M_EXCRET_S_MASK) || |
70 | + bool fpccr_s = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | 348 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
71 | + bool lspact = env->v7m.fpccr[fpccr_s] & R_V7M_FPCCR_LSPACT_MASK; | 349 | break; |
72 | + | 350 | case 13: /* Return to Thread using Process stack */ |
73 | + if (lspact && arm_feature(env, ARM_FEATURE_M_SECURITY)) { | 351 | case 9: /* Return to Thread using Main stack */ |
74 | + qemu_log_mask(CPU_LOG_INT, | 352 | - /* We only need to check NONBASETHRDENA for v7M, because in |
75 | + "...SecureFault because LSPACT and FPCA both set\n"); | 353 | + /* |
76 | + env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; | 354 | + * We only need to check NONBASETHRDENA for v7M, because in |
77 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | 355 | * v8M this bit does not exist (it is RES1). |
78 | + } else if (!env->v7m.secure && !nsacr_cp10) { | 356 | */ |
79 | + qemu_log_mask(CPU_LOG_INT, | 357 | if (!rettobase && |
80 | + "...Secure UsageFault with CFSR.NOCP because " | 358 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
81 | + "NSACR.CP10 prevents stacking FP regs\n"); | 359 | } |
82 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, M_REG_S); | 360 | |
83 | + env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_NOCP_MASK; | 361 | if (ufault) { |
84 | + } else { | 362 | - /* Bad exception return: instead of popping the exception |
85 | + if (!(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPEN_MASK)) { | 363 | + /* |
86 | + /* Lazy stacking disabled, save registers now */ | 364 | + * Bad exception return: instead of popping the exception |
87 | + int i; | 365 | * stack, directly take a usage fault on the current stack. |
88 | + bool cpacr_pass = v7m_cpacr_pass(env, env->v7m.secure, | 366 | */ |
89 | + arm_current_el(env) != 0); | 367 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK; |
90 | + | 368 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
91 | + if (stacked_ok && !cpacr_pass) { | 369 | switch_v7m_security_state(env, return_to_secure); |
92 | + /* | 370 | |
93 | + * Take UsageFault if CPACR forbids access. The pseudocode | 371 | { |
94 | + * here does a full CheckCPEnabled() but we know the NSACR | 372 | - /* The stack pointer we should be reading the exception frame from |
95 | + * check can never fail as we have already handled that. | 373 | + /* |
96 | + */ | 374 | + * The stack pointer we should be reading the exception frame from |
97 | + qemu_log_mask(CPU_LOG_INT, | 375 | * depends on bits in the magic exception return type value (and |
98 | + "...UsageFault with CFSR.NOCP because " | 376 | * for v8M isn't necessarily the stack pointer we will eventually |
99 | + "CPACR.CP10 prevents stacking FP regs\n"); | 377 | * end up resuming execution with). Get a pointer to the location |
100 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | 378 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
101 | + env->v7m.secure); | 379 | v7m_stack_read(cpu, &xpsr, frameptr + 0x1c, mmu_idx); |
102 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK; | 380 | |
103 | + stacked_ok = false; | 381 | if (!pop_ok) { |
104 | + } | 382 | - /* v7m_stack_read() pended a fault, so take it (as a tail |
105 | + | 383 | + /* |
106 | + for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) { | 384 | + * v7m_stack_read() pended a fault, so take it (as a tail |
107 | + uint64_t dn = *aa32_vfp_dreg(env, i / 2); | 385 | * chained exception on the same stack frame) |
108 | + uint32_t faddr = frameptr + 0x20 + 4 * i; | 386 | */ |
109 | + uint32_t slo = extract64(dn, 0, 32); | 387 | qemu_log_mask(CPU_LOG_INT, "...derived exception on unstacking\n"); |
110 | + uint32_t shi = extract64(dn, 32, 32); | 388 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
111 | + | 389 | return; |
112 | + if (i >= 16) { | 390 | } |
113 | + faddr += 8; /* skip the slot for the FPSCR */ | 391 | |
114 | + } | 392 | - /* Returning from an exception with a PC with bit 0 set is defined |
115 | + stacked_ok = stacked_ok && | 393 | + /* |
116 | + v7m_stack_write(cpu, faddr, slo, mmu_idx, false) && | 394 | + * Returning from an exception with a PC with bit 0 set is defined |
117 | + v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, false); | 395 | * behaviour on v8M (bit 0 is ignored), but for v7M it was specified |
118 | + } | 396 | * to be UNPREDICTABLE. In practice actual v7M hardware seems to ignore |
119 | + stacked_ok = stacked_ok && | 397 | * the lsbit, and there are several RTOSes out there which incorrectly |
120 | + v7m_stack_write(cpu, frameptr + 0x60, | 398 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) |
121 | + vfp_get_fpscr(env), mmu_idx, false); | 399 | } |
122 | + if (cpacr_pass) { | 400 | |
123 | + for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) { | 401 | if (arm_feature(env, ARM_FEATURE_V8)) { |
124 | + *aa32_vfp_dreg(env, i / 2) = 0; | 402 | - /* For v8M we have to check whether the xPSR exception field |
125 | + } | 403 | + /* |
126 | + vfp_set_fpscr(env, 0); | 404 | + * For v8M we have to check whether the xPSR exception field |
127 | + } | 405 | * matches the EXCRET value for return to handler/thread |
128 | + } else { | 406 | * before we commit to changing the SP and xPSR. |
129 | + /* Lazy stacking enabled, save necessary info to stack later */ | 407 | */ |
130 | + /* TODO : equivalent of UpdateFPCCR() pseudocode */ | 408 | bool will_be_handler = (xpsr & XPSR_EXCP) != 0; |
131 | + } | 409 | if (return_to_handler != will_be_handler) { |
132 | + } | 410 | - /* Take an INVPC UsageFault on the current stack. |
133 | + } | 411 | + /* |
134 | + | 412 | + * Take an INVPC UsageFault on the current stack. |
135 | /* | 413 | * By this point we will have switched to the security state |
136 | * If we broke a stack limit then SP was already updated earlier; | 414 | * for the background state, so this UsageFault will target |
137 | * otherwise we update SP regardless of whether any of the stack | 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 | ||
138 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 532 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) |
139 | 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) | ||
140 | if (arm_feature(env, ARM_FEATURE_V8)) { | 584 | if (arm_feature(env, ARM_FEATURE_V8)) { |
141 | lr = R_V7M_EXCRET_RES1_MASK | | 585 | lr = R_V7M_EXCRET_RES1_MASK | |
142 | - R_V7M_EXCRET_DCRS_MASK | | 586 | R_V7M_EXCRET_DCRS_MASK; |
143 | - R_V7M_EXCRET_FTYPE_MASK; | 587 | - /* The S bit indicates whether we should return to Secure |
144 | + R_V7M_EXCRET_DCRS_MASK; | 588 | + /* |
145 | /* The S bit indicates whether we should return to Secure | 589 | + * The S bit indicates whether we should return to Secure |
146 | * or NonSecure (ie our current state). | 590 | * or NonSecure (ie our current state). |
147 | * The ES bit indicates whether we're taking this exception | 591 | * The ES bit indicates whether we're taking this exception |
592 | * to Secure or NonSecure (ie our target state). We set it | ||
148 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 593 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) |
149 | if (env->v7m.secure) { | 594 | v7m_exception_taken(cpu, lr, false, ignore_stackfaults); |
150 | lr |= R_V7M_EXCRET_S_MASK; | 595 | } |
151 | } | 596 | |
152 | + if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK)) { | 597 | -/* Function used to synchronize QEMU's AArch64 register set with AArch32 |
153 | + lr |= R_V7M_EXCRET_FTYPE_MASK; | 598 | +/* |
154 | + } | 599 | + * Function used to synchronize QEMU's AArch64 register set with AArch32 |
600 | * register set. This is necessary when switching between AArch32 and AArch64 | ||
601 | * execution state. | ||
602 | */ | ||
603 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | ||
604 | env->xregs[i] = env->regs[i]; | ||
605 | } | ||
606 | |||
607 | - /* Unless we are in FIQ mode, x8-x12 come from the user registers r8-r12. | ||
608 | + /* | ||
609 | + * Unless we are in FIQ mode, x8-x12 come from the user registers r8-r12. | ||
610 | * Otherwise, they come from the banked user regs. | ||
611 | */ | ||
612 | if (mode == ARM_CPU_MODE_FIQ) { | ||
613 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | ||
614 | } | ||
615 | } | ||
616 | |||
617 | - /* Registers x13-x23 are the various mode SP and FP registers. Registers | ||
618 | + /* | ||
619 | + * Registers x13-x23 are the various mode SP and FP registers. Registers | ||
620 | * r13 and r14 are only copied if we are in that mode, otherwise we copy | ||
621 | * from the mode banked register. | ||
622 | */ | ||
623 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | ||
624 | env->xregs[23] = env->banked_r13[bank_number(ARM_CPU_MODE_UND)]; | ||
625 | } | ||
626 | |||
627 | - /* Registers x24-x30 are mapped to r8-r14 in FIQ mode. If we are in FIQ | ||
628 | + /* | ||
629 | + * Registers x24-x30 are mapped to r8-r14 in FIQ mode. If we are in FIQ | ||
630 | * mode, then we can copy from r8-r14. Otherwise, we copy from the | ||
631 | * FIQ bank for r8-r14. | ||
632 | */ | ||
633 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | ||
634 | env->pc = env->regs[15]; | ||
635 | } | ||
636 | |||
637 | -/* Function used to synchronize QEMU's AArch32 register set with AArch64 | ||
638 | +/* | ||
639 | + * Function used to synchronize QEMU's AArch32 register set with AArch64 | ||
640 | * register set. This is necessary when switching between AArch32 and AArch64 | ||
641 | * execution state. | ||
642 | */ | ||
643 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
644 | env->regs[i] = env->xregs[i]; | ||
645 | } | ||
646 | |||
647 | - /* Unless we are in FIQ mode, r8-r12 come from the user registers x8-x12. | ||
648 | + /* | ||
649 | + * Unless we are in FIQ mode, r8-r12 come from the user registers x8-x12. | ||
650 | * Otherwise, we copy x8-x12 into the banked user regs. | ||
651 | */ | ||
652 | if (mode == ARM_CPU_MODE_FIQ) { | ||
653 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
654 | } | ||
655 | } | ||
656 | |||
657 | - /* Registers r13 & r14 depend on the current mode. | ||
658 | + /* | ||
659 | + * Registers r13 & r14 depend on the current mode. | ||
660 | * If we are in a given mode, we copy the corresponding x registers to r13 | ||
661 | * and r14. Otherwise, we copy the x register to the banked r13 and r14 | ||
662 | * for the mode. | ||
663 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
155 | } else { | 664 | } else { |
156 | lr = R_V7M_EXCRET_RES1_MASK | | 665 | env->banked_r13[bank_number(ARM_CPU_MODE_USR)] = env->xregs[13]; |
157 | R_V7M_EXCRET_S_MASK | | 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 | */ | ||
158 | -- | 987 | -- |
159 | 2.20.1 | 988 | 2.20.1 |
160 | 989 | ||
161 | 990 | diff view generated by jsdifflib |
1 | The only "system register" that M-profile floating point exposes | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | via the VMRS/VMRS instructions is FPSCR, and it does not have | ||
3 | the odd special case for rd==15. Add a check to ensure we only | ||
4 | expose FPSCR. | ||
5 | 2 | ||
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 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20190416125744.27770-5-peter.maydell@linaro.org | ||
9 | --- | 9 | --- |
10 | target/arm/translate.c | 19 +++++++++++++++++-- | 10 | target/arm/translate.c | 11 ++++++----- |
11 | 1 file changed, 17 insertions(+), 2 deletions(-) | 11 | target/arm/vfp_helper.c | 36 ++++++++++++++++++++++++------------ |
12 | 2 files changed, 30 insertions(+), 17 deletions(-) | ||
12 | 13 | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.c | 16 | --- a/target/arm/translate.c |
16 | +++ b/target/arm/translate.c | 17 | +++ b/target/arm/translate.c |
17 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | 18 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) |
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) | ||
18 | } | 28 | } |
19 | } | 29 | } |
20 | } else { /* !dp */ | 30 | j = 0; |
21 | + bool is_sysreg; | 31 | - for(i=0;i<16;i++) { |
22 | + | 32 | + for (i = 0; i < 16; i++) { |
23 | if ((insn & 0x6f) != 0x00) | 33 | if (insn & (1 << i)) { |
24 | return 1; | 34 | if (is_load) { |
25 | rn = VFP_SREG_N(insn); | 35 | /* load */ |
26 | + | 36 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) |
27 | + is_sysreg = extract32(insn, 21, 1); | 37 | return; |
28 | + | 38 | } |
29 | + if (arm_dc_feature(s, ARM_FEATURE_M)) { | 39 | |
30 | + /* | 40 | - for(i=0;i<16;i++) { |
31 | + * The only M-profile VFP vmrs/vmsr sysreg is FPSCR. | 41 | + for (i = 0; i < 16; i++) { |
32 | + * Writes to R15 are UNPREDICTABLE; we choose to undef. | 42 | qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]); |
33 | + */ | 43 | - if ((i % 4) == 3) |
34 | + if (is_sysreg && (rd == 15 || (rn >> 1) != ARM_VFP_FPSCR)) { | 44 | + if ((i % 4) == 3) { |
35 | + return 1; | 45 | qemu_fprintf(f, "\n"); |
36 | + } | 46 | - else |
37 | + } | 47 | + } else { |
38 | + | 48 | qemu_fprintf(f, " "); |
39 | if (insn & ARM_CP_RW_BIT) { | 49 | + } |
40 | /* vfp->arm */ | 50 | } |
41 | - if (insn & (1 << 21)) { | 51 | |
42 | + if (is_sysreg) { | 52 | if (arm_feature(env, ARM_FEATURE_M)) { |
43 | /* system register */ | 53 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c |
44 | rn >>= 1; | 54 | index XXXXXXX..XXXXXXX 100644 |
45 | 55 | --- a/target/arm/vfp_helper.c | |
46 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | 56 | +++ b/target/arm/vfp_helper.c |
47 | } | 57 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_from_host(int host_bits) |
48 | } else { | 58 | { |
49 | /* arm->vfp */ | 59 | int target_bits = 0; |
50 | - if (insn & (1 << 21)) { | 60 | |
51 | + if (is_sysreg) { | 61 | - if (host_bits & float_flag_invalid) |
52 | rn >>= 1; | 62 | + if (host_bits & float_flag_invalid) { |
53 | /* system register */ | 63 | target_bits |= 1; |
54 | switch (rn) { | 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 | |||
55 | -- | 119 | -- |
56 | 2.20.1 | 120 | 2.20.1 |
57 | 121 | ||
58 | 122 | diff view generated by jsdifflib |
1 | Handle floating point registers in exception return. | 1 | From: Samuel Ortiz <sameo@linux.intel.com> |
---|---|---|---|
2 | This corresponds to pseudocode functions ValidateExceptionReturn(), | 2 | |
3 | ExceptionReturn(), PopStack() and ConsumeExcStackFrame(). | 3 | Those helpers are a software implementation of the ARM v8 memory zeroing |
4 | 4 | op code. They should be moved to the op helper file, which is going to | |
5 | eventually be built only when TCG is enabled. | ||
6 | |||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
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> | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20190416125744.27770-16-peter.maydell@linaro.org | ||
8 | --- | 17 | --- |
9 | target/arm/helper.c | 142 +++++++++++++++++++++++++++++++++++++++++++- | 18 | target/arm/helper.c | 92 ----------------------------------------- |
10 | 1 file changed, 141 insertions(+), 1 deletion(-) | 19 | target/arm/op_helper.c | 93 ++++++++++++++++++++++++++++++++++++++++++ |
20 | 2 files changed, 93 insertions(+), 92 deletions(-) | ||
11 | 21 | ||
12 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 22 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
13 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/helper.c | 24 | --- a/target/arm/helper.c |
15 | +++ b/target/arm/helper.c | 25 | +++ b/target/arm/helper.c |
16 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | 26 | @@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, |
17 | bool rettobase = false; | 27 | #endif |
18 | bool exc_secure = false; | 28 | } |
19 | bool return_to_secure; | 29 | |
20 | + bool ftype; | 30 | -void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) |
21 | + bool restore_s16_s31; | 31 | -{ |
22 | 32 | - /* | |
23 | /* If we're not in Handler mode then jumps to magic exception-exit | 33 | - * Implement DC ZVA, which zeroes a fixed-length block of memory. |
24 | * addresses don't have magic behaviour. However for the v8M | 34 | - * Note that we do not implement the (architecturally mandated) |
25 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | 35 | - * alignment fault for attempts to use this on Device memory |
26 | excret); | 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)); | ||
27 | } | 139 | } |
28 | 140 | } | |
29 | + ftype = excret & R_V7M_EXCRET_FTYPE_MASK; | 141 | + |
30 | + | 142 | +void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) |
31 | + if (!arm_feature(env, ARM_FEATURE_VFP) && !ftype) { | 143 | +{ |
32 | + qemu_log_mask(LOG_GUEST_ERROR, "M profile: zero FTYPE in exception " | ||
33 | + "exit PC value 0x%" PRIx32 " is UNPREDICTABLE " | ||
34 | + "if FPU not present\n", | ||
35 | + excret); | ||
36 | + ftype = true; | ||
37 | + } | ||
38 | + | ||
39 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
40 | /* EXC_RETURN.ES validation check (R_SMFL). We must do this before | ||
41 | * we pick which FAULTMASK to clear. | ||
42 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
43 | */ | ||
44 | write_v7m_control_spsel_for_secstate(env, return_to_sp_process, exc_secure); | ||
45 | |||
46 | + /* | 144 | + /* |
47 | + * Clear scratch FP values left in caller saved registers; this | 145 | + * Implement DC ZVA, which zeroes a fixed-length block of memory. |
48 | + * must happen before any kind of tail chaining. | 146 | + * Note that we do not implement the (architecturally mandated) |
147 | + * alignment fault for attempts to use this on Device memory | ||
148 | + * (which matches the usual QEMU behaviour of not implementing either | ||
149 | + * alignment faults or any memory attribute handling). | ||
49 | + */ | 150 | + */ |
50 | + if ((env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_CLRONRET_MASK) && | 151 | + |
51 | + (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK)) { | 152 | + ARMCPU *cpu = env_archcpu(env); |
52 | + if (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK) { | 153 | + uint64_t blocklen = 4 << cpu->dcz_blocksize; |
53 | + env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; | 154 | + uint64_t vaddr = vaddr_in & ~(blocklen - 1); |
54 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | 155 | + |
55 | + qemu_log_mask(CPU_LOG_INT, "...taking SecureFault on existing " | 156 | +#ifndef CONFIG_USER_ONLY |
56 | + "stackframe: error during lazy state deactivation\n"); | 157 | + { |
57 | + v7m_exception_taken(cpu, excret, true, false); | 158 | + /* |
58 | + return; | 159 | + * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than |
59 | + } else { | 160 | + * the block size so we might have to do more than one TLB lookup. |
60 | + /* Clear s0..s15 and FPSCR */ | 161 | + * We know that in fact for any v8 CPU the page size is at least 4K |
61 | + int i; | 162 | + * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only |
62 | + | 163 | + * 1K as an artefact of legacy v5 subpage support being present in the |
63 | + for (i = 0; i < 16; i += 2) { | 164 | + * same QEMU executable. So in practice the hostaddr[] array has |
64 | + *aa32_vfp_dreg(env, i / 2) = 0; | 165 | + * two entries, given the current setting of TARGET_PAGE_BITS_MIN. |
166 | + */ | ||
167 | + int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE); | ||
168 | + void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)]; | ||
169 | + int try, i; | ||
170 | + unsigned mmu_idx = cpu_mmu_index(env, false); | ||
171 | + TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); | ||
172 | + | ||
173 | + assert(maxidx <= ARRAY_SIZE(hostaddr)); | ||
174 | + | ||
175 | + for (try = 0; try < 2; try++) { | ||
176 | + | ||
177 | + for (i = 0; i < maxidx; i++) { | ||
178 | + hostaddr[i] = tlb_vaddr_to_host(env, | ||
179 | + vaddr + TARGET_PAGE_SIZE * i, | ||
180 | + 1, mmu_idx); | ||
181 | + if (!hostaddr[i]) { | ||
182 | + break; | ||
183 | + } | ||
65 | + } | 184 | + } |
66 | + vfp_set_fpscr(env, 0); | 185 | + if (i == maxidx) { |
67 | + } | 186 | + /* |
68 | + } | 187 | + * If it's all in the TLB it's fair game for just writing to; |
69 | + | 188 | + * we know we don't need to update dirty status, etc. |
70 | if (sfault) { | 189 | + */ |
71 | env->v7m.sfsr |= R_V7M_SFSR_INVER_MASK; | 190 | + for (i = 0; i < maxidx - 1; i++) { |
72 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | 191 | + memset(hostaddr[i], 0, TARGET_PAGE_SIZE); |
73 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | 192 | + } |
74 | } | 193 | + memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE)); |
75 | } | ||
76 | |||
77 | + if (!ftype) { | ||
78 | + /* FP present and we need to handle it */ | ||
79 | + if (!return_to_secure && | ||
80 | + (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK)) { | ||
81 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
82 | + env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; | ||
83 | + qemu_log_mask(CPU_LOG_INT, | ||
84 | + "...taking SecureFault on existing stackframe: " | ||
85 | + "Secure LSPACT set but exception return is " | ||
86 | + "not to secure state\n"); | ||
87 | + v7m_exception_taken(cpu, excret, true, false); | ||
88 | + return; | 194 | + return; |
89 | + } | 195 | + } |
90 | + | 196 | + /* |
91 | + restore_s16_s31 = return_to_secure && | 197 | + * OK, try a store and see if we can populate the tlb. This |
92 | + (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK); | 198 | + * might cause an exception if the memory isn't writable, |
93 | + | 199 | + * in which case we will longjmp out of here. We must for |
94 | + if (env->v7m.fpccr[return_to_secure] & R_V7M_FPCCR_LSPACT_MASK) { | 200 | + * this purpose use the actual register value passed to us |
95 | + /* State in FPU is still valid, just clear LSPACT */ | 201 | + * so that we get the fault address right. |
96 | + env->v7m.fpccr[return_to_secure] &= ~R_V7M_FPCCR_LSPACT_MASK; | 202 | + */ |
97 | + } else { | 203 | + helper_ret_stb_mmu(env, vaddr_in, 0, oi, GETPC()); |
98 | + int i; | 204 | + /* Now we can populate the other TLB entries, if any */ |
99 | + uint32_t fpscr; | 205 | + for (i = 0; i < maxidx; i++) { |
100 | + bool cpacr_pass, nsacr_pass; | 206 | + uint64_t va = vaddr + TARGET_PAGE_SIZE * i; |
101 | + | 207 | + if (va != (vaddr_in & TARGET_PAGE_MASK)) { |
102 | + cpacr_pass = v7m_cpacr_pass(env, return_to_secure, | 208 | + helper_ret_stb_mmu(env, va, 0, oi, GETPC()); |
103 | + return_to_priv); | ||
104 | + nsacr_pass = return_to_secure || | ||
105 | + extract32(env->v7m.nsacr, 10, 1); | ||
106 | + | ||
107 | + if (!cpacr_pass) { | ||
108 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | ||
109 | + return_to_secure); | ||
110 | + env->v7m.cfsr[return_to_secure] |= R_V7M_CFSR_NOCP_MASK; | ||
111 | + qemu_log_mask(CPU_LOG_INT, | ||
112 | + "...taking UsageFault on existing " | ||
113 | + "stackframe: CPACR.CP10 prevents unstacking " | ||
114 | + "FP regs\n"); | ||
115 | + v7m_exception_taken(cpu, excret, true, false); | ||
116 | + return; | ||
117 | + } else if (!nsacr_pass) { | ||
118 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, true); | ||
119 | + env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_INVPC_MASK; | ||
120 | + qemu_log_mask(CPU_LOG_INT, | ||
121 | + "...taking Secure UsageFault on existing " | ||
122 | + "stackframe: NSACR.CP10 prevents unstacking " | ||
123 | + "FP regs\n"); | ||
124 | + v7m_exception_taken(cpu, excret, true, false); | ||
125 | + return; | ||
126 | + } | ||
127 | + | ||
128 | + for (i = 0; i < (restore_s16_s31 ? 32 : 16); i += 2) { | ||
129 | + uint32_t slo, shi; | ||
130 | + uint64_t dn; | ||
131 | + uint32_t faddr = frameptr + 0x20 + 4 * i; | ||
132 | + | ||
133 | + if (i >= 16) { | ||
134 | + faddr += 8; /* Skip the slot for the FPSCR */ | ||
135 | + } | ||
136 | + | ||
137 | + pop_ok = pop_ok && | ||
138 | + v7m_stack_read(cpu, &slo, faddr, mmu_idx) && | ||
139 | + v7m_stack_read(cpu, &shi, faddr + 4, mmu_idx); | ||
140 | + | ||
141 | + if (!pop_ok) { | ||
142 | + break; | ||
143 | + } | ||
144 | + | ||
145 | + dn = (uint64_t)shi << 32 | slo; | ||
146 | + *aa32_vfp_dreg(env, i / 2) = dn; | ||
147 | + } | ||
148 | + pop_ok = pop_ok && | ||
149 | + v7m_stack_read(cpu, &fpscr, frameptr + 0x60, mmu_idx); | ||
150 | + if (pop_ok) { | ||
151 | + vfp_set_fpscr(env, fpscr); | ||
152 | + } | ||
153 | + if (!pop_ok) { | ||
154 | + /* | ||
155 | + * These regs are 0 if security extension present; | ||
156 | + * otherwise merely UNKNOWN. We zero always. | ||
157 | + */ | ||
158 | + for (i = 0; i < (restore_s16_s31 ? 32 : 16); i += 2) { | ||
159 | + *aa32_vfp_dreg(env, i / 2) = 0; | ||
160 | + } | ||
161 | + vfp_set_fpscr(env, 0); | ||
162 | + } | 209 | + } |
163 | + } | 210 | + } |
164 | + } | 211 | + } |
165 | + env->v7m.control[M_REG_S] = FIELD_DP32(env->v7m.control[M_REG_S], | 212 | + |
166 | + V7M_CONTROL, FPCA, !ftype); | 213 | + /* |
167 | + | 214 | + * Slow path (probably attempt to do this to an I/O device or |
168 | /* Commit to consuming the stack frame */ | 215 | + * similar, or clearing of a block of code we have translations |
169 | frameptr += 0x20; | 216 | + * cached for). Just do a series of byte writes as the architecture |
170 | + if (!ftype) { | 217 | + * demands. It's not worth trying to use a cpu_physical_memory_map(), |
171 | + frameptr += 0x48; | 218 | + * memset(), unmap() sequence here because: |
172 | + if (restore_s16_s31) { | 219 | + * + we'd need to account for the blocksize being larger than a page |
173 | + frameptr += 0x40; | 220 | + * + the direct-RAM access case is almost always going to be dealt |
174 | + } | 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()); | ||
175 | + } | 227 | + } |
176 | /* Undo stack alignment (the SPREALIGN bit indicates that the original | ||
177 | * pre-exception SP was not 8-aligned and we added a padding word to | ||
178 | * align it, so we undo this by ORing in the bit that increases it | ||
179 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
180 | *frame_sp_p = frameptr; | ||
181 | } | ||
182 | /* This xpsr_write() will invalidate frame_sp_p as it may switch stack */ | ||
183 | - xpsr_write(env, xpsr, ~XPSR_SPREALIGN); | ||
184 | + xpsr_write(env, xpsr, ~(XPSR_SPREALIGN | XPSR_SFPA)); | ||
185 | + | ||
186 | + if (env->v7m.secure) { | ||
187 | + bool sfpa = xpsr & XPSR_SFPA; | ||
188 | + | ||
189 | + env->v7m.control[M_REG_S] = FIELD_DP32(env->v7m.control[M_REG_S], | ||
190 | + V7M_CONTROL, SFPA, sfpa); | ||
191 | + } | 228 | + } |
192 | 229 | +#else | |
193 | /* The restored xPSR exception field will be zero if we're | 230 | + memset(g2h(vaddr), 0, blocklen); |
194 | * resuming in Thread mode. If that doesn't match what the | 231 | +#endif |
232 | +} | ||
195 | -- | 233 | -- |
196 | 2.20.1 | 234 | 2.20.1 |
197 | 235 | ||
198 | 236 | diff view generated by jsdifflib |
1 | The M-profile architecture floating point system supports | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | lazy FP state preservation, where FP registers are not | ||
3 | pushed to the stack when an exception occurs but are instead | ||
4 | only saved if and when the first FP instruction in the exception | ||
5 | handler is executed. Implement this in QEMU, corresponding | ||
6 | to the check of LSPACT in the pseudocode ExecuteFPCheck(). | ||
7 | 2 | ||
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> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20190416125744.27770-24-peter.maydell@linaro.org | ||
11 | --- | 8 | --- |
12 | target/arm/cpu.h | 3 ++ | 9 | target/arm/cpu.h | 2 - |
13 | target/arm/helper.h | 2 + | 10 | target/arm/translate.h | 5 - |
14 | target/arm/translate.h | 1 + | 11 | target/arm/cpu.c | 226 +++++++++++++++++++++++++++++++++++++ |
15 | target/arm/helper.c | 112 +++++++++++++++++++++++++++++++++++++++++ | 12 | target/arm/translate-a64.c | 128 --------------------- |
16 | target/arm/translate.c | 22 ++++++++ | 13 | target/arm/translate.c | 88 --------------- |
17 | 5 files changed, 140 insertions(+) | 14 | 5 files changed, 226 insertions(+), 223 deletions(-) |
18 | 15 | ||
19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
20 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/cpu.h | 18 | --- a/target/arm/cpu.h |
22 | +++ b/target/arm/cpu.h | 19 | +++ b/target/arm/cpu.h |
23 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cpu); |
24 | #define EXCP_NOCP 17 /* v7M NOCP UsageFault */ | 21 | void arm_v7m_cpu_do_interrupt(CPUState *cpu); |
25 | #define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */ | 22 | bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req); |
26 | #define EXCP_STKOF 19 /* v8M STKOF UsageFault */ | 23 | |
27 | +#define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */ | 24 | -void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags); |
28 | /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ | 25 | - |
29 | 26 | hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, | |
30 | #define ARMV7M_EXCP_RESET 1 | 27 | MemTxAttrs *attrs); |
31 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1) | 28 | |
32 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | ||
33 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | ||
34 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | ||
35 | +/* For M profile only, set if FPCCR.LSPACT is set */ | ||
36 | +FIELD(TBFLAG_A32, LSPACT, 18, 1) | ||
37 | /* For M profile only, set if we must create a new FP context */ | ||
38 | FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1) | ||
39 | /* For M profile only, set if FPCCR.S does not match current security state */ | ||
40 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/helper.h | ||
43 | +++ b/target/arm/helper.h | ||
44 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(v7m_blxns, void, env, i32) | ||
45 | |||
46 | DEF_HELPER_3(v7m_tt, i32, env, i32, i32) | ||
47 | |||
48 | +DEF_HELPER_1(v7m_preserve_fp_state, void, env) | ||
49 | + | ||
50 | DEF_HELPER_2(v8m_stackcheck, void, env, i32) | ||
51 | |||
52 | DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32) | ||
53 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 29 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
54 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/target/arm/translate.h | 31 | --- a/target/arm/translate.h |
56 | +++ b/target/arm/translate.h | 32 | +++ b/target/arm/translate.h |
57 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 33 | @@ -XXX,XX +XXX,XX @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn) |
58 | bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */ | 34 | #ifdef TARGET_AARCH64 |
59 | bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */ | 35 | void a64_translate_init(void); |
60 | bool v7m_new_fp_ctxt_needed; /* ASPEN set but no active FP context */ | 36 | void gen_a64_set_pc_im(uint64_t val); |
61 | + bool v7m_lspact; /* FPCCR.LSPACT set */ | 37 | -void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags); |
62 | /* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI | 38 | extern const TranslatorOps aarch64_translator_ops; |
63 | * so that top level loop can generate correct syndrome information. | 39 | #else |
64 | */ | 40 | static inline void a64_translate_init(void) |
65 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 41 | @@ -XXX,XX +XXX,XX @@ static inline void a64_translate_init(void) |
42 | static inline void gen_a64_set_pc_im(uint64_t val) | ||
43 | { | ||
44 | } | ||
45 | - | ||
46 | -static inline void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
47 | -{ | ||
48 | -} | ||
49 | #endif | ||
50 | |||
51 | void arm_test_cc(DisasCompare *cmp, int cc); | ||
52 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | 53 | index XXXXXXX..XXXXXXX 100644 |
67 | --- a/target/arm/helper.c | 54 | --- a/target/arm/cpu.c |
68 | +++ b/target/arm/helper.c | 55 | +++ b/target/arm/cpu.c |
69 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | 56 | @@ -XXX,XX +XXX,XX @@ |
70 | g_assert_not_reached(); | 57 | */ |
58 | |||
59 | #include "qemu/osdep.h" | ||
60 | +#include "qemu/qemu-print.h" | ||
61 | #include "qemu-common.h" | ||
62 | #include "target/arm/idau.h" | ||
63 | #include "qemu/module.h" | ||
64 | @@ -XXX,XX +XXX,XX @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) | ||
65 | #endif | ||
71 | } | 66 | } |
72 | 67 | ||
73 | +void HELPER(v7m_preserve_fp_state)(CPUARMState *env) | 68 | +#ifdef TARGET_AARCH64 |
69 | + | ||
70 | +static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
74 | +{ | 71 | +{ |
75 | + /* translate.c should never generate calls here in user-only mode */ | 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 | +{ | ||
76 | + g_assert_not_reached(); | 201 | + g_assert_not_reached(); |
77 | +} | 202 | +} |
78 | + | 203 | + |
79 | uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | 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) | ||
80 | { | 294 | { |
81 | /* The TT instructions can be used by unprivileged code, but in | 295 | uint32_t Aff1 = idx / clustersz; |
82 | @@ -XXX,XX +XXX,XX @@ pend_fault: | 296 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
83 | return false; | 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; | ||
84 | } | 310 | } |
85 | 311 | ||
86 | +void HELPER(v7m_preserve_fp_state)(CPUARMState *env) | 312 | -void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) |
87 | +{ | 313 | -{ |
88 | + /* | 314 | - ARMCPU *cpu = ARM_CPU(cs); |
89 | + * Preserve FP state (because LSPACT was set and we are about | 315 | - CPUARMState *env = &cpu->env; |
90 | + * to execute an FP instruction). This corresponds to the | 316 | - uint32_t psr = pstate_read(env); |
91 | + * PreserveFPState() pseudocode. | 317 | - int i; |
92 | + * We may throw an exception if the stacking fails. | 318 | - int el = arm_current_el(env); |
93 | + */ | 319 | - const char *ns_status; |
94 | + ARMCPU *cpu = arm_env_get_cpu(env); | 320 | - |
95 | + bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | 321 | - qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc); |
96 | + bool negpri = !(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_HFRDY_MASK); | 322 | - for (i = 0; i < 32; i++) { |
97 | + bool is_priv = !(env->v7m.fpccr[is_secure] & R_V7M_FPCCR_USER_MASK); | 323 | - if (i == 31) { |
98 | + bool splimviol = env->v7m.fpccr[is_secure] & R_V7M_FPCCR_SPLIMVIOL_MASK; | 324 | - qemu_fprintf(f, " SP=%016" PRIx64 "\n", env->xregs[i]); |
99 | + uint32_t fpcar = env->v7m.fpcar[is_secure]; | 325 | - } else { |
100 | + bool stacked_ok = true; | 326 | - qemu_fprintf(f, "X%02d=%016" PRIx64 "%s", i, env->xregs[i], |
101 | + bool ts = is_secure && (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK); | 327 | - (i + 2) % 3 ? " " : "\n"); |
102 | + bool take_exception; | 328 | - } |
103 | + | 329 | - } |
104 | + /* Take the iothread lock as we are going to touch the NVIC */ | 330 | - |
105 | + qemu_mutex_lock_iothread(); | 331 | - if (arm_feature(env, ARM_FEATURE_EL3) && el != 3) { |
106 | + | 332 | - ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; |
107 | + /* Check the background context had access to the FPU */ | 333 | - } else { |
108 | + if (!v7m_cpacr_pass(env, is_secure, is_priv)) { | 334 | - ns_status = ""; |
109 | + armv7m_nvic_set_pending_lazyfp(env->nvic, ARMV7M_EXCP_USAGE, is_secure); | 335 | - } |
110 | + env->v7m.cfsr[is_secure] |= R_V7M_CFSR_NOCP_MASK; | 336 | - qemu_fprintf(f, "PSTATE=%08x %c%c%c%c %sEL%d%c", |
111 | + stacked_ok = false; | 337 | - psr, |
112 | + } else if (!is_secure && !extract32(env->v7m.nsacr, 10, 1)) { | 338 | - psr & PSTATE_N ? 'N' : '-', |
113 | + armv7m_nvic_set_pending_lazyfp(env->nvic, ARMV7M_EXCP_USAGE, M_REG_S); | 339 | - psr & PSTATE_Z ? 'Z' : '-', |
114 | + env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_NOCP_MASK; | 340 | - psr & PSTATE_C ? 'C' : '-', |
115 | + stacked_ok = false; | 341 | - psr & PSTATE_V ? 'V' : '-', |
116 | + } | 342 | - ns_status, |
117 | + | 343 | - el, |
118 | + if (!splimviol && stacked_ok) { | 344 | - psr & PSTATE_SP ? 'h' : 't'); |
119 | + /* We only stack if the stack limit wasn't violated */ | 345 | - |
120 | + int i; | 346 | - if (cpu_isar_feature(aa64_bti, cpu)) { |
121 | + ARMMMUIdx mmu_idx; | 347 | - qemu_fprintf(f, " BTYPE=%d", (psr & PSTATE_BTYPE) >> 10); |
122 | + | 348 | - } |
123 | + mmu_idx = arm_v7m_mmu_idx_all(env, is_secure, is_priv, negpri); | 349 | - if (!(flags & CPU_DUMP_FPU)) { |
124 | + for (i = 0; i < (ts ? 32 : 16); i += 2) { | 350 | - qemu_fprintf(f, "\n"); |
125 | + uint64_t dn = *aa32_vfp_dreg(env, i / 2); | 351 | - return; |
126 | + uint32_t faddr = fpcar + 4 * i; | 352 | - } |
127 | + uint32_t slo = extract64(dn, 0, 32); | 353 | - if (fp_exception_el(env, el) != 0) { |
128 | + uint32_t shi = extract64(dn, 32, 32); | 354 | - qemu_fprintf(f, " FPU disabled\n"); |
129 | + | 355 | - return; |
130 | + if (i >= 16) { | 356 | - } |
131 | + faddr += 8; /* skip the slot for the FPSCR */ | 357 | - qemu_fprintf(f, " FPCR=%08x FPSR=%08x\n", |
132 | + } | 358 | - vfp_get_fpcr(env), vfp_get_fpsr(env)); |
133 | + stacked_ok = stacked_ok && | 359 | - |
134 | + v7m_stack_write(cpu, faddr, slo, mmu_idx, STACK_LAZYFP) && | 360 | - if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) == 0) { |
135 | + v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, STACK_LAZYFP); | 361 | - int j, zcr_len = sve_zcr_len_for_el(env, el); |
136 | + } | 362 | - |
137 | + | 363 | - for (i = 0; i <= FFR_PRED_NUM; i++) { |
138 | + stacked_ok = stacked_ok && | 364 | - bool eol; |
139 | + v7m_stack_write(cpu, fpcar + 0x40, | 365 | - if (i == FFR_PRED_NUM) { |
140 | + vfp_get_fpscr(env), mmu_idx, STACK_LAZYFP); | 366 | - qemu_fprintf(f, "FFR="); |
141 | + } | 367 | - /* It's last, so end the line. */ |
142 | + | 368 | - eol = true; |
143 | + /* | 369 | - } else { |
144 | + * We definitely pended an exception, but it's possible that it | 370 | - qemu_fprintf(f, "P%02d=", i); |
145 | + * might not be able to be taken now. If its priority permits us | 371 | - switch (zcr_len) { |
146 | + * to take it now, then we must not update the LSPACT or FP regs, | 372 | - case 0: |
147 | + * but instead jump out to take the exception immediately. | 373 | - eol = i % 8 == 7; |
148 | + * If it's just pending and won't be taken until the current | 374 | - break; |
149 | + * handler exits, then we do update LSPACT and the FP regs. | 375 | - case 1: |
150 | + */ | 376 | - eol = i % 6 == 5; |
151 | + take_exception = !stacked_ok && | 377 | - break; |
152 | + armv7m_nvic_can_take_pending_exception(env->nvic); | 378 | - case 2: |
153 | + | 379 | - case 3: |
154 | + qemu_mutex_unlock_iothread(); | 380 | - eol = i % 3 == 2; |
155 | + | 381 | - break; |
156 | + if (take_exception) { | 382 | - default: |
157 | + raise_exception_ra(env, EXCP_LAZYFP, 0, 1, GETPC()); | 383 | - /* More than one quadword per predicate. */ |
158 | + } | 384 | - eol = true; |
159 | + | 385 | - break; |
160 | + env->v7m.fpccr[is_secure] &= ~R_V7M_FPCCR_LSPACT_MASK; | 386 | - } |
161 | + | 387 | - } |
162 | + if (ts) { | 388 | - for (j = zcr_len / 4; j >= 0; j--) { |
163 | + /* Clear s0 to s31 and the FPSCR */ | 389 | - int digits; |
164 | + int i; | 390 | - if (j * 4 + 4 <= zcr_len + 1) { |
165 | + | 391 | - digits = 16; |
166 | + for (i = 0; i < 32; i += 2) { | 392 | - } else { |
167 | + *aa32_vfp_dreg(env, i / 2) = 0; | 393 | - digits = (zcr_len % 4 + 1) * 4; |
168 | + } | 394 | - } |
169 | + vfp_set_fpscr(env, 0); | 395 | - qemu_fprintf(f, "%0*" PRIx64 "%s", digits, |
170 | + } | 396 | - env->vfp.pregs[i].p[j], |
171 | + /* | 397 | - j ? ":" : eol ? "\n" : " "); |
172 | + * Otherwise s0 to s15 and FPSCR are UNKNOWN; we choose to leave them | 398 | - } |
173 | + * unchanged. | 399 | - } |
174 | + */ | 400 | - |
175 | +} | 401 | - for (i = 0; i < 32; i++) { |
176 | + | 402 | - if (zcr_len == 0) { |
177 | /* Write to v7M CONTROL.SPSEL bit for the specified security bank. | 403 | - qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 "%s", |
178 | * This may change the current stack pointer between Main and Process | 404 | - i, env->vfp.zregs[i].d[1], |
179 | * stack pointers if it is done for the CONTROL register for the current | 405 | - env->vfp.zregs[i].d[0], i & 1 ? "\n" : " "); |
180 | @@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx) | 406 | - } else if (zcr_len == 1) { |
181 | [EXCP_NOCP] = "v7M NOCP UsageFault", | 407 | - qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 |
182 | [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | 408 | - ":%016" PRIx64 ":%016" PRIx64 "\n", |
183 | [EXCP_STKOF] = "v8M STKOF UsageFault", | 409 | - i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].d[2], |
184 | + [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | 410 | - env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0]); |
185 | }; | 411 | - } else { |
186 | 412 | - for (j = zcr_len; j >= 0; j--) { | |
187 | if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | 413 | - bool odd = (zcr_len - j) % 2 != 0; |
188 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 414 | - if (j == zcr_len) { |
189 | return; | 415 | - qemu_fprintf(f, "Z%02d[%x-%x]=", i, j, j - 1); |
190 | } | 416 | - } else if (!odd) { |
191 | break; | 417 | - if (j > 0) { |
192 | + case EXCP_LAZYFP: | 418 | - qemu_fprintf(f, " [%x-%x]=", j, j - 1); |
193 | + /* | 419 | - } else { |
194 | + * We already pended the specific exception in the NVIC in the | 420 | - qemu_fprintf(f, " [%x]=", j); |
195 | + * v7m_preserve_fp_state() helper function. | 421 | - } |
196 | + */ | 422 | - } |
197 | + break; | 423 | - qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%s", |
198 | default: | 424 | - env->vfp.zregs[i].d[j * 2 + 1], |
199 | cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index); | 425 | - env->vfp.zregs[i].d[j * 2], |
200 | return; /* Never happens. Keep compiler happy. */ | 426 | - odd || j == 0 ? "\n" : ":"); |
201 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 427 | - } |
202 | flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1); | 428 | - } |
203 | } | 429 | - } |
204 | 430 | - } else { | |
205 | + if (arm_feature(env, ARM_FEATURE_M)) { | 431 | - for (i = 0; i < 32; i++) { |
206 | + bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; | 432 | - uint64_t *q = aa64_vfp_qreg(env, i); |
207 | + | 433 | - qemu_fprintf(f, "Q%02d=%016" PRIx64 ":%016" PRIx64 "%s", |
208 | + if (env->v7m.fpccr[is_secure] & R_V7M_FPCCR_LSPACT_MASK) { | 434 | - i, q[1], q[0], (i & 1 ? "\n" : " ")); |
209 | + flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1); | 435 | - } |
210 | + } | 436 | - } |
211 | + } | 437 | -} |
212 | + | 438 | - |
213 | *pflags = flags; | 439 | void gen_a64_set_pc_im(uint64_t val) |
214 | *cs_base = 0; | 440 | { |
215 | } | 441 | tcg_gen_movi_i64(cpu_pc, val); |
216 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 442 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
217 | index XXXXXXX..XXXXXXX 100644 | 443 | index XXXXXXX..XXXXXXX 100644 |
218 | --- a/target/arm/translate.c | 444 | --- a/target/arm/translate.c |
219 | +++ b/target/arm/translate.c | 445 | +++ b/target/arm/translate.c |
220 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | 446 | @@ -XXX,XX +XXX,XX @@ |
221 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | 447 | #include "tcg-op-gvec.h" |
222 | /* Handle M-profile lazy FP state mechanics */ | 448 | #include "qemu/log.h" |
223 | 449 | #include "qemu/bitops.h" | |
224 | + /* Trigger lazy-state preservation if necessary */ | 450 | -#include "qemu/qemu-print.h" |
225 | + if (s->v7m_lspact) { | 451 | #include "arm_ldst.h" |
226 | + /* | 452 | #include "hw/semihosting/semihost.h" |
227 | + * Lazy state saving affects external memory and also the NVIC, | 453 | |
228 | + * so we must mark it as an IO operation for icount. | 454 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns) |
229 | + */ | 455 | translator_loop(ops, &dc.base, cpu, tb, max_insns); |
230 | + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | 456 | } |
231 | + gen_io_start(); | 457 | |
232 | + } | 458 | -void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) |
233 | + gen_helper_v7m_preserve_fp_state(cpu_env); | 459 | -{ |
234 | + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | 460 | - ARMCPU *cpu = ARM_CPU(cs); |
235 | + gen_io_end(); | 461 | - CPUARMState *env = &cpu->env; |
236 | + } | 462 | - int i; |
237 | + /* | 463 | - |
238 | + * If the preserve_fp_state helper doesn't throw an exception | 464 | - if (is_a64(env)) { |
239 | + * then it will clear LSPACT; we don't need to repeat this for | 465 | - aarch64_cpu_dump_state(cs, f, flags); |
240 | + * any further FP insns in this TB. | 466 | - return; |
241 | + */ | 467 | - } |
242 | + s->v7m_lspact = false; | 468 | - |
243 | + } | 469 | - for (i = 0; i < 16; i++) { |
244 | + | 470 | - qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]); |
245 | /* Update ownership of FP context: set FPCCR.S to match current state */ | 471 | - if ((i % 4) == 3) { |
246 | if (s->v8m_fpccr_s_wrong) { | 472 | - qemu_fprintf(f, "\n"); |
247 | TCGv_i32 tmp; | 473 | - } else { |
248 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 474 | - qemu_fprintf(f, " "); |
249 | dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG); | 475 | - } |
250 | dc->v7m_new_fp_ctxt_needed = | 476 | - } |
251 | FIELD_EX32(tb_flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED); | 477 | - |
252 | + dc->v7m_lspact = FIELD_EX32(tb_flags, TBFLAG_A32, LSPACT); | 478 | - if (arm_feature(env, ARM_FEATURE_M)) { |
253 | dc->cp_regs = cpu->cp_regs; | 479 | - uint32_t xpsr = xpsr_read(env); |
254 | dc->features = env->features; | 480 | - const char *mode; |
255 | 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 | { | ||
256 | -- | 548 | -- |
257 | 2.20.1 | 549 | 2.20.1 |
258 | 550 | ||
259 | 551 | diff view generated by jsdifflib |
1 | If the floating point extension is present, then the SG instruction | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | must clear the CONTROL_S.SFPA bit. Implement this. | ||
3 | 2 | ||
4 | (On a no-FPU system the bit will always be zero, so we don't need | 3 | In the next commit we will split the TLB related routines of |
5 | to make the clearing of the bit conditional on ARM_FEATURE_VFP.) | 4 | this file, and this function will also be called in the new |
5 | file. Declare it in the "internals.h" header. | ||
6 | 6 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190701132516.26392-12-philmd@redhat.com | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20190416125744.27770-8-peter.maydell@linaro.org | ||
10 | --- | 11 | --- |
11 | target/arm/helper.c | 1 + | 12 | target/arm/internals.h | 16 ++++++++++++++++ |
12 | 1 file changed, 1 insertion(+) | 13 | target/arm/helper.c | 21 +++++---------------- |
14 | 2 files changed, 21 insertions(+), 16 deletions(-) | ||
13 | 15 | ||
16 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/internals.h | ||
19 | +++ b/target/arm/internals.h | ||
20 | @@ -XXX,XX +XXX,XX @@ static inline int exception_target_el(CPUARMState *env) | ||
21 | return target_el; | ||
22 | } | ||
23 | |||
24 | +#ifndef CONFIG_USER_ONLY | ||
25 | + | ||
26 | +/* Cacheability and shareability attributes for a memory access */ | ||
27 | +typedef struct ARMCacheAttrs { | ||
28 | + unsigned int attrs:8; /* as in the MAIR register encoding */ | ||
29 | + unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */ | ||
30 | +} ARMCacheAttrs; | ||
31 | + | ||
32 | +bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
33 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
34 | + hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
35 | + target_ulong *page_size, | ||
36 | + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); | ||
37 | + | ||
38 | +#endif /* !CONFIG_USER_ONLY */ | ||
39 | + | ||
40 | #endif | ||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 41 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 43 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/helper.c | 44 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu) | 45 | @@ -XXX,XX +XXX,XX @@ |
19 | qemu_log_mask(CPU_LOG_INT, "...really an SG instruction at 0x%08" PRIx32 | 46 | #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ |
20 | ", executing it\n", env->regs[15]); | 47 | |
21 | env->regs[14] &= ~1; | 48 | #ifndef CONFIG_USER_ONLY |
22 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | 49 | -/* Cacheability and shareability attributes for a memory access */ |
23 | switch_v7m_security_state(env, true); | 50 | -typedef struct ARMCacheAttrs { |
24 | xpsr_write(env, 0, XPSR_IT); | 51 | - unsigned int attrs:8; /* as in the MAIR register encoding */ |
25 | env->regs[15] += 4; | 52 | - unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */ |
53 | -} ARMCacheAttrs; | ||
54 | - | ||
55 | -static bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
56 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
57 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
58 | - target_ulong *page_size, | ||
59 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); | ||
60 | |||
61 | static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
62 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
63 | @@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2) | ||
64 | * @fi: set to fault info if the translation fails | ||
65 | * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes | ||
66 | */ | ||
67 | -static bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
68 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
69 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
70 | - target_ulong *page_size, | ||
71 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
72 | +bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
73 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
74 | + hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
75 | + target_ulong *page_size, | ||
76 | + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
77 | { | ||
78 | if (mmu_idx == ARMMMUIdx_S12NSE0 || mmu_idx == ARMMMUIdx_S12NSE1) { | ||
79 | /* Call ourselves recursively to do the stage 1 and then stage 2 | ||
26 | -- | 80 | -- |
27 | 2.20.1 | 81 | 2.20.1 |
28 | 82 | ||
29 | 83 | diff view generated by jsdifflib |
1 | We are close to running out of TB flags for AArch32; we could | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | start using the cs_base word, but before we do that we can | ||
3 | economise on our usage by sharing the same bits for the VFP | ||
4 | VECSTRIDE field and the XScale XSCALE_CPAR field. This | ||
5 | works because no XScale CPU ever had VFP. | ||
6 | 2 | ||
3 | These routines are TCG specific. | ||
4 | The arm_deliver_fault() function is only used within the new | ||
5 | helper. Make it static. | ||
6 | |||
7 | Suggested-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190701132516.26392-13-philmd@redhat.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20190416125744.27770-18-peter.maydell@linaro.org | ||
10 | --- | 12 | --- |
11 | target/arm/cpu.h | 10 ++++++---- | 13 | target/arm/Makefile.objs | 1 + |
12 | target/arm/cpu.c | 7 +++++++ | 14 | target/arm/internals.h | 3 - |
13 | target/arm/helper.c | 6 +++++- | 15 | target/arm/cpu.c | 6 +- |
14 | target/arm/translate.c | 9 +++++++-- | 16 | target/arm/helper.c | 53 ----------- |
15 | 4 files changed, 25 insertions(+), 7 deletions(-) | 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 | ||
16 | 21 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 22 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs |
18 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 24 | --- a/target/arm/Makefile.objs |
20 | +++ b/target/arm/cpu.h | 25 | +++ b/target/arm/Makefile.objs |
21 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1) | 26 | @@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c |
22 | FIELD(TBFLAG_A32, THUMB, 0, 1) | 27 | target/arm/translate.o: target/arm/decode-vfp.inc.c |
23 | FIELD(TBFLAG_A32, VECLEN, 1, 3) | 28 | target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c |
24 | FIELD(TBFLAG_A32, VECSTRIDE, 4, 2) | 29 | |
25 | +/* | 30 | +obj-y += tlb_helper.o |
26 | + * We store the bottom two bits of the CPAR as TB flags and handle | 31 | obj-y += translate.o op_helper.o |
27 | + * checks on the other bits at runtime. This shares the same bits as | 32 | obj-y += crypto_helper.o |
28 | + * VECSTRIDE, which is OK as no XScale CPU has VFP. | 33 | obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o |
29 | + */ | 34 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
30 | +FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2) | 35 | index XXXXXXX..XXXXXXX 100644 |
31 | /* | 36 | --- a/target/arm/internals.h |
32 | * Indicates whether cp register reads and writes by guest code should access | 37 | +++ b/target/arm/internals.h |
33 | * the secure or nonsecure bank of banked registers; note that this is not | 38 | @@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, |
34 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1) | 39 | MMUAccessType access_type, int mmu_idx, |
35 | FIELD(TBFLAG_A32, VFPEN, 7, 1) | 40 | bool probe, uintptr_t retaddr); |
36 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) | 41 | |
37 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | 42 | -void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, |
38 | -/* We store the bottom two bits of the CPAR as TB flags and handle | 43 | - int mmu_idx, ARMMMUFaultInfo *fi) QEMU_NORETURN; |
39 | - * checks on the other bits at runtime | 44 | - |
40 | - */ | 45 | /* Return true if the stage 1 translation regime is using LPAE format page |
41 | -FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2) | 46 | * tables */ |
42 | /* For M profile only, Handler (ie not Thread) mode */ | 47 | bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx); |
43 | FIELD(TBFLAG_A32, HANDLER, 21, 1) | ||
44 | /* For M profile only, whether we should generate stack-limit checks */ | ||
45 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 48 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
46 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/target/arm/cpu.c | 50 | --- a/target/arm/cpu.c |
48 | +++ b/target/arm/cpu.c | 51 | +++ b/target/arm/cpu.c |
49 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 52 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) |
50 | set_feature(env, ARM_FEATURE_THUMB_DSP); | 53 | cc->gdb_write_register = arm_cpu_gdb_write_register; |
51 | } | 54 | #ifndef CONFIG_USER_ONLY |
52 | 55 | cc->do_interrupt = arm_cpu_do_interrupt; | |
53 | + /* | 56 | - cc->do_unaligned_access = arm_cpu_do_unaligned_access; |
54 | + * We rely on no XScale CPU having VFP so we can use the same bits in the | 57 | - cc->do_transaction_failed = arm_cpu_do_transaction_failed; |
55 | + * TB flags field for VECSTRIDE and XSCALE_CPAR. | 58 | cc->get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug; |
56 | + */ | 59 | cc->asidx_from_attrs = arm_asidx_from_attrs; |
57 | + assert(!(arm_feature(env, ARM_FEATURE_VFP) && | 60 | cc->vmsd = &vmstate_arm_cpu; |
58 | + arm_feature(env, ARM_FEATURE_XSCALE))); | 61 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) |
59 | + | 62 | #ifdef CONFIG_TCG |
60 | if (arm_feature(env, ARM_FEATURE_V7) && | 63 | cc->tcg_initialize = arm_translate_init; |
61 | !arm_feature(env, ARM_FEATURE_M) && | 64 | cc->tlb_fill = arm_cpu_tlb_fill; |
62 | !arm_feature(env, ARM_FEATURE_PMSA)) { | 65 | +#if !defined(CONFIG_USER_ONLY) |
66 | + cc->do_unaligned_access = arm_cpu_do_unaligned_access; | ||
67 | + cc->do_transaction_failed = arm_cpu_do_transaction_failed; | ||
68 | +#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ | ||
69 | #endif | ||
70 | } | ||
71 | |||
63 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 72 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
64 | index XXXXXXX..XXXXXXX 100644 | 73 | index XXXXXXX..XXXXXXX 100644 |
65 | --- a/target/arm/helper.c | 74 | --- a/target/arm/helper.c |
66 | +++ b/target/arm/helper.c | 75 | +++ b/target/arm/helper.c |
67 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 76 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) |
68 | || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) { | 77 | |
69 | flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | 78 | #endif |
70 | } | 79 | |
71 | - flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar); | 80 | -bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, |
72 | + /* Note that XSCALE_CPAR shares bits with VECSTRIDE */ | 81 | - MMUAccessType access_type, int mmu_idx, |
73 | + if (arm_feature(env, ARM_FEATURE_XSCALE)) { | 82 | - bool probe, uintptr_t retaddr) |
74 | + flags = FIELD_DP32(flags, TBFLAG_A32, | 83 | -{ |
75 | + XSCALE_CPAR, env->cp15.c15_cpar); | 84 | - ARMCPU *cpu = ARM_CPU(cs); |
85 | - | ||
86 | -#ifdef CONFIG_USER_ONLY | ||
87 | - cpu->env.exception.vaddress = address; | ||
88 | - if (access_type == MMU_INST_FETCH) { | ||
89 | - cs->exception_index = EXCP_PREFETCH_ABORT; | ||
90 | - } else { | ||
91 | - cs->exception_index = EXCP_DATA_ABORT; | ||
92 | - } | ||
93 | - cpu_loop_exit_restore(cs, retaddr); | ||
94 | -#else | ||
95 | - hwaddr phys_addr; | ||
96 | - target_ulong page_size; | ||
97 | - int prot, ret; | ||
98 | - MemTxAttrs attrs = {}; | ||
99 | - ARMMMUFaultInfo fi = {}; | ||
100 | - | ||
101 | - /* | ||
102 | - * Walk the page table and (if the mapping exists) add the page | ||
103 | - * to the TLB. On success, return true. Otherwise, if probing, | ||
104 | - * return false. Otherwise populate fsr with ARM DFSR/IFSR fault | ||
105 | - * register format, and signal the fault. | ||
106 | - */ | ||
107 | - ret = get_phys_addr(&cpu->env, address, access_type, | ||
108 | - core_to_arm_mmu_idx(&cpu->env, mmu_idx), | ||
109 | - &phys_addr, &attrs, &prot, &page_size, &fi, NULL); | ||
110 | - if (likely(!ret)) { | ||
111 | - /* | ||
112 | - * Map a single [sub]page. Regions smaller than our declared | ||
113 | - * target page size are handled specially, so for those we | ||
114 | - * pass in the exact addresses. | ||
115 | - */ | ||
116 | - if (page_size >= TARGET_PAGE_SIZE) { | ||
117 | - phys_addr &= TARGET_PAGE_MASK; | ||
118 | - address &= TARGET_PAGE_MASK; | ||
119 | - } | ||
120 | - tlb_set_page_with_attrs(cs, address, phys_addr, attrs, | ||
121 | - prot, mmu_idx, page_size); | ||
122 | - return true; | ||
123 | - } else if (probe) { | ||
124 | - return false; | ||
125 | - } else { | ||
126 | - /* now we have a real cpu fault */ | ||
127 | - cpu_restore_state(cs, retaddr, true); | ||
128 | - arm_deliver_fault(cpu, address, access_type, mmu_idx, &fi); | ||
129 | - } | ||
130 | -#endif | ||
131 | -} | ||
132 | - | ||
133 | /* Note that signed overflow is undefined in C. The following routines are | ||
134 | careful to use unsigned types where modulo arithmetic is required. | ||
135 | Failure to do so _will_ break on newer gcc. */ | ||
136 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
137 | index XXXXXXX..XXXXXXX 100644 | ||
138 | --- a/target/arm/op_helper.c | ||
139 | +++ b/target/arm/op_helper.c | ||
140 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_tbl)(uint32_t ireg, uint32_t def, void *vn, | ||
141 | return val; | ||
142 | } | ||
143 | |||
144 | -#if !defined(CONFIG_USER_ONLY) | ||
145 | - | ||
146 | -static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | ||
147 | - unsigned int target_el, | ||
148 | - bool same_el, bool ea, | ||
149 | - bool s1ptw, bool is_write, | ||
150 | - int fsc) | ||
151 | -{ | ||
152 | - uint32_t syn; | ||
153 | - | ||
154 | - /* | ||
155 | - * ISV is only set for data aborts routed to EL2 and | ||
156 | - * never for stage-1 page table walks faulting on stage 2. | ||
157 | - * | ||
158 | - * Furthermore, ISV is only set for certain kinds of load/stores. | ||
159 | - * If the template syndrome does not have ISV set, we should leave | ||
160 | - * it cleared. | ||
161 | - * | ||
162 | - * See ARMv8 specs, D7-1974: | ||
163 | - * ISS encoding for an exception from a Data Abort, the | ||
164 | - * ISV field. | ||
165 | - */ | ||
166 | - if (!(template_syn & ARM_EL_ISV) || target_el != 2 || s1ptw) { | ||
167 | - syn = syn_data_abort_no_iss(same_el, | ||
168 | - ea, 0, s1ptw, is_write, fsc); | ||
169 | - } else { | ||
170 | - /* | ||
171 | - * Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template | ||
172 | - * syndrome created at translation time. | ||
173 | - * Now we create the runtime syndrome with the remaining fields. | ||
174 | - */ | ||
175 | - syn = syn_data_abort_with_iss(same_el, | ||
176 | - 0, 0, 0, 0, 0, | ||
177 | - ea, 0, s1ptw, is_write, fsc, | ||
178 | - false); | ||
179 | - /* Merge the runtime syndrome with the template syndrome. */ | ||
180 | - syn |= template_syn; | ||
181 | - } | ||
182 | - return syn; | ||
183 | -} | ||
184 | - | ||
185 | -void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, | ||
186 | - int mmu_idx, ARMMMUFaultInfo *fi) | ||
187 | -{ | ||
188 | - CPUARMState *env = &cpu->env; | ||
189 | - int target_el; | ||
190 | - bool same_el; | ||
191 | - uint32_t syn, exc, fsr, fsc; | ||
192 | - ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx); | ||
193 | - | ||
194 | - target_el = exception_target_el(env); | ||
195 | - if (fi->stage2) { | ||
196 | - target_el = 2; | ||
197 | - env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; | ||
198 | - } | ||
199 | - same_el = (arm_current_el(env) == target_el); | ||
200 | - | ||
201 | - if (target_el == 2 || arm_el_is_aa64(env, target_el) || | ||
202 | - arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { | ||
203 | - /* | ||
204 | - * LPAE format fault status register : bottom 6 bits are | ||
205 | - * status code in the same form as needed for syndrome | ||
206 | - */ | ||
207 | - fsr = arm_fi_to_lfsc(fi); | ||
208 | - fsc = extract32(fsr, 0, 6); | ||
209 | - } else { | ||
210 | - fsr = arm_fi_to_sfsc(fi); | ||
211 | - /* | ||
212 | - * Short format FSR : this fault will never actually be reported | ||
213 | - * to an EL that uses a syndrome register. Use a (currently) | ||
214 | - * reserved FSR code in case the constructed syndrome does leak | ||
215 | - * into the guest somehow. | ||
216 | - */ | ||
217 | - fsc = 0x3f; | ||
218 | - } | ||
219 | - | ||
220 | - if (access_type == MMU_INST_FETCH) { | ||
221 | - syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc); | ||
222 | - exc = EXCP_PREFETCH_ABORT; | ||
223 | - } else { | ||
224 | - syn = merge_syn_data_abort(env->exception.syndrome, target_el, | ||
225 | - same_el, fi->ea, fi->s1ptw, | ||
226 | - access_type == MMU_DATA_STORE, | ||
227 | - fsc); | ||
228 | - if (access_type == MMU_DATA_STORE | ||
229 | - && arm_feature(env, ARM_FEATURE_V6)) { | ||
230 | - fsr |= (1 << 11); | ||
231 | - } | ||
232 | - exc = EXCP_DATA_ABORT; | ||
233 | - } | ||
234 | - | ||
235 | - env->exception.vaddress = addr; | ||
236 | - env->exception.fsr = fsr; | ||
237 | - raise_exception(env, exc, syn, target_el); | ||
238 | -} | ||
239 | - | ||
240 | -/* Raise a data fault alignment exception for the specified virtual address */ | ||
241 | -void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, | ||
242 | - MMUAccessType access_type, | ||
243 | - int mmu_idx, uintptr_t retaddr) | ||
244 | -{ | ||
245 | - ARMCPU *cpu = ARM_CPU(cs); | ||
246 | - ARMMMUFaultInfo fi = {}; | ||
247 | - | ||
248 | - /* now we have a real cpu fault */ | ||
249 | - cpu_restore_state(cs, retaddr, true); | ||
250 | - | ||
251 | - fi.type = ARMFault_Alignment; | ||
252 | - arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi); | ||
253 | -} | ||
254 | - | ||
255 | -/* | ||
256 | - * arm_cpu_do_transaction_failed: handle a memory system error response | ||
257 | - * (eg "no device/memory present at address") by raising an external abort | ||
258 | - * exception | ||
259 | - */ | ||
260 | -void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, | ||
261 | - vaddr addr, unsigned size, | ||
262 | - MMUAccessType access_type, | ||
263 | - int mmu_idx, MemTxAttrs attrs, | ||
264 | - MemTxResult response, uintptr_t retaddr) | ||
265 | -{ | ||
266 | - ARMCPU *cpu = ARM_CPU(cs); | ||
267 | - ARMMMUFaultInfo fi = {}; | ||
268 | - | ||
269 | - /* now we have a real cpu fault */ | ||
270 | - cpu_restore_state(cs, retaddr, true); | ||
271 | - | ||
272 | - fi.ea = arm_extabort_type(response); | ||
273 | - fi.type = ARMFault_SyncExternal; | ||
274 | - arm_deliver_fault(cpu, addr, access_type, mmu_idx, &fi); | ||
275 | -} | ||
276 | - | ||
277 | -#endif /* !defined(CONFIG_USER_ONLY) */ | ||
278 | - | ||
279 | void HELPER(v8m_stackcheck)(CPUARMState *env, uint32_t newvalue) | ||
280 | { | ||
281 | /* | ||
282 | diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c | ||
283 | new file mode 100644 | ||
284 | index XXXXXXX..XXXXXXX | ||
285 | --- /dev/null | ||
286 | +++ b/target/arm/tlb_helper.c | ||
287 | @@ -XXX,XX +XXX,XX @@ | ||
288 | +/* | ||
289 | + * ARM TLB (Translation lookaside buffer) helpers. | ||
290 | + * | ||
291 | + * This code is licensed under the GNU GPL v2 or later. | ||
292 | + * | ||
293 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
294 | + */ | ||
295 | +#include "qemu/osdep.h" | ||
296 | +#include "cpu.h" | ||
297 | +#include "internals.h" | ||
298 | +#include "exec/exec-all.h" | ||
299 | + | ||
300 | +#if !defined(CONFIG_USER_ONLY) | ||
301 | + | ||
302 | +static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | ||
303 | + unsigned int target_el, | ||
304 | + bool same_el, bool ea, | ||
305 | + bool s1ptw, bool is_write, | ||
306 | + int fsc) | ||
307 | +{ | ||
308 | + uint32_t syn; | ||
309 | + | ||
310 | + /* | ||
311 | + * ISV is only set for data aborts routed to EL2 and | ||
312 | + * never for stage-1 page table walks faulting on stage 2. | ||
313 | + * | ||
314 | + * Furthermore, ISV is only set for certain kinds of load/stores. | ||
315 | + * If the template syndrome does not have ISV set, we should leave | ||
316 | + * it cleared. | ||
317 | + * | ||
318 | + * See ARMv8 specs, D7-1974: | ||
319 | + * ISS encoding for an exception from a Data Abort, the | ||
320 | + * ISV field. | ||
321 | + */ | ||
322 | + if (!(template_syn & ARM_EL_ISV) || target_el != 2 || s1ptw) { | ||
323 | + syn = syn_data_abort_no_iss(same_el, | ||
324 | + ea, 0, s1ptw, is_write, fsc); | ||
325 | + } else { | ||
326 | + /* | ||
327 | + * Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template | ||
328 | + * syndrome created at translation time. | ||
329 | + * Now we create the runtime syndrome with the remaining fields. | ||
330 | + */ | ||
331 | + syn = syn_data_abort_with_iss(same_el, | ||
332 | + 0, 0, 0, 0, 0, | ||
333 | + ea, 0, s1ptw, is_write, fsc, | ||
334 | + false); | ||
335 | + /* Merge the runtime syndrome with the template syndrome. */ | ||
336 | + syn |= template_syn; | ||
337 | + } | ||
338 | + return syn; | ||
339 | +} | ||
340 | + | ||
341 | +static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, | ||
342 | + MMUAccessType access_type, | ||
343 | + int mmu_idx, ARMMMUFaultInfo *fi) | ||
344 | +{ | ||
345 | + CPUARMState *env = &cpu->env; | ||
346 | + int target_el; | ||
347 | + bool same_el; | ||
348 | + uint32_t syn, exc, fsr, fsc; | ||
349 | + ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx); | ||
350 | + | ||
351 | + target_el = exception_target_el(env); | ||
352 | + if (fi->stage2) { | ||
353 | + target_el = 2; | ||
354 | + env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; | ||
355 | + } | ||
356 | + same_el = (arm_current_el(env) == target_el); | ||
357 | + | ||
358 | + if (target_el == 2 || arm_el_is_aa64(env, target_el) || | ||
359 | + arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { | ||
360 | + /* | ||
361 | + * LPAE format fault status register : bottom 6 bits are | ||
362 | + * status code in the same form as needed for syndrome | ||
363 | + */ | ||
364 | + fsr = arm_fi_to_lfsc(fi); | ||
365 | + fsc = extract32(fsr, 0, 6); | ||
366 | + } else { | ||
367 | + fsr = arm_fi_to_sfsc(fi); | ||
368 | + /* | ||
369 | + * Short format FSR : this fault will never actually be reported | ||
370 | + * to an EL that uses a syndrome register. Use a (currently) | ||
371 | + * reserved FSR code in case the constructed syndrome does leak | ||
372 | + * into the guest somehow. | ||
373 | + */ | ||
374 | + fsc = 0x3f; | ||
375 | + } | ||
376 | + | ||
377 | + if (access_type == MMU_INST_FETCH) { | ||
378 | + syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc); | ||
379 | + exc = EXCP_PREFETCH_ABORT; | ||
380 | + } else { | ||
381 | + syn = merge_syn_data_abort(env->exception.syndrome, target_el, | ||
382 | + same_el, fi->ea, fi->s1ptw, | ||
383 | + access_type == MMU_DATA_STORE, | ||
384 | + fsc); | ||
385 | + if (access_type == MMU_DATA_STORE | ||
386 | + && arm_feature(env, ARM_FEATURE_V6)) { | ||
387 | + fsr |= (1 << 11); | ||
76 | + } | 388 | + } |
77 | } | 389 | + exc = EXCP_DATA_ABORT; |
78 | 390 | + } | |
79 | flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, arm_to_core_mmu_idx(mmu_idx)); | 391 | + |
80 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 392 | + env->exception.vaddress = addr; |
81 | index XXXXXXX..XXXXXXX 100644 | 393 | + env->exception.fsr = fsr; |
82 | --- a/target/arm/translate.c | 394 | + raise_exception(env, exc, syn, target_el); |
83 | +++ b/target/arm/translate.c | 395 | +} |
84 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 396 | + |
85 | dc->fp_excp_el = FIELD_EX32(tb_flags, TBFLAG_ANY, FPEXC_EL); | 397 | +/* Raise a data fault alignment exception for the specified virtual address */ |
86 | dc->vfp_enabled = FIELD_EX32(tb_flags, TBFLAG_A32, VFPEN); | 398 | +void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, |
87 | dc->vec_len = FIELD_EX32(tb_flags, TBFLAG_A32, VECLEN); | 399 | + MMUAccessType access_type, |
88 | - dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE); | 400 | + int mmu_idx, uintptr_t retaddr) |
89 | - dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR); | 401 | +{ |
90 | + if (arm_feature(env, ARM_FEATURE_XSCALE)) { | 402 | + ARMCPU *cpu = ARM_CPU(cs); |
91 | + dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR); | 403 | + ARMMMUFaultInfo fi = {}; |
92 | + dc->vec_stride = 0; | 404 | + |
405 | + /* now we have a real cpu fault */ | ||
406 | + cpu_restore_state(cs, retaddr, true); | ||
407 | + | ||
408 | + fi.type = ARMFault_Alignment; | ||
409 | + arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi); | ||
410 | +} | ||
411 | + | ||
412 | +/* | ||
413 | + * arm_cpu_do_transaction_failed: handle a memory system error response | ||
414 | + * (eg "no device/memory present at address") by raising an external abort | ||
415 | + * exception | ||
416 | + */ | ||
417 | +void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, | ||
418 | + vaddr addr, unsigned size, | ||
419 | + MMUAccessType access_type, | ||
420 | + int mmu_idx, MemTxAttrs attrs, | ||
421 | + MemTxResult response, uintptr_t retaddr) | ||
422 | +{ | ||
423 | + ARMCPU *cpu = ARM_CPU(cs); | ||
424 | + ARMMMUFaultInfo fi = {}; | ||
425 | + | ||
426 | + /* now we have a real cpu fault */ | ||
427 | + cpu_restore_state(cs, retaddr, true); | ||
428 | + | ||
429 | + fi.ea = arm_extabort_type(response); | ||
430 | + fi.type = ARMFault_SyncExternal; | ||
431 | + arm_deliver_fault(cpu, addr, access_type, mmu_idx, &fi); | ||
432 | +} | ||
433 | + | ||
434 | +#endif /* !defined(CONFIG_USER_ONLY) */ | ||
435 | + | ||
436 | +bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | ||
437 | + MMUAccessType access_type, int mmu_idx, | ||
438 | + bool probe, uintptr_t retaddr) | ||
439 | +{ | ||
440 | + ARMCPU *cpu = ARM_CPU(cs); | ||
441 | + | ||
442 | +#ifdef CONFIG_USER_ONLY | ||
443 | + cpu->env.exception.vaddress = address; | ||
444 | + if (access_type == MMU_INST_FETCH) { | ||
445 | + cs->exception_index = EXCP_PREFETCH_ABORT; | ||
93 | + } else { | 446 | + } else { |
94 | + dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE); | 447 | + cs->exception_index = EXCP_DATA_ABORT; |
95 | + dc->c15_cpar = 0; | 448 | + } |
96 | + } | 449 | + cpu_loop_exit_restore(cs, retaddr); |
97 | dc->v7m_handler_mode = FIELD_EX32(tb_flags, TBFLAG_A32, HANDLER); | 450 | +#else |
98 | dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) && | 451 | + hwaddr phys_addr; |
99 | regime_is_secure(env, dc->mmu_idx); | 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 | +} | ||
100 | -- | 488 | -- |
101 | 2.20.1 | 489 | 2.20.1 |
102 | 490 | ||
103 | 491 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | No code used the tc6393xb_gpio_in_get() and tc6393xb_gpio_out_set() | 3 | To ease the review of the next commit, |
4 | functions since their introduction in commit 88d2c950b002. Time to | 4 | move the vfp_exceptbits_to_host() function directly after |
5 | remove them. | 5 | vfp_exceptbits_from_host(). Amusingly the diff shows we |
6 | are moving vfp_get_fpscr(). | ||
6 | 7 | ||
7 | Suggested-by: Markus Armbruster <armbru@redhat.com> | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
9 | Message-id: 20190412165416.7977-4-philmd@redhat.com | 9 | Message-id: 20190701132516.26392-15-philmd@redhat.com |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 12 | --- |
13 | include/hw/devices.h | 3 --- | 13 | target/arm/vfp_helper.c | 52 ++++++++++++++++++++--------------------- |
14 | hw/display/tc6393xb.c | 16 ---------------- | 14 | 1 file changed, 26 insertions(+), 26 deletions(-) |
15 | 2 files changed, 19 deletions(-) | ||
16 | 15 | ||
17 | diff --git a/include/hw/devices.h b/include/hw/devices.h | 16 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/devices.h | 18 | --- a/target/arm/vfp_helper.c |
20 | +++ b/include/hw/devices.h | 19 | +++ b/target/arm/vfp_helper.c |
21 | @@ -XXX,XX +XXX,XX @@ void retu_key_event(void *retu, int state); | 20 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_from_host(int host_bits) |
22 | typedef struct TC6393xbState TC6393xbState; | 21 | return target_bits; |
23 | TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem, | 22 | } |
24 | uint32_t base, qemu_irq irq); | 23 | |
25 | -void tc6393xb_gpio_out_set(TC6393xbState *s, int line, | 24 | -uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) |
26 | - qemu_irq handler); | ||
27 | -qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s); | ||
28 | qemu_irq tc6393xb_l3v_get(TC6393xbState *s); | ||
29 | |||
30 | #endif | ||
31 | diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/hw/display/tc6393xb.c | ||
34 | +++ b/hw/display/tc6393xb.c | ||
35 | @@ -XXX,XX +XXX,XX @@ struct TC6393xbState { | ||
36 | blanked : 1; | ||
37 | }; | ||
38 | |||
39 | -qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s) | ||
40 | -{ | 25 | -{ |
41 | - return s->gpio_in; | 26 | - uint32_t i, fpscr; |
27 | - | ||
28 | - fpscr = env->vfp.xregs[ARM_VFP_FPSCR] | ||
29 | - | (env->vfp.vec_len << 16) | ||
30 | - | (env->vfp.vec_stride << 20); | ||
31 | - | ||
32 | - i = get_float_exception_flags(&env->vfp.fp_status); | ||
33 | - i |= get_float_exception_flags(&env->vfp.standard_fp_status); | ||
34 | - /* FZ16 does not generate an input denormal exception. */ | ||
35 | - i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | ||
36 | - & ~float_flag_input_denormal); | ||
37 | - fpscr |= vfp_exceptbits_from_host(i); | ||
38 | - | ||
39 | - i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; | ||
40 | - fpscr |= i ? FPCR_QC : 0; | ||
41 | - | ||
42 | - return fpscr; | ||
42 | -} | 43 | -} |
43 | - | 44 | - |
44 | static void tc6393xb_gpio_set(void *opaque, int line, int level) | 45 | -uint32_t vfp_get_fpscr(CPUARMState *env) |
45 | { | ||
46 | // TC6393xbState *s = opaque; | ||
47 | @@ -XXX,XX +XXX,XX @@ static void tc6393xb_gpio_set(void *opaque, int line, int level) | ||
48 | // FIXME: how does the chip reflect the GPIO input level change? | ||
49 | } | ||
50 | |||
51 | -void tc6393xb_gpio_out_set(TC6393xbState *s, int line, | ||
52 | - qemu_irq handler) | ||
53 | -{ | 46 | -{ |
54 | - if (line >= TC6393XB_GPIOS) { | 47 | - return HELPER(vfp_get_fpscr)(env); |
55 | - fprintf(stderr, "TC6393xb: no GPIO pin %d\n", line); | ||
56 | - return; | ||
57 | - } | ||
58 | - | ||
59 | - s->handler[line] = handler; | ||
60 | -} | 48 | -} |
61 | - | 49 | - |
62 | static void tc6393xb_gpio_handler_update(TC6393xbState *s) | 50 | /* Convert vfp exception flags to target form. */ |
51 | static inline int vfp_exceptbits_to_host(int target_bits) | ||
63 | { | 52 | { |
64 | uint32_t level, diff; | 53 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits) |
54 | return host_bits; | ||
55 | } | ||
56 | |||
57 | +uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | ||
58 | +{ | ||
59 | + uint32_t i, fpscr; | ||
60 | + | ||
61 | + fpscr = env->vfp.xregs[ARM_VFP_FPSCR] | ||
62 | + | (env->vfp.vec_len << 16) | ||
63 | + | (env->vfp.vec_stride << 20); | ||
64 | + | ||
65 | + i = get_float_exception_flags(&env->vfp.fp_status); | ||
66 | + i |= get_float_exception_flags(&env->vfp.standard_fp_status); | ||
67 | + /* FZ16 does not generate an input denormal exception. */ | ||
68 | + i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | ||
69 | + & ~float_flag_input_denormal); | ||
70 | + fpscr |= vfp_exceptbits_from_host(i); | ||
71 | + | ||
72 | + i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; | ||
73 | + fpscr |= i ? FPCR_QC : 0; | ||
74 | + | ||
75 | + return fpscr; | ||
76 | +} | ||
77 | + | ||
78 | +uint32_t vfp_get_fpscr(CPUARMState *env) | ||
79 | +{ | ||
80 | + return HELPER(vfp_get_fpscr)(env); | ||
81 | +} | ||
82 | + | ||
83 | void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | ||
84 | { | ||
85 | int i; | ||
65 | -- | 86 | -- |
66 | 2.20.1 | 87 | 2.20.1 |
67 | 88 | ||
68 | 89 | diff view generated by jsdifflib |
1 | Enforce that for M-profile various FPSCR bits which are RES0 there | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | but have defined meanings on A-profile are never settable. This | ||
3 | ensures that M-profile code can't enable the A-profile behaviour | ||
4 | (notably vector length/stride handling) by accident. | ||
5 | 2 | ||
3 | The vfp_set_fpscr() helper contains code specific to the host | ||
4 | floating point implementation (here the SoftFloat library). | ||
5 | Extract this code to vfp_set_fpscr_to_host(). | ||
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190701132516.26392-16-philmd@redhat.com | ||
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 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20190416125744.27770-2-peter.maydell@linaro.org | ||
9 | --- | 11 | --- |
10 | target/arm/vfp_helper.c | 8 ++++++++ | 12 | target/arm/vfp_helper.c | 127 +++++++++++++++++++++------------------- |
11 | 1 file changed, 8 insertions(+) | 13 | 1 file changed, 66 insertions(+), 61 deletions(-) |
12 | 14 | ||
13 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | 15 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/vfp_helper.c | 17 | --- a/target/arm/vfp_helper.c |
16 | +++ b/target/arm/vfp_helper.c | 18 | +++ b/target/arm/vfp_helper.c |
19 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits) | ||
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 | { | ||
52 | int i; | ||
53 | uint32_t changed = env->vfp.xregs[ARM_VFP_FPSCR]; | ||
54 | |||
55 | - /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ | ||
56 | - if (!cpu_isar_feature(aa64_fp16, env_archcpu(env))) { | ||
57 | - val &= ~FPCR_FZ16; | ||
58 | - } | ||
59 | - | ||
60 | - if (arm_feature(env, ARM_FEATURE_M)) { | ||
61 | - /* | ||
62 | - * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits | ||
63 | - * and also for the trapped-exception-handling bits IxE. | ||
64 | - */ | ||
65 | - val &= 0xf7c0009f; | ||
66 | - } | ||
67 | - | ||
68 | - /* | ||
69 | - * We don't implement trapped exception handling, so the | ||
70 | - * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) | ||
71 | - * | ||
72 | - * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC | ||
73 | - * (which are stored in fp_status), and the other RES0 bits | ||
74 | - * in between, then we clear all of the low 16 bits. | ||
75 | - */ | ||
76 | - env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000; | ||
77 | - env->vfp.vec_len = (val >> 16) & 7; | ||
78 | - env->vfp.vec_stride = (val >> 20) & 3; | ||
79 | - | ||
80 | - /* | ||
81 | - * The bit we set within fpscr_q is arbitrary; the register as a | ||
82 | - * whole being zero/non-zero is what counts. | ||
83 | - */ | ||
84 | - env->vfp.qc[0] = val & FPCR_QC; | ||
85 | - env->vfp.qc[1] = 0; | ||
86 | - env->vfp.qc[2] = 0; | ||
87 | - env->vfp.qc[3] = 0; | ||
88 | - | ||
89 | changed ^= val; | ||
90 | if (changed & (3 << 22)) { | ||
91 | i = (val >> 22) & 3; | ||
17 | @@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | 92 | @@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) |
18 | val &= ~FPCR_FZ16; | 93 | set_float_exception_flags(0, &env->vfp.standard_fp_status); |
19 | } | 94 | } |
20 | 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 | + | ||
21 | + if (arm_feature(env, ARM_FEATURE_M)) { | 129 | + if (arm_feature(env, ARM_FEATURE_M)) { |
22 | + /* | 130 | + /* |
23 | + * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits | 131 | + * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits |
24 | + * and also for the trapped-exception-handling bits IxE. | 132 | + * and also for the trapped-exception-handling bits IxE. |
25 | + */ | 133 | + */ |
26 | + val &= 0xf7c0009f; | 134 | + val &= 0xf7c0009f; |
27 | + } | 135 | + } |
28 | + | 136 | + |
29 | /* | 137 | + /* |
30 | * We don't implement trapped exception handling, so the | 138 | + * We don't implement trapped exception handling, so the |
31 | * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) | 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); | ||
32 | -- | 164 | -- |
33 | 2.20.1 | 165 | 2.20.1 |
34 | 166 | ||
35 | 167 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Suggested-by: Markus Armbruster <armbru@redhat.com> | 3 | The vfp_set_fpscr() helper contains code specific to the host |
4 | floating point implementation (here the SoftFloat library). | ||
5 | Extract this code to vfp_set_fpscr_from_host(). | ||
6 | |||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
5 | Message-id: 20190412165416.7977-3-philmd@redhat.com | 8 | Message-id: 20190701132516.26392-17-philmd@redhat.com |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 11 | --- |
9 | hw/arm/nseries.c | 3 ++- | 12 | target/arm/vfp_helper.c | 19 +++++++++++++------ |
10 | 1 file changed, 2 insertions(+), 1 deletion(-) | 13 | 1 file changed, 13 insertions(+), 6 deletions(-) |
11 | 14 | ||
12 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c | 15 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c |
13 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/arm/nseries.c | 17 | --- a/target/arm/vfp_helper.c |
15 | +++ b/hw/arm/nseries.c | 18 | +++ b/target/arm/vfp_helper.c |
16 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits) |
17 | #include "hw/boards.h" | 20 | return host_bits; |
18 | #include "hw/i2c/i2c.h" | ||
19 | #include "hw/devices.h" | ||
20 | +#include "hw/misc/tmp105.h" | ||
21 | #include "hw/block/flash.h" | ||
22 | #include "hw/hw.h" | ||
23 | #include "hw/bt.h" | ||
24 | @@ -XXX,XX +XXX,XX @@ static void n8x0_i2c_setup(struct n800_s *s) | ||
25 | qemu_register_powerdown_notifier(&n8x0_system_powerdown_notifier); | ||
26 | |||
27 | /* Attach a TMP105 PM chip (A0 wired to ground) */ | ||
28 | - dev = i2c_create_slave(i2c, "tmp105", N8X0_TMP105_ADDR); | ||
29 | + dev = i2c_create_slave(i2c, TYPE_TMP105, N8X0_TMP105_ADDR); | ||
30 | qdev_connect_gpio_out(dev, 0, tmp_irq); | ||
31 | } | 21 | } |
32 | 22 | ||
23 | +static uint32_t vfp_get_fpscr_from_host(CPUARMState *env) | ||
24 | +{ | ||
25 | + uint32_t i; | ||
26 | + | ||
27 | + i = get_float_exception_flags(&env->vfp.fp_status); | ||
28 | + i |= get_float_exception_flags(&env->vfp.standard_fp_status); | ||
29 | + /* FZ16 does not generate an input denormal exception. */ | ||
30 | + i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | ||
31 | + & ~float_flag_input_denormal); | ||
32 | + return vfp_exceptbits_from_host(i); | ||
33 | +} | ||
34 | + | ||
35 | static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val) | ||
36 | { | ||
37 | int i; | ||
38 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | ||
39 | | (env->vfp.vec_len << 16) | ||
40 | | (env->vfp.vec_stride << 20); | ||
41 | |||
42 | - i = get_float_exception_flags(&env->vfp.fp_status); | ||
43 | - i |= get_float_exception_flags(&env->vfp.standard_fp_status); | ||
44 | - /* FZ16 does not generate an input denormal exception. */ | ||
45 | - i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | ||
46 | - & ~float_flag_input_denormal); | ||
47 | - fpscr |= vfp_exceptbits_from_host(i); | ||
48 | + fpscr |= vfp_get_fpscr_from_host(env); | ||
49 | |||
50 | i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; | ||
51 | fpscr |= i ? FPCR_QC : 0; | ||
33 | -- | 52 | -- |
34 | 2.20.1 | 53 | 2.20.1 |
35 | 54 | ||
36 | 55 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 3 | This code is specific to the SoftFloat floating-point |
4 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 4 | implementation, which is only used by TCG. |
5 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
6 | Message-id: 20190412165416.7977-11-philmd@redhat.com | 7 | Message-id: 20190701132516.26392-18-philmd@redhat.com |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 10 | --- |
9 | include/hw/net/ne2000-isa.h | 6 ++++++ | 11 | target/arm/vfp_helper.c | 26 +++++++++++++++++++++++--- |
10 | 1 file changed, 6 insertions(+) | 12 | 1 file changed, 23 insertions(+), 3 deletions(-) |
11 | 13 | ||
12 | diff --git a/include/hw/net/ne2000-isa.h b/include/hw/net/ne2000-isa.h | 14 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c |
13 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/include/hw/net/ne2000-isa.h | 16 | --- a/target/arm/vfp_helper.c |
15 | +++ b/include/hw/net/ne2000-isa.h | 17 | +++ b/target/arm/vfp_helper.c |
16 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ |
17 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
18 | * See the COPYING file in the top-level directory. | ||
19 | */ | 19 | */ |
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 | ||
20 | + | 38 | + |
21 | +#ifndef HW_NET_NE2K_ISA_H | 39 | /* Convert host exception flags to vfp form. */ |
22 | +#define HW_NET_NE2K_ISA_H | 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 | } | ||
45 | |||
46 | +#else | ||
23 | + | 47 | + |
24 | #include "hw/hw.h" | 48 | +static uint32_t vfp_get_fpscr_from_host(CPUARMState *env) |
25 | #include "hw/qdev.h" | 49 | +{ |
26 | #include "hw/isa/isa.h" | 50 | + return 0; |
27 | @@ -XXX,XX +XXX,XX @@ static inline ISADevice *isa_ne2000_init(ISABus *bus, int base, int irq, | 51 | +} |
28 | } | 52 | + |
29 | return d; | 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); | ||
30 | } | 74 | } |
31 | + | 75 | + |
32 | +#endif | 76 | +#endif |
33 | -- | 77 | -- |
34 | 2.20.1 | 78 | 2.20.1 |
35 | 79 | ||
36 | 80 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | This device is used by both ARM (BCM2836, for raspi2) and AArch64 | 3 | Under KVM, the kernel gets the HVC call and handle the PSCI requests. |
4 | (BCM2837, for raspi3) targets, and is not CPU-specific. | ||
5 | Move it to common object, so we build it once for all targets. | ||
6 | 4 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
8 | Message-id: 20190427133028.12874-1-philmd@redhat.com | 6 | Message-id: 20190701132516.26392-20-philmd@redhat.com |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 9 | --- |
12 | hw/dma/Makefile.objs | 2 +- | 10 | target/arm/internals.h | 6 +++++- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 5 insertions(+), 1 deletion(-) |
14 | 12 | ||
15 | diff --git a/hw/dma/Makefile.objs b/hw/dma/Makefile.objs | 13 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
16 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/dma/Makefile.objs | 15 | --- a/target/arm/internals.h |
18 | +++ b/hw/dma/Makefile.objs | 16 | +++ b/target/arm/internals.h |
19 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx-zdma.o | 17 | @@ -XXX,XX +XXX,XX @@ vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len); |
20 | 18 | /* Callback function for when a watchpoint or breakpoint triggers. */ | |
21 | obj-$(CONFIG_OMAP) += omap_dma.o soc_dma.o | 19 | void arm_debug_excp_handler(CPUState *cs); |
22 | obj-$(CONFIG_PXA2XX) += pxa2xx_dma.o | 20 | |
23 | -obj-$(CONFIG_RASPI) += bcm2835_dma.o | 21 | -#ifdef CONFIG_USER_ONLY |
24 | +common-obj-$(CONFIG_RASPI) += bcm2835_dma.o | 22 | +#if defined(CONFIG_USER_ONLY) || !defined(CONFIG_TCG) |
23 | static inline bool arm_is_psci_call(ARMCPU *cpu, int excp_type) | ||
24 | { | ||
25 | return false; | ||
26 | } | ||
27 | +static inline void arm_handle_psci_call(ARMCPU *cpu) | ||
28 | +{ | ||
29 | + g_assert_not_reached(); | ||
30 | +} | ||
31 | #else | ||
32 | /* Return true if the r0/x0 value indicates that this SMC/HVC is a PSCI call. */ | ||
33 | bool arm_is_psci_call(ARMCPU *cpu, int excp_type); | ||
25 | -- | 34 | -- |
26 | 2.20.1 | 35 | 2.20.1 |
27 | 36 | ||
28 | 37 | diff view generated by jsdifflib |
1 | Add a new helper function which returns the MMU index to use | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | for v7M, where the caller specifies all of the security | ||
3 | state, privilege level and whether the execution priority | ||
4 | is negative, and reimplement the existing | ||
5 | arm_v7m_mmu_idx_for_secstate_and_priv() in terms of it. | ||
6 | 2 | ||
7 | We are going to need this for the lazy-FP-stacking code. | 3 | In few commits we will split the M-profile functions from this |
4 | file, and this function will also be called in the new file. | ||
5 | Declare it in the "internals.h" header. | ||
6 | Since it is in the middle of a block of M profile functions, | ||
7 | move it previous to this block to ease the later refactor. | ||
8 | 8 | ||
9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 20190701132516.26392-21-philmd@redhat.com | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20190416125744.27770-21-peter.maydell@linaro.org | ||
12 | --- | 13 | --- |
13 | target/arm/cpu.h | 7 +++++++ | 14 | target/arm/internals.h | 2 ++ |
14 | target/arm/helper.c | 14 +++++++++++--- | 15 | target/arm/helper.c | 76 +++++++++++++++++++++--------------------- |
15 | 2 files changed, 18 insertions(+), 3 deletions(-) | 16 | 2 files changed, 40 insertions(+), 38 deletions(-) |
16 | 17 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 18 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
18 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 20 | --- a/target/arm/internals.h |
20 | +++ b/target/arm/cpu.h | 21 | +++ b/target/arm/internals.h |
21 | @@ -XXX,XX +XXX,XX @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx) | 22 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, |
22 | } | 23 | target_ulong *page_size, |
23 | } | 24 | ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); |
24 | 25 | ||
25 | +/* | 26 | +void arm_log_exception(int idx); |
26 | + * Return the MMU index for a v7M CPU with all relevant information | ||
27 | + * manually specified. | ||
28 | + */ | ||
29 | +ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, | ||
30 | + bool secstate, bool priv, bool negpri); | ||
31 | + | 27 | + |
32 | /* Return the MMU index for a v7M CPU in the specified security and | 28 | #endif /* !CONFIG_USER_ONLY */ |
33 | * privilege state. | 29 | |
34 | */ | 30 | #endif |
35 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 31 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
36 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/target/arm/helper.c | 33 | --- a/target/arm/helper.c |
38 | +++ b/target/arm/helper.c | 34 | +++ b/target/arm/helper.c |
39 | @@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el) | 35 | @@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, |
40 | return 0; | 36 | return target_el; |
41 | } | 37 | } |
42 | 38 | ||
43 | -ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | 39 | +void arm_log_exception(int idx) |
44 | - bool secstate, bool priv) | ||
45 | +ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, | ||
46 | + bool secstate, bool priv, bool negpri) | ||
47 | { | ||
48 | ARMMMUIdx mmu_idx = ARM_MMU_IDX_M; | ||
49 | |||
50 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
51 | mmu_idx |= ARM_MMU_IDX_M_PRIV; | ||
52 | } | ||
53 | |||
54 | - if (armv7m_nvic_neg_prio_requested(env->nvic, secstate)) { | ||
55 | + if (negpri) { | ||
56 | mmu_idx |= ARM_MMU_IDX_M_NEGPRI; | ||
57 | } | ||
58 | |||
59 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
60 | return mmu_idx; | ||
61 | } | ||
62 | |||
63 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
64 | + bool secstate, bool priv) | ||
65 | +{ | 40 | +{ |
66 | + bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate); | 41 | + if (qemu_loglevel_mask(CPU_LOG_INT)) { |
42 | + const char *exc = NULL; | ||
43 | + static const char * const excnames[] = { | ||
44 | + [EXCP_UDEF] = "Undefined Instruction", | ||
45 | + [EXCP_SWI] = "SVC", | ||
46 | + [EXCP_PREFETCH_ABORT] = "Prefetch Abort", | ||
47 | + [EXCP_DATA_ABORT] = "Data Abort", | ||
48 | + [EXCP_IRQ] = "IRQ", | ||
49 | + [EXCP_FIQ] = "FIQ", | ||
50 | + [EXCP_BKPT] = "Breakpoint", | ||
51 | + [EXCP_EXCEPTION_EXIT] = "QEMU v7M exception exit", | ||
52 | + [EXCP_KERNEL_TRAP] = "QEMU intercept of kernel commpage", | ||
53 | + [EXCP_HVC] = "Hypervisor Call", | ||
54 | + [EXCP_HYP_TRAP] = "Hypervisor Trap", | ||
55 | + [EXCP_SMC] = "Secure Monitor Call", | ||
56 | + [EXCP_VIRQ] = "Virtual IRQ", | ||
57 | + [EXCP_VFIQ] = "Virtual FIQ", | ||
58 | + [EXCP_SEMIHOST] = "Semihosting call", | ||
59 | + [EXCP_NOCP] = "v7M NOCP UsageFault", | ||
60 | + [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | ||
61 | + [EXCP_STKOF] = "v8M STKOF UsageFault", | ||
62 | + [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | ||
63 | + [EXCP_LSERR] = "v8M LSERR UsageFault", | ||
64 | + [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | ||
65 | + }; | ||
67 | + | 66 | + |
68 | + return arm_v7m_mmu_idx_all(env, secstate, priv, negpri); | 67 | + if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { |
68 | + exc = excnames[idx]; | ||
69 | + } | ||
70 | + if (!exc) { | ||
71 | + exc = "unknown"; | ||
72 | + } | ||
73 | + qemu_log_mask(CPU_LOG_INT, "Taking exception %d [%s]\n", idx, exc); | ||
74 | + } | ||
69 | +} | 75 | +} |
70 | + | 76 | + |
71 | /* Return the MMU index for a v7M CPU in the specified security state */ | 77 | /* |
72 | ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | 78 | * Return true if the v7M CPACR permits access to the FPU for the specified |
79 | * security state and privilege level. | ||
80 | @@ -XXX,XX +XXX,XX @@ static bool do_v7m_function_return(ARMCPU *cpu) | ||
81 | return true; | ||
82 | } | ||
83 | |||
84 | -static void arm_log_exception(int idx) | ||
85 | -{ | ||
86 | - if (qemu_loglevel_mask(CPU_LOG_INT)) { | ||
87 | - const char *exc = NULL; | ||
88 | - static const char * const excnames[] = { | ||
89 | - [EXCP_UDEF] = "Undefined Instruction", | ||
90 | - [EXCP_SWI] = "SVC", | ||
91 | - [EXCP_PREFETCH_ABORT] = "Prefetch Abort", | ||
92 | - [EXCP_DATA_ABORT] = "Data Abort", | ||
93 | - [EXCP_IRQ] = "IRQ", | ||
94 | - [EXCP_FIQ] = "FIQ", | ||
95 | - [EXCP_BKPT] = "Breakpoint", | ||
96 | - [EXCP_EXCEPTION_EXIT] = "QEMU v7M exception exit", | ||
97 | - [EXCP_KERNEL_TRAP] = "QEMU intercept of kernel commpage", | ||
98 | - [EXCP_HVC] = "Hypervisor Call", | ||
99 | - [EXCP_HYP_TRAP] = "Hypervisor Trap", | ||
100 | - [EXCP_SMC] = "Secure Monitor Call", | ||
101 | - [EXCP_VIRQ] = "Virtual IRQ", | ||
102 | - [EXCP_VFIQ] = "Virtual FIQ", | ||
103 | - [EXCP_SEMIHOST] = "Semihosting call", | ||
104 | - [EXCP_NOCP] = "v7M NOCP UsageFault", | ||
105 | - [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | ||
106 | - [EXCP_STKOF] = "v8M STKOF UsageFault", | ||
107 | - [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | ||
108 | - [EXCP_LSERR] = "v8M LSERR UsageFault", | ||
109 | - [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | ||
110 | - }; | ||
111 | - | ||
112 | - if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | ||
113 | - exc = excnames[idx]; | ||
114 | - } | ||
115 | - if (!exc) { | ||
116 | - exc = "unknown"; | ||
117 | - } | ||
118 | - qemu_log_mask(CPU_LOG_INT, "Taking exception %d [%s]\n", idx, exc); | ||
119 | - } | ||
120 | -} | ||
121 | - | ||
122 | static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
123 | uint32_t addr, uint16_t *insn) | ||
73 | { | 124 | { |
74 | -- | 125 | -- |
75 | 2.20.1 | 126 | 2.20.1 |
76 | 127 | ||
77 | 128 | diff view generated by jsdifflib |
1 | Like AArch64, M-profile floating point has no FPEXC enable | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | bit to gate floating point; so always set the VFPEN TB flag. | ||
3 | 2 | ||
4 | M-profile also has CPACR and NSACR similar to A-profile; | 3 | In the next commit we will split the M-profile functions from this |
5 | they behave slightly differently: | 4 | file. Some function will be called out of helper.c. Declare them in |
6 | * the CPACR is banked between Secure and Non-Secure | 5 | the "internals.h" header. |
7 | * if the NSACR forces a trap then this is taken to | ||
8 | the Secure state, not the Non-Secure state | ||
9 | 6 | ||
10 | Honour the CPACR and NSACR settings. The NSACR handling | 7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
11 | requires us to borrow the exception.target_el field | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
12 | (usually meaningless for M profile) to distinguish the | 9 | Message-id: 20190701132516.26392-22-philmd@redhat.com |
13 | NOCP UsageFault taken to Secure state from the more | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | usual fault taken to the current security state. | 11 | --- |
12 | target/arm/internals.h | 42 ++++++++++++++++++++++++++++++++++++++++++ | ||
13 | target/arm/helper.c | 38 ++------------------------------------ | ||
14 | 2 files changed, 44 insertions(+), 36 deletions(-) | ||
15 | 15 | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | Message-id: 20190416125744.27770-6-peter.maydell@linaro.org | ||
19 | --- | ||
20 | target/arm/helper.c | 55 +++++++++++++++++++++++++++++++++++++++--- | ||
21 | target/arm/translate.c | 10 ++++++-- | ||
22 | 2 files changed, 60 insertions(+), 5 deletions(-) | ||
23 | |||
24 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/helper.c | 18 | --- a/target/arm/internals.h |
27 | +++ b/target/arm/helper.c | 19 | +++ b/target/arm/internals.h |
28 | @@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, | 20 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t v7m_sp_limit(CPUARMState *env) |
29 | return target_el; | 21 | } |
30 | } | 22 | } |
31 | 23 | ||
32 | +/* | 24 | +/** |
25 | + * v7m_cpacr_pass: | ||
33 | + * Return true if the v7M CPACR permits access to the FPU for the specified | 26 | + * Return true if the v7M CPACR permits access to the FPU for the specified |
34 | + * security state and privilege level. | 27 | + * security state and privilege level. |
35 | + */ | 28 | + */ |
36 | +static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv) | 29 | +static inline bool v7m_cpacr_pass(CPUARMState *env, |
30 | + bool is_secure, bool is_priv) | ||
37 | +{ | 31 | +{ |
38 | + switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) { | 32 | + switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) { |
39 | + case 0: | 33 | + case 0: |
40 | + case 2: /* UNPREDICTABLE: we treat like 0 */ | 34 | + case 2: /* UNPREDICTABLE: we treat like 0 */ |
41 | + return false; | 35 | + return false; |
... | ... | ||
46 | + default: | 40 | + default: |
47 | + g_assert_not_reached(); | 41 | + g_assert_not_reached(); |
48 | + } | 42 | + } |
49 | +} | 43 | +} |
50 | + | 44 | + |
51 | static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | 45 | /** |
52 | ARMMMUIdx mmu_idx, bool ignfault) | 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 | } | ||
104 | } | ||
105 | |||
106 | -/* | ||
107 | - * Return true if the v7M CPACR permits access to the FPU for the specified | ||
108 | - * security state and privilege level. | ||
109 | - */ | ||
110 | -static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv) | ||
111 | -{ | ||
112 | - switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) { | ||
113 | - case 0: | ||
114 | - case 2: /* UNPREDICTABLE: we treat like 0 */ | ||
115 | - return false; | ||
116 | - case 1: | ||
117 | - return is_priv; | ||
118 | - case 3: | ||
119 | - return true; | ||
120 | - default: | ||
121 | - g_assert_not_reached(); | ||
122 | - } | ||
123 | -} | ||
124 | - | ||
125 | /* | ||
126 | * What kind of stack write are we doing? This affects how exceptions | ||
127 | * generated during the stacking are treated. | ||
128 | @@ -XXX,XX +XXX,XX @@ static bool v8m_is_sau_exempt(CPUARMState *env, | ||
129 | (address >= 0xe00ff000 && address <= 0xe00fffff); | ||
130 | } | ||
131 | |||
132 | -static void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
133 | +void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
134 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
135 | V8M_SAttributes *sattrs) | ||
53 | { | 136 | { |
54 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 137 | @@ -XXX,XX +XXX,XX @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address, |
55 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK; | ||
56 | break; | ||
57 | case EXCP_NOCP: | ||
58 | - armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
59 | - env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK; | ||
60 | + { | ||
61 | + /* | ||
62 | + * NOCP might be directed to something other than the current | ||
63 | + * security state if this fault is because of NSACR; we indicate | ||
64 | + * the target security state using exception.target_el. | ||
65 | + */ | ||
66 | + int target_secstate; | ||
67 | + | ||
68 | + if (env->exception.target_el == 3) { | ||
69 | + target_secstate = M_REG_S; | ||
70 | + } else { | ||
71 | + target_secstate = env->v7m.secure; | ||
72 | + } | ||
73 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, target_secstate); | ||
74 | + env->v7m.cfsr[target_secstate] |= R_V7M_CFSR_NOCP_MASK; | ||
75 | break; | ||
76 | + } | ||
77 | case EXCP_INVSTATE: | ||
78 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
79 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK; | ||
80 | @@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el) | ||
81 | return 0; | ||
82 | } | 138 | } |
83 | 139 | } | |
84 | + if (arm_feature(env, ARM_FEATURE_M)) { | 140 | |
85 | + /* CPACR can cause a NOCP UsageFault taken to current security state */ | 141 | -static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, |
86 | + if (!v7m_cpacr_pass(env, env->v7m.secure, cur_el != 0)) { | 142 | +bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, |
87 | + return 1; | 143 | MMUAccessType access_type, ARMMMUIdx mmu_idx, |
88 | + } | 144 | hwaddr *phys_ptr, MemTxAttrs *txattrs, |
89 | + | 145 | int *prot, bool *is_subpage, |
90 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY) && !env->v7m.secure) { | ||
91 | + if (!extract32(env->v7m.nsacr, 10, 1)) { | ||
92 | + /* FP insns cause a NOCP UsageFault taken to Secure */ | ||
93 | + return 3; | ||
94 | + } | ||
95 | + } | ||
96 | + | ||
97 | + return 0; | ||
98 | + } | ||
99 | + | ||
100 | /* The CPACR controls traps to EL1, or PL1 if we're 32 bit: | ||
101 | * 0, 2 : trap EL0 and EL1/PL1 accesses | ||
102 | * 1 : trap only EL0 accesses | ||
103 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
104 | flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, arm_sctlr_b(env)); | ||
105 | flags = FIELD_DP32(flags, TBFLAG_A32, NS, !access_secure_reg(env)); | ||
106 | if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30) | ||
107 | - || arm_el_is_aa64(env, 1)) { | ||
108 | + || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) { | ||
109 | flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | ||
110 | } | ||
111 | flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar); | ||
112 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
113 | index XXXXXXX..XXXXXXX 100644 | ||
114 | --- a/target/arm/translate.c | ||
115 | +++ b/target/arm/translate.c | ||
116 | @@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) | ||
117 | * for attempts to execute invalid vfp/neon encodings with FP disabled. | ||
118 | */ | ||
119 | if (s->fp_excp_el) { | ||
120 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
121 | - syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | ||
122 | + if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
123 | + gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), | ||
124 | + s->fp_excp_el); | ||
125 | + } else { | ||
126 | + gen_exception_insn(s, 4, EXCP_UDEF, | ||
127 | + syn_fp_access_trap(1, 0xe, false), | ||
128 | + s->fp_excp_el); | ||
129 | + } | ||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | -- | 146 | -- |
134 | 2.20.1 | 147 | 2.20.1 |
135 | 148 | ||
136 | 149 | diff view generated by jsdifflib |